private void ReadBondInfo(IBSocket socket, ServerVersions version) { var requestId = version >= ServerVersions.V3 ? socket.ReadInt() : -1; var secCode = socket.ReadStr(); var type = socket.ReadSecurityType(); var cusip = socket.ReadStr(); var coupon = socket.ReadDecimal(); var maturity = socket.ReadStr(); var issueDate = socket.ReadStr(); var ratings = socket.ReadStr(); var bondType = socket.ReadStr(); var couponType = socket.ReadStr(); var convertible = socket.ReadBool(); var callable = socket.ReadBool(); var putable = socket.ReadBool(); var description = socket.ReadStr(); var boardCode = socket.ReadBoardCode(); var currency = socket.ReadCurrency(); var marketName = socket.ReadStr(); var secClass = socket.ReadStr(); var contractId = socket.ReadInt(); var priceStep = socket.ReadDecimal(); var orderTypes = socket.ReadStr(); var validExchanges = socket.ReadStr(); var nextOptionDate = version >= ServerVersions.V2 ? socket.ReadStr() : null; var nextOptionType = version >= ServerVersions.V2 ? socket.ReadStr() : null; var nextOptionPartial = version >= ServerVersions.V2 ? socket.ReadBool() : (bool?)null; var notes = version >= ServerVersions.V2 ? socket.ReadStr() : null; var name = version >= ServerVersions.V4 ? socket.ReadStr() : null; var evRule = version >= ServerVersions.V6 ? socket.ReadStr() : null; var evMultiplier = version >= ServerVersions.V6 ? socket.ReadDecimal() : (decimal?)null; var secId = new SecurityId { SecurityCode = secCode, BoardCode = GetBoardCode(boardCode), InteractiveBrokers = contractId, }; if (version >= ServerVersions.V5) socket.ReadSecurityId(secId); var secMsg = new SecurityMessage { SecurityId = secId, //Name = secName, SecurityType = type, Currency = currency, Class = secClass, PriceStep = priceStep, }; secMsg.SetMarketName(marketName); secMsg.SetOrderTypes(orderTypes); secMsg.SetValidExchanges(validExchanges); // TODO //s.SetBondCusip(cusip); //s.SetCoupon(coupon); //s.SetMaturity(maturity); //s.SetIssueDate(issueDate); //s.SetRatings(ratings); //s.SetBondType(bondType); //s.SetCouponType(couponType); //s.SetConvertible(convertible); //s.SetCallable(callable); //s.SetPutable(putable); //s.SetDescription(description); //if (nextOptionDate != null) // s.SetNextOptionDate(nextOptionDate); //if (nextOptionType != null) // s.SetNextOptionType(nextOptionType); //if (nextOptionPartial != null) // s.SetNextOptionPartial(nextOptionPartial.Value); //if (notes != null) // s.SetNotes(notes); if (evRule != null) secMsg.SetEvRule(evRule); if (evMultiplier != null) secMsg.SetEvMultiplier(evMultiplier.Value); SendOutMessage(secMsg); }
private void ReadSecurityInfo(IBSocket socket, ServerVersions version) { var requestId = version >= ServerVersions.V3 ? socket.ReadInt() : -1; var secName = socket.ReadStr(); var type = socket.ReadSecurityType(); var expiryDate = socket.ReadExpiry(); var strike = socket.ReadDecimal(); var optionType = socket.ReadOptionType(); var boardCode = socket.ReadBoardCode(); var currency = socket.ReadCurrency(); var secCode = version >= ServerVersions.V2 ? socket.ReadLocalCode(secName) : null; var marketName = socket.ReadStr(); var secClass = socket.ReadStr(); var contractId = socket.ReadInt(); var priceStep = socket.ReadDecimal(); var multiplier = socket.ReadMultiplier(); var orderTypes = socket.ReadStr(); var validExchanges = socket.ReadStr(); var priceMagnifier = version >= ServerVersions.V2 ? socket.ReadInt() : (int?)null; var underlyingSecurityNativeId = version >= ServerVersions.V4 ? socket.ReadInt() : (int?)null; var name = version >= ServerVersions.V4 ? socket.ReadStr() : null; var routingExchange = version >= ServerVersions.V4 ? socket.ReadBoardCode() : null; var contractMonth = version >= ServerVersions.V6 ? socket.ReadStr() : null; var industry = version >= ServerVersions.V6 ? socket.ReadStr() : null; var category = version >= ServerVersions.V6 ? socket.ReadStr() : null; var subCategory = version >= ServerVersions.V6 ? socket.ReadStr() : null; var timeZoneId = version >= ServerVersions.V6 ? socket.ReadStr() : null; var tradingHours = version >= ServerVersions.V6 ? socket.ReadStr() : null; var liquidHours = version >= ServerVersions.V6 ? socket.ReadStr() : null; var evRule = version >= ServerVersions.V8 ? socket.ReadStr() : null; var evMultiplier = version >= ServerVersions.V8 ? socket.ReadDecimal() : (decimal?)null; var secId = new SecurityId { SecurityCode = secCode, BoardCode = GetBoardCode(boardCode), InteractiveBrokers = contractId, }; if (version >= ServerVersions.V7) socket.ReadSecurityId(secId); var secMsg = new SecurityMessage { SecurityId = secId, Name = secName, SecurityType = type, ExpiryDate = expiryDate, Strike = strike, OptionType = optionType, Currency = currency, Multiplier = multiplier ?? 0, Class = secClass, OriginalTransactionId = requestId, PriceStep = priceStep, }; secMsg.SetMarketName(marketName); secMsg.SetOrderTypes(orderTypes); secMsg.SetValidExchanges(validExchanges); if (priceMagnifier != null) secMsg.SetPriceMagnifier(priceMagnifier.Value); if (!routingExchange.IsEmpty()) secMsg.SetRoutingBoard(routingExchange); if (contractMonth != null) secMsg.SetContractMonth(contractMonth); if (industry != null) secMsg.SetIndustry(industry); if (category != null) secMsg.SetCategory(category); if (subCategory != null) secMsg.SetSubCategory(subCategory); if (timeZoneId != null) secMsg.SetTimeZoneId(timeZoneId); if (tradingHours != null) secMsg.SetTradingHours(tradingHours); if (liquidHours != null) secMsg.SetLiquidHours(liquidHours); if (evRule != null) secMsg.SetEvRule(evRule); if (evMultiplier != null) secMsg.SetEvMultiplier(evMultiplier.Value); // TODO //if (underlyingSecurityNativeId != null) // ProcessSecurityAction(null, SecurityIdGenerator.GenerateId(underlyingSecurityNativeId.Value.To<string>(), exchangeBoard), underSec => security.UnderlyingSecurityId = underSec.Id); SendOutMessage(secMsg); }