GET /position
传参:
字段名 | 类型 | 是否必传 | 字段说明 |
---|---|---|---|
- | - | - | - |
响应参数(参考TqSdk官方文档: https://doc.shinnytech.com/tqsdk/latest/reference/tqsdk.objs.html#tqsdk.objs.Position):
注意:当前持仓为0但是当日有过交易的合约,也会出现在响应结果中,如果想精确获取有持仓的合约,请在结果中根据 pos != 0 自行过滤。
字段名 | 类型 | 字段说明 |
---|---|---|
exchange_id | str | 交易所 |
instrument_id | str | 交易所内的合约代码 |
pos_long_his | int | 多头老仓手数 |
pos_long_today | int | 多头今仓手数 |
pos_short_his | int | 空头老仓手数 |
pos_short_today | int | 空头今仓手数 |
volume_long_today | int | 期货公司查询的多头今仓手数 (不推荐, 推荐使用pos_long_today) |
volume_long_his | int | 期货公司查询的多头老仓手数 (不推荐, 推荐使用pos_long_his) |
volume_long | int | 期货公司查询的多头手数 (不推荐, 推荐使用pos_long) |
volume_long_frozen_today | int | 期货公司查询的多头今仓冻结 (不推荐) |
volume_long_frozen_his | int | 期货公司查询的多头老仓冻结 (不推荐) |
volume_long_frozen | int | 期货公司查询的多头持仓冻结 (不推荐) |
volume_short_today | int | 期货公司查询的空头今仓手数 (不推荐, 推荐使用pos_short_today) |
volume_short_his | int | 期货公司查询的空头老仓手数 (不推荐, 推荐使用pos_short_his) |
volume_short | int | 期货公司查询的空头手数 (不推荐, 推荐使用pos_short) |
volume_short_frozen_today | int | 期货公司查询的空头今仓冻结 (不推荐) |
volume_short_frozen_his | int | 期货公司查询的空头老仓冻结 (不推荐) |
volume_short_frozen | int | 期货公司查询的空头持仓冻结 (不推荐) |
open_price_long | float | 多头开仓均价,以开仓价来统计 |
open_price_short | float | 空头开仓均价,以开仓价来统计 |
open_cost_long | float | 多头开仓成本,为开仓价乘以手数 |
open_cost_short | float | 空头开仓成本,为开仓价乘以手数 |
position_price_long | float | 多头持仓均价,为多头持仓成本除以多头数量 |
position_price_short | float | 空头持仓均价,为空头持仓成本除以空头数量 |
position_cost_long | float | 多头持仓成本,为今仓的开仓价乘以手数加上昨仓的昨结算价乘以手数的和 |
position_cost_short | float | 空头持仓成本,为今仓的开仓价乘以手数加上昨仓的昨结算价乘以手数的和 |
float_profit_long | float | 多头浮动盈亏 |
float_profit_short | float | 空头浮动盈亏 |
float_profit | float | 浮动盈亏 (浮动盈亏: 相对于开仓价的盈亏) |
position_profit_long | float | 多头持仓盈亏 |
position_profit_short | float | 空头持仓盈亏 |
position_profit | float | 持仓盈亏 (持仓盈亏: 相对于上一交易日结算价的盈亏),期权持仓盈亏为 0 |
margin_long | float | 多头占用保证金 |
margin_short | float | 空头占用保证金 |
margin | float | 占用保证金 |
market_value_long | float | 期权权利方市值(始终 >= 0) |
market_value_short | float | 期权义务方市值(始终 <= 0) |
market_value | float | 期权市值 |
pos | int | 净持仓手数, ==0表示无持仓或多空持仓手数相等. <0表示空头持仓大于多头持仓, >0表示多头持仓大于空头持仓 |
pos_long | int | 多头持仓手数, ==0表示无多头持仓. >0表示多头持仓手数 |
pos_short | int | 空头持仓手数, ==0表示无空头持仓. >0表示空头持仓手数 |
请求示例:
curl http://127.0.0.1:8888/position
响应示例:
{ "code": 10000, "data": { "SHFE.rb2309": { "exchange_id": "SHFE", "instrument_id": "rb2309", "pos_long_his": 0, "pos_long_today": 1, "pos_short_his": 0, "pos_short_today": 0, "volume_long_today": 1, "volume_long_his": 0, "volume_long": 1, "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": 3642.0, "open_price_short": 0.0, "open_cost_long": 36420.0, "open_cost_short": 0.0, "position_price_long": 3642.0, "position_price_short": 0.0, "position_cost_long": 36420.0, "position_cost_short": 0.0, "float_profit_long": 0.0, "float_profit_short": 0.0, "float_profit": 0.0, "position_profit_long": 0.0, "position_profit_short": 0.0, "position_profit": 0.0, "margin_long": 2924.8, "margin_short": 0.0, "margin": 2924.8, "market_value_long": 0.0, "market_value_short": 0.0, "market_value": 0.0, "pos": 1, "pos_long": 1, "pos_short": 0, "user_id": "436abcd6-4348-4cb9-b421-db8ed7e2d442", "volume_long_yd": 0, "volume_short_yd": 0, "last_price": 3642.0 } }, "msg": "操作成功!" }