Trading

get
Get Trades

https://api.liquid.com/trades?product_id={product_id}&funding_currency={funding_currency}
Get trades by applying optional filters.
Request
Response
Request
Query Parameters
product_id
optional
string
Product ID 1 for BTCUSD.
funding_currency
optional
string
Filter by example: USD.
status
optional
string
Filter by open or closed.
side
optional
string
Filter by long or short.
trading_type
optional
string
Filter by spot, margin, cfd, perpetual.
Response
200: OK
{
"models": [
{
"id": 57896,
"currency_pair_code": "BTCUSD",
"status": "open",
"side": "short",
"margin_type": "cross",
"margin_used": "0.83588",
"liquidation_price": null,
"maintenance_margin": null,
"open_quantity": "0.01",
"close_quantity": "0.0",
"quantity": "0.01",
"leverage_level": 5,
"product_code": "CASH",
"product_id": 1,
"open_price": "417.65",
"close_price": "417.0",
"trader_id": 3020,
"open_pnl": "0.0",
"close_pnl": "0.0",
"pnl": "0.0065",
"stop_loss": "0.0",
"take_profit": "0.0",
"funding_currency": "USD",
"created_at": 1456250726,
"updated_at": 1456251837,
"total_interest": "0.02"
},
...
],
"current_page": 1,
"total_pages": 1
}

get
Available Leverage

https://api.liquid.com/users/leverage_limitation
Get an account's available choices in leverage.
Request
Response
Request
Response
200: OK
[
100,
50,
25,
10,
5,
4,
2
]

put
Close a Trade

https://api.liquid.com/trades/{trade_id}/close
Close a live position (live trade) by specifying the trade ID and quantity.
Request
Response
Request
Path Parameters
trade_id
required
string
Example Trade ID:60223738.
Body Parameters
closed_quantity
optional
string
Partially close 0.00056 quantities with{"closed_quantity": "0.00056"} . If you do not specify this then the full position will be closed.
Response
200: OK
{
"id": 60223738,
"currency_pair_code": "BTCUSD",
"status": "open",
"side": "long",
"margin_used": 354.9349,
"open_quantity": 1.234,
"close_quantity": 0.00056,
"quantity": 1.23456,
"leverage_level": 25,
"product_code": "CASH",
"product_id": 1,
"original_open_price": "7190.73942",
"open_price": 7190.73942,
"close_price": 7190.680006119751166407465007776049766718,
"trader_id": 735092,
"open_pnl": -0.07332,
"close_pnl": -0.00003,
"pnl": -0.07335,
"stop_loss": "0.0",
"take_profit": "0.0",
"margin_type": "cross",
"funding_currency": "USD",
"total_interest": 0.0,
"created_at": 1599271237,
"updated_at": 1599271270,
"total_fee": 23.08123,
"close_fee": 0.0,
"liquidation_price": null,
"maintenance_margin": null,
"trading_type": "margin",
"last_settlement_at": null
}

put
Claim a Trade

https://api.liquid.com/trades/{trade_id}/claim
Claim a trade by specifying its ID. This works only for Margin pairs where the funding currency is similar to the quote currency i.e. trade BTCUSD with USD.
Request
Response
Request
Path Parameters
trade_id
required
string
Example of trade ID: 57896
Response
200: OK
{
"id": 57896,
"currency_pair_code": "BTCUSD",
"status": "closed",
"side": "short",
"margin_type": "cross",
"margin_used": "0.83588",
"liquidation_price": null,
"maintenance_margin": null,
"open_quantity": "0.01",
"close_quantity": "0.0",
"quantity": "0.01",
"leverage_level": 5,
"product_code": "CASH",
"product_id": 1,
"open_price": "417.65",
"close_price": "417.0",
"trader_id": 3020,
"open_pnl": "0.0",
"close_pnl": "0.0065",
"pnl": "0.0065",
"stop_loss": "0.0",
"take_profit": "0.0",
"funding_currency": "USD",
"created_at": 1456250726,
"updated_at": 1456251837,
"total_interest": "0.02"
}

put
Close all trades

https://api.liquid.com/trades/close_all
Closes live positions (live trades).
Request
Response
Request
Body Parameters
side
optional
string
{"side": "long} to close all long positions {"side": "short"} to close all short positions. If this is not specified then all positions, both on the long side and the short side will be closed.
Response
200: OK
[
{
"id": 60223739,
"currency_pair_code": "BTCUSD",
"status": "open",
"side": "short",
"margin_used": 58.44314,
"open_quantity": 0.813576,
"close_quantity": 0.186424,
"quantity": 1.0,
"leverage_level": 100,
"product_code": "CASH",
"product_id": 1,
"original_open_price": "7183.48932",
"open_price": 7183.48932,
"close_price": 7192.1764,
"trader_id": 735092,
"open_pnl": -5.99187,
"close_pnl": -2.69521,
"pnl": -8.68708,
"stop_loss": "0.0",
"take_profit": "0.0",
"margin_type": "cross",
"funding_currency": "USD",
"total_interest": 7.04156272700832,
"created_at": 1599271629,
"updated_at": 1599271665,
"total_fee": 18.69577,
"close_fee": 0.0,
"liquidation_price": null,
"maintenance_margin": null,
"trading_type": "cfd",
"last_settlement_at": null
},
{
"id": 60223747,
"currency_pair_code": "BTCUSD",
"status": "open",
"side": "long",
"margin_used": 143.96079,
"open_quantity": 2.0,
"close_quantity": 0.0,
"quantity": 2.0,
"leverage_level": 100,
"product_code": "CASH",
"product_id": 1,
"original_open_price": "7198.0398",
"open_price": 7198.0398,
"close_price": 7190.68,
"trader_id": 735092,
"open_pnl": -14.7196,
"close_pnl": 0.0,
"pnl": -14.7196,
"stop_loss": "0.0",
"take_profit": "0.0",
"margin_type": "isolated",
"funding_currency": "USD",
"total_interest": 2.3993466,
"created_at": 1599455927,
"updated_at": 1599455927,
"total_fee": 0.0,
"close_fee": 0.0,
"liquidation_price": "7162.04961",
"maintenance_margin": "71.9804",
"trading_type": "cfd",
"last_settlement_at": null
}
]

put
Update a Trade

https://api.liquid.com/trades/{trade_id}
Provide either only the stop loss price, only the take profit price, or both.
Request
Response
Request
Path Parameters
trade_id
required
string
Example trade ID:60223740.
Body Parameters
stop_loss
required
string
Update stop loss with{"stop_loss": "7000"}
take_profit
required
string
Update take profit with{"take_profit": "8000"}
Response
200: OK
// Success //
{
"id": 60223740,
"currency_pair_code": "BTCUSD",
"status": "open",
"side": "long",
"margin_used": "287.63008",
"open_quantity": "1.0",
"close_quantity": "0.0",
"quantity": "1.0",
"leverage_level": 25,
"product_code": "CASH",
"product_id": 1,
"original_open_price": "7190.75216",
"open_price": "7190.75216",
"close_price": "7190.68",
"trader_id": 735092,
"open_pnl": -0.07216,
"close_pnl": "0.0",
"pnl": -0.07216,
"stop_loss": "7000.0",
"take_profit": "8000.0",
"margin_type": "cross",
"funding_currency": "USD",
"total_interest": "0.0719",
"created_at": 1599271641,
"updated_at": 1599271641,
"total_fee": 0.0,
"close_fee": "0.0",
"liquidation_price": null,
"maintenance_margin": null,
"trading_type": "margin",
"last_settlement_at": null
}
// For isolated margin only,
// error when Long & stop loss <= liquidation_price
{
"message": "new_stop_loss_price_should_be_greater_than_liquidation_price",
"addition_infos": { "liquidation_price": "2800.0" }
}
// For isolated margin only,
// error when Short & stop loss >= liquidation_price //
{
"message": "new_stop_loss_price_should_be_less_than_liquidation_price",
"addition_infos": { "liquidation_price": "3200.0" }
}

put
Adjust Allocated Margin

https://api.liquid.com/trades/{trade_id}/adjust_margin
For isolated margin trades only. Adjust a trade's allocated margin a.k.a. margin used.
Request
Response
Request
Path Parameters
trade_id
required
string
Example trade ID:60223741
Body Parameters
amount
required
string
{"amount": "100"} to increase the allocated margin by 100 i.e. current 250 allocated margin becomes 250+100=350
Response
200: OK
{
"id": 60223741,
"currency_pair_code": "BTCUSD",
"status": "open",
"side": "long",
"margin_used": "350.95979",
"open_quantity": "2.0",
"close_quantity": "0.0",
"quantity": "2.0",
"leverage_level": 100,
"product_code": "CASH",
"product_id": 1,
"original_open_price": "7197.99016",
"open_price": "7197.99016",
"close_price": "7190.68",
"trader_id": 735092,
"open_pnl": -14.62032,
"close_pnl": "0.0",
"pnl": -14.62032,
"stop_loss": "0.0",
"take_profit": "0.0",
"margin_type": "isolated",
"funding_currency": "USD",
"total_interest": "2.399330053333333333333333334",
"created_at": 1599272686,
"updated_at": 1599272686,
"total_fee": 0.0,
"close_fee": "0.0",
"liquidation_price": "7058.50022",
"maintenance_margin": "71.97991",
"trading_type": "cfd",
"last_settlement_at": null
}