Browse Source

修改清仓模式数据字段

JiahengHe 1 year ago
parent
commit
fa64ed7454
4 changed files with 14 additions and 14 deletions
  1. 2 2
      global/src/clear_position_result.rs
  2. 2 2
      global/src/params.rs
  3. 8 8
      src/main.rs
  4. 2 2
      strategy/src/clear_core.rs

+ 2 - 2
global/src/clear_position_result.rs

@@ -2,7 +2,7 @@ use serde_derive::{Deserialize, Serialize};
 
 #[derive(Debug, Serialize, Deserialize, Clone)]
 pub struct ClearPositionResult {
-    pub check_id: String,
+    pub r_id: String,
     pub clear_order_num: String,
     pub clear_order_str: String,
     pub clear_position_num: String,
@@ -14,7 +14,7 @@ pub struct ClearPositionResult {
 impl ClearPositionResult {
     pub fn new() -> ClearPositionResult {
         ClearPositionResult{
-            check_id: "".to_string(),
+            r_id: "".to_string(),
             clear_order_num: "0".to_string(),
             clear_order_str: "".to_string(),
             clear_position_num: "0".to_string(),

+ 2 - 2
global/src/params.rs

@@ -53,7 +53,7 @@ pub struct Params {
     // 运行模式 0.正常策略运行, 1.清理挂单及仓位
     pub run_mode: i8,
     // 机器人id
-    pub check_id: String,
+    pub r_id: String,
 }
 
 impl Params {
@@ -101,7 +101,7 @@ impl Params {
             log_level: "info".to_string(),
             port: call_port,
             run_mode: 0,
-            check_id: "-1".to_string()
+            r_id: "-1".to_string()
         };
         Ok(params)
     }

+ 8 - 8
src/main.rs

@@ -47,7 +47,7 @@ fn read_params_json() -> Params {
     let mut call_port = 5555;
     // 运行模式 0.正常策略运行, 1.清理挂单及仓位
     let mut run_mode = 0;
-    let mut check_id = "-1".to_string();
+    let mut r_id = "-1".to_string();
 
     let args: Vec<String> = std::env::args().collect();
 
@@ -83,10 +83,10 @@ fn read_params_json() -> Params {
         }
 
         //上报ID
-        if arg.starts_with("--check_id=") {
+        if arg.starts_with("--r_id=") {
             let parts: Vec<&str> = arg.split('=').collect();
             if parts.len() == 2 {
-                check_id = parts[1].to_string();
+                r_id = parts[1].to_string();
             } else {
                 error!("启动失败,回执单id参数格式设置错误 --check_id=xxx!");
                 panic!("启动失败,回执单id参数格式设置错误 --check_id=xxx!");
@@ -98,12 +98,12 @@ fn read_params_json() -> Params {
     let mut params = Params::new_json(path, call_port).unwrap();
     if run_mode == 1 {
         params.run_mode = 1;
-        if check_id == "-1" {
-            error!("启动失败,缺少机器人id参数!");
-            panic!("启动失败,缺少机器人id参数!");
+        if r_id == "-1" {
+            error!("启动失败,缺少回执单id参数!");
+            panic!("启动失败,缺少回执单id参数!");
         }
     }
-    params.check_id = check_id;
+    params.r_id = r_id;
     return params;
 }
 
@@ -147,7 +147,7 @@ async fn main() {
         // core初始化动作
         let mut core_arc = clear_core_libs::init(params.clone(), ws_running.clone(), running.clone(), cci_arc.clone()).await;
         info!("开始执行清仓程序");
-        core_arc.exit(params.check_id).await;
+        core_arc.exit(params.r_id).await;
         info!("清仓程序执行完毕");
         // 强制退出
         std::process::exit(0);

+ 2 - 2
strategy/src/clear_core.rs

@@ -531,13 +531,13 @@ impl ClearCore {
 
 
     // #[instrument(skip(self), level="TRACE")]
-    pub async fn exit(&mut self, check_id: String) -> bool {
+    pub async fn exit(&mut self, r_id: String) -> bool {
         info!("-------------------------启动退出流程({})----------------------------", self.exit_msg);
         info!("");
 
         let mut result = self.check_position().await;
         // 设置机器人id
-        result.check_id = check_id;
+        result.r_id = r_id;
         info!("清仓程序结果 {:?}", result);
         // 判断是否有清仓,是否有异常
         if result.clear_position_num != "0" || result.clear_order_num != "0" || result.clear_other_err{