Positions #
The positions API provides information about an account’s current open positions. The response will include information such as cost basis, coins or tokens traded, and market value, which will be updated live as price information is updated. Once a position is closed, it will no longer be queryable through this API.
Get open positions
GET /v2/positions
Retrieves a list of the account’s open positions.
Response
An array of Position objectGet an open position
GET /v2/positions/{symbol}
Retrieves the account’s open position for the given
symbol
.
Parameters
Path Parameters
Attribute | Type | Requirement | Description |
---|---|---|---|
symbol |
string | Optional |
symbol or asset_id |
Response
A Position objectErrors
404 Not found
Position is not found.
Close all positions
DELETE /v2/positions
Closes (liquidates) all of the account’s open long and short positions. A response will be provided for each order that is attempted to be cancelled.
If an order is no longer cancelable, the server will respond with status 500 and reject the request.
Parameters
Query Parameters
Attribute | Type | Requirement | Description |
---|---|---|---|
cancel_orders |
boolean | Optional |
If true is specified, cancel all open orders before liquidating all positions. |
Response
HTTP 207 Multi-Status with body; an array of objects that include the order id and http status code for each status request.Errors
500
Failed to liquidate.
Close a position
DELETE /v2/positions/{symbol}
Closes (liquidates) the account’s open position for the given
symbol
. Works for both long and short positions.
Parameters
Path Parameters
Attribute | Type | Requirement | Description |
---|---|---|---|
symbol |
string | Optional |
symbol or asset_id |
Query Parameters
Attribute | Type | Requirement | Description |
---|---|---|---|
qty |
decimal | Optional |
the number of shares to liquidate. Can accept up to 9 decimal points. Cannot work with percentage |
percentage |
decimal | Optional |
percentage of position to liquidate. Must be between 0 and 100. Would only sell fractional if position is originally fractional. Can accept up to 9 decimal points. Cannot work with qty |
Response
An Order objectErrors
404 Not found
Position is not found.
Position Entity #
Example #
{
"asset_id": "904837e3-3b76-47ec-b432-046db621571b",
"symbol": "BTCUSD",
"exchange": "FTXU",
"asset_class": "crypto",
"avg_entry_price": "19660.5738784516887649",
"qty": "2.61937",
"qty_available": "2.61937",
"side": "long",
"market_value": "50931.03028",
"cost_basis": "51498.3174",
"unrealized_pl": "-567.28712",
"unrealized_plpc": "-0.0110156437848977",
"unrealized_intraday_pl": "-514.790552088631999405963",
"unrealized_intraday_plpc": "-0.0100064600731871",
"current_price": "19444",
"lastday_price": "19358",
"change_today": "0.0044426077074078",
}
Properties #
Attribute | Type | Description |
---|---|---|
asset_id |
string<uuid> | Asset ID |
symbol |
string | Symbol name of the asset |
exchange |
string | Exchange name of the asset (ErisX for crypto) |
asset_class |
string | Asset class name |
avg_entry_price |
string | Average entry price of the position |
qty |
string<int> | The number of shares |
qty_available |
string<int> | Total number of shares available minus open orders |
side |
string | “long” |
market_value |
string<number> | Total dollar amount of the position |
cost_basis |
string<number> | Total cost basis in dollar |
unrealized_pl |
string<number> | Unrealized profit/loss in dollars |
unrealized_plpc |
string<number> | Unrealized profit/loss percent (by a factor of 1) |
unrealized_intraday_pl |
string<number> | Unrealized profit/loss in dollars for the day |
unrealized_intraday_plpc |
string<number> | Unrealized profit/loss percent (by a factor of 1) |
current_price |
string<number> | Current asset price per share |
lastday_price |
string<number> | Last day’s asset price per share based on the closing value of the last trading day |
change_today |
string<number> | Percent change from last day price (by a factor of 1) |