CEF pass: universe (SEC report, 973 -> 295 listed) + stage 1 screen + stage 2a character

fundlab/cef_universe.py: SEC 'Closed-End Fund Information' report
(973 active CEFs) + company_tickers CIK join -> 295 listed common
classes (preferreds and 6(c)-converted companies flagged).  Supersedes
the N-2 full-index approach (N-2/A annual updates + 404ing index
paths).  Prices via goget.

fundlab/cef_screen.py: 290 screened - t5/t12, vol5, maxdd5, the 5
crash episodes, 12m payout proxy.  Energy/midstream CEFs (EMO +305%,
SRV +234%, NML +232%) top return AND crash resilience; Voya
Dividend-Premium series (IGD maxDD -16%); EM CEFs volatile + 14-24%
dist; long-dur munis -26..-42%.

fundlab/cef_character.py: 50-fund shortlist, 35-sleeve character +
crude tax_arb = character x (upside + 0.4 x vol).

Tests: 6 new cef checks (105 total).  RESEARCH.md: CEF form facts
(N-2ASR, N-PX, N-23C-3A, BDC caveats) + remaining stage 2b work.
This commit is contained in:
gmp
2026-08-27 22:24:12 -04:00
parent f8409fff7a
commit d1e85026bf
33 changed files with 11600 additions and 0 deletions
+35
View File
@@ -576,6 +576,40 @@ def test_drawdown() -> None:
check("fund_windows callable", callable(w), "")
def test_cef() -> None:
import numpy as np
import pandas as pd
from fundlab import cef_screen, cef_character
print("\ncef")
# _perf: flat market price, total-return line +30% over 3y -> the
# whole return is payout, maxDD ~ 0 (monotone up)
n = 3 * 252
idx = pd.bdate_range("2023-01-02", periods=n)
adj = 100.0 * (1 + np.arange(n) / 252 * 0.10)
p = cef_screen._perf(pd.DataFrame({"Close": 100.0,
"Adj Close": adj}, index=idx))
check("_perf t5 approx +30% (3y window)",
p["t5"] is not None and 0.29 < p["t5"] < 0.31, f"{p['t5']}")
check("_perf payout_12m == t12 - p12",
abs(p["payout_12m"] - (p["t12"] - p["p12"])) < 1e-12,
f"{p['payout_12m']}")
check("_perf vol5 positive", p["vol5"] is not None and p["vol5"] > 0)
check("_perf maxdd5 <= 0 (monotone up -> ~0)",
p["maxdd5"] is not None and p["maxdd5"] <= 1e-9,
f"{p['maxdd5']}")
# select(): top return + resilient + payout; NON_FUNDS excluded
scr = {
"AAA": {"sym": "aaa", "t5": 0.5, "n_pos_scen": 0, "payout_12m": 0.0},
"BBB": {"sym": "bbb", "t5": 0.4, "n_pos_scen": 4, "payout_12m": 0.0},
"CCC": {"sym": "ccc", "t5": -0.5, "n_pos_scen": 0, "payout_12m": 0.2},
"CFND": {"sym": "cfnd", "t5": 0.9, "n_pos_scen": 0, "payout_12m": 0.0},
}
sel = cef_character.select(scr)
check("select excludes NON_FUNDS", "cfnd" not in sel, str(sel))
check("select includes top return + resilient + payout",
{"aaa", "bbb", "ccc"} <= set(sel), str(sel))
def main() -> int:
test_pool()
test_text_and_objective()
@@ -590,6 +624,7 @@ def main() -> int:
test_xcheck()
test_taxplan()
test_drawdown()
test_cef()
test_edgar_live()
print(f"\n{PASS} passed, {FAIL} failed")
return 1 if FAIL else 0