Joey 4 nedēļas atpakaļ
vecāks
revīzija
f5d748a998

+ 3 - 0
modules/indicatorCalculator.dos

@@ -890,7 +890,10 @@ def cal_indicators(entity_info, benchmarks, end_day, tb_ret, benchmark_ret, risk
 	    WHERE NOT EXISTS ( SELECT * FROM ret r WHERE r.entity_id = t_entity_all_month.entity_id AND r.end_date = t_entity_all_month.end_date);
 
 	ret.sortBy!(['entity_id', 'price_date']);
+	ret.nav.bfill!();
 
+	// 根据净值计算收益,这里不能依赖数据库老数据
+	UPDATE ret SET ret = nav.ratios()-1 CONTEXT BY entity_id;
 
     // 收益、标准差、偏度、峰度、最大回撤、VaR, CVaR、卡玛比率
     rtn = cal_basic_performance(entity_info, ret, month);

+ 2 - 9
modules/returnCalculator.dos

@@ -122,21 +122,14 @@ def cal_weekly_returns(entity_type, entity_info){
      tb_nav.rename!('sec_id', 'entity_id');
 
     UPDATE tb_nav SET year_week = get_year_week(price_date);
-
-    tb_weekly_nav = SELECT entity_id, year_week, price_date.last() AS price_date, cumulative_nav.last() AS cumulative_nav
-                    FROM tb_nav n
-                    INNER JOIN entity_info ei ON n.entity_id = ei.entity_id
-                    WHERE n.price_date >= ei.inception_date // 筛掉成立日之前的净值
-                    GROUP BY entity_id, year_week
-                    ORDER BY entity_id, year_week;
     
     // 这里选最简单的计算方式:不补任何净值空洞,净值前值日期不做任何限制
     // TODO: 可以考虑将月收益也改为这种方式
     tb_rets_1w = SELECT entity_id, year_week, price_date, cumulative_nav, cumulative_nav.ratios()-1 AS ret_1w 
-                 FROM tb_weekly_nav
+                 FROM tb_nav
                  ORDER BY entity_id, year_week;
     
-    return tb_rets_1w;
+    return SELECT * FROM tb_rets_1w WHERE ret_1w > -1;
 }
 
 

+ 4 - 4
modules/task_fundPerformance.dos

@@ -73,10 +73,10 @@ def GetEntityNavTask(date) {
  *   NOTE: 1) 与Java不同的是当月indicator计算每日触发,不必等到Month-end production
  *         2) latest performance 尝试用 dolphin 本地数据
  *   
- *   Example: calFundPerformanceTask('MF', 2025.01.17);
- *            calFundPerformanceTask('MI', 2024.10.28);
+ *   Example: calFundPerformanceTask('HF', 2020.01.23);
+ *            calFundPerformanceTask('MI', 2020.10.28);
  *            calFundPerformanceTask('FI', 2024.10.28);
- *            calFundPerformanceTask('MF', get_ini_data_const()['date']);  -- 【初始化数据专用】(70min)
+ *            calFundPerformanceTask('MF', get_ini_data_const()['date']);  -- 【初始化数据专用】(100min)
  */
 def calFundPerformanceTask(entityType, date) {
 
@@ -112,7 +112,7 @@ def calFundPerformanceTask(entityType, date) {
 	    tb_fund_latest_performance = create_entity_latest_performance();
 
         funds = tb_cal_funds[i : min(tb_cal_funds.size(), i+batch_size)];
-// funds = SELECT * FROM tb_cal_funds WHERE entity_id = 'IN000002L0'
+// funds = SELECT * FROM tb_cal_funds WHERE entity_id = 'MF00004QR9'
         if(funds.isVoid() || funds.size() == 0) break;
 
         // 200ms