Browse Source

新增订单委托时间。

skyffire 9 months ago
parent
commit
4719a184d3
1 changed files with 5 additions and 0 deletions
  1. 5 0
      strategy/src/core.rs

+ 5 - 0
strategy/src/core.rs

@@ -41,6 +41,8 @@ pub struct Core {
     pub quote: String,
     //
     pub strategy: Strategy,
+    // 本地挂单时间表
+    pub local_order_times: HashMap<String, Decimal>,
     // 本地挂单表
     pub local_orders: HashMap<String, OrderInfo>,
     // 本地订单缓存队列
@@ -134,6 +136,7 @@ impl Core {
             // 现货底仓
             hold_coin: clip(params.hold_coin, Decimal::ZERO, Decimal::ONE_HUNDRED * Decimal::ONE_HUNDRED),
             strategy: Strategy::new(&params, true),
+            local_order_times: Default::default(),
             local_orders: Default::default(),
             local_orders_backup: Default::default(),
             local_orders_backup_cid: Default::default(),
@@ -488,6 +491,7 @@ impl Core {
                         }
                         // info!("成交单耗时数据:{}", time_record.to_string());
                         info!("更新推算仓位 {:?}", self.local_position_by_orders);
+                        info!("当前时间-订单委托时间={}", Decimal::from(Utc::now().timestamp_millis()) - self.local_order_times.get(&data.client_id).unwrap());
                         // 本地计算利润
                         self._print_local_trades_summary().await;
                         // 打印各类信息
@@ -816,6 +820,7 @@ impl Core {
                     fee: Default::default(),
                     trace_stack: TraceStack::new(0, Instant::now()),
                 };
+                self.local_order_times.insert(orders.limits_open.get(j).unwrap()[3].clone(), Decimal::from(Utc::now().timestamp_millis()));
                 // 本地挂单表
                 self.local_orders.insert(orders.limits_open.get(j).unwrap()[3].clone(), order_info.clone());
                 // 本地缓存表