|
@@ -223,6 +223,53 @@ def create_entity_style_stats(is_id_integer=false) {
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
+ * 建表 XXX_bfi_bm_indicator
|
|
|
+ */
|
|
|
+def create_entity_bfi_indicator(is_id_integer=false) {
|
|
|
+
|
|
|
+ return table(1000:0,
|
|
|
+ ['entity_id', 'end_date', 'factor_id',
|
|
|
+ 'upsidecapture_ret_6m', 'downsidecapture_ret_6m', 'upsidecapture_ratio_6m', 'downsidecapture_ratio_6m',
|
|
|
+ 'alpha_6m', 'winrate_6m', 'beta_6m', 'info_ratio_6m', 'tracking_error_6m', 'jensen_6m',
|
|
|
+ 'upsidecapture_ret_1y', 'downsidecapture_ret_1y', 'upsidecapture_ratio_1y', 'downsidecapture_ratio_1y',
|
|
|
+ 'alpha_1y', 'winrate_1y', 'beta_1y', 'info_ratio_1y', 'tracking_error_1y', 'jensen_1y',
|
|
|
+ 'upsidecapture_ret_2y', 'downsidecapture_ret_2y', 'upsidecapture_ratio_2y', 'downsidecapture_ratio_2y',
|
|
|
+ 'alpha_2y', 'winrate_2y', 'beta_2y', 'info_ratio_2y', 'tracking_error_2y', 'jensen_2y',
|
|
|
+ 'upsidecapture_ret_3y', 'downsidecapture_ret_3y', 'upsidecapture_ratio_3y', 'downsidecapture_ratio_3y',
|
|
|
+ 'alpha_3y', 'winrate_3y', 'beta_3y', 'info_ratio_3y', 'tracking_error_3y', 'jensen_3y',
|
|
|
+ 'upsidecapture_ret_4y', 'downsidecapture_ret_4y', 'upsidecapture_ratio_4y', 'downsidecapture_ratio_4y',
|
|
|
+ 'alpha_4y', 'winrate_4y', 'beta_4y', 'info_ratio_4y', 'tracking_error_4y', 'jensen_4y',
|
|
|
+ 'upsidecapture_ret_5y', 'downsidecapture_ret_5y', 'upsidecapture_ratio_5y', 'downsidecapture_ratio_5y',
|
|
|
+ 'alpha_5y', 'winrate_5y', 'beta_5y', 'info_ratio_5y', 'tracking_error_5y', 'jensen_5y',
|
|
|
+ 'upsidecapture_ret_10y', 'downsidecapture_ret_10y', 'upsidecapture_ratio_10y', 'downsidecapture_ratio_10y',
|
|
|
+ 'alpha_10y', 'winrate_10y', 'beta_10y', 'info_ratio_10y', 'tracking_error_10y', 'jensen_10y',
|
|
|
+ 'upsidecapture_ret_ytd', 'downsidecapture_ret_ytd', 'upsidecapture_ratio_ytd', 'downsidecapture_ratio_ytd',
|
|
|
+ 'alpha_ytd', 'winrate_ytd', 'beta_ytd', 'info_ratio_ytd', 'tracking_error_ytd', 'jensen_ytd',
|
|
|
+ 'upsidecapture_ret_incep', 'downsidecapture_ret_incep', 'upsidecapture_ratio_incep', 'downsidecapture_ratio_incep',
|
|
|
+ 'alpha_incep', 'winrate_incep', 'beta_incep', 'info_ratio_incep', 'tracking_error_incep', 'jensen_incep'],
|
|
|
+ [iif(is_id_integer, INT, SYMBOL), MONTH, SYMBOL,
|
|
|
+ DOUBLE, DOUBLE, DOUBLE, DOUBLE,
|
|
|
+ DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE,
|
|
|
+ DOUBLE, DOUBLE, DOUBLE, DOUBLE,
|
|
|
+ DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE,
|
|
|
+ DOUBLE, DOUBLE, DOUBLE, DOUBLE,
|
|
|
+ DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE,
|
|
|
+ DOUBLE, DOUBLE, DOUBLE, DOUBLE,
|
|
|
+ DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE,
|
|
|
+ DOUBLE, DOUBLE, DOUBLE, DOUBLE,
|
|
|
+ DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE,
|
|
|
+ DOUBLE, DOUBLE, DOUBLE, DOUBLE,
|
|
|
+ DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE,
|
|
|
+ DOUBLE, DOUBLE, DOUBLE, DOUBLE,
|
|
|
+ DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE,
|
|
|
+ DOUBLE, DOUBLE, DOUBLE, DOUBLE,
|
|
|
+ DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE,
|
|
|
+ DOUBLE, DOUBLE, DOUBLE, DOUBLE,
|
|
|
+ DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE] );
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+/*
|
|
|
* 建表 xxx_performance_weekly
|
|
|
*/
|
|
|
def create_entity_performance_weekly(is_id_integer=false) {
|
|
@@ -668,6 +715,59 @@ def generate_entity_style_stats(entity_info, indicators, isToMySQL, mutable enti
|
|
|
|
|
|
|
|
|
/*
|
|
|
+ * 按照 XXX_bfi_bm_indicator 表结构准备数据记录
|
|
|
+ *
|
|
|
+ * TODO: why we need isToMySQL here?
|
|
|
+ * 其它的指标恐怕也要按这个改,因为私募可能会有近6月没有数据但近2年之类的周期有数据的情况!
|
|
|
+ */
|
|
|
+def generate_entity_bfi_indicator(entity_info, indicators, isToMySQL, mutable entity_bfi_indicator) {
|
|
|
+
|
|
|
+ t = null;
|
|
|
+
|
|
|
+ v_cols_from = ['upside_capture_ret', 'downside_capture_ret', 'upside_capture_ratio', 'downside_capture_ratio', 'alpha_a', 'winrate', 'beta', 'info_a', 'track_error_a', 'jensen_a'];
|
|
|
+ v_cols_to = ['upsidecapture_ret', 'downsidecapture_ret', 'upsidecapture_ratio', 'downsidecapture_ratio', 'alpha', 'winrate', 'beta', 'info_ratio', 'tracking_error', 'jensen'];
|
|
|
+ v_cols_useless = ['track_error', 'info', 'alpha', 'treynor', 'jensen', 'm2', 'm2_a']; // 标准指标中不被当前表覆盖的数据点
|
|
|
+
|
|
|
+ if(isToMySQL) {
|
|
|
+
|
|
|
+ t = lj(
|
|
|
+ lj(
|
|
|
+ lj(
|
|
|
+ lj(
|
|
|
+ lj(
|
|
|
+ lj(
|
|
|
+ lj(
|
|
|
+ lj(
|
|
|
+ lj(entity_info,
|
|
|
+ indicators['BFI-6M'] AS t_6m, ['entity_id', 'benchmark_id', 'end_date']).dropColumns!(v_cols_useless),
|
|
|
+ indicators['BFI-1Y'] AS t_1y, ['entity_id', 'benchmark_id', 'end_date']).dropColumns!(v_cols_useless),
|
|
|
+ indicators['BFI-2Y'] AS t_2y, ['entity_id', 'benchmark_id', 'end_date']).dropColumns!(v_cols_useless),
|
|
|
+ indicators['BFI-3Y'] AS t_3y, ['entity_id', 'benchmark_id', 'end_date']).dropColumns!(v_cols_useless),
|
|
|
+ indicators['BFI-4Y'] AS t_4y, ['entity_id', 'benchmark_id', 'end_date']).dropColumns!(v_cols_useless),
|
|
|
+ indicators['BFI-5Y'] AS t_5y, ['entity_id', 'benchmark_id', 'end_date']).dropColumns!(v_cols_useless),
|
|
|
+ indicators['BFI-10Y'] AS t_10y, ['entity_id', 'benchmark_id', 'end_date']).dropColumns!(v_cols_useless),
|
|
|
+ indicators['BFI-YTD'] AS t_ytd, ['entity_id', 'benchmark_id', 'end_date']).dropColumns!(v_cols_useless),
|
|
|
+ indicators['BFI-INCEP'] AS t_incep, ['entity_id', 'benchmark_id', 'end_date']).dropColumns!(v_cols_useless);
|
|
|
+
|
|
|
+ t.rename!(v_cols_from, v_cols_to + '_6m');
|
|
|
+ t.rename!('t_1y_' + v_cols_from, v_cols_to + '_1y');
|
|
|
+ t.rename!('t_2y_' + v_cols_from, v_cols_to + '_2y');
|
|
|
+ t.rename!('t_3y_' + v_cols_from, v_cols_to + '_3y');
|
|
|
+ t.rename!('t_4y_' + v_cols_from, v_cols_to + '_4y');
|
|
|
+ t.rename!('t_5y_' + v_cols_from, v_cols_to + '_5y');
|
|
|
+ t.rename!('t_10y_' + v_cols_from, v_cols_to + '_10y');
|
|
|
+ t.rename!('t_ytd_' + v_cols_from, v_cols_to + '_ytd');
|
|
|
+ t.rename!('t_incep_' + v_cols_from, v_cols_to + '_incep');
|
|
|
+ t.dropColumns!(['inception_date', 'ini_value']).rename!('benchmark_id', 'factor_id');
|
|
|
+
|
|
|
+ entity_bfi_indicator.tableInsert(t.reorderColumns!(entity_bfi_indicator.colNames()));
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
* 按照 XXX_performance_weekly 表结构准备数据记录
|
|
|
*
|
|
|
*
|