AlphaGPT Cheat Sheet: Auto-Generating Factor Formulas, Not Predicting Prices
One-line essence: AlphaGPT does not predict prices. Like GPT writing code, it automatically generates factor formulas, uses backtest returns as the reward, and trains the formula-writing Transformer with reinforcement learning. High-scoring formulas are then connected to an on-chain wallet to place real orders. It is not a prediction model — it is a system that writes factors automatically.
Core Idea
- Generate formulas rather than predict prices.
- A Transformer autoregressively emits a token sequence — each token is either a feature or an operator. A stack-based virtual machine (StackVM) executes them into factor signals.
- Formulas are readable:
decode()can reconstruct them, e.g.MUL(RET, DECAY(VOL_CHG)). They are debuggable and interpretable. - The reward comes from backtests: formulas with higher net PnL increase the probability of the generation paths that produced them — standard RL (REINFORCE).
- data_pipeline — fetch Birdeye market data into the DB, filter low-liquidity junk coins
- model_core — factor mining engine: Transformer + VM + backtest-driven training
- strategy_manager — 15-minute live loop, loads formulas, scores and places orders, with stop-loss/take-profit
- execution — Jupiter quotes + Solana RPC signing and order submission
- dashboard — Streamlit positions/PnL/logs with an emergency-stop button
- lord — grokking experiments comparing LoRD vs L2 regularization
- times.py — same paradigm ported to 511260.SH (A-share), reward uses Sortino
- Entry threshold: sigmoid > 0.85
- Stop-loss -5% / take-profit +10%, keeping a half-position moonbag
- Exit signal: score < 0.45, with trailing take-profit
- Anti-honeypot: liquidity > $5,000 and sell quotes verifiable
- The repo does not include a trained
best_meme_strategy.json— run training first - No
.envtemplate: assemble your own Birdeye key, QuickNode RPC, and Solana private key - Many external dependencies: Postgres, Birdeye, Jupiter, QuickNode — all are required
- Red flag: your private key goes into
.env— this is real on-chain live trading; losses are not recoverable - The README contains only the author's safety disclaimer; technical docs are in CATREADME.md
model_core/alphagpt.py— modelmodel_core/vm.py— stack VMmodel_core/engine.py— training loopstrategy_manager/runner.py— live-trading entry pointexecution/trader.py— on-chain order placementtimes.py— A-share experimental version
Data Flow: From Market Data to On-Chain
1. Sample — Transformer emits formula token sequences 2. Execute — StackVM runs tokens into factor signals 3. Score — backtest net PnL as fitness 4. Feedback — REINFORCE raises the probability of good paths
Pipeline: Birdeye API → data_pipeline (liquidity/FDV filtering) → Postgres (TimescaleDB hypertable) → AlphaGPT model → StackVM → MemeBacktest → strategy_manager (signal when sigmoid > 0.85) → execution (Jupiter on-chain swap), with the RL feedback loop closing back to the model.
Tech Stack
| Area | Tools | |---|---| | Deep learning | PyTorch, Looped Transformer (+ QKNorm/RMSNorm/SwiGLU/MTPHead) | | Regularization | Newton-Schulz LoRD (Muon-style low-rank decay) | | Data sources | Birdeye (primary) / DexScreener (backup) | | Storage | PostgreSQL + TimescaleDB hypertable | | Trading | Solana RPC + Jupiter v6 aggregator | | Dashboard | Streamlit + Plotly | | A-share experiment | Tushare (times.py) |
Module Reference
Five Steps to Run
1. Create the crypto_quant database, configure .env
2. python -m data_pipeline.run_pipeline to fetch data
3. python -m model_core.engine to train, producing best_meme_strategy.json
4. python -m strategy_manager.runner for live trading
5. streamlit run dashboard/app.py to monitor and emergency-stop
Factors & Operators (12 + 12)
Base factors (6): ret (log return), liq_score (liquidity health), pressure (buy/sell pressure), fomo (volume acceleration), dev (deviation from mean), log_vol (log volume). Extended (6): volatility clustering, momentum reversal, RSI, amplitude, close position, volume trend.
Operators: ADD SUB MUL DIV NEG ABS SIGN plus GATE (gating), JUMP (jump detection), DECAY (decay stacking), DELAY1 (lag), MAX3 (three-value max).