Class CorporateEvents
The plain idea: on an ex-date the share price drops (or jumps) for a
mechanical reason, not because the holder gained or lost anything. Every
bar before the ex-date is multiplied by one factor so that the adjusted
series moves exactly like a holder's wealth would, assuming anything
paid out is reinvested in the same stock at the theoretical ex price.
CorporateActions keeps handling the 2.1 split and cash-dividend
cases; this class adds the rest.
Formally, with P the last close before the ex-date, the price
factor f applied to all earlier bars is:
CorporateEvents.StockDividend(bonus issue, ratebnew per old):f = 1 / (1 + b), volume times(1 + b).CorporateEvents.ReverseSplit(kold shares become 1):f = k, volume divided byk.CorporateEvents.Dividend(regular or special, amountd):f = (P - d) / P. Which kinds adjust is set byCorporateEvents.DividendPolicy.CorporateEvents.SpinOff(rchild shares per parent share, child reference priceC):f = (P - rC) / P.CorporateEvents.RightsIssue(rnew shares per old at subscription priceS): the theoretical ex-rights price isTERP = (P + rS) / (1 + r)andf = TERP / P.CorporateEvents.SymbolChange:f = 1; the output series takes the latest symbol.CorporateEvents.CashStockMerger: terminal for the target. No factor; the position side is inCorporateEventPositions.
Worked example (own test, CorporateEventsTest): a rights issue
of 1 new for 4 held at 80 with the stock at 100 gives
TERP = (100 + 0.25 * 80) / 1.25 = 96, so f = 0.96 and a
cum-rights close of 100 becomes 96 on the adjusted tape.
totalReturnError(BarSeries, BarSeries, List) checks the factors against an independent
share-count simulation of a reinvesting holder and returns the largest
per-bar gap between the two return series.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordCash-and-stock merger with holder election and proration.static final recordCash dividend tagged regular or special.static enumRegular or special cash dividend.static enumWhich dividends enter the back-adjustment.static interfaceA corporate event effective from its ex timestamp.static final recordReverse split:oldPerNewold shares are consolidated into one.static final recordRights issue:rationew shares per old share atsubscriptionPrice.static final recordSpin-off of a new instrument.static final recordStock dividend or bonus issue:ratenew shares per share held (0.05 = 5 %).static final recordSymbol and/or ISIN change; no economic effect. -
Method Summary
Modifier and TypeMethodDescriptionstatic BarSeriesadjust(BarSeries series, List<? extends CorporateEvents.Event> events) Back-adjusts withCorporateEvents.DividendPolicy.ALL.static BarSeriesadjust(BarSeries series, List<? extends CorporateEvents.Event> events, CorporateEvents.DividendPolicy policy) Returns a new back-adjusted series; the input is untouched.static doublepriceFactor(CorporateEvents.Event event, double prevClose, CorporateEvents.DividendPolicy policy) Price factor for one event given the last cum closeprevClose; returns 1 for events that do not adjust underpolicy.static doubleterp(double cumPrice, CorporateEvents.RightsIssue rights) Theoretical ex-rights price(P + rS) / (1 + r).static doubletotalReturnError(BarSeries raw, BarSeries adjusted, List<? extends CorporateEvents.Event> events) Total-return consistency check.static doubleVolume factor applied to bars before the ex-date (share-count changes only).
-
Method Details
-
priceFactor
public static double priceFactor(CorporateEvents.Event event, double prevClose, CorporateEvents.DividendPolicy policy) Price factor for one event given the last cum closeprevClose; returns 1 for events that do not adjust underpolicy. -
volumeFactor
Volume factor applied to bars before the ex-date (share-count changes only). -
terp
Theoretical ex-rights price(P + rS) / (1 + r). -
adjust
Back-adjusts withCorporateEvents.DividendPolicy.ALL. -
adjust
public static BarSeries adjust(BarSeries series, List<? extends CorporateEvents.Event> events, CorporateEvents.DividendPolicy policy) Returns a new back-adjusted series; the input is untouched. Factors compound from the latest event backwards, prevClose is always the raw close, and the result takes the lastCorporateEvents.SymbolChangesymbol. -
totalReturnError
public static double totalReturnError(BarSeries raw, BarSeries adjusted, List<? extends CorporateEvents.Event> events) Total-return consistency check. Simulates a holder of one share who reinvests every payout (dividends, spin-off shares sold at the child price, rights sold at their theoretical value) at the theoretical ex price, and compares that wealth path's close-to-close returns with the adjusted series. Returns the largest absolute return gap; withCorporateEvents.DividendPolicy.ALLit should be at rounding level.
-