T-83: M1.4b — Pure event-study math in @stock-bot/calculations: abnormal-return fan (AAR/CAAR) around events, date-clustered Newey-West t-stat and pre/post-2023 split (no I/O)

This commit is contained in:
Studio 2026-11-28 02:16:23 -05:00
parent ff0c5574a4
commit 1a2396916e
5 changed files with 2398 additions and 2 deletions

View file

@ -57,8 +57,11 @@ const risk = returnStatistics(returns);
and cross-sectional Signal Analysis (`analyzeSignalPanel`, `crossSectionIc`,
`neweyWestMeanTest`, `defaultNeweyWestLag`, `summarizeIcSeries`, `evaluateRecencyGate`,
`SignalAnalysisError`, `DEFAULT_MIN_CROSS_SECTION`, `DEFAULT_QUANTILE_COUNT`,
`RECENCY_SPLIT_DATE`, `RECENCY_MIN_RATIO`) are exported from both `./analytics` and
the root entry.
`RECENCY_SPLIT_DATE`, `RECENCY_MIN_RATIO`), plus pure Event-Study math (`eventDayIndex`,
`eventStudy`, `EventStudyError`, `DEFAULT_EVENT_PRE_DAYS`, `DEFAULT_EVENT_POST_DAYS`,
`DEFAULT_EVENT_MIN_EVENTS`) with date-clustered Newey-West significance, R-7 CAR
percentile fans, and a sign-preserving post-2023 recency gate, are exported from both
`./analytics` and the root entry.
## Benchmark
@ -85,6 +88,20 @@ Observed locally on Bun 1.2.16 (2 runs, seed `20260402`): `1,779.96 ms`
`8,353,819 observations/s`), `meanRankIc = 0.057294`, `rankIcTStat = 218.5078`,
`spreadMean = 0.003369`, `recencyGatePassed = true`.
Run the fixed-seed Event Study benchmark (`2,000` entities × `5,040` sessions,
`200,000` events, window `-10..+20`, covering full `eventStudy` with benchmark-adjusted
AAR/CAAR, R-7 CAR percentile fans, date-clustered Newey-West HAC, and recency gate):
```sh
bun run test:calculations
```
Observed locally on Bun 1.2.16 (2026-11-28, seed `20260404`):
```text
[event-study benchmark] events=200000 window=-10..+20 elapsedMs=608.09 events/s=328896
```
The root entry exports the supported returns, indicators and market-data helpers.
Use subpaths to avoid loading unrelated math. Shared domain types remain owned by
`@stock-bot/types`; HTTP/date/proxy helpers remain in `@stock-bot/utils`.

File diff suppressed because it is too large Load diff

View file

@ -54,3 +54,27 @@ export type {
SignalPanelDiagnostics,
TurnoverResult,
} from './signal-analysis';
export {
DEFAULT_EVENT_MIN_EVENTS,
DEFAULT_EVENT_POST_DAYS,
DEFAULT_EVENT_PRE_DAYS,
EventStudyError,
eventDayIndex,
eventStudy,
} from './event-study';
export type {
DateClusteredCarResult,
EventCarSeries,
EventDayIndexResult,
EventStudyDiagnostics,
EventStudyErrorCode,
EventStudyEvent,
EventStudyInput,
EventStudyOffsetStats,
EventStudyOptions,
EventStudyPercentiles,
EventStudyRecencyGate,
EventStudyRecencyReason,
EventStudyRecencyResult,
EventStudyResult,
} from './event-study';

View file

@ -56,10 +56,14 @@ export {
groupBySymbol,
} from './market-data';
export {
DEFAULT_EVENT_MIN_EVENTS,
DEFAULT_EVENT_POST_DAYS,
DEFAULT_EVENT_PRE_DAYS,
DEFAULT_MIN_CROSS_SECTION,
DEFAULT_QUANTILE_COUNT,
DSR_VALIDATION_GATE,
EULER_MASCHERONI,
EventStudyError,
RECENCY_MIN_RATIO,
RECENCY_SPLIT_DATE,
SignalAnalysisError,
@ -69,6 +73,8 @@ export {
deflatedSharpeRatio,
effectiveIndependentTrials,
evaluateRecencyGate,
eventDayIndex,
eventStudy,
inverseNormalCdf,
neweyWestMeanTest,
normalCdf,
@ -79,11 +85,25 @@ export {
export type {
CrossSectionIcOptions,
CrossSectionIcResult,
DateClusteredCarResult,
DeflatedSharpeInput,
DeflatedSharpeResult,
EffectiveTrialsResult,
EntityId,
EntityIdSeries,
EventCarSeries,
EventDayIndexResult,
EventStudyDiagnostics,
EventStudyErrorCode,
EventStudyEvent,
EventStudyInput,
EventStudyOffsetStats,
EventStudyOptions,
EventStudyPercentiles,
EventStudyRecencyGate,
EventStudyRecencyReason,
EventStudyRecencyResult,
EventStudyResult,
IcSummary,
IcSummaryOptions,
NeweyWestResult,

File diff suppressed because it is too large Load diff