> ## Documentation Index
> Fetch the complete documentation index at: https://calendar-effects.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# The big picture

> docs/architecture/01-big-picture.mmd

```mermaid theme={null}
%% Calendar Effects · 1 of 8 · The big picture. Read docs/architecture/README.md alongside.
%% Paste into Miro: Creation bar > Diagram > Build with code. Status as of 2026-11-24.
flowchart TB
  question(["THE QUESTION<br/>Do shopping events and holidays (Black Friday, Prime Day, Halloween...)<br/>make retail stocks move more than normal?<br/>And can a LIVE stream spot it as exactly as a careful BATCH study?"])

  subgraph S1["1 · Decide what to study · config/ and src/common/ · diagram 2"]
    cfg["config/ = the lists<br/>38 retailers, 6 events, Wikipedia titles, retail series<br/>Add a row to study something new, no code change"]
    rules["src/common/ = the rule book<br/>study.py: years, windows, thresholds<br/>contracts.py: the exact columns of every table"]
  end

  subgraph S2["2 · Collect and clean the data · ETL in etl/ · diagram 3"]
    dl["Download from the internet<br/>stock prices from Yahoo Finance<br/>page views from Wikipedia<br/>retail sales from FRED"]
    cl["Clean each source into one tidy table<br/>saved as Parquet in clean/"]
    master[("clean/master.parquet<br/>ONE row per stock per trading day, 2016–2025<br/>price, return, volume, views, event, labels<br/>98,046 rows")]
  end

  subgraph S3["3 · Pretend the past is happening live · Kafka · diagram 4"]
    producer["Producer: replay_master.py<br/>sends master one trading day at a time,<br/>like a news ticker, oldest first"]
    topic[["Kafka topic: calendar-effects-master<br/>a queue of JSON messages,<br/>one per stock per day"]]
  end

  subgraph S4["4 · Watch it live · Spark Structured Streaming · diagram 5"]
    job["Streaming job: src/streaming/job.py<br/>reads the topic in small micro-batches<br/>and remembers each stock's history (state)"]
    alerts[("Daily alerts · data/stream/signals<br/>was today's return abnormal?<br/>was today's attention a spike?")]
    cars[("Event CARs · data/stream/event_car<br/>how much each stock beat normal<br/>in the 11 days around each event")]
    preds[("Big-move watchlist · data/stream/predictions<br/>which retailers may move big tomorrow")]
  end

  subgraph S8["Learn and show · diagram 11"]
    model["Big-move model · src/ml/train.py<br/>Spark MLlib, learns from the daily alerts<br/>top 5% flags hit 4× more often than chance"]
    dash["Live dashboard · src/dashboard/app.py<br/>Streamlit: alerts, watchlist and CARs<br/>as the stream writes them"]
  end

  subgraph S5["5 · Work it out slowly · batch event study · diagram 6"]
    answer["car.py: the same CARs from all the data at once<br/>= the ANSWER KEY"]
    stats["stats.py: is the average real or luck?<br/>significance tests"]
    charts["charts.py: 5 charts for the report"]
  end

  compare{"6 · Check · diagram 7<br/>stream vs answer key:<br/>2,280 of 2,280 event windows equal"}

  subgraph S7["7 · Tell the story · Nov 23 – Dec 8"]
    report["Report"]
    video["Demo video"]
  end

  question --> S1
  cfg --> dl
  rules --> dl
  dl --> cl --> master
  master --> producer --> topic --> job
  job --> alerts
  job --> cars
  alerts --> model -->|loaded by the job| job
  job --> preds
  alerts --> dash
  cars --> dash
  preds --> dash
  dash --> video
  master --> answer --> stats --> charts
  cars --> compare
  answer --> compare
  compare --> report
  charts --> report
  alerts --> video
  cars --> video

  classDef done fill:#EAF3DE,stroke:#3B6D11,color:#27500A
  classDef todo fill:#F1EFE8,stroke:#5F5E5A,color:#444441
  classDef ask fill:#EEEDFE,stroke:#534AB7,color:#3C3489
  class cfg,rules,dl,cl,master,producer,topic,job,alerts,cars,preds,model,dash,answer,stats,charts,compare done
  class report,video todo
  class question ask
```

## Guide

```mermaid theme={null}
%% Calendar Effects · Guide 1 · The big picture · goes next to diagram 01-big-picture.mmd
%% Miro: paste onto a board, or Creation bar > Diagram > Build with code. Read top to bottom.
flowchart TB
  T["GUIDE 1 · THE BIG PICTURE<br/>what we ask, how it flows, who owns what"]

  subgraph S1["1 · THE TWO QUESTIONS"]
    direction TB
    q1["MARKET<br/>Around Black Friday, Prime Day...<br/>do retail stocks move more than normal?"]
    q2["COMPUTING<br/>Can a live stream get exactly<br/>the same answers as a batch study?"]
  end

  subgraph S2["2 · FOUR WORDS TO KNOW"]
    direction TB
    k1["RETURN<br/>today's price ÷ yesterday's − 1"]
    k2["THE MARKET · SPY<br/>a fund of the 500 biggest US firms"]
    k3["ABNORMAL RETURN<br/>actual − what the market predicts"]
    k4["CAR<br/>abnormal returns summed<br/>over the 11 days of an event"]
  end

  subgraph S3["3 · THE 7 STAGES · one diagram each"]
    direction LR
    s1["1 · DECIDE<br/>config/ + study.py"] --> s2["2 · COLLECT<br/>ETL → master table"] --> s3["3 · REPLAY<br/>Kafka, a day at a time"] --> s4["4 · WATCH LIVE<br/>Spark streaming job"] --> s5["5 · WORK IT OUT<br/>batch study = answer key"] --> s6["6 · CHECK<br/>2,280 of 2,280 CARs equal"] --> s7["7 · TELL<br/>report + demo video"]
  end

  subgraph S4["4 · WHO OWNS WHAT"]
    direction TB
    w1["MAHAD<br/>prices · streaming job<br/>comparison · demo video"]
    w2["SANCHI<br/>page views · master join<br/>Kafka producer · results"]
    w3["ANUSHIYA<br/>calendar · spike rule<br/>run_everything.sh · methods"]
    w4["AREEJ<br/>retail sales · batch study<br/>charts · report editing"]
  end

  subgraph S5["5 · FIRST RESULTS · mean CAR 2016–2025, same in stream and batch"]
    direction TB
    r1["BLACK FRIDAY<br/>+1.43%"]
    r2["CYBER MONDAY<br/>+0.77%"]
    r3["PRIME DAY<br/>+1.31%"]
    r4["HALLOWEEN<br/>−1.83%"]
    r5["CHINESE NEW YEAR<br/>+0.13%"]
    r6["REAL OR LUCK?<br/>quote stats.py's clustered p-values"]
  end

  T --> S1 --> S2 --> S3 --> S4 --> S5

  classDef head fill:#2C2C2A,stroke:#2C2C2A,color:#FFFFFF
  classDef ask fill:#EEEDFE,stroke:#534AB7,color:#3C3489
  classDef idea fill:#E6F1FB,stroke:#185FA5,color:#0C447C
  classDef step fill:#E1F5EE,stroke:#0F6E56,color:#085041
  classDef who fill:#F1EFE8,stroke:#5F5E5A,color:#444441
  classDef win fill:#EAF3DE,stroke:#3B6D11,color:#27500A
  classDef warn fill:#FAECE7,stroke:#993C1D,color:#712B13
  class T head
  class q1,q2 ask
  class k1,k2,k3,k4 idea
  class s1,s2,s3,s4,s5,s6,s7 step
  class w1,w2,w3,w4 who
  class r1,r2,r3,r4,r5 win
  class r6 warn
  style S1 fill:#FFFFFF,stroke:#B4B2A9
  style S2 fill:#FFFFFF,stroke:#B4B2A9
  style S3 fill:#FFFFFF,stroke:#B4B2A9
  style S4 fill:#FFFFFF,stroke:#B4B2A9
  style S5 fill:#FFFFFF,stroke:#B4B2A9
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.