CalculationJobs.dos 6.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. module fundit::CalculationJobs
  2. // login(`admin, `123456);
  3. // clearCachedModules();
  4. use fundit::task_fundPerformance;
  5. use fundit::task_portfolioPerformance;
  6. use fundit::task_monthlyPerformance;
  7. use fundit::task_weeklyPerformance;
  8. /*
  9. * 定时任务
  10. *
  11. * 查询任务运行; getRecentJobs();
  12. * 查询任务列表:getScheduledJobs('weekly_%');
  13. * 删除任务:deleteScheduledJob('monthly_manager_nav');
  14. * 取消任务:cancelJob('daily_portfolio_performance20250120');
  15. *
  16. * 任务全删除(用于重新Load本文件):
  17. * v_jobId = EXEC jobId from getScheduledJobs('daily_%').append!(getScheduledJobs('weekly_%')).append!(getScheduledJobs('monthly_%'));
  18. * for(jobId in v_jobId) deleteScheduledJob(jobId);
  19. *
  20. *
  21. */
  22. /* ------------- DAILY JOBS ---------------------------*/
  23. // nav sync
  24. scheduleJob('daily_nav_sync', "Sync NAV for fund and index", GetEntityNavTask{now().temporalAdd(-3d)}, 20:00m, today(), today()+30, 'D');
  25. // index and factor calculations go first
  26. scheduleJob('daily_market_index_performance', "Market Index return and indicator calculation", calFundPerformanceTask{'MI', now().temporalAdd(-3d)}, 22:00m, today(), today()+30, 'D');
  27. scheduleJob('daily_fundit_index_performance', "FundIT Index return and indicator calculation", calFundPerformanceTask{'FI', now().temporalAdd(-3d)}, 22:00m, today(), today()+30, 'D');
  28. scheduleJob('daily_factor_performance', "Factor nav, return and indicator calculation", CalFactorPerformanceTask{now().temporalAdd(-3d)}, 23:00m, today(), today()+30, 'D');
  29. // standard return and indicator calculation
  30. scheduleJob('daily_mutual_fund_performance', "Mutual fund return and indicator calculation", calFundPerformanceTask{'MF', now().temporalAdd(-3d)}, 00:00m, today(), today()+30, 'D');
  31. scheduleJob('daily_hedge_fund_performance', "Hedge fund return and indicator calculation", calFundPerformanceTask{'HF', now().temporalAdd(-3d)}, 00:30m, today(), today()+30, 'D');
  32. scheduleJob('daily_portfolio_performance', "Portfolio nav, return and indicator calculation", CalPortfolioPerformanceTask{now().temporalAdd(-3d)}, 01:00m, today(), today()+30, 'D');
  33. /* ------------- WEEKLY JOBS ---------------------------*/
  34. // RBSA calculation
  35. scheduleJob('weekly_fund_rbsa', "Fund RBSA calculation", CalEntityRBSATask{'MF', NULL, now().temporalAdd(-7d)}, 07:00m, today(), today()+30, 'W', [6, 0]);
  36. scheduleJob('weekly_portfolio_rbsa', "Portfolio RBSA calculation", CalEntityRBSATask{'PF', NULL, now().temporalAdd(-7d)}, 07:30m, today(), today()+30, 'W', [6, 0]);
  37. // Category Average index weekly NAV
  38. scheduleJob('weekly_category_avg_nav', "Category Average NAV calculation", CalCategoryAverageNavTask{now().temporalAdd(-7d)}, 08:00m, today(), today()+30, 'W', [6, 0]);
  39. // manager & company nav
  40. scheduleJob('weekly_manager_nav', "Manager NAV calculation", CalMCWeeklyNavTask{'PL', now().temporalAdd(-7d)}, 08:30m, today(), today()+30, 'W', [6, 0]);
  41. scheduleJob('weekly_company_nav', "Company NAV calculation", CalMCWeeklyNavTask{'CO', now().temporalAdd(-7d)}, 09:00m, today(), today()+30, 'W', [6, 0]);
  42. // BFI MATCHING HERE
  43. scheduleJob('weekly_fund_bfi_matching', "Fund bfi matching", MatchEntityBFITask{'MF', now().temporalAdd(-3d)}, 01:30m, today(), today()+30, 'W', [6, 0]);
  44. scheduleJob('weekly_portfolio_bfi_matching', "Portfolio bfi matching", MatchEntityBFITask{'PF', now().temporalAdd(-3d)}, 06:00m, today(), today()+30, 'W', [6, 0]);
  45. // BFI indicator calculation
  46. scheduleJob('weekly_fund_bfi_indicator', "Fund BFI indicator calculation", calEntityBfiIndicatorTask{'MF', now().temporalAdd(-3d)}, 07:00m, today(), today()+30, 'W', [6, 0]);
  47. scheduleJob('weekly_portfolio_bfi_indicator', "Portfolio BFI indicator calculation", calEntityBfiIndicatorTask{'PF', now().temporalAdd(-3d)}, 08:00m, today(), today()+30, 'W', [6, 0]);
  48. /* ------------- MONTHLY JOBS ---------------------------*/
  49. // manager & company nav
  50. scheduleJob('monthly_manager_nav', "Manager NAV calculation", CalMCMonthlyNavTask{'PL', now().temporalAdd(-1m).temporalAdd(-2d)}, 18:00m, today(), today()+30, 'M', [2, 3]);
  51. scheduleJob('monthly_company_nav', "Company NAV calculation", CalMCMonthlyNavTask{'CO', now().temporalAdd(-1m).temporalAdd(-2d)}, 20:00m, today(), today()+30, 'M', [2, 3]);
  52. // manager & company indicator
  53. scheduleJob('monthly_manager_indicator', "Manager indicator calculation", CalMCIndicatorTask{'PL', now().temporalAdd(-1m).temporalAdd(-2d)}, 22:00m, today(), today()+30, 'M', [2, 3]);
  54. scheduleJob('monthly_company_indicator', "Company indicator calculation", CalMCIndicatorTask{'CO', now().temporalAdd(-1m).temporalAdd(-2d)}, 23:00m, today(), today()+30, 'M', [2, 3]);
  55. // manager BFI matching
  56. scheduleJob('monthly_manager_bfi_matching', "Manager bfi matching", MatchManagerBFITask{now().temporalAdd(-1m).temporalAdd(-2d)}, 00:00m, today(), today()+30, 'M', [3, 4]);
  57. // manager BFI indicator
  58. scheduleJob('monthly_manager_bfi_indicator', "Manager bfi indicator calculation", CalManagerBfiIndicatorTask{now().temporalAdd(-1m).temporalAdd(-2d)}, 02:00m, today(), today()+30, 'M', [3, 4]);
  59. // manager & company rankings
  60. scheduleJob('monthly_company_ranking', "Company PBI ranking calculation", CalEntityRankingTask{'CO', now().temporalAdd(-1m).month(), true}, 03:00m, today(), today()+30, 'M', [3, 4]);
  61. scheduleJob('monthly_manager_ranking', "Manager PBI ranking calculation", CalEntityRankingTask{'PL', now().temporalAdd(-1m).month(), true}, 04:00m, today(), today()+30, 'M', [3, 4]);
  62. // manager bfi ranking
  63. scheduleJob('monthly_manager_bfi_ranking', "Manager BFI ranking calculation", CalEntityBfiRankingTask{'PL', now().temporalAdd(-1m).month(), true}, 06:00m, today(), today()+30, 'M', [3, 4]);
  64. // fund rankings
  65. scheduleJob('monthly_fund_ranking', "Fund PBI ranking calculation", CalEntityRankingTask{'MF', now().temporalAdd(-1m).month(), true}, 19:00m, today(), today()+30, 'M', [5, 6]);
  66. scheduleJob('monthly_fund_bfi_ranking', "Fund BFI ranking calculation", CalEntityBfiRankingTask{'MF', now().temporalAdd(-1m).month(), true}, 20:00m, today(), today()+30, 'M', [5, 6]);
  67. // portfolio rankings (strategy, substrategy, bfi included)
  68. scheduleJob('monthly_portfolio_ranking', "Portfolio ranking calculation", CalRelativeRankingTask{'PF', NULL, now().temporalAdd(-1m).month(), true}, 21:00m, today(), today()+30, 'M', [5, 6]);