獲取持倉
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."
}