Following up on the thread about `quantity` vs `used_quantity` (thanks for the worked example). One case that example does not cover: a symbol whose holdings() row has both settled quantity and T+1 quantity.
Example: holdings() shows `quantity: 60`, `t1_quantity: 40`, `used_quantity: 0` (the 40 were bought the previous trading day and are not yet settled). I then sell 50 shares through a CNC order the same day.
Right after the sale, what do holdings() (`quantity`, `used_quantity`, `t1_quantity`) and positions()["net"] (`quantity`, `sell_quantity`, `product`) show for that symbol? Does the sale consume settled quantity or T+1 quantity first, and does it lower `t1_quantity`, raise `used_quantity`, or both?
In the example mentioned, the holdings before the sale are:
quantity: 60 t1_quantity: 40 used_quantity: 0
After selling 50 shares through CNC on the same day, the holdings will reflect:
quantity: 10 t1_quantity: 40 used_quantity: 50
The corresponding positions()["net"] entry will show:
quantity: -50 sell_quantity: 50 product: CNC
The settled quantity is reduced from 60 to 10, while the t1_quantity remains 40. The used_quantity reflects the 50 shares sold during the day.
Therefore, the remaining holdings are represented as 10 settled shares + 40 T1 shares, while the 50-share CNC sale is reflected separately through used_quantity and the negative CNC position.
quantity: 60
t1_quantity: 40
used_quantity: 0
After selling 50 shares through CNC on the same day, the holdings will reflect:
quantity: 10
t1_quantity: 40
used_quantity: 50
The corresponding positions()["net"] entry will show:
quantity: -50
sell_quantity: 50
product: CNC
The settled quantity is reduced from 60 to 10, while the t1_quantity remains 40. The used_quantity reflects the 50 shares sold during the day.
Therefore, the remaining holdings are represented as 10 settled shares + 40 T1 shares, while the 50-share CNC sale is reflected separately through used_quantity and the negative CNC position.