kite-cli icon indicating copy to clipboard operation
kite-cli copied to clipboard

TUI order ticket shows `[ OK ]` for an autoslice order and hides slices that Kite rejected

Open jay-tau opened this issue 2 weeks ago • 0 comments

Summary

When an order placed from the TUI order ticket is autosliced, the TUI shows [ OK ] order placed: <order_id> even if Kite rejected some of the slices. The rejected slices and their errors aren't shown. The ticket turns autoslice on by itself when the quantity is above the instrument's freeze quantity, so this can happen even if the user never turned autoslice on.

#5 fixed the same gap in kite orders place --autoslice, and noted that the TUI fix would follow separately.

Steps to reproduce

These steps use the TUI's test harness (src/tui/app/test_support.rs) with an httpmock server, not a running kite binary.

  1. Serve autoslice_response.json for POST /orders/regular, matching only when the form has autoslice=true. In that response, the third of four children is an error: MarginException, "Insufficient funds. Required margin is 228365.92 but available margin is 228358.50." Counting the top-level order as slice 1, as #5 does, that's slice 4 of 5.
  2. Open a BUY ticket for NSE:INFY with a freeze quantity of 1800. Leave autoslice off, and enter quantity 9000 and a LIMIT price of 1500.
  3. Press Enter to review, then y to confirm.

Expected

The toast says that a slice failed, and why. It doesn't show a plain [ OK ].

Actual

The request carries autoslice=true (the mock matches only that), and the toast row at 160 columns is:

 [ OK ] order placed: 1914227164488687616                                                                                                            Ctrl-L log

The event log (Ctrl-L) has the same line. Nothing mentions the rejected slice.

Cause

spawn_place_order keeps only order_id from the reply, so children is never read. on_order_result then shows a success toast. The ticket sends autoslice=true whenever the quantity is above the freeze quantity (effective_autoslice / autoslice_forced).

A reply from the AMO retry in place_with_amo_fallback goes through the same code.

Found using the kiteconnect-mocks fixtures only. I haven't placed a live autoslice order.

jay-tau avatar Nov 12 '26 10:11 jay-tau