@燕浩云 get_price函数的panel快不能用了,而且经常出现key错误。我修改了一下,仅供参考:
```
grid = get_price(context.universe, g.today, g.today, fields=['paused', 'open', 'high_limit', 'low_limit'],panel=False)
# H1、清仓操作--------------------------------------------------遍历持仓股票
for stock in context.portfolio.positions:
# SS、记录股票峰值信息
if g.summit.get(stock, 0)< data[stock].high: g.summit[stock]=data[stock].high
# SP、跳过停牌股票
if grid[grid['code']==stock]['paused'].values>0: continue
# S1、目前持仓不在预选股票池中(g.muster)则清仓
if stock not in g.muster:
doLaunch(g.owning, stock, '越界清仓')
# S2、回撤10%则清仓
elif grid[grid['code']==stock]['open'].values/g.summit[stock]< 0.9:
doLaunch(g.owning, stock, '回撤清仓')
```
另外里面的unsell_positions也没了,我按API文档修改了一下:
```
for stock in context.portfolio.positions:
if context.portfolio.positions[stock].total_amount>0 or \
context.portfolio.positions[stock].locked_amount>0: remain+=1
```
2019-12-06