Order Types
4rho supports advanced order types for sophisticated trading strategies.
Time-in-Force (TIF)
Controls how long an order remains active.
| TIF | Name | Behavior |
|---|---|---|
GTC | Good Till Cancel | Remains open until explicitly cancelled (default) |
GTD | Good Till Date | Remains open until cancelled or the expiry time |
FOK | Fill or Kill | Must be fully filled immediately, or rejected |
FAK | Fill and Kill | Fills as much as possible; remainder cancelled |
GTC (Default)
{
"time_in_force": "GTC",
...
}
The order rests on the book until you cancel it or it's fully filled.
GTD
{
"time_in_force": "GTD",
"expiration": 1709222400,
...
}
The order rests on the book until the expiration unix timestamp. GTD requires a valid expiration field. A background worker checks for expired GTD orders every 5 seconds.
FOK
{
"time_in_force": "FOK",
...
}
The order must be fully filled against existing resting orders immediately. If the full quantity cannot be matched, the entire order is rejected. No partial fills.
FAK (IOC)
{
"time_in_force": "FAK",
...
}
Fills as much as possible against resting orders. Any unfilled remainder is immediately cancelled. At least one fill must occur or the order is rejected.
Post-Only
{
"post_only": true,
...
}
A post-only order is rejected if it would immediately match against an existing order (i.e., cross the spread). This guarantees the order will be a maker order, earning maker fees rather than paying taker fees.
Use post-only for passive market making strategies where you always want to provide liquidity rather than take it.
Self-Trade Prevention (STP)
Prevents your own orders from matching against each other. Essential for market makers who have both bids and offers on the same book.
| Mode | Behavior |
|---|---|
| (empty) | No self-trade prevention (default) |
cancel_taker | Cancel the incoming (taker) order |
cancel_maker | Cancel the resting (maker) order |
cancel_both | Cancel both taker and maker orders |
{
"stp_mode": "cancel_taker",
...
}
Self-trade detection is based on the maker wallet address. Orders from the same address on both sides of the book trigger STP.
Cancel-Replace
Atomically cancel an existing order and place a new one. If the cancellation fails (e.g., order already filled), the new order is not placed.
POST /v1/orders/cancel-replace
See Orders for details.
Order Amend
Modify the price or quantity of a resting order without cancelling and re-placing.
PUT /v1/orders/:hash/amend
Time priority rules:
- If only the quantity decreases, the order keeps its time priority
- If the price changes or quantity increases, the order loses its time priority (moved to back of queue at the new price level)
See Orders for details.