示例#1
0
 internal ContractComboLeg(ResponseComposer c)
 {
     ContractId         = c.ReadInt();
     Ratio              = c.ReadInt();
     TradeAction        = c.ReadStringEnum <TradeAction>();
     Exchange           = c.ReadString();
     OpenClose          = c.ReadEnum <ComboOpenClose>();
     ComboShortSaleSlot = c.ReadEnum <ComboShortSaleSlot>();
     DesignatedLocation = c.ReadString();
     ExemptCode         = c.ReadInt();
 }
示例#2
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();
     }
 }
示例#3
0
 internal TickSize(ResponseComposer c)
 {
     c.IgnoreVersion();
     RequestId = c.ReadInt();
     TickType  = c.ReadEnum <TickType>();
     Size      = c.ReadInt();
 }
示例#4
0
 internal TickMarketDataType(ResponseComposer c)
 {
     c.IgnoreVersion();
     RequestId      = c.ReadInt();
     TickType       = TickType.MarketDataType; //
     MarketDataType = c.ReadEnum <MarketDataType>();
 }
示例#5
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));
                }
            }
        }
示例#6
0
 internal NewsBulletin(ResponseComposer c)
 {
     c.IgnoreVersion();
     MessageId = c.ReadInt();
     Type      = c.ReadEnum <NewsBulletinType>();
     Message   = c.ReadString();
     Origin    = c.ReadString();
 }
示例#7
0
        internal TickOptionComputation(ResponseComposer c)
        {
            var version = c.GetVersion();

            RequestId         = c.ReadInt();
            TickType          = c.ReadEnum <TickType>();
            ImpliedVolatility = c.ReadDoubleNullable();
            if (ImpliedVolatility == -1)
            {
                ImpliedVolatility = null;
            }

            Delta = c.ReadDoubleNullable();
            if (Delta == -2)
            {
                Delta = null;
            }

            if (version >= 6 || TickType == TickType.ModelOptionComputation || TickType == TickType.DelayedModelOption)
            {
                OptPrice = c.ReadDoubleNullable();
                if (OptPrice == -1)
                {
                    OptPrice = null;
                }
                PvDividend = c.ReadDoubleNullable();
                if (PvDividend == -1)
                {
                    PvDividend = null;
                }
            }
            if (version >= 6)
            {
                Gamma = c.ReadDoubleNullable();
                if (Gamma == -2)
                {
                    Gamma = null;
                }
                Vega = c.ReadDoubleNullable();
                if (Vega == -2)
                {
                    Vega = null;
                }
                Theta = c.ReadDoubleNullable();
                if (Theta == -2)
                {
                    Theta = null;
                }
                UndPrice = c.ReadDoubleNullable();
                if (UndPrice == -1)
                {
                    UndPrice = null;
                }
            }
        }
示例#8
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();
 }
示例#9
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));
        }
示例#10
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;
        }
示例#11
0
        internal static TickByTick?Create(ResponseComposer c)
        {
            var requestId = c.ReadInt();
            var tickType  = c.ReadEnum <TickByTickType>();
            var time      = c.ReadLong();

            return(tickType switch
            {
                TickByTickType.None => null as TickByTick,
                TickByTickType.Last => new TickByTickAllLast(requestId, tickType, time, c),
                TickByTickType.AllLast => new TickByTickAllLast(requestId, tickType, time, c),
                TickByTickType.BidAsk => new TickByTickBidAsk(requestId, tickType, time, c),
                TickByTickType.MidPoint => new TickByTickMidpoint(requestId, tickType, time, c),
                _ => throw new Exception("Invalid TickByTick type.")
            });
示例#12
0
        internal static Tick Create(ResponseComposer c)
        {
            c.IgnoreVersion();
            var requestId = c.ReadInt();
            var tickType  = c.ReadEnum <TickType>();
            var str       = c.ReadString();

            if (tickType == TickType.RealtimeVolume)
            {
                return(new TickRealtimeVolume(requestId, str, c.Parser));
            }
            if (tickType == TickType.LastTimeStamp)
            {
                return(new TickTime(requestId, str));
            }
            return(new TickString(requestId, tickType, str));
        }
示例#13
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();
            }
        }
示例#14
0
 internal override void Deserialize(ResponseComposer c)
 {
     base.Deserialize(c);
     TriggerMethod = c.ReadEnum <TriggerMethod>();
 }
 internal FinancialAdvisor(ResponseComposer c)
 {
     c.IgnoreVersion();
     DataType = c.ReadEnum <FinancialAdvisorDataType>();
     XmlData  = c.ReadString();
 }