project-x-py Documentation
project-x-py is a high-performance async Python SDK for the ProjectX Trading Platform Gateway API. This library enables developers to build sophisticated trading strategies and applications by providing comprehensive async access to futures trading operations, real-time market data, Level 2 orderbook analysis, and a complete technical analysis suite with 58+ TA-Lib compatible indicators including pattern recognition.
Note
Version 3.3.4: Production-ready release with all 27 critical issues resolved. Major improvements include Risk Manager financial precision with Decimal type, comprehensive OrderBook spoofing detection (6 pattern types), enhanced memory management, and 100% async-first statistics system with health monitoring. Complete with performance optimizations and comprehensive test coverage. Fully backward compatible with v3.x.x.
Note
Stable Production Release: Since v3.1.1, this project maintains strict semantic versioning with backward compatibility between minor versions. Breaking changes only occur in major version releases (4.0.0+). Deprecation warnings are provided for at least 2 minor versions before removal.
Note
Important: This is a client library/SDK, not a trading strategy. It provides the tools and infrastructure to help developers create their own trading strategies that integrate with the ProjectX platform.
Quick Start
Install the package:
uv add project-x-py
Or with pip:
pip install project-x-py
Set up your credentials:
export PROJECT_X_API_KEY='your_api_key'
export PROJECT_X_USERNAME='your_username'
Start trading:
import asyncio
from project_x_py import TradingSuite
from project_x_py.indicators import RSI, SMA, MACD
async def main():
# V3.1: Use unified TradingSuite for simplified initialization
suite = await TradingSuite.create(
instrument="MNQ",
timeframes=["1min", "5min"],
features=["orderbook", "risk_manager"]
)
# Get market data with technical analysis
data = await suite.client.get_bars('MNQ', days=30, interval=60)
data = RSI(data, period=14) # Add RSI
data = SMA(data, period=20) # Add moving average
data = MACD(data) # Add MACD
# Place an order using the integrated order manager
response = await suite.orders.place_limit_order(
contract_id=suite.instrument_id,
side=0,
size=1,
limit_price=21050.0
)
# Clean up when done
await suite.disconnect()
# Run the async function
asyncio.run(main())
Key Features
- 🚀 Core Trading Features
Complete order management (market, limit, stop, bracket orders)
Real-time position tracking and portfolio management
Advanced risk management and position sizing
Multi-account support
- 📊 Market Data & Analysis
Async historical OHLCV data with multiple timeframes
Real-time market data feeds via async WebSocket
Level 2 orderbook analysis with institutional-grade features
58+ Technical Indicators with TA-Lib compatibility (RSI, MACD, Bollinger Bands, Pattern Recognition, etc.)
Advanced market microstructure analysis (iceberg detection, order flow, volume profile)
Market Manipulation Detection (NEW): 6 spoofing pattern types with regulatory compliance features
100% Async Statistics System (NEW): Health monitoring, multi-format export, component tracking
- 🔧 Developer Tools
Comprehensive Python typing support
Extensive examples and tutorials
Built-in logging and debugging tools
Flexible configuration management
- ⚡ Real-time Capabilities
Async live market data streaming
Real-time order and position updates
Async event-driven architecture
WebSocket-based connections with async handlers
- 🛡️ Enterprise Features (v3.3.4)
EventBus architecture for unified event handling
Factory functions with dependency injection
JWT-based authentication system
Centralized error handling with decorators
Structured JSON logging for production
Automatic retry with exponential backoff
Rate limit management
Comprehensive type safety (mypy compliant)
Financial Precision (NEW): Decimal type for exact calculations
Advanced Memory Management (NEW): Bounded buffers, automatic cleanup
Performance Optimized (NEW): 80% faster algorithms, O(N log N) complexity
Table of Contents
Getting Started
User Guide
Examples
Indices and Search
Advanced Topics