Skip to main content
src/eventstudy/charts.py · chapter The batch event study, file 4 · 256 lines · open in the repository

What it does

Final charts for the report (task #10), made from the batch event study’s outputs. car_path.png average cumulative abnormal return, day -5 to +5, per event car_by_event.png mean CAR per event with its 95% confidence interval online_vs_store.png the same, split into online and store retailers car_over_years.png mean CAR of each year’s event, per event type attention_vs_returns.png Wikipedia attention spikes against CAR, one dot per window Every confidence interval is clustered by event date (see src/eventstudy/stats.py): the retailers share each event date, so each date counts once, not once per stock. Every chart states how many events and tickers it uses. Run from anywhere after car.py and stats.py: python3 src/eventstudy/charts.py Output: data/results/charts/*.png

What is inside

  • CHARTS_DIR · line 33
  • SERIES · line 38
  • PCT · line 47
  • pct(v, digits) · line 50: +1.3% style text, without a confusing -0.0%.
  • short(name) · line 56: Display name without its bracketed alias, e.g. ‘Chinese New Year (Lunar New Year)’.
  • titled(fig, title, subtitle) · line 61: Title and subtitle above the plots, a fixed distance apart whatever the figure height.
  • zero_line(ax, vertical) · line 71
  • save(fig, name) · line 75
  • window_paths(cars) · line 82: Cumulative abnormal return on each day of each window, using the window’s own alpha and beta from car.py, so the path ends exactly at that window’s CAR.
  • mean_with_ci(values_by_date) · line 102: Mean across event dates and its confidence interval (one value per date).
  • chart_car_path(cars, names, order) · line 110
  • chart_car_by_event(summary, names, order) · line 136
  • chart_online_vs_store(summary, names, order, groups) · line 157
  • chart_car_over_years(cars, trend, names, order) · line 184
  • chart_attention_vs_returns(cars) · line 213
  • main() · line 239

Connections

Uses: src/common/contracts.py, src/common/settings.py, src/common/study.py, src/eventstudy/car.py, src/eventstudy/stats.py Used by: scripts/export_results.py, src/hosting/snapshot.py, src/hosting/publish_hf.py

Source

src/eventstudy/charts.py