Iron Rules + DRIP-ON β Reference Math
Reference Python implementation of the Five Iron Rules and DRIP-ON one-way ratchet. Illustrative only β not a live trading system, not connected to LP capital.
TL;DR: Reference Python implementation of the Five Iron Rules and DRIP-ON one-way ratchet. Illustrative only β not a live trading system, not connected to LP capital.
Summary
Reference Python implementation of the Five Iron Rules and DRIP-ON one-way ratchet. Illustrative only β not a live trading system, not connected to LP capital.
Preview
"""
Iron Rules + DRIP-ON β Reference Math
Illustrative implementation of the Five Iron Rules invariants and the DRIP-ON
one-way ratchet. NOT a live trading system. NOT connected to LP capital. NOT a
rebalance engine. Reference math only β used to specify behaviors that the real
system must guarantee.
Five Iron Rules:
IR-1 Share count only goes up (one-way ratchet).
IR-2 Leverage ceiling β hard cap below 1.10x.
IR-3 Reserve floor β minimum cash buffer always held.
IR-4 Concentration cap β single-name max position size.
IR-5 Permanent HWM β incentive only on net new HWM, never resets.
DRIP-ON: every dollar of premium / dividend / coupon income reinvests into
shares. Premium does not exit the fund.
"""
from dataclasses import dataclass, field
from typing import Dict
LEVERAGE_CEILING = 1.10
RESERVE_FLOOR_PCT = 0.05 # 5% min cash buffer
CONCENTRATION_CAP = 0.15 # 15% max single name at cost
@dataclass
class Position:
ticker: str
shares: float
cost_basis: float # avg cost per share
@dataclass
class Fund:
nav: float
cash: float
debt: float
positions: Dict[str, Position] = field(default_factory=dict)
hwm: float = 0.0
# ---- Iron Rule invariants ----
def leverage(self) -> float:
"""Gross exposure / NAV. Must stay <= LEVERAGE_CEILING (IR-2)."""
gross = sum(p.shares * p.cost_basis for p in self.positions.values())
return gross / self.nav if self.nav else 0.0
def reserve_pct(self) -> float:
"""Cash / NAV. Must stay >= RESERVE_FLOOR_PCT (IR-3)."""
return self.cash / self.nav if self.nav else 0.0
def concentration(self, ticker: str) -> float:
"""Single-name fraction of NAV. Must stay <= CONCENTRATION_CAP (IR-4)."""
p = self.positions.get(ticker)
if not p:
return 0.0
return (p.shares * p.cost_basis) / self.nav
def assert_invariants(self):
assert self.leverage() <= LEVERAGE_CEILING, f"IR-2 violated: lev={self.leverage():.3f}"
assert self.reserve_pct() >= RESERVE_FLOOR_PCT, f"IR-3 violated: cash={self.reserve_pct():.3f}"
for tkr in self.positions:
c = self.concentration(tkr)
assert c <= CONCENTRATION_CAP, f"IR-4 violated on {tkr}: conc={c:.3f}"
# ---- DRIP-ON ratchet ----
def drip_in(self, ticker: str, dollars: float, market_price: float):
"""Reinvest premium/dividend/coupon income. Share count goes up (IR-1)."""
p = self.positions.setdefault(ticker, Position(ticker, 0.0, market_price))
new_shares = dollars / market_price
new_total_shares = p.shares + new_shares
new_cost = ((p.shares * p.cost_basis) + dollars) / new_total_shares
p.shares = new_total_shares
p.cost_basis = new_cost
# IR-1: never decrement
def reclaim_assigned(self, ticker: str, shares_assigned: float, market_price: float):
"""On covered-call assignment, auto-buy back at next bid. Share count net-up."""
cost = shares_assigned * market_price
assert self.cash >= cost, "need cash to reclaim; reserve floor must hold"
β¦ (23 more lines in Drive)
Full artifact
Stored in Google Drive (husshtech): view Β· download.
Cross-referenced from
Drive shortcuts pointing back to this artifact live in:
- husshtech /
wiki/concepts/drip-on/code/iron-rules-drip-on-reference-math.py(open) β relates towiki/concepts/drip-on.md - husshone /
wiki/concepts/sell-the-wall/code/iron-rules-drip-on-reference-math.py(open) β relates towiki/concepts/sell-the-wall.md - husshtech /
wiki/concepts/aloha-flywheel/code/iron-rules-drip-on-reference-math.py(open) β relates towiki/concepts/aloha-flywheel.md
Relations
- wiki/concepts/drip-on.md
- wiki/concepts/sell-the-wall.md
- wiki/concepts/aloha-flywheel.md