Create Order

POST https://api.sfox.com/v1/orders/:side

Create an order

Create order requests are rate limited to 60 requests per second per account.

Path Parameters

ParameterTypeDescription

side required

string

Possible values: buy (buy order), sell (sell order)

Body Parameters

ParameterTypeDescription

currency_pair required

string

Pair or product to trade in the format basequote . e.g. btcusd, ethbtc, ethusdc

algorithm_id required

int

Order type / algorithm.

price required

number

Order limit price.

  • Precision: 8 decimal places for crypto, 2 decimal places for fiat

  • NOT required for Market (100) orders

  • Order fill price will always be better than or equal to this price. If market conditions do not allow it, the order will not execute.

quantity required

number

Order size in base currency quantity.

  • NOT required for Market (100) orders

  • Minimum quantity:

    • Crypto Quote Pairs:0.001

    • USD Quote Pairs: price*quantity must be >= $5

amount

number

The amount (quote currency) to spend when buying.

Required when placing BUY orders using: Market (100), Stop (304) or Trailing Stop (308) order types.

client_order_id

string

Optional field for a user-specified ID.

client_order_id serves as an idempotency key. Orders will be rejected if the client_order_id has been specified in a previous order placed in the last 24 hours.

quote_id

string

For executing on an RFQ, the quote_id received in the RFQ request.

time_in_force

string

Time in force (TIF) specifies how the lifetime of your order will be handled. Possible values:

  • GTC: Good 'til canceled orders remain open until canceled. This is the default TIF option. (Default)

  • IOC: Immediate or cancel orders instantly cancel the remaining unfilled size of an order leaving it open. Smart (200) and Limit (201) orders only.

  • FOK: Fill or kill orders are either instantly filled for the full order size or instantly rejected if the entire size cannot be matched. Market (100) and Limit (201) orders only.

  • GTD: Good 'til date orders are automatically canceled at your specified expires date time.

max_slippage

number

A risk management parameter that will limit the slippage of an order in basis points (e.g. setting max_slippage to 5 = 0.05%). Market (100), Stop (304), Trailing Stop (308) only.

expires

date-time

Specify the expiration date time of your order (UNIX timestamp in ms).

Required for orders with time_in_force = GTD

destination

string

Route the order to a specific destination.

Possible values:

  • ox for the sFOX Ox order book

  • darkpool for the sFOX Dark Pool

total_time

int

The time, in seconds, that a TWAP (307) order will stay active from the time the TWAP order is placed.

interval

int

The frequency, in seconds, that slices of a TWAP (307) order will be executed. Default: 900

continuous

boolean

TWAP (307) orders will execute slices as small as possible and frequently as possible over the total_time. interval will be ignored If continuous = true.

post_only

boolean

TWAP (307) orders will execute in "post-only" mode. The order will not take and will only execute slices as make orders.post_only means it is possible the TWAP order will not fill completely by the end of the total_time

stop_amount

number

Set the amount (quote currency) that the trigger price of a trailing stop order will trail the price of an asset. Trailing Stop (308) only.

stop_percent

number

Percentage that the trigger price of a trailing stop order will trail the price of an asset (e.g. 0.1 = 10%). Trailing Stop (308) only.

stop_any_id

int

Turn your order into an STO (Stop-Triggers-Other) or TSTO (Trailing-Stop-Triggers-Other) order: Trigger placement of an order type of your choosing at a certain price or based on a trailing amount/percent. e.g. when price reaches $100 trigger a 1-hour TWAP. Possible values:

  • 310 : STO (Stop-Triggers-Other)

  • 311 : TSTO (Trailing-Stop-Triggers-Other)

stop_any_price

number

Trigger price of an STO (Stop-Triggers-Other) order. Required if stop_any_id = 310.

stop_any_trail_amount

number

Trailing amount (quote currency) of a TSTO (Trailing-Stop-Triggers-Other) order. Required if stop_any_id = 311 and stop_any_trail_percent is not used.

stop_any_trail_percent

number

Specify the trailing percent of a TSTO (Trailing-Stop-Triggers-Other) order (e.g. 0.1 = 10%). Required if stop_any_id = 311 and stop_any_trail_amount is not used.

routing_option

string

Specify how sFOX will trade your order. Routing Options:

  • BestPrice: Prioritize price improvement. Hare (303) and Gorilla (301) only.

  • Fast: Prioritize speed of execution. Hare (303) and Gorilla (301) only.

  • WeightedExchange: Prioritize routing based on the best combination of price and speed of execution. Smart (200), Limit (201) and Hare (303) only.

Responses

201 Accepted & Created
{
    "id": 2010135,
    "side_id": 500,
    "action": "Buy",
    "algorithm_id": 201,
    "algorithm": "Limit",
    "type": "Limit",
    "pair": "btcusd",
    "quantity": 0.1,
    "price": 36431,
    "amount": 0,
    "net_market_amount": 0,
    "filled": 0,
    "vwap": 0,
    "filled_amount": 0,
    "fees": 0,
    "net_proceeds": 0,
    "status": "Started",
    "status_code": 100,
    "routing_option": "WeightedExchange",
    "routing_type": "NetPrice",
    "time_in_force": "GTC",
    "expires": null,
    "dateupdated": "2023-11-17T20:52:40.000Z",
    "date_added": "2023-11-17T20:52:40.000Z",
    "client_order_id": "ea5c8afc-419a-447d-8188-659dce1a782a",
    "user_tx_id": "ea5c8afc-419a-447d-8188-659dce1a782a",
    "o_action": "Buy",
    "algo_id": 201,
    "algorithm_options": null,
    "destination": ""
}
422 Rejected
// currency_pair not specified
{
    "error": "invalid currency_pair: undefined"
}

// currency_pair speficied but not supported or does not exist
{
    "error": "invalid currency_pair: btcusda"
}

Example Requests

curl -X POST \
  -H 'Content-type: application/json' \
  -H 'Authorization: Bearer <API_TOKEN>' \
  --data '{ "quantity": 1,
            "currency_pair": "btcusd",
            "algorithm_id": 200,
            "price": 20000 }'  \
  'https://api.sfox.com/v1/orders/buy'

Last updated