Joey 4 månader sedan
förälder
incheckning
c34d5de746
2 ändrade filer med 9 tillägg och 7 borttagningar
  1. 1 1
      modules/bfiMatcher.dos
  2. 8 6
      modules/task_fundPerformance.dos

+ 1 - 1
modules/bfiMatcher.dos

@@ -179,7 +179,7 @@ def cal_entity_index_coe(entity_type, entity_info) {
 	if(nav_index.isVoid() || nav_index.size() == 0) return null;
 
 	// 按照SQL 建表
-    entity_coe = create_entity_index_coe();
+    entity_coe = create_entity_index_coe(iif(entity_type == 'PF', true, false));
 
     // 两次循环遍历所有entity和指数
     for(entity in entity_info) {

+ 8 - 6
modules/task_fundPerformance.dos

@@ -432,9 +432,11 @@ def ms_calFundReturns() {
  * 
  * 
  *   TODO: max_r2 表在哪里被用到了?应该和基金推荐有关系
+ *   
+ *   Example: MatchEntityBFITask('MF', 2024.11.20);
  */
-def MatchEntityBFI(entityType, date) {
-//entityType = 'MF'
+def MatchEntityBFITask(entityType, date) {
+//entityType = 'PF'
 //date = 2024.11.20
 
 	rt = '';
@@ -452,7 +454,7 @@ def MatchEntityBFI(entityType, date) {
 	entity_index_coe = create_entity_index_coe();
 	
 	do {
-		// 4 min per 1000 funds
+		// 4 min per 1000 funds or 2 min per 1000 portfolios
 	    coe = cal_entity_index_coe(entityType, tb_cal_entity[i : min(size, i+batch_size)]);
 
 	    if(coe.isVoid() || coe.size() == 0) continue;
@@ -485,7 +487,7 @@ def MatchEntityBFI(entityType, date) {
 
 			// 所有的 factors 存到 xxx_factor_bfi 表;NOTE: Java 把所有 factor 的数据都存起来,这里只存 correlation 达标的记录 (反正这个表没啥用?)
 			chg_columns_for_mysql(t_bfi_candidates, iif(entityType == 'PF', 'portfolio_id', 'fund_id'));
-	        save_and_sync(t_bfi_candidates, iif(entityType == 'PF', 'raw_db..pf_portfolio_factor_bfi', 'raw_db.cm_fund_factor_bfi'), );
+	        save_and_sync(t_bfi_candidates, iif(entityType == 'PF', 'raw_db.pf_portfolio_factor_bfi', 'raw_db.cm_fund_factor_bfi'), );
 
 			if(bfi_raw.isVoid() || bfi_raw.size() == 0) continue;
 
@@ -495,7 +497,7 @@ def MatchEntityBFI(entityType, date) {
 
 	        // 最大R2因子及所有有效因子标签
 			t_max_r2 = SELECT entity_id, factor_id.first() AS factor_id, end_date,
-			                  int(NULL) AS performance_flag, coe.first() AS coe, r2.first() AS r2, concat(factor_name, ",") AS rz_portrait
+			                  string(NULL) AS performance_flag, coe.first() AS coe, r2.first() AS r2, concat(factor_name, ",") AS rz_portrait
 			           FROM ej(t_bfi, get_bfi_index_list(), 'factor_id')
 			           GROUP BY entity_id, end_date;
 
@@ -506,7 +508,7 @@ def MatchEntityBFI(entityType, date) {
 			// 有效因子中 R2 最大的因子存 xxx_max_r2 
 			chg_columns_for_mysql(t_max_r2, iif(entityType == 'PF', 'portfolio_id', 'fund_id'));
 			save_and_sync(t_max_r2, iif(entityType == 'PF', 'raw_db.pf_portfolio_factor_bfi_max_r2', 'raw_db.pf_fund_factor_bfi_by_category_group_max_r2'), );
-	        
+
 
 		} catch (ex) {