弱人工智能助力量化交易

In [1]:
# 基础库导入

from __future__ import print_function
from __future__ import division

import warnings
# warnings.filterwarnings('ignore')
# warnings.simplefilter('ignore')

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import ipywidgets
%matplotlib inline

import os
import sys
# 使用insert 0即只使用github,避免交叉使用了pip安装的abupy,导致的版本不一致问题
sys.path.insert(0, os.path.abspath('../'))
import abupy

from abupy import AbuFactorAtrNStop, AbuFactorPreAtrNStop, AbuFactorCloseAtrNStop, AbuFactorBuyBreak
from abupy import AbuFactorSellBreak
from abupy import abu, EMarketTargetType, AbuMetricsBase, ABuMarketDrawing, ABuProgress, ABuSymbolPd
from abupy import EMarketTargetType, EDataCacheType, EMarketSourceType, EMarketDataFetchMode, EStoreAbu, AbuUmpMainMul
from abupy import AbuUmpMainDeg, AbuUmpMainJump, AbuUmpMainPrice, AbuUmpMainWave, feature, AbuFeatureDegExtend
from abupy import AbuUmpEdgeDeg, AbuUmpEdgePrice, AbuUmpEdgeWave, AbuUmpEdgeFull, AbuUmpEdgeMul, AbuUmpEegeDegExtend
from abupy import AbuUmpMainDegExtend, ump, Parallel, delayed, AbuMulPidProgress


pd.options.display.max_rows = 1000
from IPython.display import display
from IPython.core.display import HTML
from pprint import pprint, pformat 

# 关闭沙盒数据
abupy.env.disable_example_env_ipython()
NumExpr defaulting to 8 threads.
disable example env

股池

股池为上证50 + 创业50 + 沪深300 + 中证500 几大指数的成分股

In [2]:
import random
from  stock_pool import stock_pool

def custom_symbols():
    symbols = []    
    symbols.extend( random.sample(stock_pool.get('zh500'), 500))
    symbols.extend( random.sample(stock_pool.get('hs300'), 300))
    symbols.extend( random.sample(stock_pool.get('sh50'), 49))
    symbols.extend( random.sample(stock_pool.get('chuang50'), 50))

    return symbols

symbols = custom_symbols()
print(symbols)
/opt/conda/lib/python3.7/site-packages/openpyxl/worksheet/header_footer.py:48: UserWarning: Cannot parse header or footer so it will be ignored
  warn("""Cannot parse header or footer so it will be ignored""")
/opt/notebooks/abupy_lecture
['002129', '002507', '002663', '600426', '600039', '600511', '002038', '601801', '600787', '601872', '300257', '002242', '600350', '601001', '600885', '600743', '002470', '600120', '600884', '300168', '002131', '002277', '600967', '000829', '002589', '603899', '000025', '300347', '603868', '000008', '002603', '600642', '000960', '600201', '601866', '600908', '000877', '000400', '600582', '300055', '002431', '600557', '600614', '002815', '601168', '600022', '600155', '601127', '000766', '002176', '002439', '002385', '600416', '600718', '600266', '603650', '300287', '300182', '600580', '600053', '002299', '000980', '000712', '002707', '300324', '000667', '600862', '600291', '002285', '600216', '600307', '002573', '000543', '002509', '002280', '600277', '000513', '603885', '600648', '600584', '300244', '000401', '002002', '002308', '300383', '002359', '600611', '000727', '603328', '603000', '600143', '000686', '600125', '600655', '002831', '600500', '000158', '002340', '002366', '600649', '002056', '300156', '002399', '600567', '002013', '000681', '600645', '600917', '000488', '603883', '600376', '000997', '002345', '600171', '601811', '000926', '002051', '603568', '600618', '000537', '002583', '300376', '601717', '600098', '002681', '601098', '000988', '600643', '600996', '002505', '600373', '000750', '000690', '600079', '002407', '000426', '600161', '002353', '600316', '000990', '600575', '600773', '600895', '002332', '600820', '600410', '002416', '600064', '002317', '600392', '601128', '601928', '002373', '002152', '600848', '300159', '000887', '600881', '002410', '600166', '002482', '601678', '600939', '600563', '600460', '603556', '601777', '000061', '601598', '601326', '000848', '603816', '600183', '600874', '002424', '002745', '002426', '600169', '600256', '002254', '000021', '002384', '000501', '002281', '002127', '002250', '600329', '000027', '600184', '601019', '600026', '600409', '300315', '002049', '600978', '603233', '000729', '000738', '002390', '600158', '002807', '002174', '600260', '300088', '600418', '002375', '600060', '300113', '000559', '600348', '600195', '000062', '600808', '603025', '603866', '300133', '601718', '600765', '300001', '603766', '000090', '600267', '000970', '000564', '002818', '002354', '600594', '002463', '002212', '000541', '002699', '002491', '002670', '002195', '300274', '000587', '600160', '600388', '600138', '603169', '000598', '002434', '002506', '000039', '300459', '002266', '002372', '002414', '600640', '600755', '000528', '000066', '603877', '300166', '000547', '002920', '601000', '300058', '002268', '600338', '000807', '300002', '002110', '000937', '002444', '603077', '002672', '601608', '002223', '600598', '603515', '600839', '002048', '000596', '601106', '600240', '000732', '600282', '002155', '000623', '600126', '002640', '600657', '002544', '600073', '000930', '603056', '002276', '600312', '000060', '002690', '600021', '000932', '002635', '002500', '600503', '000009', '300010', '300308', '600478', '600008', '600565', '000049', '603225', '600879', '300266', '000778', '000536', '002642', '600094', '600993', '600737', '600759', '603659', '600528', '002028', '601966', '600393', '600823', '600959', '000519', '600750', '600335', '603444', '600037', '000761', '600971', '603198', '601100', '002078', '002709', '000636', '600122', '002221', '600298', '002368', '002839', '600801', '300197', '600380', '000717', '603888', '002437', '601990', '002183', '000758', '300291', '601020', '300202', '601869', '600179', '000031', '300418', '002371', '601969', '600151', '601958', '300146', '002665', '600525', '002092', '000563', '000089', '600366', '600859', '600804', '000813', '600811', '002074', '002400', '600435', '600699', '002477', '600325', '600428', '601689', '600639', '002233', '300134', '002465', '600536', '000878', '002701', '600633', '000860', '600970', '603377', '600779', '002118', '600600', '600751', '600782', '600006', '002004', '600673', '603569', '600280', '002019', '600499', '300027', '600835', '600729', '002128', '000998', '600167', '600062', '600869', '000723', '600694', '000581', '000552', '600757', '002517', '002244', '600507', '002251', '000156', '603806', '300115', '600258', '002147', '000078', '000612', '600754', '002588', '600827', '600687', '601003', '300026', '300316', '601880', '601005', '000418', '002041', '600664', '000012', '000969', '000999', '601311', '601016', '600056', '600875', '603355', '002064', '600458', '600901', '600259', '000987', '600770', '600872', '600572', '600863', '600058', '002030', '002916', '600466', '000685', '002563', '002489', '600141', '300297', '300253', '600017', '000006', '002344', '603369', '000656', '000975', '600315', '002093', '002503', '603712', '002408', '603228', '601179', '002191', '300450', '002512', '601200', '002302', '600717', '300413', '600777', '603486', '600748', '002273', '002249', '603658', '000718', '600623', '601231', '000028', '600597', '300199', '600086', '000600', '000830', '600545', '002358', '002440', '603799', '600816', '600208', '002797', '600015', '002153', '000625', '000783', '600025', '600016', '000826', '601009', '002311', '603259', '601212', '600089', '000792', '600068', '600010', '600998', '002714', '002475', '601066', '300136', '000338', '601155', '600438', '600036', '601939', '603858', '600406', '601766', '600487', '600346', '600516', '601600', '300033', '601238', '300003', '601919', '600104', '000898', '600482', '300017', '002555', '000776', '600233', '601881', '601828', '600176', '601985', '603260', '000728', '601111', '601333', '000651', '601328', '002008', '600809', '600760', '000876', '002230', '002236', '600705', '603288', '603986', '300433', '002146', '002450', '601006', '000402', '600028', '600050', '300122', '600109', '601988', '601989', '601088', '300024', '600177', '300015', '601288', '002241', '002602', '000959', '600029', '000858', '601216', '002736', '600390', '000895', '601601', '600900', '600000', '600887', '600115', '002179', '600018', '002120', '600867', '600271', '600188', '600004', '002558', '601169', '601668', '601012', '601018', '002044', '601933', '601186', '601997', '601108', '600196', '000425', '000063', '601727', '300144', '601211', '600061', '600606', '600066', '002466', '601838', '000768', '002572', '601808', '601390', '000703', '600219', '000100', '601688', '000627', '600383', '600739', '000961', '600030', '601166', '600369', '000002', '002493', '601318', '000413', '601898', '002304', '601800', '601669', '600100', '002456', '600309', '601878', '603833', '000671', '002271', '002202', '002460', '000630', '601991', '002024', '601398', '600498', '601888', '600153', '600027', '601877', '002422', '600703', '000001', '000503', '600297', '601611', '600958', '601788', '300072', '601360', '601633', '601857', '600332', '000333', '300059', '600588', '000069', '000157', '000963', '600519', '603993', '600570', '600837', '600977', '002352', '603160', '601628', '000983', '601229', '000938', '000725', '600688', '600362', '600340', '002594', '600339', '601901', '600038', '600585', '600690', '601117', '002007', '300251', '000709', '600909', '600637', '601899', '002050', '600999', '600566', '000408', '600547', '600023', '002508', '603156', '300296', '600048', '002673', '002411', '600011', '601138', '000423', '601992', '002624', '002001', '601618', '600886', '601818', '600926', '600398', '002625', '601021', '600795', '000538', '600221', '000786', '001979', '600535', '600522', '002142', '002252', '600549', '600019', '002032', '300070', '600583', '600031', '600170', '001965', '002925', '002415', '000661', '002065', '600660', '600157', '600518', '000839', '601228', '600352', '002294', '002773', '601998', '600436', '002085', '002027', '601336', '600009', '600741', '600919', '601225', '600372', '601198', '000415', '300142', '600704', '600893', '600489', '300124', '601555', '600276', '000553', '600415', '000166', '002468', '002310', '600674', '002081', '600085', '601607', '300408', '002601', '600118', '000568', '600111', '601377', '600276', '600048', '601390', '600016', '603259', '600309', '601818', '600050', '601857', '600585', '600028', '600606', '601328', '600703', '600104', '601229', '600690', '601601', '601318', '601939', '600340', '601186', '600887', '601169', '603993', '601800', '601006', '600030', '601628', '601988', '601166', '600019', '601888', '601398', '601989', '600000', '601336', '601360', '601088', '600547', '600029', '601766', '601288', '601211', '600036', '600196', '601688', '601138', '601668', '300418', '300124', '300676', '300170', '300433', '300168', '300253', '300098', '300347', '300033', '300059', '300618', '300014', '300496', '300699', '300038', '300146', '300408', '300122', '300413', '300355', '300003', '300287', '300136', '300315', '300251', '300009', '300747', '300634', '300750', '300072', '300316', '300450', '300070', '300454', '300274', '300017', '300113', '300088', '300027', '300377', '300115', '300073', '300666', '300078', '300760', '300024', '300015', '300383', '300601']

策略

一个经典的均线多头排列策略,策略本身优秀与否不是重点,本次主要是研究 弱人工智能如何帮我们提高收益,是观察没有使用AI和使用AI后 的对比。

In [2]:
from picker.WzPickNonNew import WzPickNonNew
from factor.WzFactorBuyMaV6 import WzFactorBuyMaV6
from factor.WzFactorSellMaV5 import WzFactorSellMaV5

from abupy import slippage 
# 开启针对非集合竞价阶段的涨停,滑点买入价格以高概率在接近涨停的价格买入 
slippage.sbb.g_enable_limit_up = True 
# 将集合竞价阶段的涨停买入成功概率设置为0,如果设置为0.2即20%概率成功买入 
slippage.sbb.g_pre_limit_up_rate = 0 
# 开启针对非集合竞价阶段的跌停,滑点卖出价格以高概率在接近跌停的价格卖出 
slippage.ssb.g_enable_limit_down = True 
# 将集合竞价阶段的跌停卖出成功概率设置为0, 如果设置为0.2即20%概率成功卖出 
slippage.ssb.g_pre_limit_down_rate = 0


abupy.env.g_data_cache_type = EDataCacheType.E_DATA_CACHE_CSV
abupy.env.g_market_target = EMarketTargetType.E_MARKET_TARGET_CN
abupy.env.g_data_fetch_mode = EMarketDataFetchMode.E_DATA_FETCH_FORCE_LOCAL

stock_pickers = [{'class': WzPickNonNew,
                     'pick_period': 'week',
                     'weeks': 24}, 
 ]


buy_factors=[
    {'buy_crossover': False,
      'buy_lineup': '10,20,40,less2',
      'buy_support': False,
      'class': WzFactorBuyMaV6,
      'ma_filter': False,
    }
]


sell_factors = [
#     {'class': AbuFactorPreAtrNStop, 'pre_atr_n': 1.5},
    {'class': AbuFactorCloseAtrNStop, 'close_atr_n': 1.2},
    {'class': AbuFactorAtrNStop, 'stop_loss_n': 2.1},
    {'class': WzFactorSellMaV5 ,
      'ma_type': 1,
      'sell_x': 'rvv=5,6,0.22,yc,1.0'},
    {'class':  WzFactorSellMaV5,
      'ma_type': 1,
      'sell_x': 'end=10,25,50,1.0'},
]

print("随便输出点什么表示已经执行过: ")
随便输出点什么表示已经执行过: 

策略回测 - 准备交割单数据用于机器人裁判训练

将股池所有股票分切成4块,拿3/4用于机器人裁判训练, 剩下1/4是测试集用途。

In [7]:
# 回测生成买入时刻特征
abupy.env.g_enable_ml_feature = True
# 回测开始时将symbols切割分为训练集数据和测试集两份,使用训练集进行回测
abupy.env.g_enable_train_test_split = True
# 训练:测试 = 3:1
abupy.env.g_split_tt_n_folds = 4

feature.clear_user_feature()
feature.append_user_feature(AbuFeatureDegExtend)

read_cash = 5000000 #500w资金
o_pos_base =0.1 #abupy.beta.atr.g_atr_pos_base
print('o_pos_base:', o_pos_base)
abupy.beta.atr.g_atr_pos_base =  o_pos_base / 5
print('abupy.beta.atr.g_atr_pos_base:' , abupy.beta.atr.g_atr_pos_base)

abu_result_tuple = None

def run_loop_back():
    global abu_result_tuple, symbols    
    print(symbols)
    abu_result_tuple, _ = abu.run_loop_back(read_cash,
                                            buy_factors,
                                            sell_factors,
                                            choice_symbols = symbols,
#                                           choice_symbols=None,
                                            start='2016-02-02', end='2019-09-12',
                                            stock_picks= stock_pickers,
                                            #n_process_kl = 2,
                                            #n_process_pick= 1
                                           )

    # 把运行的结果保存在本地,以便之后分析回测使用,保存回测结果数据代码如下所示
    abu.store_abu_result_tuple(abu_result_tuple, n_folds=3.396, store_type=EStoreAbu.E_STORE_CUSTOM_NAME, 
                               custom_name='train_cn')
    ABuProgress.clear_output()
    AbuMetricsBase.show_general(*abu_result_tuple, only_show_returns=True).plot_max_draw_down()

def run_load_train():
    global abu_result_tuple
    abu_result_tuple = abu.load_abu_result_tuple(n_folds=3.396, store_type=EStoreAbu.E_STORE_CUSTOM_NAME, 
                                                 custom_name='train_cn')
    AbuMetricsBase.show_general(*abu_result_tuple, only_show_returns=True).plot_max_draw_down()

def select(select):
    if select == 'run loop back':
        run_loop_back()
    else:
        run_load_train()

# _ = ipywidgets.interact_manual(select, select=[ 'load train data', 'run loop back'])
run_load_train()
o_pos_base: 0.1
abupy.beta.atr.g_atr_pos_base: 0.02
买入后卖出的交易数量:2777
买入后尚未卖出的交易数量:50
胜率:40.4393%
平均获利期望:8.4614%
平均亏损期望:-4.6931%
盈亏比:1.3215
策略收益: 25.9757%
基准收益: 8.8748%
策略年化收益: 7.4216%
基准年化收益: 2.5357%
策略买入成交比例:55.4652%
策略资金利用率比例:68.0198%
策略共执行882个交易日
最大回撤: 0.167755
最大回测启始时间:2017-11-13, 结束时间2019-01-02, 共回测1141916.952000

盈亏比:1.3215,最大回撤: 0.167755, 策略获利效果不理想

用上面交割单数据训练机器人裁判

主裁:

In [6]:
import warnings
warnings.simplefilter("ignore", ResourceWarning)

# 需要全局设置为A股市场,在ump会根据市场类型保存读取对应的ump
abupy.env.g_market_target = EMarketTargetType.E_MARKET_TARGET_CN
ump_deg=None
ump_jump=None
ump_mul=None
ump_price=None
ump_main_deg_extend=None
ump_wave=None

# 使用训练集交易数据训练主裁
orders_pd_train_cn = abu_result_tuple.orders_pd

def train_main_ump():
    print('AbuUmpMainWave begin...')
    AbuUmpMainWave.ump_main_clf_dump(orders_pd_train_cn, save_order=False, show_order=False)
    print('AbuUmpMainPrice begin...')
    AbuUmpMainPrice.ump_main_clf_dump(orders_pd_train_cn, save_order=False, show_order=False)
    print('AbuUmpMainDeg begin...') #brust_min=False,  
    AbuUmpMainDeg.ump_main_clf_dump(orders_pd_train_cn, save_order=False, show_order=False) 
    print('AbuUmpMainJump begin...')
    AbuUmpMainJump.ump_main_clf_dump(orders_pd_train_cn, save_order=False, show_order=False)   
    print('AbuUmpMainMul begin...')
    AbuUmpMainMul.ump_main_clf_dump(orders_pd_train_cn, save_order=False, show_order=False)
    print('AbuUmpMainDegExtend begin...')
    AbuUmpMainDegExtend.ump_main_clf_dump(orders_pd_train_cn, save_order=False, show_order=False)
    
    # 依然使用load_main_ump,避免下面多进程内存拷贝过大
    load_main_ump()
    
def load_main_ump():
    global ump_deg, ump_jump, ump_mul, ump_price, ump_main_deg_extend, ump_wave
    ump_deg = AbuUmpMainDeg(predict=True)
    ump_jump = AbuUmpMainJump(predict=True)
    ump_mul = AbuUmpMainMul(predict=True)
    ump_price = AbuUmpMainPrice(predict=True)
    ump_main_deg_extend = AbuUmpMainDegExtend(predict=True)
    ump_wave =  AbuUmpMainWave(predict=True )
    print('load main ump complete!')

def select(select):
    if select == 'train main ump':
        train_main_ump()
    else:
        load_main_ump()

# _ = ipywidgets.interact_manual(select, select=['load main ump', 'train main ump'])

load_main_ump()
load main ump complete!

边裁

In [8]:
# from abupy import AbuUmpEdgeDeg, AbuUmpEdgePrice, AbuUmpEdgeWave, AbuUmpEdgeFull, AbuUmpEdgeMul, AbuUmpEegeDegExtend
# AbuUmpEdgeWave, AbuUmpEdgeFull, AbuUmpEdgeMul
# 需要全局设置为A股市场,在ump会根据市场类型保存读取对应的ump
abupy.env.g_market_target = EMarketTargetType.E_MARKET_TARGET_CN

# 使用训练集交易数据训练
orders_pd_train_cn = abu_result_tuple.orders_pd

print('AbuUmpEdgeDeg begin...')
AbuUmpEdgeDeg.ump_edge_clf_dump(orders_pd_train_cn)
edge_deg = AbuUmpEdgeDeg(predict=True)

print('AbuUmpEdgePrice begin...')
AbuUmpEdgePrice.ump_edge_clf_dump(orders_pd_train_cn)
edge_price = AbuUmpEdgePrice(predict=True)

print('AbuUmpEdgeMul begin...')
AbuUmpEdgeMul.ump_edge_clf_dump(orders_pd_train_cn)
edge_mul = AbuUmpEdgeMul(predict=True)

print('AbuUmpEegeDegExtend begin...')
AbuUmpEegeDegExtend.ump_edge_clf_dump(orders_pd_train_cn)
edge_deg_extend = AbuUmpEegeDegExtend(predict=True)

print('AbuUmpEdgeWave begin...')
AbuUmpEdgeWave.ump_edge_clf_dump(orders_pd_train_cn)
edge_wave = AbuUmpEdgeWave(predict=True)

print('AbuUmpEdgeFull begin...')
AbuUmpEdgeFull.ump_edge_clf_dump(orders_pd_train_cn)
edge_full = AbuUmpEdgeFull(predict=True)

print('fit edge complete!')
AbuUmpEdgeDeg begin...
please wait! dump_pickle....: /root/abu/data/ump/ump_edge_hs_deg_edge
AbuUmpEdgePrice begin...
please wait! dump_pickle....: /root/abu/data/ump/ump_edge_hs_price_edge
AbuUmpEdgeMul begin...
please wait! dump_pickle....: /root/abu/data/ump/ump_edge_hs_mul_edge
AbuUmpEegeDegExtend begin...
please wait! dump_pickle....: /root/abu/data/ump/ump_edge_hs_extend_edge_deg
AbuUmpEdgeWave begin...
please wait! dump_pickle....: /root/abu/data/ump/ump_edge_hs_wave_edge
AbuUmpEdgeFull begin...
/opt/notebooks/abupy/UmpBu/ABuUmpBase.py:187: FutureWarning: Method .as_matrix will be removed in a future version. Use .values instead.
  ump_np = ump_df.as_matrix()
please wait! dump_pickle....: /root/abu/data/ump/ump_edge_hs_full_edge
fit edge complete!

应用到新的交易

未启用裁判的测试集 - 用于对比:

In [10]:
# 测试集回测时依然生成买入时刻特征
abupy.env.g_enable_ml_feature = True
# 回测时不重新切割训练集数据和测试集
abupy.env.g_enable_train_test_split = False
# 回测时使用切割好的测试数据
abupy.env.g_enable_last_split_test = True


# 测试集依然使用10,30,50,90,120日走势拟合角度特征AbuFeatureDegExtend,做为回测时的新的视角来录制比赛(记录回测特征)
feature.clear_user_feature()
feature.append_user_feature(AbuFeatureDegExtend)

read_cash = 5000000 #500w资金
o_pos_base =0.1 #abupy.beta.atr.g_atr_pos_base
print('o_pos_base:', o_pos_base)
abupy.beta.atr.g_atr_pos_base =  o_pos_base / 2
print('abupy.beta.atr.g_atr_pos_base:' , abupy.beta.atr.g_atr_pos_base)


abu_result_tuple_test = None
order_has_result = None

def run_loop_back_test():
    global abu_result_tuple_test, order_has_result
    abu_result_tuple_test, _ = abu.run_loop_back(read_cash,
                                                 buy_factors,
                                                 sell_factors,
                                                 choice_symbols=None,
                                                 stock_picks= stock_pickers,
                                                 start='2016-02-02', end='2019-09-12')
    # 把运行的结果保存在本地,以便之后分析回测使用,保存回测结果数据代码如下所示
    abu.store_abu_result_tuple(abu_result_tuple_test, n_folds=3.396, store_type=EStoreAbu.E_STORE_CUSTOM_NAME, 
                               custom_name='test_cn')
    ABuProgress.clear_output()
    AbuMetricsBase.show_general(*abu_result_tuple_test, only_show_returns=True).plot_max_draw_down()
    # 验证A股主裁是否称职
    # 选取有交易结果的数据order_has_result
    order_has_result = abu_result_tuple_test.orders_pd[abu_result_tuple_test.orders_pd.result != 0]
    order_has_result.filter(regex='^buy(_deg_|_price_|_wave_|_jump)').head()

def run_load_test():
    global abu_result_tuple_test, order_has_result
    abu_result_tuple_test = abu.load_abu_result_tuple(n_folds=3.396, store_type=EStoreAbu.E_STORE_CUSTOM_NAME, 
                                                 custom_name='test_cn')
    AbuMetricsBase.show_general(*abu_result_tuple_test, only_show_returns=True).plot_max_draw_down()
    # 验证A股主裁是否称职
    # 选取有交易结果的数据order_has_result
    order_has_result = abu_result_tuple_test.orders_pd[abu_result_tuple_test.orders_pd.result != 0]
    order_has_result.filter(regex='^buy(_deg_|_price_|_wave_|_jump)').head()

def select_test(select):
    if select == 'run loop back':
        run_loop_back_test()
    else:
        run_load_test()

# _ = ipywidgets.interact_manual(select_test, select=['load test data', 'run loop back',])
run_load_test()
o_pos_base: 0.1
abupy.beta.atr.g_atr_pos_base: 0.05
买入后卖出的交易数量:918
买入后尚未卖出的交易数量:11
胜率:42.8105%
平均获利期望:8.1629%
平均亏损期望:-4.4437%
盈亏比:1.4638
策略收益: 44.3673%
基准收益: 8.8748%
策略年化收益: 12.6764%
基准年化收益: 2.5357%
策略买入成交比例:58.3423%
策略资金利用率比例:62.9070%
策略共执行882个交易日
最大回撤: 0.104763
最大回测启始时间:2018-05-15, 结束时间2019-01-22, 共回测724027.482000

盈亏比:1.4638,策略年化收益: 12.6764%, 最大回撤: 0.104763 <- 这是没有启用机器人裁判的成绩。

以下启用机器人裁判,看看效果

In [12]:
from warnings import simplefilter
simplefilter(action='ignore', category=FutureWarning)
simplefilter(action='ignore', category=ResourceWarning)


# abupy.env.g_data_cache_type = EDataCacheType.E_DATA_CACHE_CSV
# abupy.env.g_market_target = EMarketTargetType.E_MARKET_TARGET_CN
# abupy.env.g_data_fetch_mode = EMarketDataFetchMode.E_DATA_FETCH_FORCE_LOCAL


# 开启内置主裁
abupy.env.g_enable_ump_main_deg_block = True
# abupy.env.g_enable_ump_main_price_block = True

# 开启内置边裁
abupy.env.g_enable_ump_edge_deg_block = True
# abupy.env.g_enable_ump_edge_price_block = True

# 回测时需要开启特征生成,因为裁判开启需要生成特征做为输入
abupy.env.g_enable_ml_feature = True
# 回测时使用上一次切割好的测试集数据
abupy.env.g_enable_last_split_test = True


"""    """
feature.clear_user_feature()
# 10,30,50,90,120日走势拟合角度特征的AbuFeatureDegExtend,做为回测时的新的视角来录制比赛
feature.append_user_feature(AbuFeatureDegExtend)

# 打开使用用户自定义裁判开关
ump.manager.g_enable_user_ump = True
# 先clear一下
ump.manager.clear_user_ump()
# 把新的裁判AbuUmpMainDegExtend类名称使用append_user_ump添加到系统中
ump.manager.append_user_ump(AbuUmpEegeDegExtend)
# 把新的裁判AbuUmpMainDegExtend类名称使用append_user_ump添加到系统中
ump.manager.append_user_ump(AbuUmpMainDegExtend)


o_pos_base =0.1 #abupy.beta.atr.g_atr_pos_base
print('o_pos_base:', o_pos_base)
abupy.beta.atr.g_atr_pos_base =  o_pos_base * 1.5
print('abupy.beta.atr.g_atr_pos_base:' , abupy.beta.atr.g_atr_pos_base)


abu_result_tuple_test_ump = None
read_cash = 5000000 #500w资金

def run_loop_back_ump():
    global abu_result_tuple_test_ump, read_cash
    abu_result_tuple_test_ump, _ = abu.run_loop_back(read_cash,
                                            buy_factors,
                                            sell_factors,
#                                             choice_symbols = symbols,
                                            choice_symbols=None,
                                            stock_picks= stock_pickers,
                                            start='2016-02-02', end='2019-09-12')
    # 把运行的结果保存在本地,以便之后分析回测使用,保存回测结果数据代码如下所示
    abu.store_abu_result_tuple(abu_result_tuple_test_ump, n_folds=3.396, store_type=EStoreAbu.E_STORE_CUSTOM_NAME, 
                               custom_name='test_ump_cn')
    ABuProgress.clear_output()
    AbuMetricsBase.show_general(*abu_result_tuple_test_ump).plot_max_draw_down() #, returns_cmp=True

def run_load_ump():
    global abu_result_tuple_test_ump
    abu_result_tuple_test_ump = abu.load_abu_result_tuple(n_folds=3.396, store_type=EStoreAbu.E_STORE_CUSTOM_NAME, 
                                                 custom_name='test_ump_cn')
    AbuMetricsBase.show_general(*abu_result_tuple_test_ump).plot_max_draw_down() #, returns_cmp=True

def select_ump(select):
    if select == 'run loop back ump':
        run_loop_back_ump()
    else:
        run_load_ump()

# _ = ipywidgets.interact_manual(select_ump, select=['load test ump data','run loop back ump'])

# print("随便输出点什么表示已经执行过: ")
run_load_ump()
o_pos_base: 0.1
abupy.beta.atr.g_atr_pos_base: 0.15000000000000002
买入后卖出的交易数量:151
买入后尚未卖出的交易数量:1
胜率:52.3179%
平均获利期望:8.1635%
平均亏损期望:-3.1274%
盈亏比:2.8106
策略收益: 64.8948%
基准收益: 8.8748%
策略年化收益: 18.5414%
基准年化收益: 2.5357%
策略买入成交比例:52.6316%
策略资金利用率比例:38.4674%
策略共执行882个交易日
alpha阿尔法:0.1411
beta贝塔:0.2202
Information信息比率:0.0410
策略Sharpe夏普比率: 1.3064
基准Sharpe夏普比率: 0.2286
策略波动率Volatility: 0.1145
基准波动率Volatility: 0.1689
最大回撤: 0.086818
最大回测启始时间:2017-09-04, 结束时间2017-12-18, 共回测597153.545000

盈亏比:1.4638,策略年化收益: 12.6764%, 最大回撤: 0.104763 <- 这是没有启用机器人裁判的成绩。
盈亏比:2.8106,策略年化收益: 18.5414%, 最大回撤: 0.086818 <- 这是现在启用机器人裁判的成绩。

盈亏比大幅提高, 但是由于机器人裁判拦截了不少胜率不大的交易,交易机会少了,所以策略资金利用率比例:38.4674%,结果年化收益也只是从12% 提高到到18% 。 下面强制提高单次买入的仓位试试,看能不能提高整体收益。

尝试强制提高仓位

abupy.beta.atr.g_atr_pos_base = o_pos_base * 1.5 上面的单次买入仓位
abupy.beta.atr.g_atr_pos_base = o_pos_base * 2.5 下面的单次买入仓位

In [13]:
from warnings import simplefilter
simplefilter(action='ignore', category=FutureWarning)
simplefilter(action='ignore', category=ResourceWarning)

# 开启内置主裁
abupy.env.g_enable_ump_main_deg_block = True
# abupy.env.g_enable_ump_main_price_block = True

# 开启内置边裁
abupy.env.g_enable_ump_edge_deg_block = True
# abupy.env.g_enable_ump_edge_price_block = True

# 回测时需要开启特征生成,因为裁判开启需要生成特征做为输入
abupy.env.g_enable_ml_feature = True
# 回测时使用上一次切割好的测试集数据
abupy.env.g_enable_last_split_test = True


"""    """
feature.clear_user_feature()
# 10,30,50,90,120日走势拟合角度特征的AbuFeatureDegExtend,做为回测时的新的视角来录制比赛
feature.append_user_feature(AbuFeatureDegExtend)

# 打开使用用户自定义裁判开关
ump.manager.g_enable_user_ump = True
# 先clear一下
ump.manager.clear_user_ump()
# 把新的裁判AbuUmpMainDegExtend类名称使用append_user_ump添加到系统中
ump.manager.append_user_ump(AbuUmpEegeDegExtend)
# 把新的裁判AbuUmpMainDegExtend类名称使用append_user_ump添加到系统中
ump.manager.append_user_ump(AbuUmpMainDegExtend)

o_pos_base =0.1 #abupy.beta.atr.g_atr_pos_base
print('o_pos_base:', o_pos_base)
abupy.beta.atr.g_atr_pos_base =  o_pos_base * 2.5
print('abupy.beta.atr.g_atr_pos_base:' , abupy.beta.atr.g_atr_pos_base)


abu_result_tuple_test_ump = None
read_cash = 5000000 #500w资金

def run_loop_back_ump():
    global abu_result_tuple_test_ump, read_cash
    abu_result_tuple_test_ump, _ = abu.run_loop_back(read_cash,
                                            buy_factors,
                                            sell_factors,
#                                             choice_symbols = symbols,
                                            choice_symbols=None,
                                            stock_picks= stock_pickers,
                                            start='2016-02-02', end='2019-09-12')
    # 把运行的结果保存在本地,以便之后分析回测使用,保存回测结果数据代码如下所示
    abu.store_abu_result_tuple(abu_result_tuple_test_ump, n_folds=3.396, store_type=EStoreAbu.E_STORE_CUSTOM_NAME, 
                               custom_name='test_ump_cn_x25')
    ABuProgress.clear_output()
    AbuMetricsBase.show_general(*abu_result_tuple_test_ump).plot_max_draw_down() #, returns_cmp=True

def run_load_ump():
    global abu_result_tuple_test_ump
    abu_result_tuple_test_ump = abu.load_abu_result_tuple(n_folds=3.396, store_type=EStoreAbu.E_STORE_CUSTOM_NAME, 
                                                 custom_name='test_ump_cn_x25')
    AbuMetricsBase.show_general(*abu_result_tuple_test_ump).plot_max_draw_down() #, returns_cmp=True

def select_ump(select):
    if select == 'run loop back ump':
        run_loop_back_ump()
    else:
        run_load_ump()

# _ = ipywidgets.interact_manual(select_ump, select=['load test ump data','run loop back ump'])
# print("随便输出点什么表示已经执行过: ")

run_load_ump()
o_pos_base: 0.1
abupy.beta.atr.g_atr_pos_base: 0.25
买入后卖出的交易数量:151
买入后尚未卖出的交易数量:1
胜率:52.3179%
平均获利期望:8.2388%
平均亏损期望:-3.1274%
盈亏比:2.8367
策略收益: 61.8534%
基准收益: 8.8748%
策略年化收益: 17.6724%
基准年化收益: 2.5357%
策略买入成交比例:36.1842%
策略资金利用率比例:45.2264%
策略共执行882个交易日
alpha阿尔法:0.1370
beta贝塔:0.2734
Information信息比率:0.0380
策略Sharpe夏普比率: 1.0495
基准Sharpe夏普比率: 0.2286
策略波动率Volatility: 0.1406
基准波动率Volatility: 0.1689
最大回撤: 0.091954
最大回测启始时间:2018-05-28, 结束时间2018-12-28, 共回测704528.748000

额,资金利用率比例提高到了45.2264%, 但是年化收益反而降低了1个百分点。

可能是股池(上证50 + 创业50 + 沪深300 + 中证500 几大指数的成分股)太小, 策略本身买入因子是均线多头排列又是偏中线 中低频交易,交易机会比较少。扩大股池或者使用更高换手率的策略也许能提高收益。

分析裁判是否称职

就是分析裁判对交易的拦截是否正确。

根据阿布大师的原著《用Python做股票量化分析:量化交易之路》, 所有的信息都在一个 表中:

lcs lms lps lrs
分类簇中样本总数 分类簇中样本每笔交易平均获利 分类簇中样本交易获利总和 分类簇中样本失败率
x笔交易 平均每笔获利 获利总和 s失败率

主裁

In [11]:
from warnings import simplefilter
simplefilter(action='ignore', category=FutureWarning)
simplefilter(action='ignore', category=ResourceWarning)

"""
通过一个一个迭代交易单,将交易单中的买入时刻特征传递给ump主裁决策器,让每一个主裁来决策是否进行拦截,
这样可以统计每一个主裁的拦截成功率,以及整体拦截率等
"""

order_has_result = abu_result_tuple_test.orders_pd[abu_result_tuple_test.orders_pd.result != 0]
#print(order_has_result)

# global ump_deg,  ump_mul, ump_price, ump_main_deg_extend,ump_jump, ump_wave
# ump_deg = AbuUmpMainDeg(predict=True)
# ump_jump = AbuUmpMainJump(predict=True)

def apply_ml_features_ump(order, predicter, progress, need_hit_cnt):
    if not isinstance(order.ml_features, dict):
        import ast
        # 低版本pandas dict对象取出来会成为str
        ml_features = ast.literal_eval(order.ml_features)
    else:
        ml_features = order.ml_features
    progress.show()
    # 将交易单中的买入时刻特征传递给ump主裁决策器,让每一个主裁来决策是否进行拦截
    return predicter.predict_kwargs(need_hit_cnt=need_hit_cnt, **ml_features)

def pararllel_func(ump_object, ump_name):
    with AbuMulPidProgress(len(order_has_result), '{} complete'.format(ump_name)) as progress:
        # 启动多进程进度条,对order_has_result进行apply
        ump_result = order_has_result.apply(apply_ml_features_ump, axis=1, args=(ump_object, progress, 2,))
    return ump_name, ump_result

if sys.version_info > (3, 4, 0):
    # python3.4以上并行处理4个主裁,每一个主裁启动一个进程进行拦截决策
    parallel = Parallel(        n_jobs=4, verbose=0, pre_dispatch='2*n_jobs')
    
    out = parallel(delayed(pararllel_func)(ump_object, ump_name)
                                  for ump_object, ump_name in zip(
                                      [ump_deg, ump_mul, ump_price, ump_main_deg_extend,ump_jump, ump_wave], 
                                        ['ump_deg', 'ump_mul', 'ump_price', 'ump_main_deg_extend','ump_jump','ump_wave']))
else:
    # 3.4下由于子进程中pickle ump的内部类会找不到,所以暂时只使用一个进程一个一个的处理
    out = [pararllel_func(ump_object, ump_name) for ump_object, ump_name in zip(
                                    [ump_deg, ump_mul, ump_price, ump_main_deg_extend,ump_jump, ump_wave], 
                                    ['ump_deg', 'ump_mul', 'ump_price', 'ump_main_deg_extend','ump_jump','ump_wave'])]


# 将每一个进程中的裁判的拦截决策进行汇总
for sub_out in out:
    order_has_result[sub_out[0]] = sub_out[1]

print("随便输出点什么表示已经执行过: ")
随便输出点什么表示已经执行过: 
In [12]:
""" 通过把所有主裁的决策进行相加, 如果有投票1的即会进行拦截,四个裁判整体拦截正确率统计 """
block_pd = order_has_result.filter(regex='^ump_*')
# 把所有主裁的决策进行相加
block_pd['sum_bk'] = block_pd.sum(axis=1)
block_pd['result'] = order_has_result['result']
# 有投票1的即会进行拦截
block_pd = block_pd[block_pd.sum_bk > 0]
print('6个裁判整体拦截正确率{:.2f}%'.format(block_pd[block_pd.result == -1].result.count() / block_pd.result.count() * 100))
block_pd.tail()

pd.options.display.max_rows = 250
from IPython.display import display
from IPython.core.display import HTML
from pprint import pprint, pformat 
""" 下面统计每一个主裁的拦截正确率"""
display(HTML(' <b> 下面统计每一个主裁的拦截正确率 </b> '))

from sklearn import metrics
def sub_ump_show(block_name):
    sub_block_pd = block_pd[(block_pd[block_name] == 1)]
    # 如果失败就正确 -1->1 1->0
    sub_block_pd.result = np.where(sub_block_pd.result == -1, 1, 0)
    return metrics.accuracy_score(sub_block_pd[block_name], sub_block_pd.result) * 100, sub_block_pd.result.count()

print('角度裁判拦截正确率{:.2f}%, 拦截交易数量{}'.format(*sub_ump_show('ump_deg')))
print('角度扩展裁判拦拦截正确率{:.2f}%, 拦截交易数量{}'.format(*sub_ump_show('ump_main_deg_extend')))
print('价格裁判拦截正确率{:.2f}%, 拦截交易数量{}'.format(*sub_ump_show('ump_price')))
print('单混裁判拦截正确率{:.2f}%, 拦截交易数量{}'.format(*sub_ump_show('ump_mul')))
print('跳空缺口裁判拦截正确率{:.2f}%, 拦截交易数量{}'.format(*sub_ump_show('ump_jump')))
print('波动裁判拦截正确率{:.2f}%, 拦截交易数量{}'.format(*sub_ump_show('ump_wave')))
6个裁判整体拦截正确率57.49%
下面统计每一个主裁的拦截正确率
角度裁判拦截正确率60.17%, 拦截交易数量580
角度扩展裁判拦拦截正确率60.59%, 拦截交易数量614
价格裁判拦截正确率60.86%, 拦截交易数量442
单混裁判拦截正确率59.69%, 拦截交易数量578
跳空缺口裁判拦截正确率58.33%, 拦截交易数量504
波动裁判拦截正确率58.89%, 拦截交易数量450

边裁:

In [8]:
""" 验证边裁是否称职  """

# 选取有交易结果的数据order_has_result
# order_has_result = abu_result_tuple_test.orders_pd[abu_result_tuple_test.orders_pd.result != 0]

def apply_ml_features_edge(order, predicter, progress):
    if not isinstance(order.ml_features, dict):
        import ast
        # 低版本pandas dict对象取出来会成为str
        ml_features = ast.literal_eval(order.ml_features)
    else:
        ml_features = order.ml_features
    # 边裁进行裁决
    progress.show()
    # 将交易单中的买入时刻特征传递给ump边裁决策器,让每一个边裁来决策是否进行拦截
    edge = predicter.predict(**ml_features)
    return edge.value


def edge_pararllel_func(edge, edge_name):
    with AbuMulPidProgress(len(order_has_result), '{} complete'.format(edge_name)) as progress:
        # # 启动多进程进度条,对order_has_result进行apply
        edge_result = order_has_result.apply(apply_ml_features_edge, axis=1, args=(edge, progress,))
    return edge_name, edge_result

if sys.version_info > (3, 4, 0):
    # python3.4以上并行处理4个边裁的决策,每一个边裁启动一个进程进行拦截决策
    parallel = Parallel( n_jobs=4, verbose=0, pre_dispatch='2*n_jobs')
        
    out = parallel(delayed(edge_pararllel_func)(edge, edge_name)
                                  for edge, edge_name in zip(
                                      [edge_deg, edge_price, edge_mul, edge_deg_extend, edge_wave, edge_full], 
                                        ['edge_deg', 'edge_price', 'edge_mul', 'edge_deg_extend','edge_wave','edge_full']))
else:
    # 3.4下由于子进程中pickle ump的内部类会找不到,所以暂时只使用一个进程一个一个的处理
    out = [edge_pararllel_func(edge, edge_name) for edge, edge_name in zip(
                                            [edge_deg, edge_price, edge_mul, edge_deg_extend, edge_wave, edge_full], 
                                            ['edge_deg', 'edge_price', 'edge_mul', 'edge_deg_extend','edge_wave','edge_full'])]
    
# 将每一个进程中的裁判的拦截决策进行汇总
for sub_out in out:
    order_has_result[sub_out[0]] = sub_out[1]
    
print("随便输出点什么表示已经执行过: ")
随便输出点什么表示已经执行过: 
In [9]:
block_pd = order_has_result.filter(regex='^edge_*')
"""
    由于predict返回的结果中1代表win top
    但是我们只需要知道loss_top,所以只保留-1, 其他1转换为0。
"""
block_pd['edge_block'] = \
    np.where(np.min(block_pd, axis=1) == -1, -1, 0)

# 拿出真实的交易结果
block_pd['result'] = order_has_result['result']
# 拿出-1的结果,即判定loss_top的
block_pd = block_pd[block_pd.edge_block == -1]


print('x个裁判整体拦截正确率{:.2f}%'.format(block_pd[block_pd.result == -1].result.count() / 
                                  block_pd.result.count() * 100))

print('x个边裁拦截交易总数{}, 拦截率{:.2f}%'.format(
    block_pd.shape[0],
    block_pd.shape[0] / order_has_result.shape[0] * 100))
block_pd.head()


"""  单个 :"""

from sklearn import metrics
def sub_edge_show(edge_name):
    sub_edge_block_pd = order_has_result[(order_has_result[edge_name] == -1)]
    return metrics.accuracy_score(sub_edge_block_pd[edge_name], sub_edge_block_pd.result) * 100, sub_edge_block_pd.shape[0]

print('\r\n角度边裁拦截正确率{0:.2f}%, 拦截交易数量{1:}'.format(*sub_edge_show('edge_deg')))
print('角度扩展边裁拦截正确率{0:.2f}%, 拦截交易数量{1:}'.format(*sub_edge_show('edge_deg_extend')))
print('单混边裁拦截正确率{0:.2f}%, 拦截交易数量{1:}'.format(*sub_edge_show('edge_mul')))
print('价格边裁拦截正确率{0:.2f}%, 拦截交易数量{1:}'.format(*sub_edge_show('edge_price')))
print('Full边裁拦截正确率{0:.2f}%, 拦截交易数量{1:}'.format(*sub_edge_show('edge_full')))
print('波动边裁拦截正确率{0:.2f}%, 拦截交易数量{1:}'.format(*sub_edge_show('edge_wave')))
x个裁判整体拦截正确率62.34%
x个边裁拦截交易总数462, 拦截率50.33%

角度边裁拦截正确率73.48%, 拦截交易数量132
角度扩展边裁拦截正确率62.70%, 拦截交易数量126
单混边裁拦截正确率59.20%, 拦截交易数量125
价格边裁拦截正确率64.71%, 拦截交易数量119
Full边裁拦截正确率59.09%, 拦截交易数量22
波动边裁拦截正确率62.60%, 拦截交易数量131

裁判称职与否总结

由于训练用的数据过少(2016-2019 3年行情 * 大概 100只股票), 裁判还不算很厉害,有些正确率还不到60%。

In [11]:
# 好奇 看看裁判从哪些角度分析交易的(有哪些特征)
orders_pd_train = orders_pd_train_cn
print(orders_pd_train.columns)

orders_pd_train[0:6]
Index(['buy_date', 'buy_price', 'buy_cnt', 'buy_factor', 'symbol', 'buy_pos',
       'buy_type_str', 'expect_direction', 'sell_type_extra', 'sell_date',
       'sell_price', 'sell_type', 'ml_features', 'key', 'profit', 'result',
       'buy_deg_ang42', 'buy_deg_ang252', 'buy_deg_ang60', 'buy_deg_ang21',
       'buy_price_rank120', 'buy_price_rank90', 'buy_price_rank60',
       'buy_price_rank252', 'buy_wave_score1', 'buy_wave_score2',
       'buy_wave_score3', 'buy_atr_std', 'buy_diff_down_days',
       'buy_jump_up_power', 'buy_jump_down_power', 'buy_diff_up_days',
       'buy_deg_ang10', 'buy_deg_ang50', 'buy_deg_ang120', 'buy_deg_ang90',
       'buy_deg_ang30', 'sell_deg_ang42', 'sell_deg_ang252', 'sell_deg_ang60',
       'sell_deg_ang21', 'sell_price_rank120', 'sell_price_rank90',
       'sell_price_rank60', 'sell_price_rank252', 'sell_wave_score1',
       'sell_wave_score2', 'sell_wave_score3', 'sell_diff_down_days',
       'sell_jump_up_power', 'sell_jump_down_power', 'sell_diff_up_days',
       'sell_deg_ang10', 'sell_deg_ang50', 'sell_deg_ang120', 'sell_deg_ang90',
       'sell_deg_ang30', 'profit_cg', 'profit_cg_hunder', 'keep_days'],
      dtype='object')
Out[11]:
buy_date buy_price buy_cnt buy_factor symbol buy_pos buy_type_str expect_direction sell_type_extra sell_date ... sell_jump_down_power sell_diff_up_days sell_deg_ang10 sell_deg_ang50 sell_deg_ang120 sell_deg_ang90 sell_deg_ang30 profit_cg profit_cg_hunder keep_days
2016-04-25 20160425 251.610 700.0 WzFactorBuyMaV6:buy_support=False,buy_crossove... 002304 AbuAtrPosition call 1.0 AbuFactorCloseAtrNStop:close_atr_n=1.2 20160509 ... 0.000 65.0 1.775 5.115 0.972 4.623 1.932 0.0082 0.8207 14
2016-04-25 20160425 416.675 400.0 WzFactorBuyMaV6:buy_support=False,buy_crossove... 002007 AbuAtrPosition call 1.0 AbuFactorCloseAtrNStop:close_atr_n=1.2 20160509 ... -1.042 211.0 5.653 6.592 5.236 5.409 4.997 0.0523 5.2259 14
2016-04-26 20160426 72.920 1800.0 WzFactorBuyMaV6:buy_support=False,buy_crossove... 300433 AbuAtrPosition call 1.0 AbuFactorCloseAtrNStop:close_atr_n=1.2 20160511 ... -1.175 15.0 2.709 8.004 -12.279 -0.350 4.724 0.0193 1.9268 15
2016-04-26 20160426 72.920 1800.0 WzFactorBuyMaV6:buy_support=False,buy_crossove... 300433 AbuAtrPosition call 1.0 AbuFactorCloseAtrNStop:close_atr_n=1.2 20160511 ... -1.175 15.0 2.709 8.004 -12.279 -0.350 4.724 0.0193 1.9268 15
2016-04-26 20160426 385.735 500.0 WzFactorBuyMaV6:buy_support=False,buy_crossove... 000858 AbuAtrPosition call 1.0 AbuFactorCloseAtrNStop:close_atr_n=1.2 20160509 ... 0.000 0.0 7.354 9.778 4.536 6.851 2.662 0.0781 7.8111 13
2016-04-27 20160427 154.365 800.0 WzFactorBuyMaV6:buy_support=False,buy_crossove... 002353 AbuAtrPosition call 1.0 AbuFactorCloseAtrNStop:close_atr_n=1.2 20160614 ... -1.184 87.0 6.057 7.339 -6.319 10.612 4.739 0.0252 2.5232 48

6 rows × 60 columns

In [ ]: