set_commission(commission.PerShare(cost=0.0075, min_trade_cost=1.00))
def rebalance(context,sids,data,factor):
for sid in sids:
if data.can_trade(sid):
order = get_order(order_target_percent(sid, sids[sid]*factor))
if order is not None:
context.total_commission += order.commission
print order.status
print "commission " + str(order.commission)
def before_trading_start(context, data):
print context.total_commission
The backtest output shows a 0 commission is used. It looks like is when submitting an order, the order status is still open. So upon that time, the commission is not updated. reflecting a 0 commission?? Any ideas how to calculate the commission after it's been filled?
2016-01-04 21:45 PRINT 0.0
2016-01-04 22:35 PRINT 0
2016-01-04 22:35 PRINT commission 0
2016-01-04 22:35 PRINT 0
2016-01-04 22:35 PRINT commission 0
2016-01-05 21:45 PRINT 0.0
2016-01-05 22:35 PRINT 0
2016-01-05 22:35 PRINT commission 0
2016-01-06 21:45 PRINT 0.0
2016-01-06 22:35 PRINT 0
2016-01-07 21:45 PRINT 0.0
2016-01-08 21:45 PRINT 0.0