internal OrderStatusReport(ResponseComposer c)
        {
            var serverVersion = c.Config.ServerVersionCurrent;
            var version       = serverVersion >= ServerVersion.MarketCapPrice ? int.MaxValue : c.ReadInt();

            OrderId          = c.ReadInt();
            Status           = c.ReadStringEnum <OrderStatus>();
            Filled           = c.ReadDouble();
            Remaining        = c.ReadDouble();
            AverageFillPrice = c.ReadDouble();
            if (version >= 2)
            {
                PermanentId = c.ReadInt();
            }
            if (version >= 3)
            {
                ParentId = c.ReadInt();
            }
            if (version >= 4)
            {
                LastFillPrice = c.ReadDouble();
            }
            if (version >= 5)
            {
                ClientId = c.ReadInt();
            }
            if (version >= 6)
            {
                WhyHeld = c.ReadString();
            }
            if (serverVersion >= ServerVersion.MarketCapPrice)
            {
                MktCapPrice = c.ReadDouble();
            }
        }
예제 #2
0
        internal static void Send(ResponseComposer p)
        {
            var version   = p.GetVersion();
            var requestId = p.ReadInt();

            if (requestId == int.MaxValue)
            {
                p.ReadDouble(); // trigger parse exception for testing
            }
            var priceTickType = p.ReadEnum <TickType>();
            var price         = p.ReadDouble();
            var size          = version >= 2 ? p.ReadInt() : 0;

            var priceTick = new TickPrice(requestId, priceTickType, price, new TickAttrib(version >= 3? p: null));

            p.Output(priceTick);

            if (version >= 2)
            {
                TickType tickTypeSize = GetTickTypeSize(priceTickType);
                if (tickTypeSize != TickType.Undefined)
                {
                    p.Output(new TickSize(requestId, tickTypeSize, size));
                }
            }
        }
예제 #3
0
 internal HistoricalBidAskTick(ResponseComposer c)
 {
     Time             = c.ReadLong();
     TickAttribBidAsk = new TickAttribBidAsk(c.ReadInt());
     PriceBid         = c.ReadDouble();
     PriceAsk         = c.ReadDouble();
     SizeBid          = c.ReadLong();
     SizeAsk          = c.ReadLong();
 }
 internal DeltaNeutralContract(ResponseComposer c, bool independent)
 {
     if (independent)
     {
         c.IgnoreVersion();
         RequestId = c.ReadInt();
     }
     ContractId = c.ReadInt();
     Delta      = c.ReadDouble();
     Price      = c.ReadDouble();
 }
예제 #5
0
 internal HistoricalData(ResponseComposer c)
 {
     RequestId = c.ReadInt();
     BarCount  = c.ReadInt();
     Date      = c.ReadString();
     Open      = c.ReadDouble();
     Close     = c.ReadDouble();
     High      = c.ReadDouble();
     Low       = c.ReadDouble();
     WAP       = c.ReadDouble();
     Volume    = c.ReadLong();
 }
예제 #6
0
 internal TickExchangeForPhysical(ResponseComposer c)
 {
     c.IgnoreVersion();
     RequestId                = c.ReadInt();
     TickType                 = c.ReadEnum <TickType>();
     BasisPoints              = c.ReadDouble();
     FormattedBasisPoints     = c.ReadString();
     ImpliedFuturesPrice      = c.ReadDouble();
     HoldDays                 = c.ReadInt();
     FutureExpiry             = c.ReadString();
     DividendImpact           = c.ReadDouble();
     DividendsToLastTradeDate = c.ReadDouble();
 }
예제 #7
0
 public PnL(ResponseComposer c)
 {
     RequestId = c.ReadInt();
     DailyPnL  = c.ReadDouble();
     if (c.Config.SupportsServerVersion(ServerVersion.UnrealizedPnl))
     {
         UnrealizedPnL = c.ReadDouble();
     }
     if (c.Config.SupportsServerVersion(ServerVersion.RealizedPnl))
     {
         RealizedPnL = c.ReadDouble();
     }
 }
예제 #8
0
 internal RealtimeBar(ResponseComposer c)
 {
     c.IgnoreVersion();
     RequestId = c.ReadInt();
     Time      = Instant.FromUnixTimeSeconds(long.Parse(c.ReadString(), NumberFormatInfo.InvariantInfo));
     Open      = c.ReadDouble();
     High      = c.ReadDouble();
     Low       = c.ReadDouble();
     Close     = c.ReadDouble();
     Volume    = c.ReadLong();
     Wap       = c.ReadDouble();
     Count     = c.ReadInt();
 }
예제 #9
0
 internal HistoricalBar(ResponseComposer c)
 {
     Date   = c.ReadLocalDateTime(HistoricalBars.DateTimePattern);
     Open   = c.ReadDouble();
     High   = c.ReadDouble();
     Low    = c.ReadDouble();
     Close  = c.ReadDouble();
     Volume = c.Config.ServerVersionCurrent < ServerVersion.SyntRealtimeBats ? c.ReadInt() : c.ReadLong();
     WeightedAveragePrice = c.ReadDouble();
     if (!c.Config.SupportsServerVersion(ServerVersion.SyntRealtimeBats))
     {
         c.ReadString(); /*string hasGaps = */
     }
     Count = c.ReadInt();
 }
예제 #10
0
 internal TickReqParams(ResponseComposer c)
 {
     RequestId           = c.ReadInt();
     MinTick             = c.ReadDouble();
     BboExchange         = c.ReadString();
     SnapshotPermissions = c.ReadInt();
 }
예제 #11
0
 internal HistoricalTick(ResponseComposer c)
 {
     Time = c.ReadLong();
     c.ReadInt(); // ?
     Price = c.ReadDouble();
     Size  = c.ReadLong();
 }
예제 #12
0
        internal CommissionReport(ResponseComposer c)
        {
            c.IgnoreVersion();
            ExecutionId         = c.ReadString();
            Commission          = c.ReadDouble();
            Currency            = c.ReadString();
            RealizedPnl         = c.ReadDouble();
            Yield               = c.ReadDouble();
            YieldRedemptionDate = c.ReadInt();

            if (Execution.Executions.TryGetValue(ExecutionId, out Execution execution))
            {
                Execution = execution;
                OrderId   = execution.OrderId;
                RequestId = execution.RequestId;
            }
        }
예제 #13
0
 internal PortfolioValue(ResponseComposer c)
 {
     c.RequireVersion(8);
     Contract = new Contract
     {
         ContractId   = c.ReadInt(),
         Symbol       = c.ReadString(),
         SecurityType = c.ReadStringEnum <SecurityType>(),
         LastTradeDateOrContractMonth = c.ReadString(),
         Strike          = c.ReadDouble(),
         Right           = c.ReadStringEnum <RightType>(),
         Multiplier      = c.ReadString(),
         PrimaryExchange = c.ReadString(),
         Currency        = c.ReadString(),
         LocalSymbol     = c.ReadString(),
         TradingClass    = c.ReadString()
     };
     Position      = c.ReadDouble();
     MarketPrice   = c.ReadDouble();
     MarketValue   = c.ReadDouble();
     AverageCost   = c.ReadDouble();
     UnrealizedPnl = c.ReadDouble();
     RealizedPnl   = c.ReadDouble();
     Account       = c.ReadString();
 }
예제 #14
0
 internal HistoricalLastTick(ResponseComposer c)
 {
     Time              = c.ReadLong();
     TickAttribLast    = new TickAttribLast(c.ReadInt());
     Price             = c.ReadDouble();
     Size              = c.ReadLong();
     Exchange          = c.ReadString();
     SpecialConditions = c.ReadString();
 }
예제 #15
0
 internal AccountPosition(ResponseComposer c)
 {
     c.RequireVersion(3);
     Account  = c.ReadString();
     Contract = new Contract
     {
         ContractId   = c.ReadInt(),
         Symbol       = c.ReadString(),
         SecurityType = c.ReadStringEnum <SecurityType>(),
         LastTradeDateOrContractMonth = c.ReadString(),
         Strike       = c.ReadDouble(),
         Right        = c.ReadStringEnum <RightType>(),
         Multiplier   = c.ReadString(),
         Exchange     = c.ReadString(),
         Currency     = c.ReadString(),
         LocalSymbol  = c.ReadString(),
         TradingClass = c.ReadString()
     };
     Position    = c.ReadDouble(); // may be an int
     AverageCost = c.ReadDouble();
 }
예제 #16
0
        internal static Tick Create(ResponseComposer c)
        {
            c.IgnoreVersion();
            var requestId = c.ReadInt();
            var tickType  = c.ReadEnum <TickType>();
            var value     = c.ReadDouble();

            if (tickType == TickType.Halted)
            {
                return(new TickHalted(requestId, tickType, value == 0 ? HaltType.NotHalted : HaltType.GeneralHalt));
            }
            return(new TickGeneric(requestId, tickType, value));
        }
 internal AccountPositionMulti(ResponseComposer c)
 {
     c.IgnoreVersion();
     RequestId = c.ReadInt();
     Account   = c.ReadString();
     Contract  = new Contract
     {
         ContractId   = c.ReadInt(),
         Symbol       = c.ReadString(),
         SecurityType = c.ReadStringEnum <SecurityType>(),
         LastTradeDateOrContractMonth = c.ReadString(),
         Strike       = c.ReadDouble(),
         Right        = c.ReadStringEnum <RightType>(),
         Multiplier   = c.ReadString(),
         Exchange     = c.ReadString(),
         Currency     = c.ReadString(),
         LocalSymbol  = c.ReadString(),
         TradingClass = c.ReadString()
     };
     Pos       = c.ReadDouble();
     AvgCost   = c.ReadDouble();
     ModelCode = c.ReadString();
 }
예제 #18
0
 internal MarketDepth(ResponseComposer c, bool isLevel2)
 {
     c.IgnoreVersion();
     RequestId   = c.ReadInt();
     Position    = c.ReadInt();
     MarketMaker = isLevel2 ? c.ReadString() : string.Empty;
     Operation   = c.ReadEnum <MarketDepthOperation>();
     Side        = c.ReadEnum <MarketDepthSide>();
     Price       = c.ReadDouble();
     Size        = c.ReadInt();
     if (isLevel2 && c.Config.SupportsServerVersion(ServerVersion.SmartDepth))
     {
         IsSmartDepth = c.ReadBool();
     }
 }
예제 #19
0
        internal Execution(ResponseComposer c)
        {
            if (!c.Config.SupportsServerVersion(ServerVersion.LastLiqidity))
            {
                c.RequireVersion(10);
            }
            var requestId = c.ReadInt();
            var orderId   = c.ReadInt();

            Contract = new Contract
            {
                ContractId   = c.ReadInt(),
                Symbol       = c.ReadString(),
                SecurityType = c.ReadStringEnum <SecurityType>(),
                LastTradeDateOrContractMonth = c.ReadString(),
                Strike       = c.ReadDouble(),
                Right        = c.ReadStringEnum <RightType>(),
                Multiplier   = c.ReadString(),
                Exchange     = c.ReadString(),
                Currency     = c.ReadString(),
                LocalSymbol  = c.ReadString(),
                TradingClass = c.ReadString()
            };
            RequestId               = requestId;
            OrderId                 = orderId;
            ExecutionId             = c.ReadString();
            Time                    = c.ReadString();
            Account                 = c.ReadString();
            Exchange                = c.ReadString();
            Side                    = c.ReadStringEnum <ExecutionSide>();
            Shares                  = c.ReadDouble();
            Price                   = c.ReadDouble();
            PermanentId             = c.ReadInt();
            ClientId                = c.ReadInt();
            Liquidation             = c.ReadInt();
            CumulativeQuantity      = c.ReadDouble();
            AveragePrice            = c.ReadDouble();
            OrderReference          = c.ReadString();
            EconomicValueRule       = c.ReadString();
            EconomicValueMultiplier = c.ReadDouble();
            if (c.Config.SupportsServerVersion(ServerVersion.ModelsSupport))
            {
                ModelCode = c.ReadString();
            }
            if (c.Config.SupportsServerVersion(ServerVersion.LastLiqidity))
            {
                LastLiquidity = c.ReadEnum <Liquidity>();
            }
            Executions[ExecutionId] = this;
        }
예제 #20
0
 public PriceIncrement(ResponseComposer c)
 {
     LowEdge   = c.ReadDouble();
     Increment = c.ReadDouble();
 }
예제 #21
0
        internal ContractData(ResponseComposer c, ContractDataType type)
        {
            switch (type)
            {
            case ContractDataType.ContractData:
                c.RequireVersion(8);
                RequestId = c.ReadInt();

                Contract.Symbol       = c.ReadString();
                Contract.SecurityType = c.ReadStringEnum <SecurityType>();

                ReadLastTradeDate(c.ReadString(), false);

                Contract.Strike      = c.ReadDouble();
                Contract.Right       = c.ReadStringEnum <RightType>();
                Contract.Exchange    = c.ReadString();
                Contract.Currency    = c.ReadString();
                Contract.LocalSymbol = c.ReadString();

                MarketName = c.ReadString();

                Contract.TradingClass = c.ReadString();
                Contract.ContractId   = c.ReadInt();

                MinimumTick = c.ReadDouble();
                if (c.Config.SupportsServerVersion(ServerVersion.MdSizeMultiplier))
                {
                    MdSizeMultiplier = c.ReadInt();
                }

                Contract.Multiplier = c.ReadString();

                OrderTypes           = c.ReadString();
                ValidExchanges       = c.ReadString();
                PriceMagnifier       = c.ReadInt();
                UnderlyingContractId = c.ReadInt();
                LongName             = c.ReadString();

                Contract.PrimaryExchange = c.ReadString();

                ContractMonth           = c.ReadString();
                Industry                = c.ReadString();
                Category                = c.ReadString();
                Subcategory             = c.ReadString();
                TimeZoneId              = c.ReadString();
                TradingHours            = c.ReadString();
                LiquidHours             = c.ReadString();
                EconomicValueRule       = c.ReadString();
                EconomicValueMultiplier = c.ReadDouble();
                c.AddTagsToList(SecurityIds);
                if (c.Config.SupportsServerVersion(ServerVersion.AggGroup))
                {
                    AggGroup = c.ReadInt();
                }
                if (c.Config.SupportsServerVersion(ServerVersion.UnderlyingInfo))
                {
                    UnderSymbol  = c.ReadString();
                    UnderSecType = c.ReadString();
                }
                if (c.Config.SupportsServerVersion(ServerVersion.MarketRules))
                {
                    MarketRuleIds = c.ReadString();
                }
                if (c.Config.SupportsServerVersion(ServerVersion.RealExpirationDate))
                {
                    RealExpirationDate = c.ReadString();
                }
                break;

            case ContractDataType.BondContractData:
                var version = c.RequireVersion(6);
                RequestId = c.ReadInt();

                Contract.Symbol       = c.ReadString();
                Contract.SecurityType = c.ReadStringEnum <SecurityType>();

                Cusip  = c.ReadString();
                Coupon = c.ReadDouble();

                ReadLastTradeDate(c.ReadString(), true);

                IssueDate         = c.ReadString();
                CreditRatings     = c.ReadString();
                BondType          = c.ReadString();
                CouponType        = c.ReadString();
                Convertible       = c.ReadBool();
                Callable          = c.ReadBool();
                Putable           = c.ReadBool();
                DescriptionAppend = c.ReadString();

                Contract.Exchange     = c.ReadString();
                Contract.Currency     = c.ReadString();
                MarketName            = c.ReadString();
                Contract.TradingClass = c.ReadString();
                Contract.ContractId   = c.ReadInt();
                MinimumTick           = c.ReadDouble();
                if (c.Config.SupportsServerVersion(ServerVersion.MdSizeMultiplier))
                {
                    MdSizeMultiplier = c.ReadInt();
                }
                OrderTypes        = c.ReadString();
                ValidExchanges    = c.ReadString();
                NextOptionDate    = c.ReadString();
                NextOptionType    = c.ReadString();
                NextOptionPartial = c.ReadBool();
                Notes             = c.ReadString();
                LongName          = c.ReadString();
                if (version >= 6)
                {
                    EconomicValueRule       = c.ReadString();
                    EconomicValueMultiplier = c.ReadDouble();
                }
                if (version >= 5)
                {
                    c.AddTagsToList(SecurityIds);
                }
                if (c.Config.SupportsServerVersion(ServerVersion.AggGroup))
                {
                    AggGroup = c.ReadInt();
                }
                if (c.Config.SupportsServerVersion(ServerVersion.MarketRules))
                {
                    MarketRuleIds = c.ReadString();
                }
                break;

            case ContractDataType.ScannerContractData:
                Contract.ContractId   = c.ReadInt();
                Contract.Symbol       = c.ReadString();
                Contract.SecurityType = c.ReadStringEnum <SecurityType>();
                Contract.LastTradeDateOrContractMonth = c.ReadString();
                Contract.Strike       = c.ReadDouble();
                Contract.Right        = c.ReadStringEnum <RightType>();
                Contract.Exchange     = c.ReadString();
                Contract.Currency     = c.ReadString();
                Contract.LocalSymbol  = c.ReadString();
                MarketName            = c.ReadString();
                Contract.TradingClass = c.ReadString();
                break;
            }
        }
예제 #22
0
 internal HistogramItem(ResponseComposer c)
 {
     Price = c.ReadDouble();
     Size  = c.ReadLong();
 }
예제 #23
0
        internal OpenOrder(ResponseComposer c) // the monster
        {
            var serverVersion  = c.Config.ServerVersionCurrent;
            var messageVersion = serverVersion < ServerVersion.OrderContainer ? c.RequireVersion(17) : (int)serverVersion;
            var orderId        = c.ReadInt();

            Contract = new Contract
            {
                ContractId   = c.ReadInt(),
                Symbol       = c.ReadString(),
                SecurityType = c.ReadStringEnum <SecurityType>(),
                LastTradeDateOrContractMonth = c.ReadString(),
                Strike       = c.ReadDouble(),
                Right        = c.ReadStringEnum <RightType>(),
                Multiplier   = messageVersion >= 32 ? c.ReadString() : string.Empty,
                Exchange     = c.ReadString(),
                Currency     = c.ReadString(),
                LocalSymbol  = c.ReadString(),
                TradingClass = messageVersion >= 32 ? c.ReadString() : string.Empty
            };
            Order = new Order
            {
                OrderId       = orderId,
                TradeAction   = c.ReadStringEnum <TradeAction>(),
                TotalQuantity = c.ReadDouble(),
                OrderType     = c.ReadStringEnum <OrderType>(),
                LimitPrice    = messageVersion < 29 ? c.ReadDouble() : c.ReadDoubleNullable(),
                AuxPrice      = messageVersion < 30 ? c.ReadDouble() : c.ReadDoubleNullable(),
                TimeInForce   = c.ReadStringEnum <TimeInForce>(),
                OcaGroup      = c.ReadString(),
                Account       = c.ReadString(),
                OpenClose     = c.ReadStringEnum <OrderOpenClose>(),
                Origin        = c.ReadEnum <OrderOrigin>(),
                OrderRef      = c.ReadString(),
                ClientId      = c.ReadInt(),
                PermanentId   = c.ReadInt(),
                OutsideRegularTradingHours = c.ReadBool(),
                Hidden = c.ReadBool(),
                DiscretionaryAmount = c.ReadDouble(),
                GoodAfterTime       = c.ReadString()
            };

            OrderId = Order.OrderId;

            c.ReadString(); // skip deprecated sharesAllocation field

            Order.FinancialAdvisorGroup      = c.ReadString();
            Order.FinancialAdvisorMethod     = c.ReadStringEnum <FinancialAdvisorAllocationMethod>();
            Order.FinancialAdvisorPercentage = c.ReadString();
            Order.FinancialAdvisorProfile    = c.ReadString();

            if (c.Config.SupportsServerVersion(ServerVersion.ModelsSupport))
            {
                Order.ModelCode = c.ReadString();
            }

            Order.GoodUntilDate       = c.ReadString();
            Order.Rule80A             = c.ReadStringEnum <AgentDescription>();
            Order.PercentOffset       = c.ReadDoubleNullable();
            Order.SettlingFirm        = c.ReadString();
            Order.ShortSaleSlot       = c.ReadEnum <ShortSaleSlot>();
            Order.DesignatedLocation  = c.ReadString();
            Order.ExemptCode          = c.ReadInt();
            Order.AuctionStrategy     = c.ReadEnum <AuctionStrategy>();
            Order.StartingPrice       = c.ReadDoubleNullable();
            Order.StockReferencePrice = c.ReadDoubleNullable();
            Order.Delta           = c.ReadDoubleNullable();
            Order.StockRangeLower = c.ReadDoubleNullable();
            Order.StockRangeUpper = c.ReadDoubleNullable();
            Order.DisplaySize     = c.ReadInt();

            Order.BlockOrder          = c.ReadBool();
            Order.SweepToFill         = c.ReadBool();
            Order.AllOrNone           = c.ReadBool();
            Order.MinimumQuantity     = c.ReadIntNullable();
            Order.OcaType             = c.ReadEnum <OcaType>();
            Order.ElectronicTradeOnly = c.ReadBool();
            Order.FirmQuoteOnly       = c.ReadBool();
            Order.NbboPriceCap        = c.ReadDoubleNullable();

            Order.ParentId      = c.ReadInt();
            Order.TriggerMethod = c.ReadEnum <TriggerMethod>();

            Order.Volatility     = c.ReadDoubleNullable();
            Order.VolatilityType = c.ReadEnum <VolatilityType>();

            Order.DeltaNeutralOrderType = c.ReadString();
            Order.DeltaNeutralAuxPrice  = c.ReadDoubleNullable();

            if (!string.IsNullOrEmpty(Order.DeltaNeutralOrderType))
            {
                if (messageVersion >= 27)
                {
                    Order.DeltaNeutralContractId      = c.ReadInt();
                    Order.DeltaNeutralSettlingFirm    = c.ReadString();
                    Order.DeltaNeutralClearingAccount = c.ReadString();
                    Order.DeltaNeutralClearingIntent  = c.ReadString();
                }
                if (messageVersion >= 31)
                {
                    Order.DeltaNeutralOpenClose          = c.ReadString();
                    Order.DeltaNeutralShortSale          = c.ReadBool();
                    Order.DeltaNeutralShortSaleSlot      = c.ReadInt();
                    Order.DeltaNeutralDesignatedLocation = c.ReadString();
                }
            }

            Order.ContinuousUpdate   = c.ReadInt();
            Order.ReferencePriceType = c.ReadEnum <ReferencePriceType>();

            Order.TrailingStopPrice = c.ReadDoubleNullable();
            if (messageVersion >= 30)
            {
                Order.TrailingStopPercent = c.ReadDoubleNullable();
            }

            Order.BasisPoints             = c.ReadDoubleNullable();
            Order.BasisPointsType         = c.ReadIntNullable();
            Contract.ComboLegsDescription = c.ReadString();

            if (messageVersion >= 29)
            {
                var n = c.ReadInt();
                for (var i = 0; i < n; i++)
                {
                    Contract.ComboLegs.Add(new ContractComboLeg(c));
                }

                n = c.ReadInt();
                for (var i = 0; i < n; i++)
                {
                    Order.ComboLegs.Add(new OrderComboLeg(c.ReadDoubleNullable()));
                }
            }

            if (messageVersion >= 26)
            {
                c.AddTagsToList(Order.SmartComboRoutingParams);
            }

            if (messageVersion >= 15)
            {
                if (messageVersion >= 20)
                {
                    Order.ScaleInitLevelSize = c.ReadIntNullable();
                    Order.ScaleSubsLevelSize = c.ReadIntNullable();
                }
                else
                {
                    c.ReadString();
                    Order.ScaleInitLevelSize = c.ReadIntNullable();
                }
                Order.ScalePriceIncrement = c.ReadDoubleNullable();
            }

            if (messageVersion >= 28 && Order.ScalePriceIncrement > 0)
            {
                Order.ScalePriceAdjustValue    = c.ReadDoubleNullable();
                Order.ScalePriceAdjustInterval = c.ReadIntNullable();
                Order.ScaleProfitOffset        = c.ReadDoubleNullable();
                Order.ScaleAutoReset           = c.ReadBool();
                Order.ScaleInitPosition        = c.ReadIntNullable();
                Order.ScaleInitFillQty         = c.ReadIntNullable();
                Order.ScaleRandomPercent       = c.ReadBool();
            }

            if (messageVersion >= 24)
            {
                Order.HedgeType = c.ReadStringEnum <HedgeType>();
                if (Order.HedgeType != HedgeType.Undefined)
                {
                    Order.HedgeParam = c.ReadString();
                }
            }

            if (messageVersion >= 25)
            {
                Order.OptOutSmartRouting = c.ReadBool();
            }

            if (messageVersion >= 19)
            {
                Order.ClearingAccount = c.ReadString();
                Order.ClearingIntent  = c.ReadStringEnum <ClearingIntent>();
            }

            if (messageVersion >= 22)
            {
                Order.NotHeld = c.ReadBool();
            }

            if (messageVersion >= 20 && c.ReadBool())
            {
                Contract.DeltaNeutralContract = new DeltaNeutralContract(c, false);
            }

            if (messageVersion >= 21)
            {
                Order.AlgoStrategy = c.ReadString();
                if (!string.IsNullOrEmpty(Order.AlgoStrategy))
                {
                    c.AddTagsToList(Order.AlgoParams);
                }
            }

            if (messageVersion >= 33)
            {
                Order.Solicited = c.ReadBool();
            }

            Order.WhatIf = c.ReadBool();
            Status       = c.ReadStringEnum <OrderStatus>();

            if (serverVersion >= ServerVersion.WhatIfExtFields)
            {
                InitialMarginBefore     = c.ReadString();
                MaintenanceMarginBefore = c.ReadString();
                EquityWithLoanBefore    = c.ReadString();
                InitMarginChange        = c.ReadString();
                MaintMarginChange       = c.ReadString();
                EquityWithLoanChange    = c.ReadString();
            }
            InitMarginAfter      = c.ReadString();
            MaintMarginAfter     = c.ReadString();
            EquityWithLoanBefore = c.ReadString();
            Commission           = c.ReadDoubleNullable();
            MinimumCommission    = c.ReadDoubleNullable();
            MaximumCommission    = c.ReadDoubleNullable();
            CommissionCurrency   = c.ReadString();
            WarningText          = c.ReadString();

            if (messageVersion >= 34)
            {
                Order.RandomizeSize  = c.ReadBool();
                Order.RandomizePrice = c.ReadBool();
            }

            if (c.Config.SupportsServerVersion(ServerVersion.PeggedToBenchmark))
            {
                if (Order.OrderType == OrderType.PeggedToBenchmark)
                {
                    Order.ReferenceContractId          = c.ReadInt();
                    Order.IsPeggedChangeAmountDecrease = c.ReadBool();
                    Order.PeggedChangeAmount           = c.ReadDoubleNullable();
                    Order.ReferenceChangeAmount        = c.ReadDoubleNullable();
                    Order.ReferenceExchange            = c.ReadString();
                }

                var n = c.ReadInt();
                if (n > 0)
                {
                    for (var i = 0; i < n; i++)
                    {
                        var orderConditionType = c.ReadEnum <OrderConditionType>();
                        var condition          = OrderCondition.Create(orderConditionType);
                        condition.Deserialize(c);
                        Order.Conditions.Add(condition);
                    }
                    Order.ConditionsIgnoreRegularTradingHours = c.ReadBool();
                    Order.ConditionsCancelOrder = c.ReadBool();
                }

                Order.AdjustedOrderType      = c.ReadString();
                Order.TriggerPrice           = c.ReadDoubleNullable();
                Order.TrailingStopPrice      = c.ReadDoubleNullable();
                Order.LmtPriceOffset         = c.ReadDoubleNullable();
                Order.AdjustedStopPrice      = c.ReadDoubleNullable();
                Order.AdjustedStopLimitPrice = c.ReadDoubleNullable();
                Order.AdjustedTrailingAmount = c.ReadDoubleNullable();
                Order.AdjustableTrailingUnit = c.ReadInt();
            }

            if (c.Config.SupportsServerVersion(ServerVersion.SoftDollarTier))
            {
                Order.SoftDollarTier = new SoftDollarTier(c);
            }

            if (c.Config.SupportsServerVersion(ServerVersion.CashQty))
            {
                Order.CashQty = c.ReadDoubleNullable();
            }

            if (c.Config.SupportsServerVersion(ServerVersion.AutoPriceForHedge))
            {
                Order.DontUseAutoPriceForHedge = c.ReadBool();
            }

            if (c.Config.SupportsServerVersion(ServerVersion.OrderContainer))
            {
                Order.IsOmsContainer = c.ReadBool();
            }

            if (c.Config.SupportsServerVersion(ServerVersion.DPegOrders))
            {
                Order.DiscretionaryUpToLimitPrice = c.ReadBool();
            }
        }