Order Types

CoreMatch natively supports limit (LMT) and stop-limit (STL) orders. CoinJar Exchange also provides simulated market (MKT) orders by generating a series of IOC limit orders. These generated orders are not blocking or atomic.

Limit (LMT) orders

A limit order specifies the maximum price a buyer will pay or the minimum price a seller will accept.

Limit orders support the following time-in-force options:

  • Good Till Cancelled (GTC): The order remains on the order book until it is completely filled or cancelled.

  • Immediate Or Cancel (IOC): The order fills immediately to the extent possible and any remaining portion is cancelled. If partially filled, the remaining size is not
    revealed to the market.

  • Maker Or Cancel (MOC): The order is cancelled immediately if any part of it would fill on entry. If cancelled, no order information is revealed to the market.

Market (MKT) orders

Market orders are simulated by generating a series of IOC limit orders against available liquidity.

Because these orders are generated sequentially, the operation is not blocking or atomic. Available liquidity and prices may change while the market order is being
processed.

Stop-limit (STL) orders

A stop-limit order combines a trigger price with a limit price:

  • trigger_price determines when the order is activated.
  • price is the limit price used after activation.
  • time_in_force must be GTC.

An accepted stop-limit order initially has a status of active. While active, it is not placed on the order book and cannot receive fills, but the required funds are
reserved.

Mark price

Stop-limit orders are triggered using the product's mark price, rather than its last trade price alone.

The mark price is calculated as:

mark_price = median(best_bid, best_ask, last_trade_price)

For a normal, uncrossed order book, this is equivalent to constraining the last trade price to the current bid–ask spread:

best bidbest asklast trade pricemark price
99101100100
99101105101
991019599

Therefore:

  • If the last trade is between the best bid and best ask, the mark price is the last trade price.
  • If the last trade is above the best ask, the mark price is the best ask.
  • If the last trade is below the best bid, the mark price is the best bid.

This prevents a single trade outside the current spread from moving the mark price beyond the best available bid or ask. A new mark price can only be calculated when the
best bid, best ask, and last trade price are all available.

Whenever the calculated mark price changes, active stop-limit orders are evaluated:

  • A buy stop-limit order triggers when mark_price is greater than or equal to trigger_price.
  • A sell stop-limit order triggers when mark_price is less than or equal to trigger_price.

The mark price only determines when a stop-limit order is triggered. It is not the execution price and does not guarantee that the order will fill at the trigger price.

After triggering

Once triggered, the stop-limit order behaves like a GTC limit order using its specified price:

  • A buy order can execute at its limit price or lower.
  • A sell order can execute at its limit price or higher.
  • The order may fill completely, fill partially and book the remaining quantity, or book without receiving a fill.
  • Execution is not guaranteed.

Triggering does not create a new order. The original oid is retained, type remains STL, and trigger_price remains available after triggering.

Trigger-price rounding

The submitted trigger_price is rounded to the product's tick size:

  • Buy trigger prices are rounded up.
  • Sell trigger prices are rounded down.

The trigger_price returned by the API is the rounded value used to evaluate the order's trigger condition.

Limit-price bounds

A stop-limit order's limit price is validated relative to its rounded trigger price:

  • For a buy order, price must be strictly less than 125% of trigger_price.
  • For a sell order, price must be strictly greater than 80% of trigger_price.

An order at exactly either boundary is rejected.

Time-weighted average price (TWAP) orders

A TWAP order buys or sells a base-asset quantity over a fixed duration using a series of limit orders called child orders.

Execution schedule

Duration is 5 minutes to 24 hours, inclusive. The total size must be at least 11 times the minimum child size at acceptance.

The schedule starts immediately, with evenly spaced slices at least 30 seconds apart. Before placing the next child, the exchange cancels any open remainder and confirms the previous child's fills. Each slice covers the cumulative quantity due minus confirmed fills, rounded down to the permitted size increment.

Maker-only execution

By default, TWAP uses Maker Or Cancel (MOC) child orders. Buys start at the best bid and sells at the best ask. If fills fall behind, prices can move inside the spread but cannot cross it. If any part would fill on entry, the entire child is cancelled. Fills on resting orders incur maker fees.

Spread-crossing execution

To allow spread crossing, add these fields to POST /algo-orders/twap:

{
  "cross_spread": true,
  "max_slippage_bps": 100
}

When cross_spread is true, max_slippage_bps is required and must be an integer from 0 to 500 basis points. Otherwise, the API ignores it and returns 0.

Spread-crossing TWAP uses Good Till Cancelled (GTC) limit orders. A child can take liquidity from the first slice and incur taker fees. Any unfilled quantity can rest on the book and fill at the maker fee.

On schedule, buys quote at the observed best ask and sells at the observed best bid. If fills fall behind, the buy limit can rise above that ask or the sell limit can fall below that bid, up to max_slippage_bps. For example, 100 allows up to 1% and 0 allows no extra slippage. The allowance applies to each slice, not the TWAP's starting price.

Fills, completion, and cancellation

For new spread-crossing TWAP orders, filled_size counts only executed trades, not quantity removed by self-trade prevention. The TWAP children endpoint returns filled: null until the child closes and its fills are confirmed.

At expiry or cancellation, the exchange stops placing new children and requests cancellation of any open child. TWAP never extends the duration or switches to market orders. Full execution and average price are not guaranteed.

After natural completion or expiry, the final status is completed, partially_completed, or failed, depending on whether all, some, or none of the target filled.

Fills can still occur while cancellation is pending. Check cleanup_pending for unresolved execution and average_price_final to confirm the average price is final.

The exchange checks funds at acceptance but reserves them per child order.


Did this page help you?