corporate-action-adjuster
/corporate-action-adjuster
Restate a share trade history for stock splits and bonus issues so that share counts, cost per share and holding periods are correct before computing capital gains. Use when the user's holdings went through a split, face-value split or bonus issue, when a capital-gains run fails because sells exceed buys, when the share count in the trade file does not match the demat statement, or before any tax calculation on a long-held Indian portfolio.
- Author
- krish-vd ↗
- Repository
- claude-quant-skills ↗
- Licence
- MIT
- Last repository change
- 12.11.2026
Assessment and security
- Files in this package
- 3
- Scripts
- 2
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 12.11.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
- 2 scripts in this package. Review them before installing, as Claude may execute them.
Scripts: scripts/adjust_trades.py, scripts/fetch_actions.py
What it does and when to use it
Restate a share trade history for stock splits and bonus issues so that share counts, cost per share and holding periods are correct before computing capital gains. Use when the user's holdings went through a split, face-value split or bonus issue, when a capital-gains run fails because sells exceed buys, when the share count in the trade file does not match the demat statement, or before any tax calculation on a long-held Indian portfolio.
Original author description
Restate a share trade history for stock splits and bonus issues so that share counts, cost per share and holding periods are correct before computing capital gains. Use when the user's holdings went through a split, face-value split or bonus issue, when a capital-gains run fails because sells exceed buys, when the share count in the trade file does not match the demat statement, or before any tax calculation on a long-held Indian portfolio.
How it works
- What it does
- After running it
- Limits
SKILL.md preview
---
name: corporate-action-adjuster
description: Restate a share trade history for stock splits and bonus issues so that share counts, cost per share and holding periods are correct before computing capital gains. Use when the user's holdings went through a split, face-value split or bonus issue, when a capital-gains run fails because sells exceed buys, when the share count in the trade file does not match the demat statement, or before any tax calculation on a long-held Indian portfolio.
---
# Corporate Action Adjuster
A tradebook only records trades. After a split or bonus the demat account holds more shares than were ever bought, so FIFO matching either fails ("sell exceeds the buys supplied") or uses the wrong cost. Run this between `tradebook-importer` and `india-capital-gains`.
```bash
# 1. Look the actions up on NSE (bonus issues and splits since each symbol's first trade)
python scripts/fetch_actions.py --trades trades.csv --output actions.csv
# 2. Apply them
python scripts/adjust_trades.py --trades trades.csv --actions actions.csv --output trades_adjusted.csv
```
`fetch_actions.py` reads NSE's corporate-actions list. It writes the bonuses and splits it could read into `actions.csv` and reports everything else under `needs_manual_handling` (demergers, rights issues, buybacks, and any bonus or split whose wording it could not parse). **Show the user both lists** and have them confirm the ratios against the company announcements before step 2. You can also write `actions.csv` by hand:
`actions.csv`:
```csv
symbol,date,type,ratio
INFY,2018-09-04,bonus,1
RELIANCE,2024-10-28,bonus,1
TCS,2018-05-31,bonus,1
HDFCBANK,2019-09-19,split,2
```
- `date` is the **ex-date**.
- `split` ratio = new shares for each old share. One share becoming five is `5`; a face-value split from Rs 10 to Rs 2 is also `5`; from Rs 2 to Rs 1 is `2`.
- `bonus` ratio = bonus shares per share held. 1:1 is `1`; 1:2 (one for every two held) is `0.5`; 2:1 (two for each one held) is `2`.
**Get the ratio convention right.** Indian announcements write bonus ratios as "bonus:held", so "1:2" means one bonus share for two held. If the user quotes a ratio, confirm which way round it is, and check the resulting share count against their demat holding. The example rows above show the format only: take dates and ratios from the company's announcement or the exchange's corporate-actions page, not from memory.
## What it does
- **Split:** every trade before the ex-date is restated, quantity multiplied and price divided. Total cost and purchase dates do not change.
- **Bonus:** a new buy row is added on the ex-date at zero cost, for the shares held at that date. For tax, bonus shares cost nothing and their holding period starts on allotment, so they can be short-term while the original shares are long-term.
`actions_applied` lists what was done, including any fractional entitlement that was dropped (companies pay cash for fractions).
## After running it
1. Compare the total shares per symbol with the demat statement. A mismatch means a missed action or missing trades.
2. For shares bought before 1 Feb 2018, the 31-Jan-2018 fair market value used for grandfathering must be on the same post-split, post-bonus basis. Restate it for later actions before passing it to `india-capital-gains`.
3. Then compute gains on the adjusted file.
## Limits
Not handled: demergers (cost must be split between the companies in the ratio the company notifies), mergers and amalgamations (new symbol, carried-over cost and date), rights issues (a purchase the user should enter as a buy row at the rights price), and buybacks. For those, edit the trade file by hand from the company's notice and tell the user that is what is needed. The lookup covers NSE under the company's current symbol: a renamed or merged company may need its earlier history added by hand, and BSE-only stocks are not covered.
Files in this package (3)
- SKILL.md 4 KB
- scripts/adjust_trades.py 4 KB
- scripts/fetch_actions.py 4 KB
Versions
The database has no other skills named corporate-action-adjuster.
Database snapshot: 13.11.2026 · package version c7e42ec7df02 (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 100india-capital-gains
Compute capital gains for an Indian resident from a trade history - FIFO lot matching, short-term vs long-term classification, the 31 January 2018 grandfathering rule, the Rs 1.25 lakh equity exemption, and tax at 20% / 12.5% - for listed Indian shares and equity mutual funds,… - 100dk-capital-gains
Denmark capital gains tax: 27%/42% on share gains, progression threshold, inventory taxation for certain shares, real property gains. Trigger on: \"Denmark CGT\", \"capital gains Denmark\", \"Denmark aktieindkomst\", \"sell shares Denmark\", \"Denmark 27% 42% capital gains\",… - 100tradebook-importer
Convert a broker tradebook or trade history export (Zerodha, Groww, Upstox, Angel, Dhan, ICICI Direct, or any CSV with date, symbol, buy/sell, quantity and price) into the standard trade CSV used for capital gains, separating intraday round trips and setting F&O rows aside. Use… - 100es-capital-gains
Spain capital gains tax: savings income rates (19%–28%), holding period, main residence exemption, reinvestment relief. Trigger on: \"Spain CGT\", \"capital gains Spain\", \"Spain savings tax rate\", \"sell shares Spain\", \"IRPF capital gains\", \"Spain property CGT\", \"Spain… - 100canada-capital-gains
Adjusted cost base (average cost), realized capital gains/losses per year and superficial loss warnings for a Canadian non-registered account. Use when the user asks "what's my ACB", "how much tax if I sell", "capital gains", "superficial loss", or uploads a trades CSV. - 100us-income-tax
Estimate US federal income tax for 2026 including long-term capital gains, and capital gains rules (holding period, wash sale, loss limit). Use when the user asks "how much federal tax will I owe", "what tax bracket am I in", "tax on selling stock", "wash sale", or gives a US salary.