问答交流

回测交易记录有问题

由bqyq9vwl创建,最终由small_q 被浏览 14 用户

2015-06-12 15:00:00+00:00 [{'amount': -96900, 'dt': 2015-06-12 15:00:00+00:00, 'price': 32.619998931884766, 'order_id': 'a619b2d405a64bd7a2693505c9da7fa1', 'commission': 4109.141265449523, 'position_effect': None, 'offset_display': '', 'transaction_money': -3160877.896499634, 'realized_pnl': 40697.82257080078, 'name': '涪陵电力', 'underlying_price': 0.0, 'bar_volume': 9185952.0, 'sid': Equity(5247 [600452.SHA])}, {'amount': 41500, 'dt': 2015-06-12 09:30:00+00:00, 'price': 71.5, 'order_id': '8c583045f75b46ae834d7503618877c9', 'commission': 890.175, 'position_effect': None, 'offset_display': '', 'transaction_money': 2967250.0, 'realized_pnl': 0.0, 'name': '森源电气', 'underlying_price': 0.0, 'bar_volume': 11421128.0, 'sid': Equity(3251 [002358.SZA])}] 2015-06-15 15:00:00+00:00 [{'amount': -83265, 'dt': 2015-06-15 15:00:00+00:00, 'price': 31.099998474121094, 'order_id': '25379b11aca44c69b45fd2461808c3db', 'commission': 3366.4037848320004, 'position_effect': None, 'offset_display': '', 'transaction_money': -2589541.372947693, 'realized_pnl': -3363906.127052307, 'name': '森源电气', 'underlying_price': 0.0, 'bar_volume': 21001686.0, 'sid': Equity(3251 [002358.SZA])}, {'amount': 112200, 'dt': 2015-06-15 09:30:00+00:00, 'price': 27.43000030517578, 'order_id': '994a03e79b2c409e805a3e8e86c98703', 'commission': 923.2938102722167, 'position_effect': None, 'offset_display': '', 'transaction_money': 3077646.0342407227, 'realized_pnl': 0.0, 'name': '雏鹰农牧', 'underlying_price': 0.0, 'bar_volume': 19986853.0, 'sid': Equity(123 [002477.SZA])}]

以上森源电气除权为例,你们transaction里如果买的股票刚好经过除权,realized_pnl会计算错误,单纯用价差乘以卖出量了,应该改为各自成交价乘以各自成交量再相减,这才realized

标签

回测股票交易