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

TUI shows only the first leg's quantity of an OCO GTT, so modify overwrites the second leg's

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

Summary

For a two-leg (OCO) GTT, the TUI shows only the first leg's quantity: in the GTT list, in the delete confirmation, and in the modify ticket and its review. If the two legs have different quantities, the TUI never shows it.

Modifying such a GTT from the TUI then sends the first leg's quantity on both legs. The second leg's quantity changes, and nothing on screen says so.

kite gtt list already shows every leg (render::gtt). kite gtt modify takes the full orders JSON, so it isn't affected.

Steps to reproduce

I ran the kite binary built at f61ecc1 against a local mock server. The mock's GET /gtt/triggers returned one active two-leg GTT on NSE:INFY:

  • trigger_values: [1000, 1150]
  • orders[0]: SELL 100 @ 995, the stop loss
  • orders[1]: SELL 50 @ 1155, the target
  1. Run kite gtt list. The ORDERS column is SELL 100 @ 995.00 / SELL 50 @ 1,155.00.
  2. Open kite tui and go to the GTT pane. The ORDER column is SELL 100 @ 995.00.
  3. Press x. The confirmation's Order line is SELL 100 @ 995. Press Esc.
  4. Press m. The OCO ticket has one Quantity field, set to 100, and the Target section has no quantity.
  5. Change only the SL trigger, from 1000 to 1010, and press Enter. The review shows one line, Qty 100.
  6. Press y.

Expected

The TUI shows each leg's quantity wherever it shows the GTT, as kite gtt list and Kite web do. Modify keeps the target leg at 50 unless I change it.

Actual

The orders field of PUT /gtt/triggers/200001, as the mock logged it:

[
  {"exchange": "NSE", "order_type": "LIMIT", "price": 995.0, "product": "CNC", "quantity": 100, "tradingsymbol": "INFY", "transaction_type": "SELL"},
  {"exchange": "NSE", "order_type": "LIMIT", "price": 1155.0, "product": "CNC", "quantity": 100, "tradingsymbol": "INFY", "transaction_type": "SELL"}
]

The target leg goes from 50 to 100, and the TUI shows a success toast ([ OK ] GTT modified: …). If the target then fires, it sells 100 instead of 50.

Cause

  • The GTT list's ORDER cell and the delete confirmation read only gtt.orders.first() (views/gtt.rs#L116, panes/gtt.rs#L118).
  • Modify fills the ticket's one quantity from the first leg. From the second leg it copies only the price and trigger (panes/gtt.rs#L171-L177). TicketState has no field for a second quantity.
  • build_gtt_oco_confirm writes that one quantity into both legs, and the review has one Qty line (ticket.rs#L1199, #L1232-L1240, #L1269).

Proposal

Kite web keeps the two quantities separate:

  • Its OCO GTT form has its own "Qty." field for Stoploss and for Target.
  • It accepts different quantities. A SELL OCO on NSE:INFY with Stoploss 10 and Target 5 was saved as active with those quantities.
  • Its GTT list shows both quantities.
  • Its Modify form shows both, in separate editable fields.

Would you take a PR that brings the TUI in line with Kite web?

  1. Show each leg's quantity in the GTT list and the delete confirmation, as kite gtt list does.
  2. Give the OCO ticket a quantity for each leg, fill both from the stored GTT on modify, and show both in the review.

I found the TUI behaviour against a local mock only. I haven't run the TUI against a live GTT.

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