private void _OnConnectionStatus(double double1, IntPtr ptr1, int size1) { ConnectionStatus status = (ConnectionStatus)double1; // 连接状态更新 // 这种写法是为了解决多账号登录时,先进行Done然后再Logining或Doing的问题 if (ConnectionStatus.Disconnected == status || ConnectionStatus.Uninitialized == status) { IsConnected = false; } else if (ConnectionStatus.Done == status) { IsConnected = true; } RspUserLoginField obj = default(RspUserLoginField); if (size1 > 0) { obj = PInvokeUtility.GetObjectFromIntPtr <RspUserLoginField>(ptr1); UserLoginField = obj; } if (OnConnectionStatus_ != null) { OnConnectionStatus_(this, status, ref obj, size1); } }
private void _OnConnectionStatus(double double1, IntPtr ptr1, int size1) { ConnectionStatus status = (ConnectionStatus)double1; // 连接状态更新 IsConnected = (ConnectionStatus.Done == status); RspUserLoginField obj = default(RspUserLoginField); switch (status) { case ConnectionStatus.Logined: case ConnectionStatus.Disconnected: case ConnectionStatus.Doing: obj = PInvokeUtility.GetObjectFromIntPtr <RspUserLoginField>(ptr1); UserLoginField = obj; break; default: break; } if (OnConnectionStatus != null) { OnConnectionStatus(this, status, ref obj, size1); } }
private void _OnRtnQuoteRequest(IntPtr ptr1, int size1) { if (OnRtnQuoteRequest == null) { return; } QuoteRequestField obj = PInvokeUtility.GetObjectFromIntPtr <QuoteRequestField>(ptr1); OnRtnQuoteRequest(this, ref obj); }
private void _OnRspQryInstrument(IntPtr ptr1, int size1, double double1) { if (OnRspQryInstrument_ == null) { return; } InstrumentField obj = PInvokeUtility.GetObjectFromIntPtr <InstrumentField>(ptr1); OnRspQryInstrument_(this, ref obj, size1, double1 != 0); }
private void _OnRspQryInvestorPosition(IntPtr ptr1, int size1, double double1) { if (OnRspQryInvestorPosition_ == null) { return; } PositionField obj = PInvokeUtility.GetObjectFromIntPtr <PositionField>(ptr1); OnRspQryInvestorPosition_(this, ref obj, size1, double1 != 0); }
private void _OnRspQryQuote(IntPtr ptr1, int size1, double double1) { if (OnRspQryQuote_ == null) { return; } QuoteField obj = PInvokeUtility.GetObjectFromIntPtr <QuoteField>(ptr1); OnRspQryQuote_(this, ref obj, size1, double1 != 0); }
private void _OnLog(IntPtr ptr1) { if (OnLog_ == null) { return; } LogField obj = PInvokeUtility.GetObjectFromIntPtr <LogField>(ptr1); OnLog_(this, ref obj); }
private void _OnRtnError(IntPtr ptr1) { if (OnRtnError_ == null) { return; } ErrorField obj = PInvokeUtility.GetObjectFromIntPtr <ErrorField>(ptr1); OnRtnError_(this, ref obj); }
private void _OnRspQryHistoricalBars(IntPtr ptr1, int size1, IntPtr ptr2, int size2, double double1) { if (OnRspQryHistoricalBars == null) { return; } HistoricalDataRequestField obj = PInvokeUtility.GetObjectFromIntPtr <HistoricalDataRequestField>(ptr2); OnRspQryHistoricalBars(this, ptr1, size1, ref obj, size2, double1 != 0); }
private void _OnRspQrySettlementInfo(IntPtr ptr1, int size1, double double1) { if (OnRspQrySettlementInfo_ == null) { return; } SettlementInfoField obj = PInvokeUtility.GetObjectFromIntPtr <SettlementInfoField>(ptr1); OnRspQrySettlementInfo_(this, ref obj, size1, double1 != 0); }
private void _OnRtnTrade(IntPtr ptr1, int size1) { if (OnRtnTrade == null) { return; } TradeField obj = PInvokeUtility.GetObjectFromIntPtr <TradeField>(ptr1); OnRtnTrade(this, ref obj); }
private void _OnRtnOrder(IntPtr ptr1, int size1) { if (OnRtnOrder == null) { return; } OrderField obj = PInvokeUtility.GetObjectFromIntPtr <OrderField>(ptr1); OnRtnOrder(this, ref obj); }
private void _OnRspQryTradingAccount(IntPtr ptr1, int size1, double double1) { if (OnRspQryTradingAccount == null) { return; } AccountField obj = PInvokeUtility.GetObjectFromIntPtr <AccountField>(ptr1); OnRspQryTradingAccount(this, ref obj, size1, double1 != 0); }
private void OnRspQryHistoricalBars_callback(object sender, IntPtr pBars, int size1, ref HistoricalDataRequestField request, int size2, bool bIsLast) { int size = Marshal.SizeOf(typeof(BarField)); (sender as XApi).GetLog().Info("<--OnRspQryHistoricalBars:{0},{1},{2},{3}条", request.CurrentDate, request.InstrumentID, request.ExchangeID, size1 / size); HistoricalDataRecord record; if (!historicalDataRecords.TryGetValue(request.RequestId, out record)) { return; } List <Bar> list = new List <Bar>(); for (int i = 0; i < size1 / size; ++i) { IntPtr ptr = (IntPtr)(pBars + size * i); BarField obj = PInvokeUtility.GetObjectFromIntPtr <BarField>(ptr); int Millisecond = 0; DateTime dt = GetDateTime(obj.Date, obj.Time, Millisecond); // 这地方应当加历史数据另存的地方才好 if (SaveToCsv) { LogEventInfo logEvent = new LogEventInfo(NLog.LogLevel.Trace, tickLog.Name, BarFieldToString(obj, dt)); // 用户可能需要按收到数据的合约与时间分目录或文件 logEvent.Properties[Symbol] = record.Request.Instrument.Symbol; logEvent.Properties[Date] = request.CurrentDate.ToString(); logEvent.Properties[BarSize] = request.BarSize.ToString(); barLog.Log(logEvent); } if (FilterDateTime) { if (FilterDateTime_(record.Request, dt)) { Bar b = new Bar(dt, dt.AddSeconds(record.Request.BarSize.Value), record.Request.Instrument.Id, record.Request.BarType.Value, record.Request.BarSize.Value, obj.Open, obj.High, obj.Low, obj.Close, (long)obj.Volume, (long)obj.OpenInterest); list.Add(b); } } } if (EmitHistoricalData) { HistoricalData data = new HistoricalData { RequestId = record.Request.RequestId, Objects = list.ToArray(), TotalNum = list.Count, }; base.EmitHistoricalData(data); } if (bIsLast) { EmitHistoricalDataEnd(record.Request.RequestId, RequestResult.Completed, ""); } }