Add tools/undervalued.py: trading strategy, goods priced below production cost
Finds manufactured goods currently selling below their implied production cost (live input cost vs output price) - candidates to buy and hold for a price-reversion bounce, the mirror of the "is this worth building" question saturation.py already answers. Backtested first (326 output tickers, 287 deduplicated dip-onset episodes across 112 distinct tickers): +3mo forward return mean +21.3%/median +8.9%/73.2% hit rate at >=10 units/day volume - real signal, not noise, but only ~0.10-0.24%/day, far below the 14-29%/day marginal ROI this session's production builds found. Documented prominently in the tool's own docstring and CLAUDE.md so it doesn't get mistaken for a primary strategy - it's for excess idle capital once better-yielding builds are exhausted, not before. Promoted daily_prices() out of tools/history.py into puga/history.py so both tools share it, per the self-improve rule. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Manufactured goods currently selling below their implied production cost (output price minus
|
||||
live input cost) - candidates to buy and hold for a price-reversion bounce, not to build.
|
||||
|
||||
EXPECTED ROI IS MUCH LOWER THAN THIS PROJECT'S PRODUCTION BUILDS. Backtest (2026-10-09, 326
|
||||
output tickers, 287 independent dip-onset episodes across 112 distinct tickers, >=10 units/day
|
||||
volume): +3 months forward price return mean +21.3%, median +8.9%, 73.2% of episodes positive.
|
||||
That's ~0.10-0.24%/day, or very roughly ~41%/year if you could always immediately redeploy into
|
||||
a new dip (optimistic) - versus 14-29%/day marginal ROI on the production buildings this toolkit
|
||||
has been recommending. Gross price return only, no spread/freight/storage-fee/capital-lockup cost
|
||||
subtracted. Only deploy EXCESS capital here once better-yielding builds are exhausted - this is
|
||||
not a primary strategy.
|
||||
|
||||
tools/undervalued.py # AI1, min 5 units/day traded
|
||||
tools/undervalued.py --cx AI1 --min-vol 10 --top 10
|
||||
"""
|
||||
import argparse, sys
|
||||
from pathlib import Path
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
||||
from puga import config, undervalued
|
||||
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--cx", default=config.DEFAULT_CX)
|
||||
ap.add_argument("--min-vol", type=float, default=5.0, help="min units/day traded (noise filter, thin markets won't revert reliably)")
|
||||
ap.add_argument("--top", type=int, default=20)
|
||||
a = ap.parse_args()
|
||||
|
||||
rows = undervalued.scan_current(a.cx, a.min_vol)
|
||||
if not rows:
|
||||
print(f"nothing currently priced below production cost at {a.cx} with volume >= {a.min_vol}/day")
|
||||
return
|
||||
print(f"# {a.cx} min-vol>={a.min_vol}/day (gross price return only - see docstring for backtest caveats)")
|
||||
print(f"{'ticker':6} {'margin%':>8} {'price':>10} {'vol/d':>7} bld")
|
||||
for r in rows[:a.top]:
|
||||
print(f"{r['ticker']:6} {r['margin_pct']:8.1f} {r['price']:10.1f} {r['volume']:7.1f} {r['building']}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user