零、动量策略VS反转策略
1、实现代码
# 导入函数库 import jqdata import pandas as pd import numpy as np import datetime import math def initialize(context): set_option('use_real_price', True) set_order_cost(OrderCost(close_tax=0.001, open_commission=0.0003, close_commission=0.0003, min_commission=5), type='stock') g.benchmark = '000300.XSHG' g.N = 10 set_benchmark(g.benchmark) run_monthly(handle, 1) def handle(context): stock = get_index_stocks('000300.XSHG') df_close = history(30,field='close',security_list=list(stock)).T df_close['ret']=(df_close.iloc[:,-1]-df_close.iloc[:,0])/df_close.iloc[:,0] sorted_stocks = df_close.sort('ret',ascending=True).index tohold = sorted_stocks[:g.N] for stock in context.portfolio.positions: if stock not in tohold: order_target_value(stock, 0) tobuy = [stock for stock in tohold if stock not in context.portfolio.positions] if len(tobuy) > 0: print('Buying') cash = context.portfolio.available_cash / len(tobuy) cash_every_stock = cash / len(tobuy) for stock in tobuy: order_value(stock, cash_every_stock)
2、长线截图
一、羊驼交易法则
二、羊驼交易法则实现代码
import jqdata import pandas as pd def initialize(context): set_benchmark('000002.XSHG') set_option('use_real_price', True) set_order_cost(OrderCost(close_tax=0.001, open_commission=0.0003, close_commission=0.0003, min_commission=5), type='stock') g.security = get_index_stocks('000002.XSHG') g.period = 30 g.N = 10 g.change = 1 g.init = True run_monthly(handle, 1) def get_sorted_stocks(context,stocks): df = history(g.period, field='close', security_list=stocks).T # print(df) df['ret'] = (df.iloc[:,len(df.columns)-1] - df.iloc[:,0])/df.iloc[:,0] df =df.sort(columns='ret', ascending=False) return df.index.values def handle(context): if g.init: stocks = get_sorted_stocks(context, g.security)[:g.N] cash =context.portfolio.available_cash * 0.9 / len(stocks) for stock in stocks: order_value(stock, cash) g.init = False return stocks = get_sorted_stocks(context, context.portfolio.positions.keys()) for stock in stocks[-g.change:]: order_target(stock, 0)
三、股灾时期测试
1、编译运行
2、完成输出日志
1 2015-06-01 09:30:00 - WARNING - 开仓数量必须是100的整数倍,调整为 300: Order(security=600503.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=None) 2 3 2015-06-01 09:30:00 - INFO - 订单已提交: StockOrder(entrust_id=1540973576 security=600503.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2015-06-01 09:30:00 error=) 4 5 2015-06-01 09:30:00 - WARNING - 下单检查标的数量: StockOrder(entrust_id=1540973576 security=600503.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2015-06-01 09:30:00 error=开仓数量必须是100的整数倍,调整为 300) 6 7 2015-06-01 09:30:00 - INFO - order StockOrder(entrust_id=1540973576 security=600503.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2015-06-01 09:30:00 error=开仓数量必须是100的整数倍,调整为 300) trade price: 26.58, amount:300, commission: 5.0 8 9 2015-06-01 09:30:00 - INFO - 订单已委托: StockOrder(entrust_id=1540973576 security=600503.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2015-06-01 09:30:00 error=开仓数量必须是100的整数倍,调整为 300) 10 11 2015-06-01 09:30:00 - WARNING - 开仓数量必须是100的整数倍,调整为 300: Order(security=601608.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=None) 12 13 2015-06-01 09:30:00 - INFO - 订单已提交: StockOrder(entrust_id=1540973577 security=601608.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2015-06-01 09:30:00 error=) 14 15 2015-06-01 09:30:00 - WARNING - 下单检查标的数量: StockOrder(entrust_id=1540973577 security=601608.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2015-06-01 09:30:00 error=开仓数量必须是100的整数倍,调整为 300) 16 17 2015-06-01 09:30:00 - INFO - order StockOrder(entrust_id=1540973577 security=601608.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2015-06-01 09:30:00 error=开仓数量必须是100的整数倍,调整为 300) trade price: 25.53, amount:300, commission: 5.0 18 19 2015-06-01 09:30:00 - INFO - 订单已委托: StockOrder(entrust_id=1540973577 security=601608.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2015-06-01 09:30:00 error=开仓数量必须是100的整数倍,调整为 300) 20 21 2015-06-01 09:30:00 - WARNING - 开仓数量必须是100的整数倍,调整为 300: Order(security=600701.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=None) 22 23 2015-06-01 09:30:00 - INFO - 订单已提交: StockOrder(entrust_id=1540973578 security=600701.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2015-06-01 09:30:00 error=) 24 25 2015-06-01 09:30:00 - WARNING - 下单检查标的数量: StockOrder(entrust_id=1540973578 security=600701.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2015-06-01 09:30:00 error=开仓数量必须是100的整数倍,调整为 300) 26 27 2015-06-01 09:30:00 - WARNING - 已经涨停, 市价买单取消: StockOrder(entrust_id=1540973578 security=600701.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2015-06-01 09:30:00 error=开仓数量必须是100的整数倍,调整为 300) 28 29 2015-06-01 09:30:00 - INFO - 订单取消完成:StockOrder(entrust_id=1540973578 security=600701.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2015-06-01 09:30:00 error=开仓数量必须是100的整数倍,调整为 300) 30 31 2015-06-01 09:30:00 - INFO - 订单已委托: StockOrder(entrust_id=1540973578 security=600701.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2015-06-01 09:30:00 error=开仓数量必须是100的整数倍,调整为 300) 32 33 2015-06-01 09:30:00 - WARNING - 开仓数量必须是100的整数倍,调整为 0: Order(security=603600.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=None) 34 35 2015-06-01 09:30:00 - INFO - 订单已提交: StockOrder(entrust_id=1540973579 security=603600.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2015-06-01 09:30:00 error=) 36 37 2015-06-01 09:30:00 - WARNING - 订单委托失败: StockOrder(entrust_id=1540973579 security=603600.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2015-06-01 09:30:00 error=开仓数量必须是100的整数倍,调整为 0 38 目标数量已经满足, 没有提交委托) 39 40 2015-06-01 09:30:00 - WARNING - 开仓数量必须是100的整数倍,调整为 400: Order(security=600293.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=None) 41 42 2015-06-01 09:30:00 - INFO - 订单已提交: StockOrder(entrust_id=1540973580 security=600293.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2015-06-01 09:30:00 error=) 43 44 2015-06-01 09:30:00 - WARNING - 下单检查标的数量: StockOrder(entrust_id=1540973580 security=600293.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2015-06-01 09:30:00 error=开仓数量必须是100的整数倍,调整为 400) 45 46 2015-06-01 09:30:00 - INFO - order StockOrder(entrust_id=1540973580 security=600293.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2015-06-01 09:30:00 error=开仓数量必须是100的整数倍,调整为 400) trade price: 20.76, amount:400, commission: 5.0 47 48 2015-06-01 09:30:00 - INFO - 订单已委托: StockOrder(entrust_id=1540973580 security=600293.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2015-06-01 09:30:00 error=开仓数量必须是100的整数倍,调整为 400) 49 50 2015-06-01 09:30:00 - WARNING - 开仓数量必须是100的整数倍,调整为 300: Order(security=600090.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=None) 51 52 2015-06-01 09:30:00 - INFO - 订单已提交: StockOrder(entrust_id=1540973581 security=600090.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2015-06-01 09:30:00 error=) 53 54 2015-06-01 09:30:00 - WARNING - 下单检查标的数量: StockOrder(entrust_id=1540973581 security=600090.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2015-06-01 09:30:00 error=开仓数量必须是100的整数倍,调整为 300) 55 56 2015-06-01 09:30:00 - INFO - order StockOrder(entrust_id=1540973581 security=600090.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2015-06-01 09:30:00 error=开仓数量必须是100的整数倍,调整为 300) trade price: 23.61, amount:300, commission: 5.0 57 58 2015-06-01 09:30:00 - INFO - 订单已委托: StockOrder(entrust_id=1540973581 security=600090.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2015-06-01 09:30:00 error=开仓数量必须是100的整数倍,调整为 300) 59 60 2015-06-01 09:30:00 - WARNING - 开仓数量必须是100的整数倍,调整为 500: Order(security=600076.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=None) 61 62 2015-06-01 09:30:00 - INFO - 订单已提交: StockOrder(entrust_id=1540973582 security=600076.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2015-06-01 09:30:00 error=) 63 64 2015-06-01 09:30:00 - WARNING - 下单检查标的数量: StockOrder(entrust_id=1540973582 security=600076.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2015-06-01 09:30:00 error=开仓数量必须是100的整数倍,调整为 500) 65 66 2015-06-01 09:30:00 - WARNING - 已经涨停, 市价买单取消: StockOrder(entrust_id=1540973582 security=600076.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2015-06-01 09:30:00 error=开仓数量必须是100的整数倍,调整为 500) 67 68 2015-06-01 09:30:00 - INFO - 订单取消完成:StockOrder(entrust_id=1540973582 security=600076.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2015-06-01 09:30:00 error=开仓数量必须是100的整数倍,调整为 500) 69 70 2015-06-01 09:30:00 - INFO - 订单已委托: StockOrder(entrust_id=1540973582 security=600076.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2015-06-01 09:30:00 error=开仓数量必须是100的整数倍,调整为 500) 71 72 2015-06-01 09:30:00 - WARNING - 开仓数量必须是100的整数倍,调整为 200: Order(security=600745.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=None) 73 74 2015-06-01 09:30:00 - INFO - 订单已提交: StockOrder(entrust_id=1540973583 security=600745.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2015-06-01 09:30:00 error=) 75 76 2015-06-01 09:30:00 - WARNING - 下单检查标的数量: StockOrder(entrust_id=1540973583 security=600745.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2015-06-01 09:30:00 error=开仓数量必须是100的整数倍,调整为 200) 77 78 2015-06-01 09:30:00 - INFO - order StockOrder(entrust_id=1540973583 security=600745.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2015-06-01 09:30:00 error=开仓数量必须是100的整数倍,调整为 200) trade price: 42.1, amount:200, commission: 5.0 79 80 2015-06-01 09:30:00 - INFO - 订单已委托: StockOrder(entrust_id=1540973583 security=600745.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2015-06-01 09:30:00 error=开仓数量必须是100的整数倍,调整为 200) 81 82 2015-06-01 09:30:00 - WARNING - 开仓数量必须是100的整数倍,调整为 400: Order(security=600179.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=None) 83 84 2015-06-01 09:30:00 - INFO - 订单已提交: StockOrder(entrust_id=1540973584 security=600179.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2015-06-01 09:30:00 error=) 85 86 2015-06-01 09:30:00 - WARNING - 下单检查标的数量: StockOrder(entrust_id=1540973584 security=600179.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2015-06-01 09:30:00 error=开仓数量必须是100的整数倍,调整为 400) 87 88 2015-06-01 09:30:00 - INFO - order StockOrder(entrust_id=1540973584 security=600179.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2015-06-01 09:30:00 error=开仓数量必须是100的整数倍,调整为 400) trade price: 20.63, amount:400, commission: 5.0 89 90 2015-06-01 09:30:00 - INFO - 订单已委托: StockOrder(entrust_id=1540973584 security=600179.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2015-06-01 09:30:00 error=开仓数量必须是100的整数倍,调整为 400) 91 92 2015-06-01 09:30:00 - WARNING - 开仓数量必须是100的整数倍,调整为 400: Order(security=601106.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=None) 93 94 2015-06-01 09:30:00 - INFO - 订单已提交: StockOrder(entrust_id=1540973585 security=601106.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2015-06-01 09:30:00 error=) 95 96 2015-06-01 09:30:00 - WARNING - 下单检查标的数量: StockOrder(entrust_id=1540973585 security=601106.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2015-06-01 09:30:00 error=开仓数量必须是100的整数倍,调整为 400) 97 98 2015-06-01 09:30:00 - INFO - order StockOrder(entrust_id=1540973585 security=601106.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2015-06-01 09:30:00 error=开仓数量必须是100的整数倍,调整为 400) trade price: 19.87, amount:400, commission: 5.0 99 100 2015-06-01 09:30:00 - INFO - 订单已委托: StockOrder(entrust_id=1540973585 security=601106.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2015-06-01 09:30:00 error=开仓数量必须是100的整数倍,调整为 400) 101 102 2015-06-29 09:29:00 - INFO - Security(code=600503.XSHG) 在 2015-06-29 发生了分红:每股税前分红0.004, 税后分红0.0032, 每股变成1.0股。 103 104 2015-06-29 09:29:00 - INFO - 分红前,price=20.66, avg_cost=26.58, acc_avg_cost=26.5966666667, amount=300 105 106 2015-06-29 09:29:00 - INFO - 分红后,price=20.66, avg_cost=26.576, acc_avg_cost=26.5926666667, amount=300 107 108 2015-07-01 09:30:00 - INFO - 订单已提交: StockOrder(entrust_id=1540973586 security=600090.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2015-07-01 09:30:00 error=) 109 110 2015-07-01 09:30:00 - INFO - order StockOrder(entrust_id=1540973586 security=600090.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2015-07-01 09:30:00 error=) trade price: 18.48, amount:300, commission: 10.54 111 112 2015-07-01 09:30:00 - INFO - 订单已委托: StockOrder(entrust_id=1540973586 security=600090.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2015-07-01 09:30:00 error=) 113 114 2015-07-16 09:29:00 - INFO - Security(code=600293.XSHG) 在 2015-07-16 发生了分红:每股税前分红0.013, 税后分红0.0104, 每股变成1.0股。 115 116 2015-07-16 09:29:00 - INFO - 分红前,price=8.16, avg_cost=20.76, acc_avg_cost=20.7725, amount=400 117 118 2015-07-16 09:29:00 - INFO - 分红后,price=8.15, avg_cost=20.747, acc_avg_cost=20.7595, amount=400 119 120 2015-07-21 09:29:00 - INFO - Security(code=601106.XSHG) 在 2015-07-21 发生了分红:每股税前分红0.001, 税后分红0.0008, 每股变成1.0股。 121 122 2015-07-21 09:29:00 - INFO - 分红前,price=11.08, avg_cost=19.87, acc_avg_cost=19.8825, amount=400 123 124 2015-07-21 09:29:00 - INFO - 分红后,price=11.08, avg_cost=19.869, acc_avg_cost=19.8815, amount=400 125 126 2015-08-03 09:30:00 - WARNING - 下单失败,证券(600745.XSHG)今日停牌: StockOrder: _locked_cash=0, _commission=0, _hold_cost=0, _order_id=1540973587, _margin=False, _side=long, _amount=200, _action=close, _mode=OrderTargetAmount: _amount=0, _style=MarketOrderStyle, _order_cost=0, _security=Security(code=600745.XSHG), _status=new, _filled_amount=0, _avg_cost=0 127 128 2015-08-25 09:29:00 - INFO - Security(code=601608.XSHG) 在 2015-08-25 发生了分红:每股税前分红0.065, 税后分红0.052, 每股变成1.5股。 129 130 2015-08-25 09:29:00 - INFO - 分红前,price=7.57, avg_cost=25.53, acc_avg_cost=25.5466666667, amount=300 131 132 2015-08-25 09:29:00 - INFO - 分红后,price=5.0, avg_cost=16.9766666667, acc_avg_cost=16.9877777778, amount=450 133 134 2015-09-01 09:30:00 - INFO - 订单已提交: StockOrder(entrust_id=1540973588 security=600293.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2015-09-01 09:30:00 error=) 135 136 2015-09-01 09:30:00 - INFO - order StockOrder(entrust_id=1540973588 security=600293.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2015-09-01 09:30:00 error=) trade price: 7.59, amount:400, commission: 8.04 137 138 2015-09-01 09:30:00 - INFO - 订单已委托: StockOrder(entrust_id=1540973588 security=600293.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2015-09-01 09:30:00 error=) 139 140 2015-10-08 09:30:00 - INFO - 订单已提交: StockOrder(entrust_id=1540973589 security=600503.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2015-10-08 09:30:00 error=) 141 142 2015-10-08 09:30:00 - INFO - order StockOrder(entrust_id=1540973589 security=600503.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2015-10-08 09:30:00 error=) trade price: 9.3, amount:300, commission: 7.79 143 144 2015-10-08 09:30:00 - INFO - 订单已委托: StockOrder(entrust_id=1540973589 security=600503.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2015-10-08 09:30:00 error=) 145 146 2015-11-02 09:30:00 - WARNING - 下单失败,证券(600745.XSHG)今日停牌: StockOrder: _locked_cash=0, _commission=0, _hold_cost=0, _order_id=1540973590, _margin=False, _side=long, _amount=200, _action=close, _mode=OrderTargetAmount: _amount=0, _style=MarketOrderStyle, _order_cost=0, _security=Security(code=600745.XSHG), _status=new, _filled_amount=0, _avg_cost=0 147 148 2015-12-01 09:30:00 - INFO - 订单已提交: StockOrder(entrust_id=1540973591 security=601106.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2015-12-01 09:30:00 error=) 149 150 2015-12-01 09:30:00 - INFO - order StockOrder(entrust_id=1540973591 security=601106.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2015-12-01 09:30:00 error=) trade price: 8.37, amount:400, commission: 8.35 151 152 2015-12-01 09:30:00 - INFO - 订单已委托: StockOrder(entrust_id=1540973591 security=601106.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2015-12-01 09:30:00 error=) 153 154 2016-01-04 09:30:00 - INFO - 订单已提交: StockOrder(entrust_id=1540973592 security=601608.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2016-01-04 09:30:00 error=) 155 156 2016-01-04 09:30:00 - INFO - order StockOrder(entrust_id=1540973592 security=601608.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2016-01-04 09:30:00 error=) trade price: 6.89, amount:450, commission: 8.1 157 158 2016-01-04 09:30:00 - INFO - 订单已委托: StockOrder(entrust_id=1540973592 security=601608.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2016-01-04 09:30:00 error=) 159 160 2016-02-01 09:30:00 - WARNING - 下单失败,证券(600745.XSHG)今日停牌: StockOrder: _locked_cash=0, _commission=0, _hold_cost=0, _order_id=1540973593, _margin=False, _side=long, _amount=200, _action=close, _mode=OrderTargetAmount: _amount=0, _style=MarketOrderStyle, _order_cost=0, _security=Security(code=600745.XSHG), _status=new, _filled_amount=0, _avg_cost=0 161 162 2016-03-01 09:30:00 - WARNING - 下单失败,证券(600745.XSHG)今日停牌: StockOrder: _locked_cash=0, _commission=0, _hold_cost=0, _order_id=1540973594, _margin=False, _side=long, _amount=200, _action=close, _mode=OrderTargetAmount: _amount=0, _style=MarketOrderStyle, _order_cost=0, _security=Security(code=600745.XSHG), _status=new, _filled_amount=0, _avg_cost=0 163 164 2016-04-01 09:30:00 - INFO - 订单已提交: StockOrder(entrust_id=1540973595 security=600179.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2016-04-01 09:30:00 error=) 165 166 2016-04-01 09:30:00 - INFO - order StockOrder(entrust_id=1540973595 security=600179.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2016-04-01 09:30:00 error=) trade price: 12.73, amount:400, commission: 10.09 167 168 2016-04-01 09:30:00 - INFO - 订单已委托: StockOrder(entrust_id=1540973595 security=600179.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2016-04-01 09:30:00 error=) 169 170 2016-05-03 09:30:00 - WARNING - 下单失败,证券(600745.XSHG)今日停牌: StockOrder: _locked_cash=0, _commission=0, _hold_cost=0, _order_id=1540973596, _margin=False, _side=long, _amount=200, _action=close, _mode=OrderTargetAmount: _amount=0, _style=MarketOrderStyle, _order_cost=0, _security=Security(code=600745.XSHG), _status=new, _filled_amount=0, _avg_cost=0 171 172 2016-06-01 09:30:00 - INFO - 订单已提交: StockOrder(entrust_id=1540973597 security=600745.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2016-06-01 09:30:00 error=) 173 174 2016-06-01 09:30:00 - INFO - order StockOrder(entrust_id=1540973597 security=600745.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2016-06-01 09:30:00 error=) trade price: 24.73, amount:200, commission: 9.95 175 176 2016-06-01 09:30:00 - INFO - 订单已委托: StockOrder(entrust_id=1540973597 security=600745.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2016-06-01 09:30:00 error=)
3、运行回测
5、最大回撤
四、非股灾时期测试
1、编译运行
2、完成输出日志
1 2014-06-03 09:30:00 - WARNING - 开仓数量必须是100的整数倍,调整为 700: Order(security=600234.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=None) 2 3 2014-06-03 09:30:00 - INFO - 订单已提交: StockOrder(entrust_id=1540974090 security=600234.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2014-06-03 09:30:00 error=) 4 5 2014-06-03 09:30:00 - WARNING - 下单检查标的数量: StockOrder(entrust_id=1540974090 security=600234.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2014-06-03 09:30:00 error=开仓数量必须是100的整数倍,调整为 700) 6 7 2014-06-03 09:30:00 - INFO - order StockOrder(entrust_id=1540974090 security=600234.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2014-06-03 09:30:00 error=开仓数量必须是100的整数倍,调整为 700) trade price: 12.06, amount:700, commission: 5.0 8 9 2014-06-03 09:30:00 - INFO - 订单已委托: StockOrder(entrust_id=1540974090 security=600234.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2014-06-03 09:30:00 error=开仓数量必须是100的整数倍,调整为 700) 10 11 2014-06-03 09:30:00 - WARNING - 开仓数量必须是100的整数倍,调整为 1500: Order(security=600317.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=None) 12 13 2014-06-03 09:30:00 - INFO - 订单已提交: StockOrder(entrust_id=1540974091 security=600317.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2014-06-03 09:30:00 error=) 14 15 2014-06-03 09:30:00 - WARNING - 下单检查标的数量: StockOrder(entrust_id=1540974091 security=600317.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2014-06-03 09:30:00 error=开仓数量必须是100的整数倍,调整为 1500) 16 17 2014-06-03 09:30:00 - INFO - order StockOrder(entrust_id=1540974091 security=600317.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2014-06-03 09:30:00 error=开仓数量必须是100的整数倍,调整为 1500) trade price: 5.71, amount:1500, commission: 5.0 18 19 2014-06-03 09:30:00 - INFO - 订单已委托: StockOrder(entrust_id=1540974091 security=600317.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2014-06-03 09:30:00 error=开仓数量必须是100的整数倍,调整为 1500) 20 21 2014-06-03 09:30:00 - WARNING - 开仓数量必须是100的整数倍,调整为 1800: Order(security=600074.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=None) 22 23 2014-06-03 09:30:00 - INFO - 订单已提交: StockOrder(entrust_id=1540974092 security=600074.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2014-06-03 09:30:00 error=) 24 25 2014-06-03 09:30:00 - WARNING - 下单检查标的数量: StockOrder(entrust_id=1540974092 security=600074.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2014-06-03 09:30:00 error=开仓数量必须是100的整数倍,调整为 1800) 26 27 2014-06-03 09:30:00 - WARNING - 已经涨停, 市价买单取消: StockOrder(entrust_id=1540974092 security=600074.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2014-06-03 09:30:00 error=开仓数量必须是100的整数倍,调整为 1800) 28 29 2014-06-03 09:30:00 - INFO - 订单取消完成:StockOrder(entrust_id=1540974092 security=600074.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2014-06-03 09:30:00 error=开仓数量必须是100的整数倍,调整为 1800) 30 31 2014-06-03 09:30:00 - INFO - 订单已委托: StockOrder(entrust_id=1540974092 security=600074.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2014-06-03 09:30:00 error=开仓数量必须是100的整数倍,调整为 1800) 32 33 2014-06-03 09:30:00 - WARNING - 开仓数量必须是100的整数倍,调整为 1200: Order(security=600876.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=None) 34 35 2014-06-03 09:30:00 - INFO - 订单已提交: StockOrder(entrust_id=1540974093 security=600876.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2014-06-03 09:30:00 error=) 36 37 2014-06-03 09:30:00 - WARNING - 下单检查标的数量: StockOrder(entrust_id=1540974093 security=600876.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2014-06-03 09:30:00 error=开仓数量必须是100的整数倍,调整为 1200) 38 39 2014-06-03 09:30:00 - INFO - order StockOrder(entrust_id=1540974093 security=600876.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2014-06-03 09:30:00 error=开仓数量必须是100的整数倍,调整为 1200) trade price: 7.3, amount:1200, commission: 5.0 40 41 2014-06-03 09:30:00 - INFO - 订单已委托: StockOrder(entrust_id=1540974093 security=600876.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2014-06-03 09:30:00 error=开仓数量必须是100的整数倍,调整为 1200) 42 43 2014-06-03 09:30:00 - WARNING - 开仓数量必须是100的整数倍,调整为 400: Order(security=600756.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=None) 44 45 2014-06-03 09:30:00 - INFO - 订单已提交: StockOrder(entrust_id=1540974094 security=600756.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2014-06-03 09:30:00 error=) 46 47 2014-06-03 09:30:00 - WARNING - 下单检查标的数量: StockOrder(entrust_id=1540974094 security=600756.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2014-06-03 09:30:00 error=开仓数量必须是100的整数倍,调整为 400) 48 49 2014-06-03 09:30:00 - INFO - order StockOrder(entrust_id=1540974094 security=600756.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2014-06-03 09:30:00 error=开仓数量必须是100的整数倍,调整为 400) trade price: 18.96, amount:400, commission: 5.0 50 51 2014-06-03 09:30:00 - INFO - 订单已委托: StockOrder(entrust_id=1540974094 security=600756.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2014-06-03 09:30:00 error=开仓数量必须是100的整数倍,调整为 400) 52 53 2014-06-03 09:30:00 - WARNING - 开仓数量必须是100的整数倍,调整为 500: Order(security=600432.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=None) 54 55 2014-06-03 09:30:00 - INFO - 订单已提交: StockOrder(entrust_id=1540974095 security=600432.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2014-06-03 09:30:00 error=) 56 57 2014-06-03 09:30:00 - WARNING - 下单检查标的数量: StockOrder(entrust_id=1540974095 security=600432.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2014-06-03 09:30:00 error=开仓数量必须是100的整数倍,调整为 500) 58 59 2014-06-03 09:30:00 - INFO - order StockOrder(entrust_id=1540974095 security=600432.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2014-06-03 09:30:00 error=开仓数量必须是100的整数倍,调整为 500) trade price: 15.37, amount:500, commission: 5.0 60 61 2014-06-03 09:30:00 - INFO - 订单已委托: StockOrder(entrust_id=1540974095 security=600432.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2014-06-03 09:30:00 error=开仓数量必须是100的整数倍,调整为 500) 62 63 2014-06-03 09:30:00 - WARNING - 开仓数量必须是100的整数倍,调整为 700: Order(security=600139.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=None) 64 65 2014-06-03 09:30:00 - INFO - 订单已提交: StockOrder(entrust_id=1540974096 security=600139.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2014-06-03 09:30:00 error=) 66 67 2014-06-03 09:30:00 - WARNING - 下单检查标的数量: StockOrder(entrust_id=1540974096 security=600139.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2014-06-03 09:30:00 error=开仓数量必须是100的整数倍,调整为 700) 68 69 2014-06-03 09:30:00 - INFO - order StockOrder(entrust_id=1540974096 security=600139.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2014-06-03 09:30:00 error=开仓数量必须是100的整数倍,调整为 700) trade price: 11.38, amount:700, commission: 5.0 70 71 2014-06-03 09:30:00 - INFO - 订单已委托: StockOrder(entrust_id=1540974096 security=600139.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2014-06-03 09:30:00 error=开仓数量必须是100的整数倍,调整为 700) 72 73 2014-06-03 09:30:00 - WARNING - 开仓数量必须是100的整数倍,调整为 1500: Order(security=601001.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=None) 74 75 2014-06-03 09:30:00 - INFO - 订单已提交: StockOrder(entrust_id=1540974097 security=601001.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2014-06-03 09:30:00 error=) 76 77 2014-06-03 09:30:00 - WARNING - 下单检查标的数量: StockOrder(entrust_id=1540974097 security=601001.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2014-06-03 09:30:00 error=开仓数量必须是100的整数倍,调整为 1500) 78 79 2014-06-03 09:30:00 - INFO - order StockOrder(entrust_id=1540974097 security=601001.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2014-06-03 09:30:00 error=开仓数量必须是100的整数倍,调整为 1500) trade price: 5.93, amount:1500, commission: 5.0 80 81 2014-06-03 09:30:00 - INFO - 订单已委托: StockOrder(entrust_id=1540974097 security=601001.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2014-06-03 09:30:00 error=开仓数量必须是100的整数倍,调整为 1500) 82 83 2014-06-03 09:30:00 - WARNING - 开仓数量必须是100的整数倍,调整为 1100: Order(security=600760.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=None) 84 85 2014-06-03 09:30:00 - INFO - 订单已提交: StockOrder(entrust_id=1540974098 security=600760.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2014-06-03 09:30:00 error=) 86 87 2014-06-03 09:30:00 - WARNING - 下单检查标的数量: StockOrder(entrust_id=1540974098 security=600760.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2014-06-03 09:30:00 error=开仓数量必须是100的整数倍,调整为 1100) 88 89 2014-06-03 09:30:00 - INFO - order StockOrder(entrust_id=1540974098 security=600760.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2014-06-03 09:30:00 error=开仓数量必须是100的整数倍,调整为 1100) trade price: 7.77, amount:1100, commission: 5.0 90 91 2014-06-03 09:30:00 - INFO - 订单已委托: StockOrder(entrust_id=1540974098 security=600760.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2014-06-03 09:30:00 error=开仓数量必须是100的整数倍,调整为 1100) 92 93 2014-06-03 09:30:00 - WARNING - 开仓数量必须是100的整数倍,调整为 400: Order(security=600536.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=None) 94 95 2014-06-03 09:30:00 - INFO - 订单已提交: StockOrder(entrust_id=1540974099 security=600536.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2014-06-03 09:30:00 error=) 96 97 2014-06-03 09:30:00 - WARNING - 下单检查标的数量: StockOrder(entrust_id=1540974099 security=600536.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2014-06-03 09:30:00 error=开仓数量必须是100的整数倍,调整为 400) 98 99 2014-06-03 09:30:00 - INFO - order StockOrder(entrust_id=1540974099 security=600536.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2014-06-03 09:30:00 error=开仓数量必须是100的整数倍,调整为 400) trade price: 22.02, amount:400, commission: 5.0 100 101 2014-06-03 09:30:00 - INFO - 订单已委托: StockOrder(entrust_id=1540974099 security=600536.XSHG mode=OrderValue: _value=9000.0 style=MarketOrderStyle side=long margin=False entrust_time=2014-06-03 09:30:00 error=开仓数量必须是100的整数倍,调整为 400) 102 103 2014-06-16 09:29:00 - INFO - Security(code=600317.XSHG) 在 2014-06-16 发生了分红:每股税前分红0.529, 税后分红0.4232, 每股变成3.0股。 104 105 2014-06-16 09:29:00 - INFO - 分红前,price=2.49, avg_cost=5.71, acc_avg_cost=5.71333333333, amount=1500 106 107 2014-06-16 09:29:00 - INFO - 分红后,price=0.65, avg_cost=1.727, acc_avg_cost=1.72811111111, amount=4500 108 109 2014-07-01 09:30:00 - INFO - 订单已提交: StockOrder(entrust_id=1540974100 security=601001.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2014-07-01 09:30:00 error=) 110 111 2014-07-01 09:30:00 - INFO - order StockOrder(entrust_id=1540974100 security=601001.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2014-07-01 09:30:00 error=) trade price: 5.46, amount:1500, commission: 13.19 112 113 2014-07-01 09:30:00 - INFO - 订单已委托: StockOrder(entrust_id=1540974100 security=601001.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2014-07-01 09:30:00 error=) 114 115 2014-08-01 09:30:00 - INFO - 订单已提交: StockOrder(entrust_id=1540974101 security=600234.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2014-08-01 09:30:00 error=) 116 117 2014-08-01 09:30:00 - INFO - order StockOrder(entrust_id=1540974101 security=600234.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2014-08-01 09:30:00 error=) trade price: 14.28, amount:700, commission: 15.0 118 119 2014-08-01 09:30:00 - INFO - 订单已委托: StockOrder(entrust_id=1540974101 security=600234.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2014-08-01 09:30:00 error=) 120 121 2014-09-01 09:30:00 - INFO - 订单已提交: StockOrder(entrust_id=1540974102 security=600139.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2014-09-01 09:30:00 error=) 122 123 2014-09-01 09:30:00 - INFO - order StockOrder(entrust_id=1540974102 security=600139.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2014-09-01 09:30:00 error=) trade price: 14.29, amount:700, commission: 15.0 124 125 2014-09-01 09:30:00 - INFO - 订单已委托: StockOrder(entrust_id=1540974102 security=600139.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2014-09-01 09:30:00 error=) 126 127 2014-10-08 09:30:00 - INFO - 订单已提交: StockOrder(entrust_id=1540974103 security=600756.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2014-10-08 09:30:00 error=) 128 129 2014-10-08 09:30:00 - INFO - order StockOrder(entrust_id=1540974103 security=600756.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2014-10-08 09:30:00 error=) trade price: 25.65, amount:400, commission: 15.26 130 131 2014-10-08 09:30:00 - INFO - 订单已委托: StockOrder(entrust_id=1540974103 security=600756.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2014-10-08 09:30:00 error=) 132 133 2014-11-03 09:30:00 - INFO - 订单已提交: StockOrder(entrust_id=1540974104 security=600432.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2014-11-03 09:30:00 error=) 134 135 2014-11-03 09:30:00 - INFO - order StockOrder(entrust_id=1540974104 security=600432.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2014-11-03 09:30:00 error=) trade price: 14.48, amount:500, commission: 12.24 136 137 2014-11-03 09:30:00 - INFO - 订单已委托: StockOrder(entrust_id=1540974104 security=600432.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2014-11-03 09:30:00 error=) 138 139 2014-12-01 09:30:00 - WARNING - 下单失败,证券(600760.XSHG)今日停牌: StockOrder: _locked_cash=0, _commission=0, _hold_cost=0, _order_id=1540974105, _margin=False, _side=long, _amount=1100, _action=close, _mode=OrderTargetAmount: _amount=0, _style=MarketOrderStyle, _order_cost=0, _security=Security(code=600760.XSHG), _status=new, _filled_amount=0, _avg_cost=0 140 141 2015-01-05 09:30:00 - INFO - 订单已提交: StockOrder(entrust_id=1540974106 security=600760.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2015-01-05 09:30:00 error=) 142 143 2015-01-05 09:30:00 - INFO - order StockOrder(entrust_id=1540974106 security=600760.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2015-01-05 09:30:00 error=) trade price: 10.7, amount:1100, commission: 16.77 144 145 2015-01-05 09:30:00 - INFO - 订单已委托: StockOrder(entrust_id=1540974106 security=600760.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2015-01-05 09:30:00 error=) 146 147 2015-02-02 09:30:00 - INFO - 订单已提交: StockOrder(entrust_id=1540974107 security=600317.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2015-02-02 09:30:00 error=) 148 149 2015-02-02 09:30:00 - INFO - order StockOrder(entrust_id=1540974107 security=600317.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2015-02-02 09:30:00 error=) trade price: 4.75, amount:4500, commission: 27.79 150 151 2015-02-02 09:30:00 - INFO - 订单已委托: StockOrder(entrust_id=1540974107 security=600317.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2015-02-02 09:30:00 error=) 152 153 2015-03-02 09:30:00 - INFO - 订单已提交: StockOrder(entrust_id=1540974108 security=600536.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2015-03-02 09:30:00 error=) 154 155 2015-03-02 09:30:00 - INFO - order StockOrder(entrust_id=1540974108 security=600536.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2015-03-02 09:30:00 error=) trade price: 44.3, amount:400, commission: 23.04 156 157 2015-03-02 09:30:00 - INFO - 订单已委托: StockOrder(entrust_id=1540974108 security=600536.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2015-03-02 09:30:00 error=) 158 159 2015-04-01 09:30:00 - INFO - 订单已提交: StockOrder(entrust_id=1540974109 security=600876.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2015-04-01 09:30:00 error=) 160 161 2015-04-01 09:30:00 - INFO - order StockOrder(entrust_id=1540974109 security=600876.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2015-04-01 09:30:00 error=) trade price: 11.48, amount:1200, commission: 18.78 162 163 2015-04-01 09:30:00 - INFO - 订单已委托: StockOrder(entrust_id=1540974109 security=600876.XSHG mode=OrderTargetAmount: _amount=0 style=MarketOrderStyle side=long margin=False entrust_time=2015-04-01 09:30:00 error=)
3、运行回测
5、最大回撤
五、报错
1、测试前超过一年
1、错误信息
Traceback (most recent call last): File "jqboson/core/entry.py", line 356, in _run engine.start() File "jqboson/core/engine.py", line 224, in start self._dispatcher.start() File "jqboson/core/dispatcher.py", line 223, in start self._run_loop() File "jqboson/core/dispatcher.py", line 190, in _run_loop self._loop.run() File "jqboson/core/loop/loop.py", line 73, in run self._handle_queue() File "jqboson/core/loop/loop.py", line 103, in _handle_queue message.callback(**message.callback_data) File "jqboson/core/dispatcher.py", line 103, in callback self._event_bus.emit(evt) File "jqboson/core/bus.py", line 47, in emit ret.append(call(event)) File "jqboson/core/strategy.py", line 285, in _wrapper return cb(self._context.strategy_environment.strategy_context) File "/tmp/strategy/user_code.py", line 33, in handle stocks = get_sorted_stocks(context, context.portfolio.positions.keys()) File "/tmp/strategy/user_code.py", line 21, in get_sorted_stocks df['ret'] = (df.iloc[:,len(df.columns)-1] - df.iloc[:,0]) / df.iloc[:,0] File "pandas/core/indexing.py", line 1187, in __getitem__ return self._getitem_tuple(key) File "pandas/core/indexing.py", line 1426, in _getitem_tuple retval = getattr(retval, self.name)._getitem_axis(key, axis=axis) File "pandas/core/indexing.py", line 1480, in _getitem_axis return self._get_loc(key, axis=axis) File "pandas/core/indexing.py", line 89, in _get_loc return self.obj._ixs(key, axis=axis) File "pandas/core/frame.py", line 1743, in _ixs label = self.columns[i] File "pandas/core/index.py", line 1076, in __getitem__ return getitem(key) IndexError: index -1 is out of bounds for axis 0 with size 0