当前位置: 首页>>代码示例>>C#>>正文


C# Native.IBSocket类代码示例

本文整理汇总了C#中StockSharp.InteractiveBrokers.Native.IBSocket的典型用法代码示例。如果您正苦于以下问题:C# IBSocket类的具体用法?C# IBSocket怎么用?C# IBSocket使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IBSocket类属于StockSharp.InteractiveBrokers.Native命名空间,在下文中一共展示了IBSocket类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadScannerParameters

		private void ReadScannerParameters(IBSocket socket)
		{
			var xml = socket.ReadStr();
			SendOutMessage(new ScannerParametersMessage { Parameters = xml });
		}
开发者ID:EricGarrison,项目名称:StockSharp,代码行数:5,代码来源:InteractiveBrokersMessageAdapter_MarketData.cs

示例2: ReadPortfolio

		private void ReadPortfolio(IBSocket socket, ServerVersions version)
		{
			var name = socket.ReadStr();
			var value = socket.ReadStr();
			var currency = socket.ReadStr();
			var port = version >= ServerVersions.V2 ? socket.ReadStr() : null;

			if (port == null || currency == "BASE")
				return;

			var pfMsg = this.CreatePortfolioChangeMessage(port);

			switch (name)
			{
				case "CashBalance":
					pfMsg.Add(PositionChangeTypes.CurrentValue, value.To<decimal>());
					break;
				case "Currency":
					pfMsg.Add(PositionChangeTypes.Currency, currency.To<CurrencyTypes>());
					break;
				case "RealizedPnL":
					pfMsg.Add(PositionChangeTypes.RealizedPnL, value.To<decimal>());
					break;
				case "UnrealizedPnL":
					pfMsg.Add(PositionChangeTypes.UnrealizedPnL, value.To<decimal>());
					break;
				case "NetLiquidation":
					pfMsg.Add(PositionChangeTypes.CurrentPrice, value.To<decimal>());
					break;
				case "Leverage-S":
					pfMsg.Add(PositionChangeTypes.Leverage, value.To<decimal>());
					break;
				default:
					var info = pfMsg.ExtensionInfo = new Dictionary<object, object>();

					if (currency.IsEmpty())
						info[name] = value;
					else
					{
						info[name] = new Currency
						{
							Type = currency.To<CurrencyTypes>(),
							Value = value.To<decimal>(),
						};
					}

					break;
			}

			SendOutMessage(pfMsg);
		}
开发者ID:xyicheng,项目名称:StockSharp,代码行数:51,代码来源:InteractiveBrokersMessageAdapter_Transaction.cs

示例3: ReadPortfolioUpdateTime

		private void ReadPortfolioUpdateTime(IBSocket socket)
		{
			/*var timeStamp = */socket.ReadStr();
			//updateAccountTime(timeStamp);
		}
开发者ID:xyicheng,项目名称:StockSharp,代码行数:5,代码来源:InteractiveBrokersMessageAdapter_Transaction.cs

示例4: ProcessTransactionResponse

		private bool ProcessTransactionResponse(IBSocket socket, ResponseMessages message, ServerVersions version)
		{
			switch (message)
			{
				case ResponseMessages.OrderStatus:
				{
					// http://www.interactivebrokers.com/en/software/api/apiguide/java/orderstatus.htm
					ReadOrderStatus(socket, version);
					return true;
				}
				case ResponseMessages.Portfolio:
				{
					// http://www.interactivebrokers.com/en/software/api/apiguide/java/updateaccountvalue.htm
					ReadPortfolio(socket, version);
					return true;
				}
				case ResponseMessages.PortfolioPosition:
				{
					// http://www.interactivebrokers.com/en/software/api/apiguide/java/updateportfolio.htm
					ReadPortfolioPosition(socket, version);
					return true;
				}
				case ResponseMessages.PortfolioUpdateTime:
				{
					ReadPortfolioUpdateTime(socket);
					return true;
				}
				case ResponseMessages.OpenOrder:
				{
					// http://www.interactivebrokers.com/en/software/api/apiguide/java/openorder.htm
					ReadOpenOrder(socket, version);
					return true;
				}
				case ResponseMessages.NextOrderId:
				{
					ReadNextOrderId(socket);
					return true;
				}
				case ResponseMessages.MyTrade:
				{
					// http://www.interactivebrokers.com/en/software/api/apiguide/java/execdetails.htm
					ReadMyTrade(socket, version);
					return true;
				}
				case ResponseMessages.ManagedAccounts:
				{
					// http://www.interactivebrokers.com/en/software/api/apiguide/java/managedaccounts.htm
					ReadManagedAccounts(socket);
					return true;
				}
				case ResponseMessages.OpenOrderEnd:
				{
					//openOrderEnd(socket);
					return true;
				}
				case ResponseMessages.AccountDownloadEnd:
				{
					ReadPortfolioName(socket);
					return true;
				}
				case ResponseMessages.MyTradeEnd:
				{
					// http://www.interactivebrokers.com/en/software/api/apiguide/java/execdetailsend.htm
					ReadMyTradeEnd(socket);
					return true;
				}
				case ResponseMessages.CommissionReport:
				{
					ReadCommissionReport(socket);
					return true;
				}
				case ResponseMessages.Position:
				{
					ReadPosition(socket, version);
					return true;
				}
				case ResponseMessages.PositionEnd:
				{
					ReadPositionEnd(socket);
					return true;
				}
				case ResponseMessages.AccountSummary:
				{
					ReadAccountSummary(socket);
					return true;
				}
				case ResponseMessages.AccountSummaryEnd:
				{
					ReadAccountSummaryEnd(socket);
					return true;
				}
				default:
					return false;
			}
		}
开发者ID:xyicheng,项目名称:StockSharp,代码行数:95,代码来源:InteractiveBrokersMessageAdapter_Transaction.cs

示例5: ReadAccountSummaryEnd

		private void ReadAccountSummaryEnd(IBSocket socket)
		{
			var requestId = socket.ReadInt();
			SendOutMessage(new PortfolioLookupResultMessage { OriginalTransactionId = requestId });
		}
开发者ID:xyicheng,项目名称:StockSharp,代码行数:5,代码来源:InteractiveBrokersMessageAdapter_Transaction.cs

示例6: ReadCommissionReport

		private void ReadCommissionReport(IBSocket socket)
		{
			var tradeId = socket.ReadStr();
			var value = socket.ReadDecimal();
			var currency = socket.ReadCurrency();
			var pnl = socket.ReadNullDecimal();
			var yield = socket.ReadNullDecimal();
			var redemptionDate = socket.ReadNullDateTime("yyyyMMdd");

			var secId = _secIdByTradeIds.TryGetValue2(tradeId);

			if (secId == null)
				return;

			// TODO
			//SendOutMessage(new ExecutionMessage
			//{
			//	ExecutionType = ExecutionTypes.Trade,
			//	TradeStringId = tradeId,
			//	Commission = value,
			//	SecurityId = secId.Value,
			//});
		}
开发者ID:xyicheng,项目名称:StockSharp,代码行数:23,代码来源:InteractiveBrokersMessageAdapter_Transaction.cs

示例7: ReadPositionEnd

		private void ReadPositionEnd(IBSocket socket)
		{
		}
开发者ID:xyicheng,项目名称:StockSharp,代码行数:3,代码来源:InteractiveBrokersMessageAdapter_Transaction.cs

示例8: ReadMarketDataType

		private void ReadMarketDataType(IBSocket socket)
		{
			/* requestId */
			socket.ReadInt();

			IsRealTimeMarketData = socket.ReadBool();

			//marketDataType(reqId, mdt);
		}
开发者ID:EricGarrison,项目名称:StockSharp,代码行数:9,代码来源:InteractiveBrokersMessageAdapter_MarketData.cs

示例9: ReadFinancialAdvice

		private void ReadFinancialAdvice(IBSocket socket)
		{
			var type = socket.ReadInt();
			var xml = socket.ReadStr();

			SendOutMessage(new FinancialAdviseMessage
			{
				AdviseType = type,
				Data = xml
			});
		}
开发者ID:EricGarrison,项目名称:StockSharp,代码行数:11,代码来源:InteractiveBrokersMessageAdapter_MarketData.cs

示例10: ReadDeltaNuetralValidation

		private void ReadDeltaNuetralValidation(IBSocket socket)
		{
			/* requestId */
			socket.ReadInt();

			//UnderComp underComp = new UnderComp();
			//underComp.ConId = 
			socket.ReadInt();
			//underComp.Delta = 
			socket.ReadDecimal();
			//underComp.Price = 
			socket.ReadDecimal();

			//deltaNuetralValidation(reqId, underComp);
		}
开发者ID:EricGarrison,项目名称:StockSharp,代码行数:15,代码来源:InteractiveBrokersMessageAdapter_MarketData.cs

示例11: ReadTickSnapshotEnd

		private void ReadTickSnapshotEnd(IBSocket socket)
		{
			/*var requestId = */socket.ReadInt();
			//SendOutMessage(_level1Messages.GetAndRemove(requestId));
		}
开发者ID:EricGarrison,项目名称:StockSharp,代码行数:5,代码来源:InteractiveBrokersMessageAdapter_MarketData.cs

示例12: ReadSecurityInfoEnd

		private void ReadSecurityInfoEnd(IBSocket socket)
		{
			SendOutMessage(new SecurityLookupResultMessage { OriginalTransactionId = socket.ReadInt() });
		}
开发者ID:EricGarrison,项目名称:StockSharp,代码行数:4,代码来源:InteractiveBrokersMessageAdapter_MarketData.cs

示例13: ReadFundamentalData

		private void ReadFundamentalData(IBSocket socket)
		{
			var requestId = socket.ReadInt();
			var data = socket.ReadStr();

			SendOutMessage(new FundamentalReportMessage
			{
				Data = data,
				OriginalTransactionId = requestId,
			});
		}
开发者ID:EricGarrison,项目名称:StockSharp,代码行数:11,代码来源:InteractiveBrokersMessageAdapter_MarketData.cs

示例14: ReadRealTimeBars

		private void ReadRealTimeBars(IBSocket socket)
		{
			var requestId = socket.ReadInt();
			var time = socket.ReadLongDateTime();
			var open = socket.ReadDecimal();
			var high = socket.ReadDecimal();
			var low = socket.ReadDecimal();
			var close = socket.ReadDecimal();
			var volume = socket.ReadLong();
			var wap = socket.ReadDecimal();
			var count = socket.ReadInt();

			SendOutMessage(new TimeFrameCandleMessage
			{
				OpenPrice = open,
				HighPrice = high,
				LowPrice = low,
				ClosePrice = close,
				TotalVolume = volume,
				OpenTime = time,
				CloseVolume = count,
				SecurityId = GetSecurityId(requestId),
				OriginalTransactionId = requestId,
			});

			//realTimeBar(reqId, time, open, high, low, close, volume, wap, count);
		}
开发者ID:EricGarrison,项目名称:StockSharp,代码行数:27,代码来源:InteractiveBrokersMessageAdapter_MarketData.cs

示例15: 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);

//.........这里部分代码省略.........
开发者ID:xyicheng,项目名称:StockSharp,代码行数:101,代码来源:InteractiveBrokersMessageAdapter_Transaction.cs


注:本文中的StockSharp.InteractiveBrokers.Native.IBSocket类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。