Browse Source

修复订单耗时的时间单位。

skyffire 1 năm trước cách đây
mục cha
commit
d203599118
3 tập tin đã thay đổi với 3 bổ sung51 xóa
  1. 1 1
      global/src/trace_stack.rs
  2. 2 1
      standard/src/gate_swap.rs
  3. 0 49
      strategy/src/exchange_disguise.rs

+ 1 - 1
global/src/trace_stack.rs

@@ -150,7 +150,7 @@ impl fmt::Display for TraceStack {
         }
 
         if self.after_send != 0 && self.before_send != 0 {
-            msg.push_str(format!("发送订单耗时(发送-服务器处理-响应到本地){}ms  ", (self.after_send - self.before_send).to_f64().unwrap() / 1000.0).as_str());
+            msg.push_str(format!("发送订单耗时(发送-服务器处理-响应到本地){}ms  ", (self.after_send - self.before_send).to_f64().unwrap() / 1e6f64).as_str());
         }
 
         // if self.after_send != 0 && self.after_network != 0 {

+ 2 - 1
standard/src/gate_swap.rs

@@ -555,9 +555,10 @@ impl Platform for GateSwap {
             spawn(async move {
                 ts.on_before_send();
                 let result = self_clone.take_order(&cid, &side, price, amount).await;
+                ts.on_after_send();
+
                 match result {
                     Ok(mut result) => {
-                        ts.on_after_send();
                         info!("{}", ts.to_string());
 
                         result.trace_stack = ts;

+ 0 - 49
strategy/src/exchange_disguise.rs

@@ -108,55 +108,6 @@ pub async fn on_special_depth(core_arc: Arc<Mutex<Core>>,
     }
 }
 
-// pub async fn on_trade(trade: OriginalTradeBa,
-//                       core_arc_clone: Arc<Mutex<Core>>) {
-    // let mut core = core_arc_clone.lock().await;
-    // // 1. 塞入数据到core
-    // core.trades.push(trade.clone());
-    // // 2. 长度检查
-    // if core.trades.len() > core.recall_max_count {
-    //     core.trades.remove(0);
-    // }
-    // // 3. 如果少于100条,不进行判断
-    // if core.trades.len() < 100 {
-    //     return;
-    // }
-    // // 求最近的多空总和
-    // let mut long_sum = Decimal::ZERO;
-    // let mut short_sum = Decimal::ZERO;
-    // let last_trade_t = trade.t.clone();
-    // let mut rev = core.trades.clone();
-    // rev.reverse();
-    // for trade_o in rev {
-    //     // 如果该元素已过期,我们是按时间顺序插入的,说明前面的应该都过期了,跳出循环,停止检测
-    //     if trade_o.t < last_trade_t - core.recall_time {
-    //         continue;
-    //     }
-    //
-    //     // 卖出订单
-    //     if trade_o.m {
-    //         short_sum += trade_o.q;
-    //     } else {
-    //         long_sum += trade_o.q;
-    //     }
-    // }
-    //
-    // // 做多主动性
-    // if (long_sum / (long_sum + short_sum)) > core.long_volume_rate {
-    //     if core.side != "long".to_string() {
-    //         core.side = "long".to_string();
-    //     }
-    // } else if (short_sum / (long_sum + short_sum)) > core.short_volume_rate {
-    //     if core.side != "short".to_string() {
-    //         core.side = "short".to_string();
-    //     }
-    // } else {
-    //     if core.side != "normal".to_string() {
-    //         core.side = "normal".to_string();
-    //     }
-    // }
-// }
-
 pub async fn on_order() {}
 
 pub async fn on_position() {}