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 at the best price on its own side less the offset for a buy, or plus the offset for a sell. It never rests at a price that would trade at once against the other side of the book, and never beyondprice_limit. When the best price moves by a cent or more, Lean cancels the
order and places it again at the new price. 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.
- 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. - Creating a limit chase is refused with
503 FEATURE_DISABLEDwhile trading is paused, or 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. 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.
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.