research: separate S&P 400 sleeve family vs IJH (all REJECT)
After S&P 400 names failed inside the large-cap momentum top 10, test them as their own sleeve: top 30, monthly, buffer 1, 20 bp, judged by alpha vs IJH and by whether 1/3 of the book in the sleeve beats 1/3 in IJH. Four hypotheses and a control, definitions and rule written before the run. Holdout 2017-01..2026-09: mid-cap momentum -1.0%/yr vs IJH (corr 0.83 with the large-cap book), lottery-excluded momentum -1.7%, SUE earnings momentum -1.7%, quality-screened momentum +3.5% (t 1.28), quality composite +3.4% (t 1.23; book 0.91 vs 0.85 with IJH). Quality is positive in both halves but underpowered; nothing is adopted. fetch_us_fundamentals gains --universe mid: EDGAR facts for S&P 400 ever-members, CIKs accepted only when an SEC name matches the iShares holding name. fundamentals.load_mid builds the same factors on that panel. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -23,6 +23,8 @@ import pandas as pd
|
||||
|
||||
RAW = os.path.join("data", "research", "us_fund_raw.pkl")
|
||||
CACHE = os.path.join("data", "research", "us_fund_factors.pkl")
|
||||
MID_RAW = os.path.join("data", "research", "us_mid_fund_raw.pkl") # fetch_us_fundamentals --universe mid
|
||||
MID_CACHE = os.path.join("data", "research", "us_mid_fund_factors.pkl")
|
||||
|
||||
DURATION = {
|
||||
"revenue": ["Revenues", "RevenueFromContractWithCustomerExcludingAssessedTax",
|
||||
@@ -143,8 +145,8 @@ def _series_by_ticker(df: pd.DataFrame) -> dict[str, pd.DataFrame]:
|
||||
# build
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def build(p) -> dict[str, pd.DataFrame]:
|
||||
with open(RAW, "rb") as fh:
|
||||
def build(p, raw_path: str = RAW) -> dict[str, pd.DataFrame]:
|
||||
with open(raw_path, "rb") as fh:
|
||||
raw = pickle.load(fh)
|
||||
facts = raw["facts"]
|
||||
dates, tickers = p.dates, list(p.close.columns)
|
||||
@@ -282,11 +284,16 @@ def build(p) -> dict[str, pd.DataFrame]:
|
||||
return {k: v.astype("float32") for k, v in F.items()}
|
||||
|
||||
|
||||
def load(p, rebuild: bool = False) -> dict[str, pd.DataFrame]:
|
||||
if os.path.exists(CACHE) and not rebuild:
|
||||
with open(CACHE, "rb") as fh:
|
||||
def load(p, rebuild: bool = False, raw_path: str = RAW, cache: str = CACHE) -> dict[str, pd.DataFrame]:
|
||||
if os.path.exists(cache) and not rebuild:
|
||||
with open(cache, "rb") as fh:
|
||||
return pickle.load(fh)
|
||||
F = build(p)
|
||||
with open(CACHE, "wb") as fh:
|
||||
F = build(p, raw_path)
|
||||
with open(cache, "wb") as fh:
|
||||
pickle.dump(F, fh, protocol=4)
|
||||
return F
|
||||
|
||||
|
||||
def load_mid(p, rebuild: bool = False) -> dict[str, pd.DataFrame]:
|
||||
"""The same factors for the S&P 400 panel (research/lab/panel_mid.py)."""
|
||||
return load(p, rebuild, MID_RAW, MID_CACHE)
|
||||
|
||||
Reference in New Issue
Block a user