NS Learnathon - Trading for Bitcoin
-
Install Homebrew
- Visit brew.sh
-
Install uv
# On macOS brew install uvNote:
uvis likepoetrybut better in every way. Learn more -
Fork and Clone
# Fork the repo at https://github.com/athon-millane/nstrade.git git clone https://github.com/your-username/nstrade.git -
Python Setup
# Optional: Install Python 3.12 if needed uv python install 3.12 # Initialize venv and install dependencies uv sync
# Add upstream remote
git remote add upstream https://github.com/athon-millane/nstrade.git
# Pull from upstream (either method)
git pull upstream main
# OR
git fetch upstream
git merge upstream main-
Copy the Template
cp strategies/template.py strategies/my_strategy.py
-
Edit Your Strategy
- Set your name, strategy name, and description
- Implement your strategy logic in
process_bar()andget_signal() - Optionally implement a vectorized version in
get_signals()
-
Quick Test
python scripts/test_strategy.py strategies/my_strategy.py
This will:
- Validate your strategy implementation
- Test on development period (2011-2024)
- Test on holdout period (2025)
-
Detailed Evaluation
- Open
notebooks/evaluate.ipynbin Jupyter - Change the
strategy_pathto point to your strategy file - Run all cells to see:
- Detailed performance metrics
- Interactive plots of price, volume, equity curve, drawdowns, and Sharpe ratio
- Buy/sell points overlaid on the price chart
- Trade-by-trade analysis
- Open
-
Submit Your Strategy
- Create a pull request
- Our CI will validate and backtest your strategy
- If successful, it will be added to the leaderboard
- Speed up backtest (maybe vectorise, maybe parallelise)
- Set up a standardised flow for creating, contributing and backtesting new
Strategy - Capture user metadata in Strategy for leaderboard display
- Set up CI/CD YAML file:
- Validate strategy backtestability
- Run backtests on our dataset
- Store results in leaderboard file
- Handle unique submissions (User + Strategy name)
- Define development/holdout sets:
development.csv: Data up to end of 2024holdout.csv: All of 2025- Strategies should only use
development.csv
- Sharpe ratio as primary metric
- Drawdown
- Win rate
- Number of trades
- Sortino ratio
- R² of equity curve (suggested by Barnabas)
- Current focus: Ensure test data isn't used in strategy development
- More comprehensive security measures to be addressed later
- SMA Crossover performance appears suspiciously good
- Most bootstrapped strategies perform poorly without fees and slippage
- Recommended: Include 0.3% fee+slippage per trade