Skip to main content

bse_corp_actions.py — Corporate Actions

Downloads, parses and stores BSE's split/bonus/rights/dividend events, mirroring nseeod/corp_actions.py but against BSE's own feed and scr_bse_corp_action.

cd backend
python -m bseeod.bse_corp_actions download --dir D:/kss/stock/EODData/BSE_CA [--from-year 2020 --to-year 2026]
python -m bseeod.bse_corp_actions parse --dir D:/kss/stock/EODData/BSE_CA [--apply]
python -m bseeod.bse_corp_actions daily [--dir ...] # last 30 days + parse (Bhav Downloader hook)
python -m bseeod.bse_corp_actions stats

Source — Reverse-Engineered, No Documented API​

BSE's corporate-actions page (bseindia.com/corporates/corporate_act) has no documented API. The endpoint was found by reverse-engineering the page's Angular bundle (2026-10-11): fetched all ~55 minified JS chunks the page loads, grepped for the field names visible in the rendered table (ND_START_DATE, BC_START_DATE), found the owning component, and traced its S.BSE_Domain_APIUrl + v.url.DefaultData URL-builder call back to the DefaultData:"/DefaultData/w" entry in a shared URL-constants object.

GET https://api.bseindia.com/BseIndiaAPI/api/DefaultData/w
?scripcode=&Fdate={YYYYMMDD}&TDate={YYYYMMDD}&Purposecode=
&ddlcategorys=E&ddlindustrys=&segment=0&strSearch=S

Returns a plain JSON array. No date-range cap observed — a full year (2020-01-01..2020-12-31) returned 1,489 rows in one call, so (unlike NSE's corp_actions.py, which walks month-by-month to avoid a silent API cap) this downloads one call per year.

Fields: scrip_code, short_name, long_name, Ex_date ("02 Jan 2020"), exdate ("20200102", compact), Purpose (free text), RD_Date, BCRD_FROM, BCRD_TO, ND_START_DATE, ND_END_DATE, payment_date. No isin, no series/segment, no face value.

curl/bare HTTP clients are blocked; Python requests works

Confirmed live 2026-10-11: the endpoint returns 403 Access Denied (Akamai) to a plain curl call even with full browser headers (Referer, Origin, User-Agent) — Akamai is blocking on something below the header level, most likely TLS fingerprint. It works cleanly from Python's requests with the same headers, and from a real browser. _fetch() uses requests with the headers below; no special TLS-impersonation workaround (unlike mcxeod's curl_cffi requirement) has been needed.

_HEADERS = {
"User-Agent": "Mozilla/5.0 ...",
"Accept": "application/json, text/plain, */*",
"Referer": "https://www.bseindia.com/corporates/corporate_act",
"Origin": "https://www.bseindia.com",
}

Reuses nseeod.corp_actions's Regex Engine as a Library​

split_subject, parse_piece, _date, _num are imported directly from nseeod.corp_actions, not re-derived. They operate on generic English financial text (splitting a subject/purpose line into (kind, text) pieces, then extracting ratios/amounts/face-values per kind), not on any NSE-specific data structure — exactly the kind of shared library the approved plan called for.

BSE's Purpose text turns out to be even more directly machine-readable than NSE's subject lines for the common cases:

Purpose textParses as
"Bonus issue 1:1"BONUS, ratio 1:1, AUTO
"Stock Split From Rs.10/- to Rs.2/-"SPLIT, old_fv=10, new_fv=2, AUTO — both face values stated directly in one string
"Interim Dividend - Rs. - 12.0000"DIVIDEND, amount=12.0 — after the text-cleanup fix below

The Rs. - 12.0000 text bug​

Confirmed live bug, now fixed

Every BSE dividend Purpose string has a literal - between Rs. and the amount ("Interim Dividend - Rs. - 12.0000") — a gap nseeod.corp_actions's _RS regex doesn't expect (NSE's own phrasing is never written that way). First live test: 0 of 1,290 dividend rows parsed as AUTO — every single one fell through to REVIEW. Fixed with a BSE-specific text normalizer applied before handing text to the shared parser:

_RS_DASH_GAP = re.compile(r"((?:rs|re|inr)\.?)\s*-\s*(?=\d)", re.I)

def _clean_purpose(text: str) -> str:
return _RS_DASH_GAP.sub(r"\1 ", text or "")

After the fix: 1,287 of 1,290 AUTO (1 correctly SKIP for a nil dividend, 2 REVIEW for genuinely ambiguous text).


_Resolver — scrip_code, Not symbol​

class _Resolver:
"""scrip_code -> scr_bse_master masid. scrip_code is BSE's stable
numeric identifier (unlike a ticker symbol, it never changes), so this
is a plain dict lookup - no rename/traded-as walk needed."""

A plain {scrip_code: masid} dict built once per parse() call. No traded_as()-style walk back through a symbol-change history (unlike NSE's _Resolver, which must walk symbolchange.csv backward because NSE files old events under today's symbol) — scrip_code doesn't change, so there's nothing to walk.


parse(folder, apply=False)​

Same AUTO/REVIEW/VERIFIED/IGNORED/SKIP state machine as nseeod.corp_actions.parse(): replaces BSE_API-sourced rows in AUTO or REVIEW status; rows a human set VERIFIED/IGNORED are kept untouched. Verified idempotent live — running parse --apply twice in a row left the row count unchanged (1,392 both times).


Live-Verified Results (2020 backup, 1,392 rows)​

ActionAUTOREVIEWSKIP
BONUS3900
SPLIT2520
DIVIDEND1,28721
RIGHTS0190
OTHER0170

RIGHTS is 100% REVIEW by design — the ratio is known from the Purpose text, but the factor needs the cum-date close price, which only reconcile() (not built yet) computes.


Not Built: reconcile()​

nseeod/corp_actions.py's reconcile() — checking a parsed action against the real price series for a gap on the ex-date, snapping undocumented jumps to a known factor, and flipping low-confidence AUTO rows to REVIEW — depends on eq_store.price_windows()/price_moves(), which weren't ported to bse_store.py. Until it exists:

  • SPLIT/BONUS/DIVIDEND factors parsed as AUTO are usable but unverified against real price data (NSE's own factors are also sourced this way first — reconcile only confirms/flags, per that module's docstring — so this isn't a lower bar than NSE's day-one state, just not yet caught up to NSE's current, reconciled state).
  • RIGHTS factors stay REVIEW indefinitely (no cum-date close lookup to compute them from).
  • bse_store.get_eod(adjust=...) stays unimplemented for anything but 'none'.