获取持仓
GET/api/v1.0/accounts/{acc_id}/positions查询指定交易账户的持仓列表。
路径参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
acc_id | string | 是 | 业务账户 ID。 |
请求参数
| 参数 | 类型 | 位置 | 必填 | 说明 |
|---|---|---|---|---|
code | string | 查询 | 否 | 标的代码过滤,只返回匹配的持仓。不传则返回全部。期货持仓需传带月份的合约代码,不支持按主力合约代码过滤。 |
pl_ratio_min | string | 查询 | 否 | 盈亏比例下限过滤。传 10 则返回盈亏比例 ≥ +10% 的持仓。 |
pl_ratio_max | string | 查询 | 否 | 盈亏比例上限过滤。传 20 则返回盈亏比例 ≤ +20% 的持仓。 |
响应参数
| 字段 | 类型 | 说明 |
|---|---|---|
position_side | string | 持仓方向。可选值:NONE(未知)、LONG(多头,默认)、SHORT(空头)。 |
code | string | 标的代码。 |
stock_name | string | 标的名称。 |
qty | string | 持仓数量。 |
can_sell_qty | string | 可卖数量。 |
currency | string | 交易币种。 |
nominal_price | string | 市价。 |
cost_price | string | 摊薄成本(证券账户)。平均开仓价(期货账户)。 |
cost_price_valid | bool | 成本价是否有效。 |
market_val | string | 市值。 |
pl_ratio | string | 盈亏比例。 |
pl_ratio_valid | bool | 盈亏比例是否有效。 |
pl_val | string | 盈亏金额。 |
pl_val_valid | bool | 盈亏金额是否有效。 |
today_pl_val | string | 今日盈亏。 |
today_trd_val | string | 今日成交额。 |
today_buy_qty | string | 今日买入总量。 |
today_buy_val | string | 今日买入总额。 |
today_sell_qty | string | 今日卖出总量。 |
today_sell_val | string | 今日卖出总额。 |
unrealized_pl | string | 未实现盈亏。 |
realized_pl | string | 已实现盈亏。 |
响应示例
json
{
"s": "ok",
"d": [
{
"position_side": "LONG",
"code": "US.AAPL",
"stock_name": "Apple Inc.",
"qty": "100",
"can_sell_qty": "100",
"currency": "USD",
"nominal_price": "185.500",
"cost_price": "180.000",
"cost_price_valid": true,
"market_val": "18550.00",
"pl_ratio": "3.06",
"pl_ratio_valid": true,
"pl_val": "550.00",
"pl_val_valid": true,
"today_pl_val": "50.00",
"today_trd_val": "0.00",
"today_buy_qty": "0",
"today_buy_val": "0.00",
"today_sell_qty": "0",
"today_sell_val": "0.00",
"unrealized_pl": "550.00",
"realized_pl": "200.00"
}
]
}失败响应:
json
{
"s": "error",
"errcode": -1200,
"errmsg": "Error message."
}