project-x-py Documentation

PyPI version Python versions License Documentation Status

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.1.0: High-performance production suite with 2-5x performance improvements. Features memory-mapped overflow storage, orjson integration, WebSocket message batching, and advanced caching with compression. Complete async architecture with unified TradingSuite interface.

Warning

Development Phase: This project is under active development. New updates may introduce breaking changes without backward compatibility. During this development phase, we prioritize clean, modern code architecture over maintaining legacy implementations.

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)

🔧 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.0.0+)
  • 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)

Table of Contents

Indices and tables