Kaynağa Gözat

公平价格(仿真)以及它的ema,fix11

skyffire 10 ay önce
ebeveyn
işleme
2a79c6d085
1 değiştirilmiş dosya ile 8 ekleme ve 4 silme
  1. 8 4
      src/msv.rs

+ 8 - 4
src/msv.rs

@@ -6,7 +6,6 @@ use rust_decimal::{Decimal};
 use rust_decimal::prelude::{FromPrimitive, ToPrimitive};
 use rust_decimal_macros::dec;
 use serde_json::{json, Value};
-use tracing::info;
 use crate::db_connector::{get_simple_depths_json, get_trades_json};
 use crate::params_utils::{get_str, parse_str_to_decimal};
 use crate::server::{Response, SimpleDepth, Trade};
@@ -125,7 +124,6 @@ pub fn generate_msv_by_trades(mut trades: Vec<Trade>, mills_back: Decimal, simpl
         b / a
     };
     let gamma_fair: Decimal = Decimal::ONE / Decimal::from_i64(c).unwrap();
-    info!(?a, ?b, ?c, ?gamma_fair);
 
     // ================== 计算每个点的具体波动率以及回溯幅度 ===================
     trades.sort_by(|a, b| Decimal::from_str(a.id.as_str()).unwrap().cmp(&Decimal::from_str(b.id.as_str()).unwrap()));
@@ -321,9 +319,15 @@ pub fn generate_msv_by_trades(mut trades: Vec<Trade>, mills_back: Decimal, simpl
             // 下标步近
             msv_index = msv_index + 1;
         }
+
         if max_fair_d.is_zero() || max_fair_ema_d.is_zero() {
-            max_fair_d = fair_data[msv_index - 1][1];
-            max_fair_ema_d = fair_data[msv_index - 1][2];
+            if msv_index == 0 {
+                max_fair_d = fair_data[0][1];
+                max_fair_ema_d = fair_data[0][2];
+            } else {
+                max_fair_d = fair_data[msv_index - 1][1];
+                max_fair_ema_d = fair_data[msv_index - 1][2];
+            }
         }
 
         // 获取时间范围内的深度数据、买一及卖一价数据