lighter is
refused with 422 and reason NO_EXECUTABLE_VENUE. This example uses a test key, so nothing real
moves:
Give at most one of
offset_ticks, offset_price, offset_shares and offset_beat_best. The
limit chase reads back the one it uses and null for the others, with offset_beat_best false
unless it beats the best price.
A limit chase made in the Lean app can instead rest as far back as it can within a set distance of
the midpoint. It reads back that distance in dollars as offset_midpoint, which is null for
every other limit chase. A request cannot set offset_midpoint, but an edit can keep it by leaving
the offset out or replace it with one of the offsets above. On Polymarket the midpoint is the one
Polymarket uses for liquidity rewards, which leaves out small orders at the top of the book.
The key needs the trade scope. The answer is 200 with the limit chase, which reads active
while it follows the book. current_price is the price the order rests at now, and is null while
the chase waits for a book to follow.
How the order moves
Lean places the order where its offset puts it relative to the best price on its own side: behind it byoffset_ticks or offset_price, inside the queue depth offset_shares allows, or one tick
better with offset_beat_best. On Polymarket and Hyperliquid a buy rests higher when needed to stay
worth at least 1 USD. It never rests at a price that would trade at once against the other side of
the book, and never beyond price_limit. When its target price moves by a price tick or more, Lean
moves the order there, waiting 2 seconds after the last move unless the order would otherwise trade
at once or sit beyond price_limit. With offset_shares, it moves by the queue ahead of it rather
than by each price change. On Kalshi the order is changed in place; on other venues Lean cancels it
and places it again. Each fill adds to filled_quantity and
avg_fill_price, and the rest keeps following the book.
Limits on what can be traded
- A sell takes shares the account holds, and shares already offered by a resting sell order or
covered by a stop loss count as taken. A sell above what is left is refused with
400 VALIDATION_ERROR. - A test key’s buy needs enough simulated cash on the venue for
quantityshares atprice_limit, or at $1 a share without one, and is refused with400 VALIDATION_ERRORotherwise. A live key’s buy is not checked against the account’s cash when you create it, so checkGET /v1/balancesfirst: the venue refuses an order the account can’t pay for. - An order must be at least the market’s minimum number of shares. On Hyperliquid it must also fit
the venue’s size step. On Polymarket and Hyperliquid, a buy with a
price_limitmust be worth at least 1 USD at that price. - The market must be open and must trade on the venue you name. A market that cannot be traded on
that venue is refused with
422 VALIDATION_ERRORanddetails.reason: "NO_EXECUTABLE_VENUE", and a venue the trading account does not allow withdetails.reason: "VENUE_NOT_ALLOWED". - A limit chase counts against the key’s limits as an order of the most it can trade for, from when
it is created: a buy as
quantityshares atprice_limit, or at the top price of $1 a share without one, and a sell at that same top price. A buy above the key’s per order limit is refused withdetails.reason: "ORDER_NOTIONAL_LIMIT", and one past the key’s or account’s daily limit withdetails.reason: "DAILY_NOTIONAL_LIMIT". A sell counts toward the day too, but only takes risk off, so neither limit refuses it. A test key’s limit chases count against its own limits. - With a live key, a limit chase is refused with
403 FORBIDDENwhen the account can’t trade on the venue: for example, on Kalshi and Polymarket US no API key is connected in the Lean app, or on Polymarket the wallet isn’t set up or its approvals need refreshing in the Lean app. - Creating a limit chase is refused with
503 FEATURE_DISABLEDwhile trading is paused, or, for a live key, while Lean has paused limit chases on the venue. See Pause trading.
Track and cancel
GET /v1/limit-chases lists the limit chases of the key’s trading account, newest first: every one
still active, and those that ended in the last hour. A live key also sees the limit chases made in
the Lean app on that account. Kalshi and Polymarket US limit chases belong to you rather than to a
trading account, so a live key sees all of yours on those venues. GET /v1/limit-chases/{id} reads one.
Cancel one with DELETE /v1/limit-chases/{id}:
200 with the limit chase and cancel_requested_at set. A live limit chase keeps its
status for a moment while Lean cancels its resting order, then reads canceled. A test limit chase
reads canceled at once. Canceling works while trading is paused, and a limit chase that has
already ended is refused with 400 VALIDATION_ERROR.
Pausing trading does not stop a limit chase that is already on the book. Cancel it if you want it
gone.
Change a limit chase
Change the size, offset or price limit of a limit chase withPATCH /v1/limit-chases/{id}. It
keeps its id, and fields you leave out keep their values:
The new values are checked as they are when you create one. A buy is checked as a whole against
your per order limit, and whatever the edit adds to the most it can trade for, from a larger size
or a higher or removed
price_limit, counts toward your day. The answer is 200 with the limit chase as
edited. A live one answers with edit_pending: true and moves its resting order a moment later.
Read it by id to confirm: once Lean applies the edit, edit_pending turns false. If Lean refuses
the edit, for example because fills overtook a smaller size, the limit chase keeps its earlier
values and last_error says why. A list shows a pending edit the same way, though it can trail an
edit accepted a moment earlier.
On Kalshi, Lean changes the resting order in place rather than canceling and placing it again, so a
smaller size at the same price keeps its place in the queue. Only an active limit chase can
change: one that has ended is refused with 400 VALIDATION_ERROR, and one with a cancel pending with 409 CONFLICT.
A limit chase that changed while you edited it also answers 409 CONFLICT on test and live keys
alike, and so does a live one whose earlier edit is still pending; send the edit again.
Test keys
A test key’s limit chase is checked like a live one, against the market and the test account’s simulated cash and shares. It follows the venue’s public book and fills in simulation once the best price on the other side reaches its price. It is brought up to date with the book each time you list or read it, so its price and fills change between reads. It never reaches the venue, and its fills show in the test account’s positions and balances. See Test mode and live mode.Fills
A limit chase is not an order you placed, so its fills are listed inGET /v1/fills with order_id
set to null, and GET /v1/fills?order_id= never returns them. A live key sees each fill the venue
reports for the chase’s resting order. A test key sees one fill per limit chase for what it has
filled so far, at avg_fill_price, with liquidity maker and filled_at the time the chase was
created. It is listed once something fills and grows as more fills, keeping the same id.