You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
在RiceQuant测试
判断某知股票是否是当前持仓股票时,使用order_book_id in context.portfolio.positions时,始终是False,即使order_book_id 的股票当前有持仓。
for stock in context.universe:
#当可用资金不足以买入一手股票时,order_percent函数不返回order对象,而是返回一个空值
#分钟级别回测时,应下单量超过当前bar的总交易量的25%,导致下单无法全部成交。
if is_suspended(stock) or context.portfolio.cash<=100*bar_dict[stock].last:
break
if stock in context.portfolio.positions:
target_percent = context.portfolio.positions.value_percent + 0.1
else:
target_percent = 0.1
logger.info('%s, %s, %s' % (stock, context.portfolio.positions, stock in context.portfolio.positions))
日志输出:
2012-12-21 09:35:00.00 INFO 002594.XSHE, [], False
2012-12-24 09:35:00.00 INFO 002594.XSHE, ['002594.XSHE'], False
第二行应该返回True
The text was updated successfully, but these errors were encountered:
在RiceQuant测试
判断某知股票是否是当前持仓股票时,使用order_book_id in context.portfolio.positions时,始终是False,即使order_book_id 的股票当前有持仓。
日志输出:
2012-12-21 09:35:00.00 INFO 002594.XSHE, [], False
2012-12-24 09:35:00.00 INFO 002594.XSHE, ['002594.XSHE'], False
第二行应该返回True
The text was updated successfully, but these errors were encountered: