浮亏平仓:
[Python] 复制代码 code = "SQRB00"
mintick = get_instruments(code).mintick #最小变动价位
portfolio = get_portfolio (code, 2)
#获取rb00当前最新价
current_c = get_dynainf(code, 7)
#多持仓均价,注意这里取的是开仓均价,不是持仓均价
duo_av = portfolio.buy_avg_open_price
kong_av = portfolio.sell_avg_open_price
if duo_av>0 and duo_av-current_c>mintick*10:
sell_close(code, "Market", volume=portfolio.buy_quantity,serial_id = 1)
if kong_av>0 and current_c-kong_av>mintick*10:
buy_close(code, "Market", volume=portfolio.sell_quantity,serial_id = 2)
|