/// <summary>
        /// The margin that must be held in order to increase the position by the provided quantity
        /// </summary>
        /// <param name="parameters">An object containing the security and quantity of shares</param>
        /// <returns>The initial margin required for the option (i.e. the equity required to enter a position for this option)</returns>
        /// <remarks>
        /// We fix the option to 1.5x the initial because of its close coupling with the underlying.
        /// The option's contract multiplier is 1x, but might be more sensitive to volatility shocks in the long
        /// run when it comes to calculating the different market scenarios attempting to simulate VaR, resulting
        /// in a margin greater than the underlying's margin.
        /// </remarks>
        public override InitialMargin GetInitialMarginRequirement(InitialMarginParameters parameters)
        {
            var underlyingRequirement = base.GetInitialMarginRequirement(parameters.ForUnderlying()).Value;
            var positionSide          = parameters.Quantity > 0 ? PositionSide.Long : PositionSide.Short;

            return(new InitialMargin(GetMarginRequirement(_futureOption, underlyingRequirement, positionSide)));
        }
Beispiel #2
0
 /// <summary>
 /// The margin that must be held in order to increase the position by the provided quantity
 /// </summary>
 /// <param name="parameters">An object containing the security and quantity</param>
 /// <returns>The initial margin required for the provided security and quantity</returns>
 public InitialMargin GetInitialMarginRequirement(InitialMarginParameters parameters)
 {
     using (Py.GIL())
     {
         return((_model.GetInitialMarginRequirement(parameters) as PyObject)
                .GetAndDispose <InitialMargin>());
     }
 }
Beispiel #3
0
        /// <summary>
        /// The margin that must be held in order to increase the position by the provided quantity
        /// </summary>
        /// <returns>The initial margin required for the provided security and quantity</returns>
        public override InitialMargin GetInitialMarginRequirement(InitialMarginParameters parameters)
        {
            var security = parameters.Security;
            var quantity = parameters.Quantity;
            var value    = security.QuoteCurrency.ConversionRate
                           * security.SymbolProperties.ContractMultiplier
                           * security.Price
                           * quantity;

            return(new InitialMargin(value * GetMarginRequirement(security, value)));
        }
Beispiel #4
0
        /// <summary>
        /// The margin that must be held in order to increase the position by the provided quantity
        /// </summary>
        public override InitialMargin GetInitialMarginRequirement(InitialMarginParameters parameters)
        {
            var security = parameters.Security;
            var quantity = parameters.Quantity;

            if (security?.GetLastData() == null || quantity == 0m)
            {
                return(InitialMargin.Zero);
            }

            var marginReq = GetCurrentMarginRequirements(security);

            if (EnableIntradayMargins &&
                security.Exchange.ExchangeOpen &&
                !security.Exchange.ClosingSoon)
            {
                return(new InitialMargin(marginReq.InitialIntraday * quantity));
            }

            // margin is per contract
            return(new InitialMargin(marginReq.InitialOvernight * quantity));
        }
        public InitialMargin GetInitialMarginRequirement(InitialMarginParameters parameters)
        {
            EnsureSecurityExists(parameters.Security);
            var expected = SecurityModel.GetInitialMarginRequirement(parameters);

            if (reentry)
            {
                return(expected);
            }

            reentry = true;
            var actual = PositionGroupModel.GetInitialMarginRequirement(new PositionGroupInitialMarginParameters(
                                                                            Portfolio, new PositionGroup(PositionGroupModel, new Position(parameters.Security, parameters.Quantity))
                                                                            ));

            Assert.AreEqual(expected.Value, actual.Value,
                            $"{PositionGroupModel.GetType().Name}:{nameof(GetInitialMarginRequirement)}"
                            );

            reentry = false;
            return(expected);
        }
 /// <summary>
 /// The margin that must be held in order to increase the position by the provided quantity
 /// </summary>
 /// <param name="parameters">An object containing the security and quantity of shares</param>
 /// <returns>The initial margin required for the provided security and quantity</returns>
 public override InitialMargin GetInitialMarginRequirement(InitialMarginParameters parameters)
 {
     return(parameters.Quantity * _marginRequiredPerUnitInAccountCurrency);
 }
 /// <summary>
 /// The margin that must be held in order to increase the position by the provided quantity
 /// </summary>
 /// <param name="parameters">An object containing the security and quantity of shares</param>
 /// <returns>The initial margin required for the option (i.e. the equity required to enter a position for this option)</returns>
 /// <remarks>
 /// We fix the option to 1.5x the initial because of its close coupling with the underlying.
 /// The option's contract multiplier is 1x, but might be more sensitive to volatility shocks in the long
 /// run when it comes to calculating the different market scenarios attempting to simulate VaR, resulting
 /// in a margin greater than the underlying's margin.
 /// </remarks>
 public override InitialMargin GetInitialMarginRequirement(InitialMarginParameters parameters)
 {
     return(new InitialMargin(FixedMarginMultiplier
                              * base.GetInitialMarginRequirement(parameters.ForUnderlying()).Value
                              ));
 }
Beispiel #8
0
 /// <summary>
 /// The percentage of an order's absolute cost that must be held in free cash in order to place the order
 /// </summary>
 public override InitialMargin GetInitialMarginRequirement(InitialMarginParameters parameters)
 {
     return(new InitialMargin(base.GetInitialMarginRequirement(parameters).Value
                              *GetMarginCorrectionFactor(parameters.Security)
                              ));
 }