本文整理汇总了C#中StockSharp.Messages.ExecutionMessage.SetClientId方法的典型用法代码示例。如果您正苦于以下问题:C# ExecutionMessage.SetClientId方法的具体用法?C# ExecutionMessage.SetClientId怎么用?C# ExecutionMessage.SetClientId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StockSharp.Messages.ExecutionMessage
的用法示例。
在下文中一共展示了ExecutionMessage.SetClientId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadOrderStatus
private void ReadOrderStatus(IBSocket socket, ServerVersions version)
{
var id = socket.ReadInt();
var status = socket.ReadOrderStatus();
/* filled */
socket.ReadInt();
var balance = socket.ReadDecimal();
var avgPrice = socket.ReadDecimal();
var permId = version >= ServerVersions.V2 ? socket.ReadInt() : (int?)null;
var parentId = version >= ServerVersions.V3 ? socket.ReadInt() : (int?)null;
var lastTradePrice = version >= ServerVersions.V4 ? socket.ReadDecimal() : (decimal?)null;
var clientId = version >= ServerVersions.V5 ? socket.ReadInt() : (int?)null;
var whyHeld = version >= ServerVersions.V6 ? socket.ReadStr() : null;
var execMsg = new ExecutionMessage
{
ExecutionType = ExecutionTypes.Transaction,
OriginalTransactionId = id,
Balance = balance,
OrderStatus = status,
OrderState = status.ToOrderState(),
HasOrderInfo = true,
};
execMsg.SetAveragePrice(avgPrice);
if (permId != null)
execMsg.SetPermId(permId.Value);
if (parentId != null)
execMsg.Condition = new IBOrderCondition { ParentId = parentId.Value };
if (lastTradePrice != null)
execMsg.SetLastTradePrice(lastTradePrice.Value);
if (clientId != null)
execMsg.SetClientId(clientId.Value);
if (whyHeld != null)
execMsg.SetWhyHeld(whyHeld);
SendOutMessage(execMsg);
}
示例2: ReadOpenOrder
//.........这里部分代码省略.........
//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);
}
示例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);
//.........这里部分代码省略.........