浏览代码

提交测试版本,移除部分日志。

skyfffire 1 年之前
父节点
当前提交
7a4b8d0a46
共有 2 个文件被更改,包括 20 次插入13 次删除
  1. 6 1
      exchanges/tests/binance_swap_test.rs
  2. 14 12
      strategy/src/gate_swap.rs

+ 6 - 1
exchanges/tests/binance_swap_test.rs

@@ -25,7 +25,7 @@ async fn ws_custom_subscribe() {
 
 
     let (write_tx, write_rx) = futures_channel::mpsc::unbounded();
-    let (read_tx, mut read_rx) = futures_channel::mpsc::unbounded::<ResponseData>();
+    let (read_tx, mut read_rx) = futures_channel::mpsc::unbounded();
 
     // let (write_tx, write_rx) = tokio::sync::broadcast::channel::<Message>(10);
     // let (read_tx, mut read_rx) = tokio::sync::broadcast::channel::<ResponseData>(10);
@@ -57,6 +57,11 @@ async fn ws_custom_subscribe() {
                     info!("bian>{}", trace_stack.to_string());
                 }
             }
+
+            // 从通道中接收并丢弃所有的消息,直到通道为空
+            while let Ok(Some(_)) = read_rx.try_next() {
+                // 消息被忽略
+            }
         }
         // trace!("线程-数据读取-结束");
     });

+ 14 - 12
strategy/src/gate_swap.rs

@@ -81,20 +81,18 @@ pub async fn gate_swap_run(bool_v1: Arc<AtomicBool>,
 
         loop {
             if let Some(data) = read_rx.next().await {
-                let mut trace_stack = TraceStack::default();
-                trace_stack.on_after_network(data.time);
-                trace_stack.on_before_unlock_quant();
+                on_data(bot_arc_clone.clone(),
+                        &mut update_flag_u,
+                        multiplier,
+                        run_symbol.clone(),
+                        &mut max_buy,
+                        &mut min_sell,
+                        data).await;
 
-                if data.time != 0 {
-                    info!("gate>{}", trace_stack.to_string());
+                // 从通道中接收并丢弃所有的消息,直到通道为空
+                while let Ok(Some(_)) = read_rx.try_next() {
+                    // 消息被忽略
                 }
-                // on_data(bot_arc_clone.clone(),
-                //         &mut update_flag_u,
-                //         multiplier,
-                //         run_symbol.clone(),
-                //         &mut max_buy,
-                //         &mut min_sell,
-                //         data).await;
             }
         }
     });
@@ -111,6 +109,10 @@ async fn on_data(bot_arc_clone: Arc<Mutex<Quant>>,
     trace_stack.on_after_network(data.time);
     trace_stack.on_before_unlock_quant();
 
+    if data.time != 0 {
+        info!("gate>{}", trace_stack.to_string());
+    }
+
     // if data.code != "200".to_string() {
     //     return;
     // }