瀏覽代碼

公式调整。

skyffire 1 年之前
父節點
當前提交
230bd9725b
共有 1 個文件被更改,包括 9 次插入2 次删除
  1. 9 2
      src/rank.rs

+ 9 - 2
src/rank.rs

@@ -77,17 +77,24 @@ pub fn generate_rank_by_indicator_map(indicator_map: &MutexGuard<HashMap<String,
         // ============== epr相关数据的计算 =================
         let mut epr_total = Decimal::ZERO;
         let mut epr_max = Decimal::ZERO;
+        let mut epr_count = Decimal::ZERO;
         for value in indicators.eprs.iter() {
             if value[1].abs() < ONE_PERCENT {
                 continue;
             }
 
             epr_total += value[1];
+            epr_count += Decimal::ONE;
 
             if value[1] > epr_max {
                 epr_max = value[1]
             }
         }
+        let epr_avg = if epr_count == Decimal::ZERO {
+            epr_total
+        } else {
+            epr_total / epr_count
+        };
 
         // ============== liq相关数据的计算 =================
         let mut liquidity_total = Decimal::ZERO;
@@ -105,9 +112,9 @@ pub fn generate_rank_by_indicator_map(indicator_map: &MutexGuard<HashMap<String,
         // msv_score计算规则
         let mut msv_score = if msv_abs_total > Decimal::ZERO && epr_total > Decimal::ZERO {
             if epr_total > msv_abs_total {
-                (epr_max * SIXTY).powd(Decimal::TWO)
+                (epr_avg * SIXTY).powd(Decimal::TWO)
             } else {
-                (epr_max * SIXTY * (epr_total / msv_abs_total)).powd(Decimal::TWO)
+                (epr_avg * SIXTY * (epr_total / msv_abs_total)).powd(Decimal::TWO)
             }
         } else {
             Decimal::ZERO