Showing corporate actions

How the Math Engine Works

Trade Console uses an advanced mathematical engine to convert thousands of raw broker trades into a perfect accounting ledger. Here is exactly how the data is processed:

1. The FIFO Ledger (First-In, First-Out)

The engine sorts every trade you've ever made chronologically. When you sell 100 shares of a stock, the engine "looks back" in time and mathematically consumes the oldest 100 shares you bought. This is the industry-standard accounting method for calculating true realized P&L.

2. Intraday vs. Delivery Prioritization

Before the FIFO engine looks back into history, it specifically scans the exact day of the trade. If it finds a Buy and a Sell for the same asset on the exact same date, it matches them together instantly as an Intraday Trade. Only the "leftover" shares spill over into the Delivery queue.

3. Active Positions & Live Margins

  • Invested: For Equity, this is simply your Qty * Average Buy Price.
  • Margin Used: For F&O Shorts, the engine pings Angel One's live Margin API to get the exact overnight span + exposure margin required for your specific strike price.
  • Live CMP: When you click Refresh, the system connects to the live market to pull the Current Market Price for all open assets and calculates live Unrealized P&L.

4. Corporate Actions & Stock Splits

Split adjustment is applied to all trades (both buy and sell) that occurred before the split ex-date. This restates both sides to post-split equivalents before FIFO runs — ensuring stocks fully bought and sold pre-split show zero open position rather than phantom shares.

5. The Options Settlement Engine

If you short an option and let it expire, brokers often don't provide an Exit record in your CSV. Trade Console detects expired options, fetches historical closing prices of the underlying from Yahoo Finance for the exact expiration date, calculates whether the option expired ITM or OTM, and automatically generates the correct settlement exit.

6. IIFL F&O Symbol Handling

IIFL stores option contracts as separate columns (Code, Expiry, Strike, OptionType). Trade Console reconstructs the full contract symbol (e.g. COFORGE26FEB1440PE) so that each individual strike gets its own independent FIFO queue rather than being pooled together.

7. The Strategy Recommendation Engine

In the Closed History tab, the engine calculates the exact number of days you held an asset and automatically suggests strategies:

  • 0DTE: Buy and sell an option on the exact same day.
  • Overnight pre-expiry: Short an option and hold it exactly 1 day.
  • Long-term Holding: Any asset held more than 180 days.
NET P&L
₹0
TODAY'S GAIN
₹0
CURRENT HOLDINGS
₹0
MARGIN USED
₹0
TRADES / POSITIONS
0
No data loaded.
Tip Press Ctrl+K to open the command palette.