Jupyter Notebook Examples¶
Interactive Jupyter notebooks for exploring the ProjectX Python SDK.
Available Notebooks¶
Getting Started¶
- Basic Connection - First steps with the SDK
- Trading Suite Setup - Complete trading environment setup
- Market Data Exploration - Working with historical and real-time data
Trading Strategies¶
- Simple Moving Average Strategy - Basic trend following
- RSI Mean Reversion - Oversold/overbought trading
- Volume Profile Trading - Key level identification
Technical Analysis¶
- Indicator Showcase - All 59+ indicators demonstrated
- Pattern Recognition - FVG and Order Block detection
- Multi-Timeframe Analysis - Confluence across timeframes
Risk Management¶
- Position Sizing - Kelly Criterion and fixed risk
- Portfolio Analytics - Performance metrics and analysis
- Risk Metrics - Sharpe, Sortino, and drawdown
Market Microstructure¶
- OrderBook Analysis - Level 2 data exploration
- Order Flow - Trade classification and imbalance
- Spoofing Detection - Identifying manipulation patterns
Running the Notebooks¶
Prerequisites¶
# Install Jupyter and dependencies
pip install jupyter notebook ipywidgets plotly pandas
# Install the SDK
pip install project-x-py[all]
Environment Setup¶
Create a .env
file in the notebooks directory:
Launch Jupyter¶
# Clone the repository
git clone https://github.com/TexasCoding/project-x-py.git
cd project-x-py/notebooks
# Start Jupyter
jupyter notebook
Notebook Features¶
Interactive Visualizations¶
- Real-time chart updates with Plotly
- Interactive order book visualization
- Candlestick charts with indicators
- Performance dashboards
Live Data Integration¶
- Connect to real-time WebSocket feeds
- Stream market data into notebooks
- Place and monitor orders interactively
- Real-time position tracking
Educational Content¶
- Step-by-step explanations
- Code cells with detailed comments
- Markdown cells with theory
- Exercise cells for practice
Best Practices¶
Safety First¶
# Always use paper trading for testing
suite = await TradingSuite.create(
["MNQ"],
mode="paper" # Paper trading mode
)
Memory Management¶
# Clean up resources in notebooks
try:
# Your trading code here
pass
finally:
await suite.disconnect()
Async in Notebooks¶
# Use nest_asyncio for async support
import nest_asyncio
nest_asyncio.apply()
# Now you can use await directly
suite = await TradingSuite.create(["MNQ"])
Contributing Notebooks¶
We welcome notebook contributions! Please ensure:
- Clear objectives - State what the notebook demonstrates
- Runnable code - Test with paper trading account
- Documentation - Explain concepts and code
- Visualizations - Use charts to illustrate points
- Safety warnings - Include risk disclaimers
Example Notebook Structure¶
# Cell 1: Setup
import asyncio
import nest_asyncio
from project_x_py import TradingSuite
import plotly.graph_objects as go
import pandas as pd
nest_asyncio.apply()
# Cell 2: Connect
suite = await TradingSuite.create(
["MNQ"],
timeframes=["1min", "5min"],
features=["orderbook"]
)
# Cell 3: Analysis
# Your strategy or analysis code
# Cell 4: Visualization
fig = go.Figure(data=[
go.Candlestick(
x=df['timestamp'],
open=df['open'],
high=df['high'],
low=df['low'],
close=df['close']
)
])
fig.show()
# Cell 5: Cleanup
await suite.disconnect()
Resources¶
License¶
All notebooks are provided under the MIT License. Use at your own risk for educational purposes only.