How I Built a Self-Improving Python Bot That Earns Money While I Sleep
In the quest for passive income, I built something unconventional: a Python bot that improves itself, creates digital products, and sells them autonomously. Here's how it works.
The Architecture
The system has three core components:
- RSI Engine (Recursive Self-Improvement) — analyzes what's working and doubles down
- Profit Worker — creates Python scripts, packages them, and lists them for sale
- Storefront — a self-hosted web app that serves products and verifies Bitcoin payments
The RSI Engine
class RSIEngine:
def __init__(self, state_dir="states"):
self.state_dir = Path(state_dir)
self.state_file = self.state_dir / "rsi_state.json"
def analyze_cycle(self):
""Analyze what worked and what didn't."""
state = self.load_state()
products = self.load_products()
improvements = []
for product in products:
views = self.get_views(product["name"])
sales = self.get_sales(product["name"])
if views > 10 and sales == 0:
improvements.append({
"type": "optimize_listing",
"product": product["name"],
"reason": f"{views} views but 0 sales"
})
elif sales > 0:
improvements.append({
"type": "create_variant",
"product": product["name"],
"reason": "Proven seller — create bundle"
})
return improvements
Payment Verification with Bitcoin
We use the Blockstream API to verify payments without any third-party processor:
import requests
def verify_btc_payment(address, expected_amount):
""Check if a Bitcoin payment was received."""
utxo_url = f"https://blockstream.info/api/address/{address}/utxo"
utxos = requests.get(utxo_url, timeout=10).json()
total_satoshis = sum(u.get("value", 0) for u in utxos)
expected_satoshis = int(expected_amount * 1e8)
return total_satoshis >= expected_satoshis
Real Results
After running for 2 weeks:
- 193 products created and validated
- 128 storefront visits from organic traffic
- $10 in actual Bitcoin revenue from a real test sale
- 3 RSI improvement cycles completed automatically
Key Takeaways
- Start small — a $10 sale proves the model works
- Validate everything — syntax-check all generated code
- Use Bitcoin — no payment processor can shut you down
- Let the bot learn — track what works, drop what doesn't
The full system runs on a 4GB RAM cloud VM with Ollama for local inference. Total hardware cost: $0.













