Exemplo n.º 1
0
def cal_obj(signal, name, period=5, quantile=5):
    obj = SignalDigger()
    obj.process_signal_before_analysis(
        signal,
        price=price,
        n_quantiles=quantile,
        period=period,
        can_enter=can_enter,
        can_exit=can_exit,
        mask=mask,
    )
    obj.create_full_report()
    return obj
Exemplo n.º 2
0
def cal_obj(signal, name, period, quantile):
    price_bench = dv.data_benchmark
    obj = SignalDigger(output_folder="hs300/%s" % name, output_format='pdf')
    obj.process_signal_before_analysis(signal,
                                       price=price,
                                       n_quantiles=quantile,
                                       period=period,
                                       mask=mask,
                                       group=sw1,
                                       can_enter=can_enter,
                                       can_exit=can_exit,
                                       commission=0.0003)
    obj.create_full_report()
    return obj
Exemplo n.º 3
0
ic_20_mean = dict()
ic_20_std = dict()
ir_20 = dict()
for name in ic_20.columns:
    ic_20_mean[name] = ic_20[name].loc[start:].mean()
    ic_20_std[name] = ic_20[name].loc[start:].std()
    ir_20[name] = ic_20_mean[name] / ic_20_std[name]

import datetime

trade_date = pd.Series(ic_20.index)
trade_date = trade_date.apply(
    lambda x: datetime.datetime.strptime(str(x), '%Y%m%d'))
ic_20.index = trade_date

obj = SignalDigger(output_folder='./output', output_format='pdf')
obj.process_signal_before_analysis(
    signal=comb_factors["equal_weight"],
    price=dv.get_ts("close_adj"),
    high=dv.get_ts("high_adj"),  # 可为空
    low=dv.get_ts("low_adj"),  # 可为空
    n_quantiles=5,  # quantile分类数
    mask=mask,  # 过滤条件
    can_enter=can_enter,  # 是否能进场
    can_exit=can_exit,  # 是否能出场
    period=period,  # 持有期
    benchmark_price=dv.data_benchmark,  # 基准价格 可不传入,持有期收益(return)计算为绝对收益
    commission=0.0008,
)
obj.create_full_report()
plt.show()
Exemplo n.º 4
0
    price=dv.get_ts("close_adj"),
    high=dv.get_ts("high_adj"),  # 可为空
    low=dv.get_ts("low_adj"),  # 可为空
    group=dv.get_ts("sw1"),  # 可为空
    n_quantiles=5,  # quantile分类数
    mask=mask,  # 过滤条件
    can_enter=can_enter,  # 是否能进场
    can_exit=can_exit,  # 是否能出场
    period=5,  # 持有期
    benchmark_price=dv.data_benchmark,  # 基准价格 可不传入,持有期收益(return)计算为绝对收益
    commission=0.0008,
)
signal_data = obj.signal_data

import matplotlib.pyplot as plt
print(obj.create_full_report())
plt.show()

from jaqs_fxdayu.research.signaldigger.analysis import analysis
result = analysis(signal_data, is_event=False, period=5)

print("——ic分析——")
print(result["ic"])
print("——选股收益分析——")
print(result["ret"])
print("——最大潜在盈利/亏损分析——")
print(result["space"])
import matplotlib.pyplot as plt
obj.create_full_report()
plt.show()
Exemplo n.º 5
0
import matplotlib.pyplot as plt
obj = SignalDigger()

def draw_analysis(signal_data,period):  
    obj.signal_data = signal_data
    obj.period = period
    obj.create_full_report()
    plt.show()

#全样本可视化操作:
draw_analysis(optimizer.all_signals[ret_best[0]["signal_name"]], period=30)

#当然,这里也可以仿制第二章中的方法,不定义函数,直接运行:
''''
obj.signal_data=optimizer.all_signals[ret_best[0]["signal_name"]]
obj.period = 30
obj.create_full_report()
plt.show()
''''

#样本内可视化:
draw_analysis(optimizer.all_signals[ret_best[0]["signal_name"]].loc[20140101:20160101], period=30)
A=optimizer.all_signals[ret_best[0]["signal_name"]].loc[20140101:20160101] #!!!,选择时间进行操作
#样本外可视化:
draw_analysis(optimizer.all_signals[ret_best[0]["signal_name"]].loc[20160101:], period=30)


#step4:运用参数优化器例2:
# 以持有期mean_ic为最优化目标
ic_best = optimizer.enumerate_optimizer(target_type="return_ic",#优化目标类型
                                        target = "IC Mean",
                                        in_sample_range=[20140101,20160101],#样本内范围 默认为None,在全样本上优化