TUI shows `100.00L` instead of `1.00Cr` for amounts and quantities just under a crore
Summary
When the TUI shortens an amount or a quantity to lakh or crore, anything from 99,99,500 to 99,99,999 shows as 100.00L. It should show 1.00Cr.
Steps to reproduce
I ran the kite binary built at 340dd03 against a local mock server, in a 160×40 terminal. The mock's GET /portfolio/holdings returned NSE:TCS with quantity 10,000, average price 500.02 and last price 1,500.00, so its P&L is +99,99,800.00.
- Open
kite tui. - Press
3for Portfolio.
Expected
The TCS P&L cell in Holdings shows +1.00Cr.
Actual
The Holdings row:
│▶ NSE:TCS 10000 1,500.00 +1.50Cr +100.00L +199.99% +0.67%│
+99,99,800.00 is 13 characters, too wide for the 12-cell P&L column, so the TUI shortens it, and gets +100.00L.
The functions behind it give:
| Value | compact_amount |
compact_qty |
|---|---|---|
| 99,99,499 | 99.99L |
99.99L |
| 99,99,500 | 100.00L |
100.00L |
| 99,99,999 | 100.00L |
100.00L |
| 1,00,00,000 | 1.00Cr |
1.00Cr |
The TUI uses these wherever it shortens a figure:
fit_money, for P&L and value cells too wide for their column: Holdings, Positions, Auctions, the Overview panels and tiles, and the index change on the Overview.compact_amount, in the Bids and IPO views.compact_qty, for volume and OI in Watch, Quote, Movers, the option chain, the chart and alert history, and for the market depth totals.
Cause
compact_amount picks lakh whenever the amount is under 1,00,00,000, and only then rounds to two decimals. 99.995 lakh rounds to 100.00. compact_qty does the same in its 100_000..=9_999_999 arm, and fit_money shortens through compact_amount.
I found this against a local mock server only, not a live account.