1.81K 浏览
0
while True:
    api.wait_update()
    position=api.get_position()
    print(position.volume_short)

这样子写老是出错,不知道为什么
cornerman 已回答的问题 2021年12月31日
0
klines = api.get_kline_serial(symbol, duration_seconds=60)
target_pos = TargetPosTask(api, symbol)

position = api.get_position()

print(position)
for i, j in position.items():
    print('合约:', i, 'pos_long:', j['pos_long'], 'pos_short:', j['pos_short'])

得到:
{'SHFE.rb2205': <tqsdk.objs.Position object at 0x0000024FF46423D0>, D({'exchange_id': 'SHFE', 'instrument_id': 'rb2205', 'pos_long_his': 0, 'pos_long_today': 0, 'pos_short_his': 0, 'pos_short_today': 0, 'volume_long_today': 0, 'volume_long_his': 0, 'volume_long': 0, 'volume_long_frozen_today': 0, 'volume_long_frozen_his': 0, 'volume_long_frozen': 0, 'volume_short_today': 0, 'volume_short_his': 0, 'volume_short': 0, 'volume_short_frozen_today': 0, 'volume_short_frozen_his': 0, 'volume_short_frozen': 0, 'open_price_long': nan, 'open_price_short': nan, 'open_cost_long': nan, 'open_cost_short': nan, 'position_price_long': nan, 'position_price_short': nan, 'position_cost_long': nan, 'position_cost_short': nan, 'float_profit_long': nan, 'float_profit_short': nan, 'float_profit': nan, 'position_profit_long': nan, 'position_profit_short': nan, 'position_profit': nan, 'margin_long': nan, 'margin_short': nan, 'margin': nan, 'market_value_long': nan, 'market_value_short': nan, 'market_value': nan, 'pos': 0, 'pos_long': 0, 'pos_short': 0})}

合约: SHFE.rb2205 pos_long: 0 pos_short: 0
cornerman 已回答的问题 2021年12月31日