module fundit::task_fundPerformance use fundit::fundCalculator use fundit::dataPuller use fundit::returnCalculator use fundit::indicatorCalculator /* * 定时任务:最新净值触发的业绩指标计算 * * @param entityType : 'MF', 'HF'... * @param date : 净值更新时间 * * TODO: 目前收益表在MySQL中,所以需要将计算的最新收益与MySQL中的历史数据合并 */ def calFundPerformance(entityType, date) { very_old_date = 1990.01.01; if(find(['HF', 'MF'], entityType) < 0) return null; // 取有最新净值变动的基金列表 tb_cal_funds = get_entity_list_by_nav_updatetime(entityType, NULL, date, true); // 分批跑 i = 0; batch_size = 1000; do { funds = tb_cal_funds[i:batch_size] // 计算月收益 rets = mix_monthly_returns(entityType, funds); // TODO: 最新更新的收益存入数据库 // 计算月度指标 rets.rename!('cumulative_nav', 'nav'); indicators = cal_monthly_indicators(entityType, 'PBI', rets); // TODO: 最新更新的指标存入数据库 i += batch_size; } while (i < batch_size); // } while (i <= tb_cal_funds.size()); return; }