public static void ReadHedge(this IBSocket socket, IBOrderCondition ibCon) { var str = socket.ReadStr(); if (str.IsEmpty()) { ibCon.Hedge.Type = null; return; } switch (str) { case "D": ibCon.Hedge.Type = IBOrderCondition.HedgeTypes.Delta; break; case "B": ibCon.Hedge.Type = IBOrderCondition.HedgeTypes.Beta; break; case "F": ibCon.Hedge.Type = IBOrderCondition.HedgeTypes.FX; break; case "P": ibCon.Hedge.Type = IBOrderCondition.HedgeTypes.Pair; break; default: throw new InvalidOperationException(LocalizedStrings.Str2508Params.Put(str)); } ibCon.Hedge.Param = socket.ReadStr(); }
public static IBSocket SendHedge(this IBSocket socket, IBOrderCondition condition) { if (condition == null) { throw new ArgumentNullException(nameof(condition)); } if (socket.ServerVersion < ServerVersions.V54) { return(socket); } if (condition.Hedge.Type == null) { return(socket.Send(string.Empty)); } else { switch (condition.Hedge.Type.Value) { case IBOrderCondition.HedgeTypes.Delta: socket.Send("D"); break; case IBOrderCondition.HedgeTypes.Beta: socket.Send("B"); break; case IBOrderCondition.HedgeTypes.FX: socket.Send("F"); break; case IBOrderCondition.HedgeTypes.Pair: socket.Send("P"); break; default: throw new ArgumentOutOfRangeException(); } return(socket.Send(condition.Hedge.Param)); } }
public static IBSocket SendDeltaNeutral(this IBSocket socket, IBOrderCondition condition) { if (condition == null) { throw new ArgumentNullException(nameof(condition)); } var volatility = condition.Volatility; if (socket.ServerVersion < ServerVersions.V28) { return(socket.Send(volatility.OrderType == OrderTypes.Market)); } else { socket.SendOrderType(volatility.OrderType, volatility.ExtendedOrderType); socket.Send(volatility.StopPrice); if (volatility.ExtendedOrderType != IBOrderCondition.ExtendedOrderTypes.Empty) { if (socket.ServerVersion >= ServerVersions.V58) { socket .Send(volatility.ConId) .Send(volatility.SettlingFirm) .SendPortfolio(volatility.ClearingPortfolio) .Send(volatility.ClearingIntent); } if (socket.ServerVersion >= ServerVersions.V66) { socket .Send(volatility.ShortSale.IsOpenOrClose) .Send(volatility.IsShortSale) .SendShortSale(volatility.ShortSale); } } return(socket); } }
private void ReadOpenOrder(IBSocket socket, ServerVersions version) { var transactionId = socket.ReadInt(); var contractId = version >= ServerVersions.V17 ? socket.ReadInt() : -1; var secCode = socket.ReadStr(); var type = socket.ReadSecurityType(); var expiryDate = socket.ReadExpiry(); var strike = socket.ReadDecimal(); var optionType = socket.ReadOptionType(); var multiplier = version >= ServerVersions.V32 ? socket.ReadMultiplier() : null; var boardCode = socket.ReadBoardCode(); var currency = socket.ReadCurrency(); secCode = version >= ServerVersions.V2 ? socket.ReadLocalCode(secCode) : null; var secClass = (version >= ServerVersions.V32) ? socket.ReadStr() : null; var ibCon = new IBOrderCondition(); // read order fields var direction = socket.ReadOrderSide(); var volume = socket.ReadDecimal(); OrderTypes orderType; IBOrderCondition.ExtendedOrderTypes? extendedType; socket.ReadOrderType(out orderType, out extendedType); ibCon.ExtendedType = extendedType; var price = socket.ReadDecimal(); ibCon.StopPrice = socket.ReadDecimal(); var expiration = socket.ReadStr(); ibCon.Oca.Group = socket.ReadStr(); var portfolio = socket.ReadStr(); ibCon.IsOpenOrClose = socket.ReadStr() == "O"; ibCon.Origin = (IBOrderCondition.OrderOrigins)socket.ReadInt(); var comment = socket.ReadStr(); var clientId = version >= ServerVersions.V3 ? socket.ReadInt() : (int?)null; int? permId = null; if (version >= ServerVersions.V4) { permId = socket.ReadInt(); if (version < ServerVersions.V18) { // will never happen /* order.m_ignoreRth = */ socket.ReadBool(); } else ibCon.OutsideRth = socket.ReadBool(); ibCon.Hidden = socket.ReadBool(); ibCon.SmartRouting.DiscretionaryAmount = socket.ReadDecimal(); } if (version >= ServerVersions.V5) ibCon.GoodAfterTime = socket.ReadNullDateTime(IBSocketHelper.TimeFormat); if (version >= ServerVersions.V6) { // skip deprecated sharesAllocation field socket.ReadStr(); } if (version >= ServerVersions.V7) { ibCon.FinancialAdvisor.Group = socket.ReadStr(); ibCon.FinancialAdvisor.Allocation = socket.ReadFinancialAdvisor(); ibCon.FinancialAdvisor.Percentage = socket.ReadStr(); ibCon.FinancialAdvisor.Profile = socket.ReadStr(); } var orderExpiryDate = version >= ServerVersions.V8 ? socket.ReadNullDateTime(IBSocketHelper.TimeFormat) : null; var visibleVolume = volume; if (version >= ServerVersions.V9) { ibCon.Agent = socket.ReadAgent(); ibCon.PercentOffset = socket.ReadDecimal(); ibCon.Clearing.SettlingFirm = socket.ReadStr(); ibCon.ShortSale.Slot = (IBOrderCondition.ShortSaleSlots)socket.ReadInt(); ibCon.ShortSale.Location = socket.ReadStr(); if (socket.ServerVersion == ServerVersions.V51) socket.ReadInt(); //exempt code else if (version >= ServerVersions.V23) ibCon.ShortSale.ExemptCode = socket.ReadInt(); ibCon.AuctionStrategy = (IBOrderCondition.AuctionStrategies)socket.ReadInt(); ibCon.StartingPrice = socket.ReadDecimal(); ibCon.StockRefPrice = socket.ReadDecimal(); ibCon.Delta = socket.ReadDecimal(); ibCon.StockRangeLower = socket.ReadDecimal(); ibCon.StockRangeUpper = socket.ReadDecimal(); visibleVolume = socket.ReadInt(); if (version < ServerVersions.V18) { // will never happen /* order.m_rthOnly = */ socket.ReadBool(); } ibCon.BlockOrder = socket.ReadBool(); ibCon.SweepToFill = socket.ReadBool(); ibCon.AllOrNone = socket.ReadBool(); ibCon.MinVolume = socket.ReadInt(); ibCon.Oca.Type = (IBOrderCondition.OcaTypes)socket.ReadInt(); ibCon.SmartRouting.ETradeOnly = socket.ReadBool(); ibCon.SmartRouting.FirmQuoteOnly = socket.ReadBool(); ibCon.SmartRouting.NbboPriceCap = socket.ReadDecimal(); } if (version >= ServerVersions.V10) { ibCon.ParentId = socket.ReadInt(); ibCon.TriggerMethod = (IBOrderCondition.TriggerMethods)socket.ReadInt(); } if (version >= ServerVersions.V11) { ibCon.Volatility.Volatility = socket.ReadDecimal(); ibCon.Volatility.VolatilityTimeFrame = socket.ReadVolatilityType(); if (version == ServerVersions.V11) { if (!socket.ReadBool()) ibCon.Volatility.ExtendedOrderType = IBOrderCondition.ExtendedOrderTypes.Empty; else ibCon.Volatility.OrderType = OrderTypes.Market; } else { OrderTypes volOrdertype; IBOrderCondition.ExtendedOrderTypes? volExtendedType; socket.ReadOrderType(out volOrdertype, out volExtendedType); ibCon.Volatility.OrderType = volOrdertype; ibCon.Volatility.ExtendedOrderType = volExtendedType; ibCon.Volatility.StopPrice = socket.ReadDecimal(); if (volExtendedType != IBOrderCondition.ExtendedOrderTypes.Empty) { if (version >= ServerVersions.V27) { ibCon.Volatility.ConId = socket.ReadInt(); ibCon.Volatility.SettlingFirm = socket.ReadStr(); var portfolioName = socket.ReadStr(); if (!portfolioName.IsEmpty()) ibCon.Volatility.ClearingPortfolio = portfolioName; ibCon.Volatility.ClearingIntent = socket.ReadStr(); } if (version >= ServerVersions.V31) { var isOpenOrCloseStr = socket.ReadStr(); ibCon.Volatility.ShortSale.IsOpenOrClose = isOpenOrCloseStr == "?" ? (bool?)null : isOpenOrCloseStr.To<int>() == 1; ibCon.Volatility.IsShortSale = socket.ReadBool(); ibCon.Volatility.ShortSale.Slot = (IBOrderCondition.ShortSaleSlots)socket.ReadInt(); ibCon.Volatility.ShortSale.Location = socket.ReadStr(); } } } ibCon.Volatility.ContinuousUpdate = socket.ReadBool(); if (socket.ServerVersion == ServerVersions.V26) { ibCon.StockRangeLower = socket.ReadDecimal(); ibCon.StockRangeUpper = socket.ReadDecimal(); } ibCon.Volatility.IsAverageBestPrice = socket.ReadBool(); } if (version >= ServerVersions.V13) ibCon.TrailStopPrice = socket.ReadDecimal(); if (version >= ServerVersions.V30) ibCon.TrailStopVolumePercentage = socket.ReadNullDecimal(); if (version >= ServerVersions.V14) { ibCon.Combo.BasisPoints = socket.ReadDecimal(); ibCon.Combo.BasisPointsType = socket.ReadInt(); ibCon.Combo.LegsDescription = socket.ReadStr(); } if (version >= ServerVersions.V29) { var comboLegsCount = socket.ReadInt(); if (comboLegsCount > 0) { //contract.m_comboLegs = new Vector(comboLegsCount); for (var i = 0; i < comboLegsCount; ++i) { //int conId = socket.ReadInt(); //int ratio = socket.ReadInt(); //String action = socket.ReadStr(); //String exchange = socket.ReadStr(); //int openClose = socket.ReadInt(); //int shortSaleSlot = socket.ReadInt(); //String designatedLocation = socket.ReadStr(); //int exemptCode = socket.ReadInt(); //ComboLeg comboLeg = new ComboLeg(conId, ratio, action, exchange, openClose, // shortSaleSlot, designatedLocation, exemptCode); //contract.m_comboLegs.add(comboLeg); } } var orderComboLegsCount = socket.ReadInt(); if (orderComboLegsCount > 0) { //order.m_orderComboLegs = new Vector(orderComboLegsCount); for (var i = 0; i < orderComboLegsCount; ++i) { //var comboPrice = socket.ReadNullDecimal(); //OrderComboLeg orderComboLeg = new OrderComboLeg(comboPrice); //order.m_orderComboLegs.add(orderComboLeg); } } } if (version >= ServerVersions.V26) { var smartComboRoutingParamsCount = socket.ReadInt(); if (smartComboRoutingParamsCount > 0) { var @params = new List<Tuple<string, string>>(); for (var i = 0; i < smartComboRoutingParamsCount; ++i) @params.Add(Tuple.Create(socket.ReadStr(), socket.ReadStr())); ibCon.SmartRouting.ComboParams = @params; } } if (version >= ServerVersions.V15) { if (version >= ServerVersions.V20) { ibCon.Scale.InitLevelSize = socket.ReadNullInt(); ibCon.Scale.SubsLevelSize = socket.ReadNullInt(); } else { /* int notSuppScaleNumComponents = */ socket.ReadNullInt(); ibCon.Scale.InitLevelSize = socket.ReadNullInt(); } ibCon.Scale.PriceIncrement = socket.ReadNullDecimal(); } if (version >= ServerVersions.V28 && ibCon.Scale.PriceIncrement > 0) { ibCon.Scale.PriceAdjustValue = socket.ReadNullDecimal(); ibCon.Scale.PriceAdjustInterval = socket.ReadInt(); ibCon.Scale.ProfitOffset = socket.ReadNullDecimal(); ibCon.Scale.AutoReset = socket.ReadBool(); ibCon.Scale.InitPosition = socket.ReadNullInt(); ibCon.Scale.InitFillQty = socket.ReadNullInt(); ibCon.Scale.RandomPercent = socket.ReadBool(); } if (version >= ServerVersions.V24) socket.ReadHedge(ibCon); if (version >= ServerVersions.V25) ibCon.SmartRouting.OptOutSmartRouting = socket.ReadBool(); if (version >= ServerVersions.V19) { var portfolioName = socket.ReadStr(); if (!portfolioName.IsEmpty()) ibCon.Clearing.ClearingPortfolio = portfolioName; ibCon.Clearing.Intent = socket.ReadIntent(); } if (version >= ServerVersions.V22) ibCon.SmartRouting.NotHeld = socket.ReadBool(); if (version >= ServerVersions.V20) { if (socket.ReadBool()) { //UnderlyingComponent underComp = new UnderlyingComponent(); //underComp.ContractId = socket.ReadInt(); //underComp.Delta = socket.ReadDecimal(); //underComp.Price = socket.ReadDecimal(); //contract.UnderlyingComponent = underComp; } } if (version >= ServerVersions.V21) { ibCon.Algo.Strategy = socket.ReadStr(); if (!ibCon.Algo.Strategy.IsEmpty()) { var algoParamsCount = socket.ReadInt(); if (algoParamsCount > 0) { var algoParams = new List<Tuple<string, string>>(); for (var i = 0; i < algoParamsCount; i++) algoParams.Add(Tuple.Create(socket.ReadStr(), socket.ReadStr())); ibCon.Algo.Params = algoParams; } } } //OrderState orderState = new OrderState(); OrderStatus? status = null; if (version >= ServerVersions.V16) { socket.ReadStr(); //order.WhatIf = !(string.IsNullOrEmpty(rstr) || rstr == "0"); status = socket.ReadOrderStatus(); //orderState.InitMargin = socket.ReadStr(); //orderState.MaintMargin = socket.ReadStr(); //orderState.EquityWithLoan = socket.ReadStr(); //orderState.IbCommission = socket.ReadNullDecimal(); //orderState.MinCommission = socket.ReadNullDecimal(); //orderState.MaxCommission = socket.ReadNullDecimal(); //orderState.CommissionCurrency = socket.ReadStr(); //orderState.WarningText = socket.ReadStr(); } var secId = new SecurityId { SecurityCode = secCode, BoardCode = GetBoardCode(boardCode), InteractiveBrokers = contractId, }; SendOutMessage(new SecurityMessage { SecurityId = secId, ExpiryDate = expiryDate, Strike = strike, OptionType = optionType, Class = secClass, SecurityType = type, Currency = currency, Multiplier = multiplier ?? 0, }); var orderMsg = new ExecutionMessage { ExecutionType = ExecutionTypes.Transaction, SecurityId = secId, OriginalTransactionId = transactionId, OrderType = orderType, Side = direction, OrderVolume = volume, OrderPrice = price, Condition = ibCon, ExpiryDate = orderExpiryDate, VisibleVolume = visibleVolume, PortfolioName = portfolio, Comment = comment, OrderStatus = status, OrderState = status?.ToOrderState(), HasOrderInfo = true, }; if (orderMsg.OrderState == OrderStates.Active || orderMsg.OrderState == OrderStates.Done) orderMsg.OrderId = transactionId; switch (expiration) { case "DAY": orderMsg.TimeInForce = TimeInForce.PutInQueue; break; case "GTC": //orderMsg.ExpiryDate = DateTimeOffset.MaxValue; break; case "IOC": orderMsg.TimeInForce = TimeInForce.CancelBalance; break; case "FOK": orderMsg.TimeInForce = TimeInForce.MatchOrCancel; break; case "GTD": break; case "OPG": ibCon.IsMarketOnOpen = true; break; default: throw new InvalidOperationException(LocalizedStrings.Str2515Params.Put(expiration)); } if (clientId != null) orderMsg.SetClientId(clientId.Value); if (permId != null) orderMsg.SetPermId(permId.Value); SendOutMessage(orderMsg); }
public static IBSocket SendCombo(this IBSocket socket, WeightedIndexSecurity security, IBOrderCondition condition = null) { if (security == null) { throw new ArgumentNullException(nameof(security)); } var innerSecurities = security.InnerSecurities.ToArray(); socket.Send(innerSecurities.Length); foreach (var innerSecurity in innerSecurities) { var weight = security.Weights[innerSecurity]; socket .SendContractId(innerSecurity.ToSecurityId()) .Send((int)weight.Abs()) .SendSide(weight >= 0 ? Sides.Buy : Sides.Sell) .SendBoardCode(innerSecurity.Board.Code); if (condition == null) { continue; } var shortSale = condition.Combo.ShortSales[innerSecurity.ToSecurityId()]; socket .Send(shortSale.IsOpenOrClose) .SendShortSale(shortSale, true); } return(socket); }
public static IBSocket SendCombo(this IBSocket socket, WeightedIndexSecurity security, IBOrderCondition condition = null) { if (security == null) throw new ArgumentNullException("security"); var innerSecurities = security.InnerSecurities.ToArray(); socket.Send(innerSecurities.Length); foreach (var innerSecurity in innerSecurities) { var weight = security.Weights[innerSecurity]; socket .SendContractId(innerSecurity.ToSecurityId()) .Send((int)weight.Abs()) .SendSide(weight >= 0 ? Sides.Buy : Sides.Sell) .SendBoardCode(innerSecurity.Board.Code); if (condition == null) continue; var shortSale = condition.Combo.ShortSales[innerSecurity.ToSecurityId()]; socket .Send(shortSale.IsOpenOrClose) .SendShortSale(shortSale, true); } return socket; }
public static void ReadOrderType(this IBSocket socket, out OrderTypes type, out IBOrderCondition.ExtendedOrderTypes? extendedType) { var str = socket.ReadStr(); switch (str.ToUpperInvariant()) { case "LMT": type = OrderTypes.Limit; extendedType = IBOrderCondition.ExtendedOrderTypes.Empty; break; case "MKT": type = OrderTypes.Market; extendedType = IBOrderCondition.ExtendedOrderTypes.Empty; break; case "MOC": type = OrderTypes.Conditional; extendedType = IBOrderCondition.ExtendedOrderTypes.MarketOnClose; break; case "LMTCLS": type = OrderTypes.Conditional; extendedType = IBOrderCondition.ExtendedOrderTypes.LimitOnClose; break; case "PEGMKT": type = OrderTypes.Conditional; extendedType = IBOrderCondition.ExtendedOrderTypes.PeggedToMarket; break; case "STP": type = OrderTypes.Conditional; extendedType = IBOrderCondition.ExtendedOrderTypes.Stop; break; case "STP LMT": type = OrderTypes.Conditional; extendedType = IBOrderCondition.ExtendedOrderTypes.StopLimit; break; case "TRAIL": type = OrderTypes.Conditional; extendedType = IBOrderCondition.ExtendedOrderTypes.TrailingStop; break; case "REL": type = OrderTypes.Conditional; extendedType = IBOrderCondition.ExtendedOrderTypes.Relative; break; case "VWAP": type = OrderTypes.Conditional; extendedType = IBOrderCondition.ExtendedOrderTypes.VolumeWeightedAveragePrice; break; case "TRAILLIMIT": type = OrderTypes.Conditional; extendedType = IBOrderCondition.ExtendedOrderTypes.TrailingStopLimit; break; case "VOL": type = OrderTypes.Conditional; extendedType = IBOrderCondition.ExtendedOrderTypes.Volatility; break; case "NONE": type = OrderTypes.Conditional; extendedType = null; break; case "": type = OrderTypes.Conditional; extendedType = IBOrderCondition.ExtendedOrderTypes.Empty; break; case "Default": type = OrderTypes.Conditional; extendedType = IBOrderCondition.ExtendedOrderTypes.Default; break; case "SCALE": type = OrderTypes.Conditional; extendedType = IBOrderCondition.ExtendedOrderTypes.Scale; break; case "MIT": type = OrderTypes.Conditional; extendedType = IBOrderCondition.ExtendedOrderTypes.MarketIfTouched; break; case "LIT": type = OrderTypes.Conditional; extendedType = IBOrderCondition.ExtendedOrderTypes.LimitIfTouched; break; default: throw new InvalidOperationException(LocalizedStrings.Str2504Params.Put(str)); } }
public static IBSocket SendHedge(this IBSocket socket, IBOrderCondition condition) { if (condition == null) throw new ArgumentNullException("condition"); if (socket.ServerVersion < ServerVersions.V54) return socket; if (condition.Hedge.Type == null) return socket.Send(string.Empty); else { switch (condition.Hedge.Type.Value) { case IBOrderCondition.HedgeTypes.Delta: socket.Send("D"); break; case IBOrderCondition.HedgeTypes.Beta: socket.Send("B"); break; case IBOrderCondition.HedgeTypes.FX: socket.Send("F"); break; case IBOrderCondition.HedgeTypes.Pair: socket.Send("P"); break; default: throw new ArgumentOutOfRangeException(); } return socket.Send(condition.Hedge.Param); } }
public static IBSocket SendShortSale(this IBSocket socket, IBOrderCondition.ShortSaleCondition shortSale, bool extendCode = false) { socket.Send((int)shortSale.Slot); socket.Send(shortSale.Location); if (extendCode) { if (socket.ServerVersion >= ServerVersions.V51) socket.Send(shortSale.ExemptCode); } return socket; }
public static IBSocket SendIntent(this IBSocket socket, IBOrderCondition.ClearingIntents? intent) { if (intent == null) return socket; switch (intent.Value) { case IBOrderCondition.ClearingIntents.Broker: return socket.Send("IB"); case IBOrderCondition.ClearingIntents.Away: return socket.Send("Away"); case IBOrderCondition.ClearingIntents.PostTradeAllocation: return socket.Send("PTA"); default: throw new ArgumentOutOfRangeException(); } }
public static IBSocket SendDeltaNeutral(this IBSocket socket, IBOrderCondition condition) { if (condition == null) throw new ArgumentNullException("condition"); var volatility = condition.Volatility; if (socket.ServerVersion < ServerVersions.V28) { return socket.Send(volatility.OrderType == OrderTypes.Market); } else { socket.SendOrderType(volatility.OrderType, volatility.ExtendedOrderType); socket.Send(volatility.StopPrice); if (volatility.ExtendedOrderType != IBOrderCondition.ExtendedOrderTypes.Empty) { if (socket.ServerVersion >= ServerVersions.V58) { socket .Send(volatility.ConId) .Send(volatility.SettlingFirm) .SendPortfolio(volatility.ClearingPortfolio) .Send(volatility.ClearingIntent); } if (socket.ServerVersion >= ServerVersions.V66) { socket .Send(volatility.ShortSale.IsOpenOrClose) .Send(volatility.IsShortSale) .SendShortSale(volatility.ShortSale); } } return socket; } }
public static IBSocket SendAgent(this IBSocket socket, IBOrderCondition.AgentDescriptions? description) { if (description == null) return socket.Send(string.Empty); switch (description.Value) { case IBOrderCondition.AgentDescriptions.Individual: return socket.Send("I"); case IBOrderCondition.AgentDescriptions.Agency: return socket.Send("A"); case IBOrderCondition.AgentDescriptions.AgentOtherMember: return socket.Send("W"); case IBOrderCondition.AgentDescriptions.IndividualPTIA: return socket.Send("J"); case IBOrderCondition.AgentDescriptions.AgencyPTIA: return socket.Send("U"); case IBOrderCondition.AgentDescriptions.AgentOtherMemberPTIA: return socket.Send("M"); case IBOrderCondition.AgentDescriptions.IndividualPT: return socket.Send("K"); case IBOrderCondition.AgentDescriptions.AgencyPT: return socket.Send("Y"); case IBOrderCondition.AgentDescriptions.AgentOtherMemberPT: return socket.Send("N"); default: throw new ArgumentOutOfRangeException(); } }
public static IBSocket SendFinancialAdvisor(this IBSocket socket, IBOrderCondition.FinancialAdvisorAllocations? allocation) { if (allocation == null) return socket.Send(string.Empty); switch (allocation.Value) { case IBOrderCondition.FinancialAdvisorAllocations.PercentChange: return socket.Send("PctChange"); case IBOrderCondition.FinancialAdvisorAllocations.AvailableEquity: return socket.Send("AvailableEquity"); case IBOrderCondition.FinancialAdvisorAllocations.NetLiquidity: return socket.Send("NetLiq"); case IBOrderCondition.FinancialAdvisorAllocations.EqualQuantity: return socket.Send("EqualQuantity"); default: throw new ArgumentOutOfRangeException(); } }
public static IBSocket SendOrderType(this IBSocket socket, OrderTypes orderType, IBOrderCondition.ExtendedOrderTypes? extendedOrderType) { switch (orderType) { case OrderTypes.Limit: return socket.Send("LMT"); case OrderTypes.Market: return socket.Send("MKT"); case OrderTypes.Conditional: { if (extendedOrderType == null) return socket.Send("NONE"); switch (extendedOrderType) { case IBOrderCondition.ExtendedOrderTypes.MarketOnClose: return socket.Send("MOC"); case IBOrderCondition.ExtendedOrderTypes.LimitOnClose: return socket.Send("LMTCLS"); case IBOrderCondition.ExtendedOrderTypes.PeggedToMarket: return socket.Send("PEGMKT"); case IBOrderCondition.ExtendedOrderTypes.Stop: return socket.Send("STP"); case IBOrderCondition.ExtendedOrderTypes.StopLimit: return socket.Send("STP LMT"); case IBOrderCondition.ExtendedOrderTypes.TrailingStop: return socket.Send("TRAIL"); case IBOrderCondition.ExtendedOrderTypes.Relative: return socket.Send("REL"); case IBOrderCondition.ExtendedOrderTypes.VolumeWeightedAveragePrice: return socket.Send("VWAP"); case IBOrderCondition.ExtendedOrderTypes.TrailingStopLimit: return socket.Send("TRAILLIMIT"); case IBOrderCondition.ExtendedOrderTypes.Volatility: return socket.Send("VOL"); case IBOrderCondition.ExtendedOrderTypes.Empty: return socket.Send(""); case IBOrderCondition.ExtendedOrderTypes.Default: return socket.Send("Default"); case IBOrderCondition.ExtendedOrderTypes.Scale: return socket.Send("SCALE"); case IBOrderCondition.ExtendedOrderTypes.MarketIfTouched: return socket.Send("MIT"); case IBOrderCondition.ExtendedOrderTypes.LimitIfTouched: return socket.Send("LIT"); default: throw new ArgumentOutOfRangeException("extendedOrderType", extendedOrderType, LocalizedStrings.Str2500); } } default: throw new ArgumentOutOfRangeException("orderType", orderType, LocalizedStrings.Str1600); } }