Create Orders

POST request with body parameters for Spot, Margin, CFD/Infinity, Perpetuals.

Create an Order

POST https://api.liquid.com/orders

This section explains shareable body parameter for trading_type of Spot, Margin, CFD/Infinity, Perpetuals. For body parameters specific to a trading_type , navigate further below.

Request Body

NameTypeDescription

order_type

string

Supported values: limit, market, market_with_range, trailing_stop, limit_post_only, stop

product_id

number

For BTCUSD product ID is 1.

side

string

Supported values: buy or sell.

quantity

string

The quantity to buy or sell.

price

string

Price per unit of crypto. Only required if order_type is limit, limit_post_only, market_with_range, stop.

price_range

string

Only available if order_type is market_with_range. Using relative value of max deviation from best price on market (slippage control). Will override price parameter.

trailing_stop_type

string

Only available if order_type is trailing_stop. Supported values: price, percentage.

trailing_stop_value

string

Only available if order_type is trailing_stop. The distance (by percent or price) that the order should trail the market price.

client_order_id

string

Create a self-identified Order ID, a custom unique identifying JSON string up to 36 bytes with any content (as long as it is unique). User must avoid special characters besides "-". client_order_id must always be unique and not be reused.

// Refer to specific examples further below

Nonce is not required in authentication’s payload if client_order_id is provided.

limit_post_only orders are limit orders that are only accepted if they do not immediately execute. limit_post _only orders never take liquidity.

limit_post_only order will not match with pre-existing orders. If your order would cause a match with a pre-existing order, your limit_post_only order will be cancelled.

limit_post_only order ensures that you pay the maker and not the taker fee.

Available leverage may be limited based on position and/or jurisdiction.

For spot trading (leverage_level=1), the funding_currency, if specified, has to equal to the product's quoted currency, for example to create an order in product BTCJPY, the funding currency has to be JPY.

For market_with_range:

  • price:

    • if order is buy: this order swipes out sell price ladders that has price lower than its price. If this action (partial order execution) bumps market ask price higher than its price, remaining unfulfilled quantity cancelled.

    • if order is sell: this order swipes out buy price ladders that has price higher than its price. If this action (partial order execution) bumps market ask price lower than its price, remaining unfulfilled quantity cancelled.

  • price_range:

    • if order is buy: get the current market ask, + the price_range, then we have price and apply above logic.

    • if order is sell: get the current market bid, - the price_range.

Spot Order Type Examples

Limit Order

POST /orders/

// With Client Order ID //
{
    "order_type": "limit",
    "product_id": "27",
    "side": "buy",
    "quantity": "0.01",
    "price": "100",
    "client_order_id": "7b41d04a-1551-455a-939c-81c41c365ad9"
}

// Ensures order is a maker//
{
    "order_type": "limit_post_only",
    "product_id": "27",
    "side": "buy",
    "quantity": "0.44",
    "price": "150"
}

Market Order

POST /orders/

{
    "order_type": "market",
    "product_id": "27",
    "side": "buy",
    "quantity": "0.444"
}

// Market with range supports immediate-or-cancel (IOC)
// execution up to the stated price_range to
// control price slippage
{
    "order_type": "market_with_range",
    "product_id": "27",
    "side": "sell",
    "quantity": "10",
    "price_range": "0.1"
}

Stop Order

POST /orders/

{
    "order_type": "stop",
    "product_id": "27",
    "side": "buy",
    "quantity": "1.2",
    "price": "140"
}

Trailing-Stop Order

POST /orders/

// With 10% higher than market price //
{
    "order_type": "trailing_stop",
    "product_id": "27",
    "side": "buy",
    "quantity": "0.666",
    "trailing_stop_type": "percentage",
    "trailing_stop_value": "0.05"
}
// Absolute value of 100 higher than market price //
{
    "order_type": "trailing_stop",
    "product_id": "27",
    "side": "buy",
    "quantity": "0.666",
    "trailing_stop_type": "price",
    "trailing_stop_value": "100"
}

Margin Orders Additional Body Parameters

Parameters

Optional

Description

leverage_level

No

Valid levels: 2, 4, 5, 10, 25. Failure to supply these will result in an execution of spot order with leverage of 1

trading_type

No

Supported value: margin

margin_type

Yes

Supported value:cross or isolated, defaults to isolated. Only available if leverage_level is not 1.

When "margin_type": "isolated" the funding_currency is the quote currency and does not support other funding currencies.

funding_currency

Conditional

Supported values are: SGD, JPY, USD when "margin_type": "cross". When placing a BTCJPY order and account does not have JPY but has enough USD balance, then specify "funding_currency": "USD". This will automatically switch margin_type to cross.

order_direction

Yes

Supported values: one_direction, two_direction, netout. Defaults totwo_direction. When a user has an open Long position in one_direction, placing a Short order will be rejected, and vice versa.

Use two_direction to have an open Long position and an open Short position simultaneously. Decrease the position sizes of a long position, place a short order with netout.

take_profit

Yes

Only available if leverage_level is greater than 1. If order side is buy the value of take_profitmust be greater than the order's price. If order side is sell the value of take_profit must be less than the order's price. This same rule applies to orders that are executed at market. Take profit will be executed as a limit order.

stop_loss

Yes

Only available if leverage_level is greater than 1. If order side is buy the value of take_profitmust be less than the order's price. If order side is sell the value of take_profit must be greater than the order's price. This same rule applies to orders that are executed at market. Stop Loss will be executed as a market order.

Limit Order

POST /orders/

// With Client Order ID //
{
    "order_type": "limit",
    "product_id": "27",
    "side": "buy",
    "price": "120",
    "quantity": "0.333",
    "leverage_level": "25",
    "trading_type": "margin",
    "margin_type": "isolated",
    "funding_currency": "USD",
    "order_direction": "netout",
    "take_profit": "150",
    "stop_loss": "100",
    "client_order_id": "7b41d04a-1551-455a-939c-81c41c365ad9"
}

// Ensures order is a maker//
{
    "order_type": "limit_post_only",
    "product_id": "27",
    "side": "buy",
    "quantity": "0.44",
    "price": "150",
    "leverage_level": "25",
    "trading_type": "margin"
}

Market Order

POST /orders/

{
    "order_type": "market",
    "product_id": "27",
    "side": "buy",
    "quantity": "0.444",
    "leverage_level": "25",
    "trading_type": "margin",
    "margin_type": "cross",
    "funding_currency": "USD",
    "order_direction": "netout",
    "take_profit": "200",
    "stop_loss": "100"
}

// Market with range supports immediate-or-cancel (IOC)
// execution up to the stated price_range to
// control price slippage
{
    "order_type": "market_with_range",
    "product_id": "27",
    "side": "sell",
    "quantity": "10",
    "price_range": "0.1",
    "leverage_level": "25",
    "trading_type": "margin"
}

Stop Order

POST /orders/

{
    "order_type": "stop",
    "product_id": "27",
    "side": "buy",
    "price": "120",
    "quantity": "0.333",
    "leverage_level": "25",
    "trading_type": "margin",
    "margin_type": "cross",
    "funding_currency": "USD",
    "order_direction": "netout",
    "take_profit": "150",
    "stop_loss": "100"
}

Trailing-Stop Order

POST /orders/

// With 10% higher than market price //
{
    "order_type": "trailing_stop",
    "product_id": "27",
    "side": "buy",
    "quantity": "0.666",
    "leverage_level": "2",
    "trading_type": "margin",
    "trailing_stop_type": "percentage",
    "trailing_stop_value": "0.10"
}

// With absolute value of 100 higher than market price //
{
    "order_type": "trailing_stop",
    "product_id": "27",
    "side": "buy",
    "quantity": "0.666",
    "leverage_level": "2",
    "trading_type": "margin",
    "trailing_stop_type": "price",
    "trailing_stop_value": "100"
}

CFD/Infinity Orders Additional Body Parameters

Parameters

Optional

Description

leverage_level

No

Valid levels: 2, 4, 5, 10, 25, 50, 100. Failure to supply these will result in an execution of spot order with leverage of 1

trading_type

No

Supported values: cfd

margin_type

Yes

Supported value:cross or isolated, defaults to isolated. Only available if leverage_level is not 1.

When "margin_type": "isolated" the funding_currency is the quote currency and does not support other funding currencies.

funding_currency

Conditional

Supported values are: SGD, JPY, USD when "margin_type": "cross". When placing a BTCJPY order and account does not have JPY but has enough USD balance, then specify "funding_currency": "USD". This will automatically switch margin_type to cross.

order_direction

Yes

Supported values: one_direction, two_direction, netout. Defaults totwo_direction. When a user has an open Long position in one_direction, placing a Short order will be rejected, and vice versa.

Use two_direction to have an open Long position and an open Short position simultaneously. Decrease the position sizes of a long position, place a short order with netout.

take_profit

Yes

Only available if leverage_level is greater than 1. If order side is buy the value of take_profitmust be greater than the order's price. If order side is sell the value of take_profit must be less than the order's price. This same rule applies to orders that are executed at market. Take profit will be executed as a limit order.

stop_loss

Yes

Only available if leverage_level is greater than 1. If order side is buy the value of take_profitmust be less than the order's price. If order side is sell the value of take_profit must be greater than the order's price. This same rule applies to orders that are executed at market. Stop loss will be executed as a market order.

Limit Order

POST /orders/

// With Client Order ID //
{
    "order_type": "limit",
    "product_id": "27",
    "side": "buy",
    "price": "120",
    "quantity": "0.333",
    "leverage_level": "25",
    "trading_type": "cfd",
    "margin_type": "isolated",
    "funding_currency": "USD",
    "order_direction": "netout",
    "take_profit": "150",
    "stop_loss": "100",
    "client_order_id": "7b41d04a-1551-455a-939c-81c41c365ad9"
}

// Ensures order is a maker//
{
    "order_type": "limit_post_only",
    "product_id": "27",
    "side": "buy",
    "quantity": "0.55",
    "price": "100",
    "leverage_level": "25",
    "trading_type": "cfd"
}

Market Order

POST /orders/

{
    "order_type": "market",
    "product_id": "27",
    "side": "buy",
    "quantity": "0.444",
    "leverage_level": "25",
    "trading_type": "cfd",
    "margin_type": "cross",
    "funding_currency": "USD",
    "order_direction": "netout",
    "take_profit": "200",
    "stop_loss": "100"
}

// Market with range supports immediate-or-cancel (IOC)
// execution up to the stated price_range to
// control price slippage
{
    "order_type": "market_with_range",
    "product_id": "27",
    "side": "sell",
    "quantity": "10",
    "price_range": "0.1",
    "leverage_level": "50",
    "trading_type": "cfd"
}

Stop Order

POST /orders/

{
    "order_type": "stop",
    "product_id": "27",
    "side": "buy",
    "price": "120",
    "quantity": "0.333",
    "leverage_level": "25",
    "trading_type": "cfd",
    "margin_type": "cross",
    "funding_currency": "USD",
    "order_direction": "netout",
    "take_profit": "150",
    "stop_loss": "100"
}

Trailing-Stop Order

POST /orders/

// With 10% higher than market price //
{
    "order_type": "trailing_stop",
    "product_id": "27",
    "side": "buy",
    "quantity": "0.666",
    "leverage_level": "2",
    "trading_type": "cfd",
    "trailing_stop_type": "percentage",
    "trailing_stop_value": "0.10"
}

// With absolute value of 100 higher than market price //
{
    "order_type": "trailing_stop",
    "product_id": "27",
    "side": "buy",
    "quantity": "0.666",
    "leverage_level": "2",
    "trading_type": "cfd",
    "trailing_stop_type": "price",
    "trailing_stop_value": "100"
}

Perpetual Orders Additional Body Parameters

Parameters

Optional

Description

leverage_level

No

Valid levels: 2, 4, 5, 10, 25, 50, 100. Failure to supply these will result in an execution of spot order with leverage of 1

trading_type

No

Supported values: perpetual

margin_type

Yes

Supported value:cross or isolated, defaults to isolated. Only available if leverage_level is not 1.

funding_currency

Conditional

Currency used to fund the trade with. Default is quoted currency (e.g a trade in BTCUSD product will use USD as the funding currency as default)

order_direction

Yes

Supported values: one_direction, netout. Defaults toone_direction. When a user has an open Long position in one_direction, placing a Short order will be rejected, and vice versa. Decrease the position sizes of a long position, place a short order with netout.

take_profit

Yes

Only available if leverage_level is greater than 1. If order side is buy the value of take_profitmust be greater than the order's price. If order side is sell the value of take_profit must be less than the order's price. This same rule applies to orders that are executed at market. Take profit will be executed as a limit order.

stop_loss

Yes

Only available if leverage_level is greater than 1. If order side is buy the value of take_profitmust be less than the order's price. If order side is sell the value of take_profit must be greater than the order's price. This same rule applies to orders that are executed at market. Stop Loss will be executed as a market order.

Limit Order

POST /orders/

// With Client Order ID //
{
    "order_type": "limit",
    "product_id": "603",
    "side": "buy",
    "quantity": "0.123",
    "price": "300000",
    "leverage_level": "100",
    "trading_type": "perpetual",
    "margin_type": "isolated",
    "funding_currency": "JPY",
    "order_direction": "netout",
    "take_profit": "322222",
    "stop_loss": "288888",
    "client_order_id": "7b41d04a-1551-455a-939c-81c41c365ad9"
}

// Ensures order is a maker//
{
    "order_type": "limit_post_only",
    "product_id": "603",
    "side": "buy",
    "quantity": "0.66",
    "price": "450000",
    "leverage_level": "100",
    "trading_type": "perpetual"
}

Market Order

POST /orders/

{
    "order_type": "market",
    "product_id": "603",
    "side": "buy",
    "quantity": "1.23",
    "leverage_level": "100",
    "trading_type": "perpetual",
    "margin_type": "isolated",
    "funding_currency": "JPY",
    "order_direction": "netout"
}

// Market with range supports immediate-or-cancel (IOC)
// execution up to the stated price_range to
// control price slippage
{
    "order_type": "market_with_range",
    "product_id": "603",
    "side": "sell",
    "quantity": "0.5",
    "price_range": "10000",
    "leverage_level": "100",
    "trading_type": "perpetual"
}

Stop Order

POST /orders/

{
    "order_type": "stop",
    "product_id": "603",
    "side": "buy",
    "quantity": "0.123",
    "price": "500000",
    "leverage_level": "100",
    "trading_type": "perpetual",
    "margin_type": "isolated",
    "funding_currency": "JPY",
    "order_direction": "netout",
    "take_profit": "522222",
    "stop_loss": "488888"
}

Trailing-Stop Order

POST /orders/

// With 10% higher than market price //
{
    "order_type": "trailing_stop",
    "product_id": "603",
    "side": "buy",
    "quantity": "0.234",
    "leverage_level": "100",
    "trading_type": "perpetual",
    "trailing_stop_type": "percentage",
    "trailing_stop_value": "0.10"
}

// With absolute value of 10000 higher than market price //
{
    "order_type": "trailing_stop",
    "product_id": "603",
    "side": "buy",
    "quantity": "0.345",
    "leverage_level": "100",
    "trading_type": "perpetual",
    "trailing_stop_type": "price",
    "trailing_stop_value": "10000"
}

Last updated