Browse Source

公式调整。

skyffire 1 year ago
parent
commit
4096775bdc
1 changed files with 8 additions and 23 deletions
  1. 8 23
      src/rank.rs

+ 8 - 23
src/rank.rs

@@ -44,6 +44,8 @@ pub fn generate_rank_by_indicator_map(indicator_map: &MutexGuard<HashMap<String,
         let mut msv_abs_max = Decimal::ZERO;
         let mut msv_count = Decimal::ZERO;
         let mut effective_epr_count = Decimal::ZERO;
+        let mut epr_total = Decimal::ZERO;
+        let mut epr_max = Decimal::ZERO;
         for (index, value) in indicators.msv.iter().enumerate() {
             let msv_abs_value = value[1].abs();
 
@@ -59,8 +61,13 @@ pub fn generate_rank_by_indicator_map(indicator_map: &MutexGuard<HashMap<String,
             }
 
             let epr = &indicators.eprs[index];
-            if epr[1] > msv_abs_value * ONE_QUARTER {
+            if epr[1] > msv_abs_value * ONE_QUARTER || epr[1].abs() > ONE_PERCENT {
                 effective_epr_count += Decimal::ONE;
+                epr_total += epr[1];
+
+                if value[1] > epr_max {
+                    epr_max = value[1]
+                }
             }
         }
         // 计算波动率平均值
@@ -74,28 +81,6 @@ pub fn generate_rank_by_indicator_map(indicator_map: &MutexGuard<HashMap<String,
         let mut coverted_open_base = (msv_abs_max + msv_abs_avg) / TWO_HUNDRED;
         coverted_open_base.rescale(8);
 
-        // ============== 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;
         for value in indicators.liqs.iter() {