金融量化分析【day113】:羊驼策略
零、动量策略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、完成输出日志
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) 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=) 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) 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 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) 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) 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=) 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) 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 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) 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) 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=) 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) 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) 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) 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) 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) 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=) 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
目标数量已经满足, 没有提交委托) 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) 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=) 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) 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 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) 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) 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=) 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) 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 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) 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) 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=) 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) 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) 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) 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) 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) 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=) 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) 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 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) 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) 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=) 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) 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 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) 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) 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=) 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) 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 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) 2015-06-29 09:29:00 - INFO - Security(code=600503.XSHG) 在 2015-06-29 发生了分红:每股税前分红0.004, 税后分红0.0032, 每股变成1.0股。 2015-06-29 09:29:00 - INFO - 分红前,price=20.66, avg_cost=26.58, acc_avg_cost=26.5966666667, amount=300 2015-06-29 09:29:00 - INFO - 分红后,price=20.66, avg_cost=26.576, acc_avg_cost=26.5926666667, amount=300 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=) 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 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=) 2015-07-16 09:29:00 - INFO - Security(code=600293.XSHG) 在 2015-07-16 发生了分红:每股税前分红0.013, 税后分红0.0104, 每股变成1.0股。 2015-07-16 09:29:00 - INFO - 分红前,price=8.16, avg_cost=20.76, acc_avg_cost=20.7725, amount=400 2015-07-16 09:29:00 - INFO - 分红后,price=8.15, avg_cost=20.747, acc_avg_cost=20.7595, amount=400 2015-07-21 09:29:00 - INFO - Security(code=601106.XSHG) 在 2015-07-21 发生了分红:每股税前分红0.001, 税后分红0.0008, 每股变成1.0股。 2015-07-21 09:29:00 - INFO - 分红前,price=11.08, avg_cost=19.87, acc_avg_cost=19.8825, amount=400 2015-07-21 09:29:00 - INFO - 分红后,price=11.08, avg_cost=19.869, acc_avg_cost=19.8815, amount=400 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 2015-08-25 09:29:00 - INFO - Security(code=601608.XSHG) 在 2015-08-25 发生了分红:每股税前分红0.065, 税后分红0.052, 每股变成1.5股。 2015-08-25 09:29:00 - INFO - 分红前,price=7.57, avg_cost=25.53, acc_avg_cost=25.5466666667, amount=300 2015-08-25 09:29:00 - INFO - 分红后,price=5.0, avg_cost=16.9766666667, acc_avg_cost=16.9877777778, amount=450 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=) 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 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=) 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=) 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 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=) 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 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=) 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 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=) 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=) 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 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=) 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 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 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=) 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 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=) 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 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=) 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 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、完成输出日志
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) 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=) 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) 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 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) 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) 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=) 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) 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 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) 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) 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=) 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) 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) 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) 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) 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) 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=) 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) 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 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) 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) 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=) 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) 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 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) 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) 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=) 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) 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 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) 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) 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=) 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) 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 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) 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) 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=) 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) 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 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) 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) 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=) 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) 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 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) 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) 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=) 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) 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 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) 2014-06-16 09:29:00 - INFO - Security(code=600317.XSHG) 在 2014-06-16 发生了分红:每股税前分红0.529, 税后分红0.4232, 每股变成3.0股。 2014-06-16 09:29:00 - INFO - 分红前,price=2.49, avg_cost=5.71, acc_avg_cost=5.71333333333, amount=1500 2014-06-16 09:29:00 - INFO - 分红后,price=0.65, avg_cost=1.727, acc_avg_cost=1.72811111111, amount=4500 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=) 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 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=) 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=) 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 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=) 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=) 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 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=) 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=) 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 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=) 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=) 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 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=) 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 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=) 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 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=) 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=) 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 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=) 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=) 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 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=) 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=) 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 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
金融量化分析【day113】:羊驼策略的更多相关文章
- day31 堡垒机尾声 + Python与金融量化分析(一)
堡垒机尾声: 代码案例:https://github.com/liyongsan/git_class/tree/master/day31 课堂笔记:file send: 1.选择本地文件 2.远程路径 ...
- 金融量化分析【day112】:初识量化交易
一.摘要 为什么需要量化交易? 量化交易是做什么? 量化交易的价值何在? 做量化交易需要什么? 聚宽是什么? 零基础如何快速入门量化交易? 自测与自学 二.量化交易比传统交易强多少? 它能让你的交易效 ...
- 金融量化分析【day110】:金融基础知识
一.股票 股票: 股票是股份公司发给出资人的一种凭证,股票的持有者就是股份公司的股东. 股票的面值与市值 面值表示票面金额 市值表示市场价值 上市/IPO: 企业通过证券交易所公开向社会增发股票以募集 ...
- Python与金融量化分析----金融与量化投资
一:金融了解 金融:就是对现有资源进行重新的整合之后,进行价值和利润的等效流通. 金融工具: 股票 期货 黄金 外汇 基金 ............. 股票: 股票是股份公司发给出资人多的一种凭证,股 ...
- day32 Python与金融量化分析(二)
第一部分:金融与量化投资 股票: 股票是股份公司发给出资人的一种凭证,股票的持有者就是股份公司的股东. 股票的面值与市值 面值表示票面金额 市值表示市场价值 上市/IPO: 企业通过证券交易所公开向社 ...
- 金融量化分析-python量化分析系列之---使用python获取股票历史数据和实时分笔数据
财经数据接口包tushare的使用(一) Tushare是一款开源免费的金融数据接口包,可以用于获取股票的历史数据.年度季度报表数据.实时分笔数据.历史分笔数据,本文对tushare的用法,已经存在的 ...
- 金融量化分析【day113】:聚宽自带策略
一.策略代码 # 导入函数库 from jqdata import * # 初始化函数,设定基准等等 def initialize(context): # 设定沪深300作为基准 set_benchm ...
- 金融量化分析【day113】:布林带策略
一.布林带策略简介 1.简介 2.计算公式 3.图形 二.布林带策略代码 import jqdata def initialize(context): set_benchmark('0000 ...
- 金融量化分析【day113】:PGEC策略
一.PGE简介 二.PGE代码 # 导入函数库 import jqdata import pandas as pd def initialize(context): set_benchmark('00 ...
随机推荐
- 基于Spring3 MVC实现基于form表单文件上传
http://blog.csdn.net/jia20003/article/details/8474374/
- Fortify Scan - Static Code Analyzer
https://software.microfocus.com/en-us/products/application-security-testing/overview https://softwar ...
- ionic3.x开发小坑记录(一)
自定义font的时候,在assets中创建的文件夹名字别用fonts,会与ionic默认样式冲突,在浏览器中调试是正常的,到手机上就出问题了. 在html中写img的src直接如图 assets前面 ...
- 关于flask 上直接使用py.test测试框架进行测试
这个周末基本上都在研究这玩意儿中度过了,虽然效率不高,英文文档看得晕头转向,但是好歹弄出来了 有个结果测试也通过了现在粗略总结一下有时间补上更多详细的例子. 首先使用py.test测试框架,可以做最简 ...
- 用Delphi制作动态菜单 该文章《用Delphi制作动态菜单》
---恢复内容开始--- 1.首先,确定动态菜单的数据来源,即要确定动态菜单标题是来自Windows的系统注册表,还是来自一个数据库,或者是来自一个子目录,主要由程序的功能而定.这里假设主窗口名为Ma ...
- ZJOI2019 Day1游记
退役吧垃圾 考的再烂还是要把自己捡起来 如果不想让自己的OI生涯就到这里止步的话 就给我滚去拿剩下的300分吧 浙江省前十六,学校前五,day1比别人差一百多分.如果这样还能进省队的话,我就成为传说了 ...
- spring cloud 入门系列一:初识spring cloud
最近看到微服务很火,也是未来的趋势, 所以就去学习下,在dubbo和spring cloud之间我选择了从spring cloud,主要有如下几种原因: dubbo主要专注于微服务中的一个环节--服务 ...
- 23个Python爬虫开源项目代码,包含微信、淘宝、豆瓣、知乎、微博等
今天为大家整理了23个Python爬虫项目.整理的原因是,爬虫入门简单快速,也非常适合新入门的小伙伴培养信心,所有链接指向GitHub,微信不能直接打开,老规矩,可以用电脑打开. 关注公众号「Pyth ...
- Python爬虫:HTTP协议、Requests库
HTTP协议: HTTP(Hypertext Transfer Protocol):即超文本传输协议.URL是通过HTTP协议存取资源的Internet路径,一个URL对应一个数据资源. HTTP协议 ...
- 自学Zabbix7.1 IT services
自学Zabbix7.1 IT services 1. 概念IT Services 服务器或者某项服务.业务的可用率,不懂技术的上级领导会过问最近服务器可用率如何.所有api的状况怎么样?通常一些技术人 ...