private void On_SubscribeReceived(NetMQMessage message) { int count = message.FrameCount; if (count < 3) { return; } string accountNo = message.Pop().ConvertToString(); var msgHeader = message.Pop().ToByteArray(); var payload = message.Pop(); ReportHeader header = ReportHeader.Parser.ParseFrom(msgHeader); if (header.ApiId == ID_STOCK_PLACE_REPORT) { PlacedReport report = PlacedReport.Parser.ParseFrom(payload.ToByteArray()); PlaceReportReceived?.Invoke(accountNo, header, report); } else if (header.ApiId == ID_STOCK_FILL_REPORT) { FillReport report = FillReport.Parser.ParseFrom(payload.ToByteArray()); FillReportReceived?.Invoke(accountNo, header, report); } else if (header.ApiId == ID_STOCK_CANCEL_REPORT) { CancellationReport report = CancellationReport.Parser.ParseFrom(payload.ToByteArray()); CancelReportReceived?.Invoke(accountNo, header, report); } }
private void On_FillReportReceived(string accountNo, ReportHeader header, FillReport report) { string log = string.Format("{0} 账号:{1} {2} 券:{3} 数量:{4,6} 价格:{5,8}. 单号:{6,10}, 原号:{7,10}. 成交:{8, 6} 价格:{9, 8}. {10} ", report.FillStatus, report.AccountNo, report.OrderSide, report.Code, report.Quantity, report.Price, report.OrderExchangeId, report.OrderOriginalId, report.FillQuantity, report.FillPrice, header.Message ); BeginInvoke(new MethodInvoker(() => { WriteReport(log); })); }
private void On_Trade_Fill(string accountNo, ReportHeader header, FillReport report) { BeginInvoke(new MethodInvoker(() => { TradeMessage.Text = string.Format("成交 {0} {1} {2} {3}", report.Code, report.Quantity, report.FillQuantity, DateTime.Now.ToString("HH:mm:ss.fff")); })); }