stock/notebooks/README.md
2026-02-27 03:17:12 +08:00

138 lines
2.4 KiB
Markdown

# OpenClaw Trading - Jupyter Notebooks
Interactive tutorials for learning OpenClaw Trading.
## Prerequisites
Install Jupyter:
```bash
pip install jupyter matplotlib pandas
```
Install OpenClaw:
```bash
pip install -e ".."
```
Or set PYTHONPATH:
```bash
export PYTHONPATH=/path/to/openclaw/src:$PYTHONPATH
```
## Starting Jupyter
```bash
jupyter notebook
```
This will open a browser window with the notebook interface.
## Available Notebooks
### 01_getting_started.ipynb
Introduction to OpenClaw Trading basics:
- Creating an economic tracker
- Simulating trades
- Tracking performance
- Visualizing balance history
- Comparing different strategies
**Duration:** 15-20 minutes
### 02_agent_comparison.ipynb
Compare different types of agents:
- Market Analyst vs Sentiment Analyst
- Impact of skill levels
- Factor performance comparison
- Agent survival rates
**Duration:** 20-30 minutes
### 03_backtesting.ipynb
Learn backtesting strategies:
- Running simple backtests
- Parameter optimization
- Walk-forward analysis
- Performance visualization
**Duration:** 25-35 minutes
### 04_custom_strategies.ipynb
Create custom trading strategies:
- Building custom agents
- Creating custom factors
- Strategy optimization
- Advanced backtesting
**Duration:** 30-45 minutes
## Running the Notebooks
1. Start Jupyter:
```bash
jupyter notebook
```
2. Click on a notebook file (.ipynb)
3. Run cells with:
- `Shift+Enter`: Run current cell and move to next
- `Ctrl+Enter`: Run current cell and stay
- `Cell > Run All`: Run all cells
4. To restart:
- `Kernel > Restart & Clear Output`: Start fresh
- `Kernel > Restart & Run All`: Restart and run all
## Tips
- Run cells in order (top to bottom)
- If you get errors, try `Kernel > Restart & Run All`
- Modify the code and experiment!
- Check the documentation for more details
## Troubleshooting
### Module Not Found
If you get `ModuleNotFoundError`, ensure:
1. OpenClaw is installed: `pip install -e ".."`
2. PYTHONPATH is set correctly
3. You're running Jupyter from the notebooks directory
### Plot Not Showing
If plots don't display:
```python
%matplotlib inline
```
Add this at the beginning of the notebook.
### Kernel Crashes
If the kernel crashes:
1. `Kernel > Restart`
2. `Cell > Run All Above` (to get back to where you were)
3. Continue from there
## Additional Resources
- [Main Documentation](../docs/)
- [Examples](../examples/)
- [API Reference](../docs/source/api.rst)