本文整理汇总了C#中StockSharp.InteractiveBrokers.Native.IBSocket.ReadBoardCode方法的典型用法代码示例。如果您正苦于以下问题:C# IBSocket.ReadBoardCode方法的具体用法?C# IBSocket.ReadBoardCode怎么用?C# IBSocket.ReadBoardCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StockSharp.InteractiveBrokers.Native.IBSocket
的用法示例。
在下文中一共展示了IBSocket.ReadBoardCode方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadPortfolioPosition
private void ReadPortfolioPosition(IBSocket socket, ServerVersions version)
{
var contractId = version >= ServerVersions.V6 ? socket.ReadInt() : -1;
var secName = socket.ReadStr();
var type = socket.ReadSecurityType();
var expiryDate = socket.ReadExpiry();
var strike = socket.ReadDecimal();
var optionType = socket.ReadOptionType();
var multiplier = version >= ServerVersions.V7 ? socket.ReadMultiplier() : null;
var boardCode = version >= ServerVersions.V7 ? socket.ReadBoardCode() : null;
var currency = socket.ReadCurrency();
var secCode = (version >= ServerVersions.V2) ? socket.ReadStr() : secName;
var secClass = (version >= ServerVersions.V8) ? socket.ReadStr() : null;
var position = socket.ReadDecimal();
var marketPrice = socket.ReadDecimal();
var marketValue = socket.ReadDecimal();
var averagePrice = 0m;
var unrealizedPnL = 0m;
var realizedPnL = 0m;
if (version >= ServerVersions.V3)
{
averagePrice = socket.ReadDecimal();
unrealizedPnL = socket.ReadDecimal();
realizedPnL = socket.ReadDecimal();
}
var portfolio = version >= ServerVersions.V4 ? socket.ReadStr() : null;
if (version == ServerVersions.V6 && socket.ServerVersion == ServerVersions.V39)
boardCode = socket.ReadBoardCode();
var secId = new SecurityId
{
SecurityCode = secCode,
BoardCode = GetBoardCode(boardCode),
InteractiveBrokers = contractId,
};
SendOutMessage(new SecurityMessage
{
SecurityId = secId,
Name = secName,
SecurityType = type,
ExpiryDate = expiryDate,
Strike = strike,
OptionType = optionType,
Currency = currency,
Multiplier = multiplier ?? 0,
Class = secClass
});
if (portfolio.IsEmpty())
return;
SendOutMessage(
this
.CreatePositionChangeMessage(portfolio, secId)
.Add(PositionChangeTypes.CurrentValue, position)
.Add(PositionChangeTypes.CurrentPrice, marketPrice)
.Add(PositionChangeTypes.AveragePrice, averagePrice)
.Add(PositionChangeTypes.UnrealizedPnL, unrealizedPnL)
.Add(PositionChangeTypes.RealizedPnL, realizedPnL));
// TODO
//pos.SetMarketValue(marketValue);
}
示例2: ReadOpenOrder
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)
{
//.........这里部分代码省略.........
示例3: ReadMyTrade
private void ReadMyTrade(IBSocket socket, ServerVersions version)
{
/* requestId */
if (version >= ServerVersions.V7)
socket.ReadInt();
// http://www.interactivebrokers.com/en/software/api/apiguide/java/execution.htm
var transactionId = socket.ReadInt();
//Handle the 2^31-1 == 0 bug
if (transactionId == int.MaxValue)
transactionId = 0;
//Read Contract Fields
var contractId = version >= ServerVersions.V5 ? socket.ReadInt() : -1;
var secName = socket.ReadStr();
var type = socket.ReadSecurityType();
var expiryDate = socket.ReadExpiry();
var strike = socket.ReadDecimal();
var optionType = socket.ReadOptionType();
var multiplier = version >= ServerVersions.V9 ? socket.ReadMultiplier() : null;
var boardCode = socket.ReadBoardCode();
var currency = socket.ReadCurrency();
var secCode = socket.ReadLocalCode(secName);
var secClass = (version >= ServerVersions.V10) ? socket.ReadStr() : null;
var tradeId = socket.ReadStr();
var time = socket.ReadDateTime("yyyyMMdd HH:mm:ss");
var portfolio = socket.ReadStr();
/* exchange */
socket.ReadStr();
var side = socket.ReadTradeSide();
var volume = socket.ReadDecimal();
var price = socket.ReadDecimal();
var permId = version >= ServerVersions.V2 ? socket.ReadInt() : (int?)null;
var clientId = version >= ServerVersions.V3 ? socket.ReadInt() : (int?)null;
var liquidation = version >= ServerVersions.V4 ? socket.ReadInt() : (int?)null;
var cumulativeQuantity = version >= ServerVersions.V6 ? socket.ReadInt() : (int?)null;
var averagePrice = version >= ServerVersions.V6 ? socket.ReadDecimal() : (decimal?)null;
var orderRef = version >= ServerVersions.V8 ? socket.ReadStr() : null;
var evRule = version >= ServerVersions.V9 ? socket.ReadStr() : null;
var evMultiplier = version >= ServerVersions.V9 ? socket.ReadDecimal() : (decimal?)null;
var secId = new SecurityId
{
SecurityCode = secCode,
BoardCode = GetBoardCode(boardCode),
InteractiveBrokers = contractId,
};
SendOutMessage(new SecurityMessage
{
SecurityId = secId,
Name = secName,
SecurityType = type,
ExpiryDate = expiryDate,
Strike = strike,
OptionType = optionType,
Currency = currency,
Multiplier = multiplier ?? 0,
Class = secClass
});
// заявка была создана руками
if (transactionId == 0)
return;
_secIdByTradeIds[tradeId] = secId;
var execMsg = new ExecutionMessage
{
ExecutionType = ExecutionTypes.Transaction,
OriginalTransactionId = transactionId,
TradeStringId = tradeId,
OriginSide = side,
TradePrice = price,
TradeVolume = volume,
PortfolioName = portfolio,
ServerTime = time,
SecurityId = secId,
HasTradeInfo = true,
};
if (permId != null)
execMsg.SetPermId(permId.Value);
if (clientId != null)
execMsg.SetClientId(clientId.Value);
if (liquidation != null)
execMsg.SetLiquidation(liquidation.Value);
if (cumulativeQuantity != null)
execMsg.SetCumulativeQuantity(cumulativeQuantity.Value);
if (averagePrice != null)
execMsg.SetAveragePrice(averagePrice.Value);
//.........这里部分代码省略.........
示例4: ReadPosition
private void ReadPosition(IBSocket socket, ServerVersions version)
{
var account = socket.ReadStr();
var contractId = socket.ReadInt();
var secName = socket.ReadStr();
var type = socket.ReadSecurityType();
var expiryDate = socket.ReadExpiry();
var strike = socket.ReadDecimal();
var optionType = socket.ReadOptionType();
var multiplier = socket.ReadMultiplier();
var boardCode = socket.ReadBoardCode();
var currency = socket.ReadCurrency();
var secCode = socket.ReadLocalCode(secName);
var secClass = (version >= ServerVersions.V2) ? socket.ReadStr() : null;
var pos = socket.ReadDecimal();
var avgCost = 0m;
if (version >= ServerVersions.V3)
avgCost = socket.ReadDecimal();
var secId = new SecurityId
{
SecurityCode = secCode,
BoardCode = GetBoardCode(boardCode),
InteractiveBrokers = contractId,
};
SendOutMessage(new SecurityMessage
{
SecurityId = secId,
Name = secName,
SecurityType = type,
ExpiryDate = expiryDate,
Strike = strike,
OptionType = optionType,
Currency = currency,
Multiplier = multiplier ?? 0,
Class = secClass
});
SendOutMessage(this
.CreatePositionChangeMessage(account, secId)
.Add(PositionChangeTypes.CurrentValue, pos)
.Add(PositionChangeTypes.AveragePrice, avgCost));
}
示例5: ReadNewsBulletins
private void ReadNewsBulletins(IBSocket socket)
{
var newsId = socket.ReadInt();
var newsType = (ExchangeNewsTypes)socket.ReadInt();
var newsMessage = socket.ReadStr();
var originatingExch = socket.ReadBoardCode();
SendOutMessage(new NewsMessage
{
Id = newsId.To<string>(),
BoardCode = originatingExch,
Headline = newsMessage,
ExtensionInfo = new Dictionary<object, object> { { "Type", newsType } },
ServerTime = this.CurrentTime.Convert(TimeHelper.Est)
});
}
示例6: ReadMarketDepth
private void ReadMarketDepth(IBSocket socket, ResponseMessages message)
{
var requestId = socket.ReadInt();
var secId = GetSecurityId(requestId);
/* position */
var pos = socket.ReadInt();
if (message == ResponseMessages.MarketDepthL2)
{
/* marketMaker */
secId.BoardCode = socket.ReadBoardCode();
}
var operation = socket.ReadInt();
var side = socket.ReadBool() ? Sides.Buy : Sides.Sell;
var price = socket.ReadDecimal();
var volume = socket.ReadInt();
var prevQuotes = _depths.SafeAdd(secId, key =>
Tuple.Create(new SortedDictionary<decimal, decimal>(new BackwardComparer<decimal>()), new SortedDictionary<decimal, decimal>()));
var quotes = side == Sides.Buy ? prevQuotes.Item1 : prevQuotes.Item2;
this.AddDebugLog("MD {0} {1} POS {2} PRICE {3} VOL {4}", secId, operation, pos, price, volume);
switch (operation)
{
case 0: // insert
{
if (!CollectionHelper.TryAdd(quotes, price, volume))
quotes[price] += volume;
break;
}
case 1: // update
{
if (quotes.Count > (pos + 1))
{
var sign = side == Sides.Buy ? 1 : -1;
if (quotes[pos + 1] * sign >= price * sign)
{
for (var i = quotes.Count - 1; i >= pos + 1; i--)
quotes.Remove(quotes[quotes.Keys.ElementAt(i)]);
}
}
if (quotes.Count > pos)
{
//if (quotes[quotes.Keys.ElementAt(pos)] == price)
// quotes[price] = volume;
//else
//{
// depth.Remove(quotes[pos]);
// depth.AddQuote(quote);
//}
quotes[price] = volume;
}
else
{
if (!CollectionHelper.TryAdd(quotes, price, volume))
quotes[price] += volume;
}
break;
}
case 2: // delete
{
if (quotes.Count > pos)
quotes.Remove(quotes.Keys.ElementAt(pos));
break;
}
}
SendOutMessage(new QuoteChangeMessage
{
SecurityId = secId,
Bids = prevQuotes.Item1.Select(p => new QuoteChange(Sides.Buy, p.Key, p.Value)).ToArray(),
Asks = prevQuotes.Item2.Select(p => new QuoteChange(Sides.Sell, p.Key, p.Value)).ToArray(),
ServerTime = this.CurrentTime.Convert(TimeZoneInfo.Utc),
});
}
示例7: ReadBondInfo
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);
}
示例8: ReadSecurityInfo
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);
//.........这里部分代码省略.........
示例9: ReadScannerData
private void ReadScannerData(IBSocket socket, ServerVersions version)
{
var requestId = socket.ReadInt();
var count = socket.ReadInt();
var tmp = Enumerable
.Range(0, count)
.Select(s =>
{
var rank = socket.ReadInt();
var contractId = 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 = socket.ReadLocalCode(secName);
var marketName = socket.ReadStr();
var secClass = socket.ReadStr();
var distance = socket.ReadStr();
var benchmark = socket.ReadStr();
var projection = socket.ReadStr();
var legs = version >= ServerVersions.V2 ? socket.ReadStr() : null;
return new
{
Rank = rank,
ContractId = contractId,
SecName = secName,
SecCode = secCode,
Type = type,
ExpiryDate = expiryDate,
Strike = strike,
OptionType = optionType,
BoardCode = boardCode,
Currency = currency,
MarketName = marketName,
SecClass = secClass,
Distance = distance,
Benchmark = benchmark,
Projection = projection,
Legs = legs,
};
})
.ToArray();
var results = tmp.Select(t =>
{
var secId = new SecurityId
{
SecurityCode = t.SecCode,
BoardCode = GetBoardCode(t.BoardCode),
InteractiveBrokers = t.ContractId,
};
SendOutMessage(new SecurityMessage
{
SecurityId = secId,
Name = t.SecName,
SecurityType = t.Type,
ExpiryDate = t.ExpiryDate,
Strike = t.Strike,
OptionType = t.OptionType,
Currency = t.Currency,
Class = t.SecClass
});
var result = new ScannerResult
{
Rank = t.Rank,
SecurityId = secId,
Distance = t.Distance,
Benchmark = t.Benchmark,
Projection = t.Projection,
Legs = t.Legs
};
return result;
}).ToArray();
SendOutMessage(new ScannerResultMessage
{
Results = results,
OriginalTransactionId = requestId,
});
}