|
@@ -26,26 +26,10 @@ cal_method = 2;
|
|
|
tb_portfolio_ret = cal_portfolio_return(portfolio_ids, very_old_date, cal_method);
|
|
|
tb_portfolio_ret.sortBy!(['portfolio_id', 'price_date'], [1, 1]);
|
|
|
|
|
|
-select portfolio_id, price_date.month(), price_date.last(), (1+ret).prod()-1, nav.last()
|
|
|
-from tb_portfolio_ret
|
|
|
-where price_date <= end_day
|
|
|
-group by portfolio_id, price_date.month()
|
|
|
-
|
|
|
// calculate indicators
|
|
|
end_day = 2024.08.31
|
|
|
|
|
|
-bmk_ret = SELECT fund_id, temporalParse(end_date, 'yyyy-MM') AS end_date, ret FROM get_fund_monthly_ret("'IN00000008'", 1990.01.01, end_day, true);
|
|
|
-risk_free_rate = SELECT fund_id, temporalParse(end_date, 'yyyy-MM') AS end_date, ret FROM get_risk_free_rate("'IN0000000M'", 1990.01.01, end_day);
|
|
|
-
|
|
|
-// calculate monthly return
|
|
|
-// funky thing is you can't use "AS" for the grouping columns?
|
|
|
-tb_ret = SELECT portfolio_id, price_date.month(), price_date.last() AS price_date, (1+ret).prod()-1 AS ret, nav.last() AS nav
|
|
|
- FROM tb_portfolio_ret
|
|
|
- WHERE price_date <= end_day
|
|
|
- GROUP BY portfolio_id, price_date.month();
|
|
|
-
|
|
|
-tb_ret.rename!(['portfolio_id', 'month_price_date'], ['entity_id', 'end_date']);
|
|
|
+tb_indicators = cal_portfolio_indicators(portfolio_ids, end_day, cal_method, true);
|
|
|
|
|
|
-tb_indicators = cal_all_trailing_indicators(tb_ret, end_day, bmk_ret, risk_free_rate, 'm');
|
|
|
+select * from tb_indicators[0]
|
|
|
|
|
|
-select * from tb_indicators[8]
|