ETF rotation bot
Does a simple weekly ETF rotation hold up on a paper account?
Why I built it
No machine learning makes the decisions. The rules are simple on purpose so I can explain every trade; an LLM only writes a short summary after each rebalance.
What it does
A weekly rules-based ETF rotation on an Alpaca paper account, packaged with Docker and monitored from a Streamlit dashboard.
Under the hood
Market regime
Every Friday at 15:45 New York time: bearish if SPY is below its 200- and 50-day averages and more than 5% under its 60-day high.
Defensive or offensive
Bearish: gold, commodities and Treasuries. Bullish: the 7 best of 24 assets by trend quality and return over volatility.
Volatility scaling
Offensive exposure goes from 97% in calm markets to 30% in turbulent ones, and is cut again if the account falls 10% below its peak.
Hard limits
12% per asset, 28% per sector, 2% cash always kept, no leverage; orders in dollar amounts, skipping any position within 4% of target.
An honest backtest
Weekly since 2016 with fees and a stress case, and the README lists its flaws: look-ahead in the asset list, approximated Bitcoin ETFs, a simplified copy of the live rules.