예제 #1
0
 private ConcurrentDictionary<string, OrderRecord> pendingCancels;   // 撤单拒绝时使用
 private OrderRecord GetExternalOrder(ref TradeField field)
 {
     ExternalOrderRecord record;
     if (externalOrders.TryGetValue(field.InstrumentID, out record)) {
         if (field.OpenClose == OpenCloseType.Open) {
             return field.Side == XAPI.OrderSide.Buy ? record.BuyOpen : record.SellOpen;
         }
         return field.Side == XAPI.OrderSide.Buy ? record.BuyClose : record.SellClose;
     }
     return null;
 }
예제 #2
0
 static void OnRtnTrade(object sender, ref TradeField trade)
 {
     Console.WriteLine("CC " + trade.Time + "CC " + trade.ID + "CC " + trade.TradeID);
 }
예제 #3
0
 public void Process(ref TradeField trade)
 {
     OrderRecord record;
     if (!workingOrders.TryGetValue(trade.ID, out record)) {
         record = GetExternalOrder(ref trade);
     }
     if (record != null) {
         record.AddFill(trade.Price, (int)trade.Qty);
         SQ.ExecType execType = SQ.ExecType.ExecTrade;
         SQ.OrderStatus orderStatus = (record.LeavesQty > 0) ? SQ.OrderStatus.PartiallyFilled : SQ.OrderStatus.Filled;
         ExecutionReport report = CreateReport(record, execType, orderStatus);
         report.LastPx = trade.Price;
         report.LastQty = trade.Qty;
         provider.EmitExecutionReport(report);
     }
 }
 private void OnRtnTrade_callback(object sender, ref TradeField trade)
 {
     (sender as XApi).Log.Debug("OnRtnTrade:" + trade.ToFormattedString());
     try
     {
         orderMap.Process(ref trade);
     }
     catch (Exception ex)
     {
         (sender as XApi).Log.Error(ex);
     }
 }