Build a trading algorithm that maximizes profit on historical Pumpfun token trades.
# Install dependencies
pip install -r requirements.txt
# Run evaluation (uses pre-built trades.duckdb)
python eval.py --db trades.duckdb- The evaluation engine streams historical trades to your algorithm one at a time
- For each trade, your algorithm decides: BUY or NO_ACTION
- When you BUY, you spend 1 SOL to acquire tokens at the current AMM price
- Your position auto-sells after 1500 slots (~10 minutes) at the prevailing price
- Your profit/loss is calculated and aggregated across all trades
algo.py - This is the ONLY file you should modify.
def algo(trade: Dict[str, Any], state: Dict[str, Any]) -> Action:
# Your strategy here
return Action.NO_ACTION # or Action.BUYEach trade dict contains:
| Field | Description |
|---|---|
mint |
Token address |
slot |
Solana slot number |
sol_amount |
SOL amount in lamports (1 SOL = 1e9) |
token_amount |
Token amount |
is_buy |
1 for buy, 0 for sell |
virtual_sol_reserves |
AMM virtual SOL reserves |
virtual_token_reserves |
AMM virtual token reserves |
user |
Wallet address |
signature |
Transaction signature |
stateis a mutable dict persisted across calls for the same token- Each token gets a fresh
statedict - no cross-token state - Use it to track patterns, count trades, store indicators, etc.
eval.py- The evaluation enginerequirements.txt- Dependenciestrades.duckdb- Pre-built database (optional, for faster loading)
# Using pre-built database (recommended)
python eval.py --db trades.duckdb
# With more workers for parallel processing
python eval.py --db trades.duckdb --workers 8The evaluation produces:
- Console summary - Total trades, win rate, profit/loss
- trades.csv - Detailed log of all executed trades
Example output:
==================================================
EVALUATION RESULTS
==================================================
Total trades executed: 74
Profitable: 22 (29.7%)
Losing: 52 (70.3%)
Breakeven: 0 (0.0%)
Total profit: +7.117070 SOL
Average profit/trade: +0.096176623 SOL
Best trade: +7.721855 SOL (mint: 7RpskwFd...)
Worst trade: -0.738114 SOL (mint: Cc4qkHkh...)
Trades excluded (no exit within 1500 slots): 326
==================================================
Your algorithm is scored by Total Profit in SOL.
| File | Description |
|---|---|
algo.py |
Your trading algorithm (EDIT THIS) |
eval.py |
Evaluation engine (DO NOT EDIT) |
requirements.txt |
Python dependencies |
trades.duckdb |
Pre-built database (200K trades, 7,953 tokens) |
Good luck!