Browse Source

一些小细节的修改。

skyfffire 2 years ago
parent
commit
01ac5c10a2
5 changed files with 14 additions and 14 deletions
  1. 3 5
      global/src/delay_time.rs
  2. 1 1
      global/src/log_utils.rs
  3. 3 3
      src/quant_libs.rs
  4. 6 4
      strategy/src/quant.rs
  5. 1 1
      strategy/src/strategy.rs

+ 3 - 5
global/src/delay_time.rs

@@ -21,12 +21,10 @@ pub struct DelayTime {
 
 impl fmt::Display for DelayTime {
     fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
-        write!(f, "订单来源: {},数据格式化时间{}微妙, quant执行时间{}微妙, 策略执行时间{}微妙, orderCommand: {}",
+        write!(f, "订单来源: {},数据格式化时间{}微妙, 策略执行时间{}微妙",
               self.source,
               self.format_end - self.format_start,
-              self.quant_end - self.quant_start,
-              self.strategy_end - self.strategy_start,
-              self.order_command
-        )
+              // self.quant_end - self.quant_start,
+              self.strategy_end - self.strategy_start)
     }
 }

+ 1 - 1
global/src/log_utils.rs

@@ -20,7 +20,7 @@ pub fn final_init(level: &str) -> WorkerGuard {
     let (non_blocking, guard) = tracing_appender::non_blocking(file_appender);
 
     let fmt_layer = fmt::layer()
-        .with_target(false)
+        .with_target(true)
         .with_level(true)
         .with_writer(io::stdout)
         .with_span_events(fmt::format::FmtSpan::FULL);

+ 3 - 3
src/quant_libs.rs

@@ -88,16 +88,16 @@ pub async fn init(params: Params, ws_running: Arc<AtomicBool>, running: Arc<Atom
         }
     });
 
-    // let error_handler_quant_arc = quant_arc.clone();
+    let error_handler_quant_arc = quant_arc.clone();
     tokio::spawn(async move {
         loop {
             tokio::time::sleep(Duration::from_millis(1)).await;
 
             match error_receiver.recv().await {
                 Some(error) => {
-                    // let quant = error_handler_quant_arc.lock().await;
-
+                    let mut quant = error_handler_quant_arc.lock().await;
                     error!("main: 订单出现错误{:?}", error);
+                    quant.strategy._print_summary();
                 },
                 None => {
                     error!("Error channel has been closed!");

+ 6 - 4
strategy/src/quant.rs

@@ -315,6 +315,7 @@ impl Quant {
 
     pub fn update_local_order(&mut self, data: OrderInfo, time_record: &mut MutexGuard<DelayTime>) {
         if data.filled != Decimal::ZERO {
+            info!("\n\n");
             info!("接收到订单信息①:{:?}", data);
         }
         /*
@@ -488,10 +489,11 @@ impl Quant {
                         }
                         info!("成交单耗时数据:{}", time_record.to_string());
                         info!("更新推算仓位 {:?}", self.local_position_by_orders);
-                        // 打印各类信息
-                        self.strategy._print_summary();
                         // 本地计算利润
                         self._print_local_trades_summary();
+                        // 打印各类信息
+                        self.strategy.local_orders = self.local_orders.clone();
+                        self.strategy._print_summary();
                     }
                     // 每次有订单变动就触发一次策略
                     if self.mode_signal == 0 && self.ready == 1 {
@@ -672,10 +674,10 @@ impl Quant {
             }
         }
         // 更新仓位信息
-        info!("收到新的仓位推送, position: {:?}, local_position: {:?}", data, position);
         if position != self.local_position {
-            self.local_position = position;
+            info!("收到新的仓位推送, position: {:?}, local_position: {:?}", data, position);
             info!("更新本地仓位:{:?}", self.local_position);
+            self.local_position = position;
         }
     }
 

+ 1 - 1
strategy/src/strategy.rs

@@ -442,7 +442,7 @@ impl Strategy {
             msg.push_str(format!("杠杆{:?}X 价值{:?}U 价格{:?} 偏离{:?}%\n", order_lever_rate, order_value, order.price, order_bias).as_str());
         }
 
-        msg.push_str(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\n\n");
+        msg.push_str(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n");
         info!("{}", msg);
     }