Trading

Get Trades

GET https://api.liquid.com/trades?product_id={product_id}&funding_currency={funding_currency}

Get trades by applying optional filters.

Query Parameters

Name
Type
Description

product_id

string

Product ID 1 for BTCUSD.

funding_currency

string

Filter by example: USD.

status

string

Filter by open or closed.

side

string

Filter by long or short.

trading_type

string

Filter by spot, margin, cfd, perpetual.

{
  "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
}

Available Leverage

GET https://api.liquid.com/users/leverage_limitation

Get an account's available choices in leverage.

[
    100,
    50,
    25,
    10,
    5,
    4,
    2
]

Close a Trade

PUT https://api.liquid.com/trades/{trade_id}/close

Close a live position (live trade) by specifying the trade ID and quantity.

Path Parameters

Name
Type
Description

trade_id

string

Example Trade ID:60223738.

Request Body

Name
Type
Description

closed_quantity

string

Partially close 0.00056 quantities with{"closed_quantity": "0.00056"} . If you do not specify this then the full position will be closed.

{
    "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
}

Claim a Trade

PUT 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.

Path Parameters

Name
Type
Description

trade_id

string

Example of trade ID: 57896

{
  "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"
}

Close all trades

PUT https://api.liquid.com/trades/close_all

Closes live positions (live trades).

Request Body

Name
Type
Description

side

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.

[
    {
        "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
    }
]

Update a Trade

PUT https://api.liquid.com/trades/{trade_id}

Provide either only the stop loss price, only the take profit price, or both.

Path Parameters

Name
Type
Description

trade_id

string

Example trade ID:60223740.

Request Body

Name
Type
Description

stop_loss

string

Update stop loss with{"stop_loss": "7000"}

take_profit

string

Update take profit with{"take_profit": "8000"}

// 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" }
}

Adjust Allocated Margin

PUT 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.

Path Parameters

Name
Type
Description

trade_id

string

Example trade ID:60223741

Request Body

Name
Type
Description

amount

string

{"amount": "100"} to increase the allocated margin by 100 i.e. current 250 allocated margin becomes 250+100=350

{
    "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
}

Last updated