Joey 3 ヶ月 前
コミット
639ca46c82

+ 76 - 1
modules/dataSaver.dos

@@ -585,6 +585,28 @@ def create_entity_indicator_ranking(is_id_integer=false) {
                  DOUBLE, INT, INT, DOUBLE, INT, INT]);
 }
 
+
+/*
+ *   建基金经理/公司表 XXXX_indicator_ranking
+ */
+def create_mc_indicator_ranking(is_id_integer=false) {
+
+    return table(1000:0, 
+                ['entity_id', 'curve_type', 'category_id', 'end_date', 'indicator_id',
+                 'indicator_1m', 'absrank_1m', 'perrank_1m', 'indicator_3m', 'absrank_3m', 'perrank_3m', 
+                 'indicator_6m', 'absrank_6m', 'perrank_6m', 'indicator_1y', 'absrank_1y', 'perrank_1y', 
+                 'indicator_2y', 'absrank_2y', 'perrank_2y', 'indicator_3y', 'absrank_3y', 'perrank_3y', 
+                 'indicator_5y', 'absrank_5y', 'perrank_5y', 
+                 'indicator_10y', 'absrank_10y', 'perrank_10y', 'indicator_ytd', 'absrank_ytd', 'perrank_ytd'],
+                [SYMBOL, INT, SYMBOL, STRING, INT,
+                 DOUBLE, INT, INT, DOUBLE, INT, INT,
+                 DOUBLE, INT, INT, DOUBLE, INT, INT,
+                 DOUBLE, INT, INT, DOUBLE, INT, INT,
+                 DOUBLE, INT, INT,
+                 DOUBLE, INT, INT, DOUBLE, INT, INT]);
+}
+
+
 /*
  *   建表 XXXX_indicator_ranking_num, raise_type 没有用
  */
@@ -633,6 +655,53 @@ def create_entity_indicator_ranking_num() {
 
 
 /*
+ *   建基金经理/公司表 XXXX_indicator_ranking_num, raise_type 没有用
+ */
+def create_mc_indicator_ranking_num() {
+
+    return table(1000:0, 
+                ['curve_type', 'category_id', 'end_date', 'indicator_id',
+                 'avg_1m', 'avg_1m_cnt', 'perrank_percent_5_1m', 'perrank_percent_10_1m', 'perrank_percent_25_1m', 'perrank_percent_50_1m',
+                 'perrank_percent_75_1m', 'perrank_percent_90_1m', 'perrank_percent_95_1m', 'best_1m', 'worst_1m',
+                 'avg_3m', 'avg_3m_cnt', 'perrank_percent_5_3m', 'perrank_percent_10_3m', 'perrank_percent_25_3m', 'perrank_percent_50_3m',
+                 'perrank_percent_75_3m', 'perrank_percent_90_3m', 'perrank_percent_95_3m', 'best_3m', 'worst_3m',
+                 'avg_6m', 'avg_6m_cnt', 'perrank_percent_5_6m', 'perrank_percent_10_6m', 'perrank_percent_25_6m', 'perrank_percent_50_6m',
+                 'perrank_percent_75_6m', 'perrank_percent_90_6m', 'perrank_percent_95_6m', 'best_6m', 'worst_6m',
+                 'avg_1y', 'avg_1y_cnt', 'perrank_percent_5_1y', 'perrank_percent_10_1y', 'perrank_percent_25_1y', 'perrank_percent_50_1y',
+                 'perrank_percent_75_1y', 'perrank_percent_90_1y', 'perrank_percent_95_1y', 'best_1y', 'worst_1y',
+                 'avg_2y', 'avg_2y_cnt', 'perrank_percent_5_2y', 'perrank_percent_10_2y', 'perrank_percent_25_2y', 'perrank_percent_50_2y',
+                 'perrank_percent_75_2y', 'perrank_percent_90_2y', 'perrank_percent_95_2y', 'best_2y', 'worst_2y',
+                 'avg_3y', 'avg_3y_cnt', 'perrank_percent_5_3y', 'perrank_percent_10_3y', 'perrank_percent_25_3y', 'perrank_percent_50_3y',
+                 'perrank_percent_75_3y', 'perrank_percent_90_3y', 'perrank_percent_95_3y', 'best_3y', 'worst_3y',
+                 'avg_5y', 'avg_5y_cnt', 'perrank_percent_5_5y', 'perrank_percent_10_5y', 'perrank_percent_25_5y', 'perrank_percent_50_5y',
+                 'perrank_percent_75_5y', 'perrank_percent_90_5y', 'perrank_percent_95_5y', 'best_5y', 'worst_5y',
+                 'avg_10y', 'avg_10y_cnt', 'perrank_percent_5_10y', 'perrank_percent_10_10y', 'perrank_percent_25_10y', 'perrank_percent_50_10y',
+                 'perrank_percent_75_10y', 'perrank_percent_90_10y', 'perrank_percent_95_10y', 'best_10y', 'worst_10y',
+                 'avg_ytd', 'avg_ytd_cnt', 'perrank_percent_5_ytd', 'perrank_percent_10_ytd', 'perrank_percent_25_ytd', 'perrank_percent_50_ytd',
+                 'perrank_percent_75_ytd', 'perrank_percent_90_ytd', 'perrank_percent_95_ytd', 'best_ytd', 'worst_ytd'],
+                [INT, SYMBOL, STRING, INT,
+                 DOUBLE, INT, DOUBLE, DOUBLE, DOUBLE, DOUBLE,
+                 DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE,
+                 DOUBLE, INT, DOUBLE, DOUBLE, DOUBLE, DOUBLE,
+                 DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE,
+                 DOUBLE, INT, DOUBLE, DOUBLE, DOUBLE, DOUBLE,
+                 DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE,
+                 DOUBLE, INT, DOUBLE, DOUBLE, DOUBLE, DOUBLE,
+                 DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE,
+                 DOUBLE, INT, DOUBLE, DOUBLE, DOUBLE, DOUBLE,
+                 DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE,
+                 DOUBLE, INT, DOUBLE, DOUBLE, DOUBLE, DOUBLE,
+                 DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE,
+                 DOUBLE, INT, DOUBLE, DOUBLE, DOUBLE, DOUBLE,
+                 DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE,
+                 DOUBLE, INT, DOUBLE, DOUBLE, DOUBLE, DOUBLE,
+                 DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE,
+                 DOUBLE, INT, DOUBLE, DOUBLE, DOUBLE, DOUBLE,
+                 DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE ]);
+}
+
+
+/*
  *   根据 mysql 表改动某些字段
  */
 def chg_columns_for_mysql(mutable tb_mysql, id_col_name) {
@@ -931,6 +1000,9 @@ def generate_entity_style_stats(entity_info, indicators, isToMySQL, mutable enti
 
 /*
  *   按照 XXX_bfi_bm_indicator 表结构准备数据记录
+ *   
+ *   @param entity_info <TABLE>: [COLUMNS] entity_id, end_date, benchmark_id, inception_date, ini_value [,curve_type, strategy]
+ *   @param indicators <DICTIONARY>
  * 
  *   TODO: why we need isToMySQL here?
  *         其它的指标恐怕也要按这个改,因为私募可能会有近6月没有数据但近2年之类的周期有数据的情况!
@@ -978,7 +1050,10 @@ def generate_entity_bfi_indicator(entity_info, indicators, isToMySQL, mutable en
 		t.rename!('t_10y_' + v_cols_from, v_cols_to + '_10y');
 		t.rename!('t_ytd_' + v_cols_from, v_cols_to + '_ytd');
 		t.rename!('t_incep_' + v_cols_from, v_cols_to + '_incep');
-		t.dropColumns!(['inception_date', 'ini_value']).rename!('benchmark_id', 'factor_id');
+
+		if(t.columnNames().find('inception_date') >= 0) t.dropColumns!('inception_date');
+		if(t.columnNames().find('ini_value') >= 0) t.dropColumns!('ini_value');
+		t.rename!('benchmark_id', 'factor_id');
 
         entity_bfi_indicator.tableInsert(t.reorderColumns!(entity_bfi_indicator.colNames()));
 

+ 2 - 2
modules/operationDataPuller.dos

@@ -441,12 +441,12 @@ def get_entity_info(entity_type, entity_ids) {
     	t.rename!('factor_id', 'entity_id');
     } else if(entity_type == 'PL') {
 
-    	t = get_personnel_info(s_entity_ids);
+    	t = get_personnel_info_for_perf(s_entity_ids);
     	t.rename!('manager_id', 'entity_id');
     	
     } else if(entity_type == 'CO') {
 
-    	t = get_company_info(s_entity_ids);
+    	t = get_company_info_for_perf(s_entity_ids);
     	t.rename!('company_id', 'entity_id');    	
     }
 

+ 7 - 17
modules/rbsaCalculator.dos

@@ -223,9 +223,9 @@ def cal_single_entity_RBSA(entity_type, entity_id, index_ids, freq='w', start_da
 /*
  *  计算单基金或组合的RBSA
  * 
- *  @param entity_type <STRING>: 目标基金/组合的类型
- *  @param entity_id <STRING>: 目标基金/组合的ID
- *  @param index_ids <VECTOR>: 基准指数IDs
+ *  @param entity_type <STRING>: MF, HF, PF
+ *  @param entity_ret <TABLE>: [COLUMNS] entity_id, price_date, ret
+ *  @param index_ret <TABLE>: [COLUMNS] entity_id, price_date, ret
  *  @param freq <STRING>: m, w, d
  *  @param start_day <DATE>
  *  @param end_day <DATE>
@@ -241,7 +241,7 @@ def cal_single_entity_RBSA(entity_type, entity_id, index_ids, freq='w', start_da
 def cal_entity_RBSA(entity_type, entity_ret, index_ret, freq='w', start_day=1900.01.01, end_day=2099.12.31, is_long=true, window=24, step=24) {
 // entity_type='MF'
 // freq='w'
-// start_day=2023.12.28
+// start_day=2024.01.05
 // end_day=today()
 // is_long=true
 // window=48
@@ -264,27 +264,17 @@ def cal_entity_RBSA(entity_type, entity_ret, index_ret, freq='w', start_day=1900
 			p_fund_id = fund_info.p_fund_id;
 			primary_benchmark_id = fund_info.benchmark_id;
 			if(p_fund_id != NULL) {
-				tb_entity_ret = get_entity_return(entity_type, p_fund_id , freq, start_day, end_day, true);
+				tb_entity_ret = SELECT entity_id, price_date, ret FROM get_entity_return(entity_type, p_fund_id , freq, start_day, end_day, true);
 				alternative_id = p_fund_id[0];
 				level = 4;
 			} else if(primary_benchmark_id != NULL) {
-				tb_entity_ret = get_entity_return(entity_type, primary_benchmark_id, freq, start_day, end_day, true);
+				tb_entity_ret = SELECT entity_id, price_date, ret FROM get_entity_return(entity_type, primary_benchmark_id, freq, start_day, end_day, true);
 				alternative_id = primary_benchmark_id[0];
 				level = 3;
 			} else {
 				return tb_result;
 			}
-		} else if(entity_type == 'PF'){
-
-			portfolio_info = get_portfolio_info(tb_entity_ret.entity_id);
-			primary_benchmark_id = portfolio_info.benchmark_id;
-			if(primary_benchmark_id != NULL) {
-				tb_entity_ret = get_entity_return(entity_type, primary_benchmark_id, freq, start_day, end_day, true);
-				alternative_id  = primary_benchmark_id[0];
-				level = 3;
-			} else
-				return tb_result;
-		}
+		} 
 	}
 
 	tb_entity_ret.addColumn('effective_date', STRING);

+ 2 - 2
modules/task_weeklyPerformnce.dos

@@ -23,7 +23,7 @@ use fundit::dataSaver;
  *            CalEntityRBSATask('PF', NULL, 2024.11.25T10:00:00);
  */
 def CalEntityRBSATask(entityType, entityIds, updateTime) {
-// entityType = 'PF'
+// entityType = 'MF'
 //entityIds = NULL
 //updateTime = 2024.10.14T10:00:00
 
@@ -84,7 +84,7 @@ def CalEntityRBSATask(entityType, entityIds, updateTime) {
 		
 			}
 		}
-	
+
 		if(entityType IN ['MF', 'HF'])
 			save_and_sync(tb_result, 'raw_db.pf_fund_rbsa_breakdown', 'raw_db.pf_fund_rbsa_breakdown');
 		else