commit 0f1be9a122a74a73dad174c7e1a7cdc56dd4802b
parent f31da659e995ca77a474320d1efc92cf1811bf93
Author: Erik Loualiche <eloualic@umn.edu>
Date: Sun, 22 Mar 2026 16:56:26 -0500
Fix flaky EventStudy test, restrict CI to tag pushes only [skip ci]
- EventStudy: use seed!(42) and increase event injection from 5% to 20%
so CAR test reliably passes across platforms
- CI: trigger only on v* tag pushes (saves WRDS query costs)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Diffstat:
2 files changed, 9 insertions(+), 18 deletions(-)
diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml
@@ -2,21 +2,8 @@
name: CI
on:
push:
- branches:
- - main
tags:
- - "*"
- paths:
- - "src/**"
- - "test/**"
- - "Project.toml"
- - ".github/workflows/CI.yml"
- pull_request:
- paths:
- - "src/**"
- - "test/**"
- - "Project.toml"
- - ".github/workflows/CI.yml"
+ - "v*"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
diff --git a/test/UnitTests/EventStudy.jl b/test/UnitTests/EventStudy.jl
@@ -2,6 +2,9 @@
import Dates: Date, Day
import Statistics: mean
+ import Random: seed!
+
+ seed!(42) # deterministic random draws
# Build synthetic daily returns panel: 2 firms, 300 trading days
dates = Date("2010-01-04"):Day(1):Date("2011-04-01")
@@ -20,9 +23,10 @@
mkt_returns = 0.0005 .+ 0.008 .* randn(n)
df_ret.mktrf = vcat(mkt_returns, mkt_returns)
- # Inject a positive event: +5% abnormal return on event day for firm 1
+ # Inject a large positive event: +20% abnormal return on event day for firm 1
+ # Must be large enough to dominate cumulative noise over the 21-day event window
event_idx_firm1 = 270 # well within bounds for estimation window
- df_ret.ret[event_idx_firm1] += 0.05
+ df_ret.ret[event_idx_firm1] += 0.20
events = DataFrame(
permno = [1, 2],
@@ -39,8 +43,8 @@
@test !ismissing(result.car[1])
@test !ismissing(result.car[2])
@test result.n_obs[1] == 21 # -10 to +10 inclusive
- # Firm 1 should have positive CAR (we injected +5%)
- @test result.car[1] > 0.03
+ # Firm 1 should have positive CAR (we injected +20%)
+ @test result.car[1] > 0.10
end
# ---- Market model ----