Example #1
0
        internal static MarginAndQuantityResult CalculateUnfilledMarginArgsForPlacePendingOrder(AccountClass.Instrument instrument, Transaction tran, bool isBuy, Dictionary <Guid, decimal> remainFilledLotPerOrderDict)
        {
            MarginAndQuantityResult result = new MarginAndQuantityResult();
            bool    isAutoClose            = tran.Owner.IsAutoClose || instrument.IsPhysical;
            decimal canAutoCloseLot        = CalculateUnfilledAutoCloseLot(instrument, tran, isBuy, isAutoClose, remainFilledLotPerOrderDict);
            Dictionary <Guid, decimal> unfilledLotPerTran = null;

            if (isAutoClose && canAutoCloseLot > 0)
            {
                decimal totalAutoCloseLot = FilledCalculator.CalculateTotalAutoCloseLot(instrument, isBuy, canAutoCloseLot, remainFilledLotPerOrderDict);
                unfilledLotPerTran = CalculateRemainUnfilledLotPerTransactionInSameDirection(instrument, isBuy, totalAutoCloseLot);
            }
            result = CalculateUnfilledMarginAndQuantity(instrument, isBuy, unfilledLotPerTran);
            return(result);
        }