|
@@ -4,30 +4,32 @@ use fundit::dataPuller;
|
|
|
use fundit::dataSaver;
|
|
|
use fundit::returnCalculator;
|
|
|
use fundit::indicatorCalculator;
|
|
|
-use fundit::bfiMatcher;
|
|
|
-use fundit::rankingCalculator;
|
|
|
+
|
|
|
|
|
|
/*
|
|
|
* [定时任务]:最新净值触发的业绩指标计算
|
|
|
*
|
|
|
* @param entityType <STRING>: 'MF', 'HF'...
|
|
|
- * @param date <DATETIME>: 净值更新时间, 为空时缺省为当前时间-1天;为1900.01.01或更早日期时代表初始化,指标会被存入本地数据库
|
|
|
+ * @param date <DATETIME>: 净值更新时间, 为空时缺省为当前时间-1天;为1990.01.01或更早日期时代表初始化,指标会被存入本地数据库
|
|
|
*
|
|
|
* NOTE: 与Java不同的是当月indicator计算每日触发,不必等到Month-end production
|
|
|
*
|
|
|
* Example: calFundPerformanceTask('MF', 2024.10.28);
|
|
|
* calFundPerformanceTask('MI', 2024.10.28);
|
|
|
*/
|
|
|
-def calFundPerformanceTask(entityType, mutable date) {
|
|
|
+def calFundPerformanceTask(entityType, date) {
|
|
|
|
|
|
rt = '';
|
|
|
|
|
|
if(!(entityType IN ['MF', 'HF', 'MI', 'FI'])) return null;
|
|
|
|
|
|
- if(date.isNothing() || date.isNull()) date = temporalAdd(now(), -1d);
|
|
|
+ if(date.isNothing() || date.isNull())
|
|
|
+ end_day = temporalAdd(now(), -1d);
|
|
|
+ else
|
|
|
+ end_day = date;
|
|
|
|
|
|
// 取有最新净值变动的基金列表 (1s)
|
|
|
- tb_cal_funds = get_entity_list_by_nav_updatetime(entityType, NULL, date, true);
|
|
|
+ tb_cal_funds = get_entity_list_by_nav_updatetime(entityType, NULL, end_day, true);
|
|
|
|
|
|
if(tb_cal_funds.isVoid() || tb_cal_funds.size() == 0 ) return;
|
|
|
|
|
@@ -120,7 +122,7 @@ def calFundPerformanceTask(entityType, mutable date) {
|
|
|
save_and_sync(tb_fund_latest_performance, 'raw_db.fund_latest_performance', 'raw_db.fund_latest_nav_performance');
|
|
|
|
|
|
// 数据初始化时将指标存入本地,做排名之用
|
|
|
- if(date <= 1900.01.01) {
|
|
|
+ if(end_day <= 1990.01.01) {
|
|
|
save_table(tb_fund_performance, 'raw_db.fund_performance', false);
|
|
|
save_table(tb_fund_indicator, 'raw_db.fund_indicator', false);
|
|
|
save_table(tb_fund_risk_stats, 'raw_db.fund_risk_stats', false);
|
|
@@ -281,69 +283,3 @@ def calFundIndexCorrelation(entityType, date) {
|
|
|
|
|
|
return coe;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-/*
|
|
|
- * 计算排名并存入数据库
|
|
|
- *
|
|
|
- * @param end_date <MONTH>
|
|
|
- *
|
|
|
- * Example: cal_entity_ranking('MF', 2024.09M, true);
|
|
|
- */
|
|
|
-def CalEntityRanking(entity_type, end_date, isFromMySQL) {
|
|
|
-/*
|
|
|
-entity_type = 'MF';
|
|
|
-end_date = 2024.09M;
|
|
|
-isFromMySQL = true;
|
|
|
-*/
|
|
|
- entity_info = get_entity_info(entity_type, NULL);
|
|
|
-
|
|
|
- // 收益
|
|
|
- v_ranking_tables = cal_ret_ranking(entity_type, entity_info, end_date, isFromMySQL);
|
|
|
- save_ranking_tables(v_ranking_tables);
|
|
|
-
|
|
|
- // 风险相关的指标
|
|
|
- v_ranking_tables = cal_risk_ranking(entity_type, entity_info, end_date, isFromMySQL);
|
|
|
- save_ranking_tables(v_ranking_tables);
|
|
|
-
|
|
|
- // 风险调整收益指标
|
|
|
- v_ranking_tables = cal_risk_adj_return_ranking(entity_type, entity_info, end_date, isFromMySQL);
|
|
|
- save_ranking_tables(v_ranking_tables);
|
|
|
-
|
|
|
- // 杂项指标
|
|
|
- v_ranking_tables = cal_other_indicator_ranking(entity_type, entity_info, end_date, isFromMySQL);
|
|
|
- save_ranking_tables(v_ranking_tables);
|
|
|
-
|
|
|
-/*
|
|
|
- v_tables = NULL;
|
|
|
-
|
|
|
- if(entity_type IN ['MF', 'HF', 'MI', 'FI']) {
|
|
|
-
|
|
|
- v_tables = ['mfdb.fund_performance', 'mfdb.fund_risk_stats', 'mfdb.fund_riskadjret_stats', 'mfdb.fund_indicator', 'mfdb.fund_style_stats'];
|
|
|
-
|
|
|
- } else if(entity_type = 'PF') {
|
|
|
-
|
|
|
- v_tables = ['pfdb.pf_portfolio_performance', 'pfdb.pf_portfolio_risk_stats', 'pfdb.pf_portfolio_riskadjret_stats', 'pfdb.pf_portfolio_indicator', 'pfdb.pf_portfolio_style_stats'];
|
|
|
-
|
|
|
- } else if(entity_type = 'CF') {
|
|
|
-
|
|
|
- v_tables = ['pfdb.pf_cus_fund_performance', 'pfdb.pf_cus_fund_risk_stats', 'pfdb.pf_cus_fund_riskadjret_stats', 'pfdb.pf_cus_fund_indicator', 'pfdb.pf_cus_fund_style_stats'];
|
|
|
-
|
|
|
- } else if(entity_type = 'FA') {
|
|
|
-
|
|
|
- v_tables = ['pfdb.cm_factor_performance', 'pfdb.cm_factor_risk_stats', 'pfdb.cm_factor_riskadjret_stats', 'pfdb.cm_factor_indicator', 'pfdb.cm_factor_style_stats'];
|
|
|
-
|
|
|
- } else if(entity_type = 'CI') {
|
|
|
-
|
|
|
- v_tables = ['pfdb.cm_udf_index_performance', 'pfdb.cm_udf_index_risk_stats', 'pfdb.cm_udf_index_riskadjret_stats', 'pfdb.cm_udf_index_indicator', 'pfdb.cm_udf_index_style_stats'];
|
|
|
- }
|
|
|
-
|
|
|
- if(v_tables.isNull()) return null;
|
|
|
-
|
|
|
- for(table in v_tables) {
|
|
|
-
|
|
|
- tb_data = get_monthly_indicator_data(table, end_date, isFromMySQL);
|
|
|
-
|
|
|
- }
|
|
|
-*/
|
|
|
-}
|