调整卖出订单功能问题
由j2015创建,最终由j2015 被浏览 59 用户
请问如何修改下面的卖出订单的代码,实现判断当股票总仓位大于总市值金额的60%时,卖出大于60%的那部分排序末位的仓位?
if not is_staging and cash_for_sell > 0:
equities = {e.symbol: e for e, p in context.perf_tracker.position_tracker.positions.items()}
instruments = list(reversed(list(ranker_prediction.instrument[ranker_prediction.instrument.apply(
lambda x: x in equities and not context.has_unfinished_sell_order(equities[x]))])))
for instrument in instruments:
context.order_target(context.symbol(instrument), 0)
cash_for_sell -= positions[instrument]
if cash_for_sell <= 0:
break
\