Joey hai 1 mes
pai
achega
495ee9c0c4
Modificáronse 2 ficheiros con 64 adicións e 10 borrados
  1. 31 10
      codes/CalculationJobs.dos
  2. 33 0
      codes/ini_data_table.dos

+ 31 - 10
codes/CalculationJobs.dos

@@ -1,4 +1,5 @@
-login(`admin, `123456);
+// login(`admin, `123456);
+// clearCachedModules();
 
 use fundit::task_fundPerformance;
 use fundit::task_portfolioPerformance;
@@ -10,16 +11,22 @@ use fundit::task_monthlyPerformance;
  *  定时任务
  *  
  * 查询任务运行; getRecentJobs();
- * 查询任务列表:getScheduledJobs('daily_%');
- * 删除任务:deleteScheduledJob('monthly_fund_ranking000');
+ * 查询任务列表:getScheduledJobs('weekly_%');
+ * 删除任务:deleteScheduledJob('monthly_company_nav');
  * 
- * 
- *  SELECT jobId, (endTime - startTime)/1000 as sec, errorMsg from getRecentJobs()
+ * 任务全删除(用于重新Load本文件):
+ *  v_jobId = EXEC jobId from getScheduledJobs('daily_%').append!(getScheduledJobs('weekly_%')).append!(getScheduledJobs('monthly_%'));
+ *  for(jobId in v_jobId) deleteScheduledJob(jobId);
+ *  
+ *  
  */
 
 
 /* -------------  DAILY JOBS ---------------------------*/
 
+// nav sync
+scheduleJob('daily_nav_sync', "Sync NAV for fund and index", GetEntityNavTask{now().temporalAdd(-3d)}, 20:00m, today(), today()+30, 'D');
+
 // index and factor calculations go first
 scheduleJob('daily_market_index_performance', "Market Index return and indicator calculation", calFundPerformanceTask{'MI', now().temporalAdd(-3d)}, 22:00m, today(), today()+30, 'D');
 scheduleJob('daily_fundit_index_performance', "FundIT Index return and indicator calculation", calFundPerformanceTask{'FI', now().temporalAdd(-3d)}, 22:00m, today(), today()+30, 'D');
@@ -40,6 +47,10 @@ scheduleJob('weekly_portfolio_rbsa', "Portfolio RBSA calculation", CalEntityRBSA
 // Category Average index weekly NAV
 scheduleJob('weekly_category_avg_nav', "Category Average NAV calculation", CalCategoryAverageNavTask{now().temporalAdd(-7d)}, 08:00m, today(), today()+30, 'W', [6, 0]);
 
+// manager & company nav
+scheduleJob('weekly_manager_nav', "Manager NAV calculation", CalMCWeeklyNavTask{'PL', now().temporalAdd(-7d)}, 08:30m, today(), today()+30, 'W', [6, 0]);
+scheduleJob('weekly_company_nav', "Company NAV calculation", CalMCWeeklyNavTask{'CO', now().temporalAdd(-7d)}, 09:00m, today(), today()+30, 'W', [6, 0]);
+
 
 // BFI MATCHING HERE
 scheduleJob('weekly_fund_bfi_matching', "Fund bfi matching", MatchEntityBFITask{'MF', now().temporalAdd(-3d)}, 01:30m, today(), today()+30, 'W', [6, 0]);
@@ -52,15 +63,25 @@ scheduleJob('weekly_portfolio_bfi_indicator', "Portfolio BFI indicator calculati
 /* -------------  MONTHLY JOBS ---------------------------*/
 
 // manager & company nav
-scheduleJob('monthly_manager_nav', "Manager NAV calculation", CalMCNavTask{'PL', now().temporalAdd(-1m).month(), true}, 18:00m, today(), today()+30, 'M', [2, 3]);
-scheduleJob('monthly_company_nav', "Company NAV calculation", CalMCNavTask{'CO', now().temporalAdd(-1m).month(), true}, 20:00m, today(), today()+30, 'M', [2, 3]);
+scheduleJob('monthly_manager_nav', "Manager NAV calculation", CalMCMonthlyNavTask{'PL', now().temporalAdd(-1m).month()}, 18:00m, today(), today()+30, 'M', [2, 3]);
+scheduleJob('monthly_company_nav', "Company NAV calculation", CalMCMonthlyNavTask{'CO', now().temporalAdd(-1m).month()}, 20:00m, today(), today()+30, 'M', [2, 3]);
 
 // manager & company indicator
-scheduleJob('monthly_manager_indicator', "Manager indicator calculation", CalMCIndicatorTask{'PL', now().temporalAdd(-1m).month(), true}, 22:00m, today(), today()+30, 'M', [2, 3]);
-scheduleJob('monthly_company_indicator', "Company indicator calculation", CalMCIndicatorTask{'CO', now().temporalAdd(-1m).month(), true}, 23:00m, today(), today()+30, 'M', [2, 3]);
+scheduleJob('monthly_manager_indicator', "Manager indicator calculation", CalMCIndicatorTask{'PL', now().temporalAdd(-1m).month()}, 22:00m, today(), today()+30, 'M', [2, 3]);
+scheduleJob('monthly_company_indicator', "Company indicator calculation", CalMCIndicatorTask{'CO', now().temporalAdd(-1m).month()}, 23:00m, today(), today()+30, 'M', [2, 3]);
 
 // manager BFI matching
-scheduleJob('monthly_manager_bfi_matching', "Manager bfi matching", MatchManagerBFITask{now().temporalAdd(-1m).month(), true}, 00:00m, today(), today()+30, 'M', [3, 4]);
+scheduleJob('monthly_manager_bfi_matching', "Manager bfi matching", MatchManagerBFITask{now().temporalAdd(-1m).month()}, 00:00m, today(), today()+30, 'M', [3, 4]);
+
+// manager BFI indicator
+scheduleJob('monthly_manager_bfi_indicator', "Manager bfi indicator calculation", CalManagerBfiIndicatorTask{now().temporalAdd(-1m).month()}, 02:00m, today(), today()+30, 'M', [3, 4]);
+
+// manager & company rankings
+scheduleJob('monthly_company_ranking', "Company PBI ranking calculation", CalEntityRankingTask{'CO', now().temporalAdd(-1m).month(), true}, 03:00m, today(), today()+30, 'M', [3, 4]);
+scheduleJob('monthly_manager_ranking', "Manager PBI ranking calculation", CalEntityRankingTask{'PL', now().temporalAdd(-1m).month(), true}, 04:00m, today(), today()+30, 'M', [3, 4]);
+
+// manager bfi ranking
+scheduleJob('monthly_manager_bfi_ranking', "Manager BFI ranking calculation", CalEntityBfiRankingTask{'PL', now().temporalAdd(-1m).month(), true}, 06:00m, today(), today()+30, 'M', [3, 4]);
 
 
 // fund rankings

+ 33 - 0
codes/ini_data_table.dos

@@ -0,0 +1,33 @@
+login(`admin, `123456);
+
+use fundit::sqlUtilities;
+
+/*
+ *  初始化建库
+ */
+
+directory = "dfs://fundit/mfdb/";
+// dropDatabase(directory);
+// Not sure why PKEY cannot be used
+db = database(directory, partitionType=HASH, partitionScheme=[SYMBOL, 5], engine='TSDB');
+
+directory = "dfs://fundit/pfdb/";
+db = database(directory, partitionType=HASH, partitionScheme=[SYMBOL, 5], engine='TSDB');
+
+directory = "dfs://fundit/raw_db/";
+db = database(directory, partitionType=HASH, partitionScheme=[SYMBOL, 5], engine='TSDB');
+
+/*
+ *  初始化建表
+ * 
+ */
+
+db = get_local_database('fundit', 'mfdb');
+tb_nav = table(100:0, ['entity_id', 'price_date', 'cumulative_nav', 'nav', 'isvalid', 'createtime', 'updatetime'],
+                      [SYMBOL, DATE, DOUBLE, DOUBLE, INT, DATETIME, DATETIME]);
+//dropTable(db, 'public_nav');
+createPartitionedTable(db, tb_nav, 'public_nav', partitionColumns='entity_id', sortColumns=['entity_id', 'price_date'], keepDuplicates=LAST);
+createPartitionedTable(db, tb_nav, 'nav', partitionColumns='entity_id', sortColumns=['entity_id', 'price_date'], keepDuplicates=LAST);
+createPartitionedTable(db, tb_nav, 'market_indexes', partitionColumns='entity_id', sortColumns=['entity_id', 'price_date'], keepDuplicates=LAST);
+
+