TUI shows only the first leg's quantity of an OCO GTT, so modify overwrites the second leg's
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 lossorders[1]: SELL 50 @ 1155, the target
- Run
kite gtt list. The ORDERS column isSELL 100 @ 995.00 / SELL 50 @ 1,155.00. - Open
kite tuiand go to the GTT pane. The ORDER column isSELL 100 @ 995.00. - Press
x. The confirmation's Order line isSELL 100 @ 995. PressEsc. - Press
m. The OCO ticket has one Quantity field, set to 100, and the Target section has no quantity. - Change only the SL trigger, from 1000 to 1010, and press
Enter. The review shows one line,Qty 100. - 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).TicketStatehas no field for a second quantity. build_gtt_oco_confirmwrites that one quantity into both legs, and the review has oneQtyline (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?
- Show each leg's quantity in the GTT list and the delete confirmation, as
kite gtt listdoes. - 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.