|
@@ -1,10 +1,14 @@
|
|
|
module fundit::task_fundPerformance
|
|
|
|
|
|
-use fundit::dataPuller;
|
|
|
+use fundit::sqlUtilities;
|
|
|
+use fundit::operationDataPuller;
|
|
|
+use fundit::performanceDataPuller;
|
|
|
use fundit::dataSaver;
|
|
|
use fundit::returnCalculator;
|
|
|
use fundit::indicatorCalculator;
|
|
|
-
|
|
|
+use fundit::rbsaCalculator;
|
|
|
+use fundit::bfiMatcher;
|
|
|
+use fundit::ms_dataPuller;
|
|
|
|
|
|
/*
|
|
|
* [定时任务]:最新净值触发的业绩指标计算
|
|
@@ -144,6 +148,50 @@ def calFundPerformanceTask(entityType, date) {
|
|
|
|
|
|
|
|
|
/*
|
|
|
+ * 根据收益更新日期计算 RBSA
|
|
|
+ *
|
|
|
+ * Example: CalFundRBSATask('MF', ['MF00003PW1'], 2024.10.14T10:00:00);
|
|
|
+ */
|
|
|
+def CalFundRBSATask(entityType, entityIds, updateTime) {
|
|
|
+// entityType = 'MF'
|
|
|
+//entityIds = ['MF00003PW1']
|
|
|
+//updateTime = 2024.10.14T10:00:00
|
|
|
+
|
|
|
+ tb_result = table(100:0,
|
|
|
+ ["entity_id", "asset_type_id", "index_id", "effective_date", "level", "alternative_id", "weighting"],
|
|
|
+ [iif(entityType=='PF', INT, STRING), STRING, STRING, STRING, INT, STRING, DOUBLE]);
|
|
|
+
|
|
|
+ t = get_entity_list_by_weekly_return_updatetime(entityType, entityIds, updateTime, true);
|
|
|
+
|
|
|
+ window = 48;
|
|
|
+ step = 13;
|
|
|
+
|
|
|
+ if(t.isVoid() || t.size() == 0) return;
|
|
|
+
|
|
|
+ d_rbsa = get_rbsa_index();
|
|
|
+
|
|
|
+ for(entity in t) {
|
|
|
+//entity=t[0]
|
|
|
+ for(asset_type in d_rbsa.keys()) {
|
|
|
+//asset_type=d_rbsa.keys()[3]
|
|
|
+ // 起始日期是最早更新日期再向前推一个时间窗口
|
|
|
+ res = cal_entity_RBSA(entityType, entity.entity_id, d_rbsa[asset_type], 'w',
|
|
|
+ t.price_date.temporalAdd(-window, 'w')[0], today(), true, window, step);
|
|
|
+
|
|
|
+ // 每日任务只负责更新最新的rbsa结果
|
|
|
+ latest_date = (EXEC price_date.max() AS price_date FROM res)[0];
|
|
|
+
|
|
|
+ tb_result.tableInsert(SELECT entity_id, asset_type, index_id, price_date, level, alternative_id, weights
|
|
|
+ FROM res WHERE price_date = latest_date);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ save_and_sync(tb_result, 'raw_db.pf_fund_rbsa_breakdown', 'raw_db.pf_fund_rbsa_breakdown');
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+/*
|
|
|
* 【临时】用于数据初始化:只计算收益
|
|
|
*
|
|
|
* @param entityType <STRING>: 'MF', 'HF'...
|