Esempio n. 1
0
        /// <summary>
        /// Gets the margin available for trading a specific symbol in a specific direction.
        /// </summary>
        /// <param name="symbol">The symbol to compute margin remaining for</param>
        /// <param name="direction">The order/trading direction</param>
        /// <returns>The maximum order size that is currently executable in the specified direction</returns>
        public decimal GetMarginRemaining(Symbol symbol, OrderDirection direction = OrderDirection.Buy)
        {
            var security = Securities[symbol];

            var positionGroup = Positions.GetOrCreateDefaultGroup(security);
            var parameters    = new PositionGroupBuyingPowerParameters(this, positionGroup, direction);

            return(positionGroup.BuyingPowerModel.GetPositionGroupBuyingPower(parameters));
        }