|
1 | 1 | """ |
2 | 2 | ProjectX Python SDK for Trading Applications |
3 | 3 |
|
4 | | -A comprehensive Python SDK for the ProjectX Trading Platform Gateway API, providing developers |
5 | | -with tools to build sophisticated trading strategies and applications. This library offers |
6 | | -comprehensive access to: |
7 | | -
|
8 | | -- Market data retrieval and real-time streaming |
9 | | -- Account management and authentication |
10 | | -- Order placement, modification, and cancellation |
11 | | -- Position management and portfolio analytics |
12 | | -- Trade history and execution analysis |
13 | | -- Advanced technical indicators and market analysis |
14 | | -- Level 2 orderbook depth and market microstructure |
| 4 | +Author: @TexasCoding |
| 5 | +Date: 2025-08-02 |
| 6 | +
|
| 7 | +Overview: |
| 8 | + A comprehensive Python SDK for the ProjectX Trading Platform Gateway API, providing |
| 9 | + developers with tools to build sophisticated trading strategies and applications. |
| 10 | + This library offers comprehensive access to real-time market data, order management, |
| 11 | + position tracking, and advanced analytics for algorithmic trading. |
| 12 | +
|
| 13 | +Key Features: |
| 14 | + - Real-time market data streaming and historical data access |
| 15 | + - Comprehensive order management (market, limit, stop, bracket orders) |
| 16 | + - Position tracking and portfolio analytics |
| 17 | + - Level 2 orderbook depth and market microstructure analysis |
| 18 | + - Advanced technical indicators and pattern recognition |
| 19 | + - Risk management and position sizing tools |
| 20 | + - Multi-timeframe data management and analysis |
| 21 | + - WebSocket-based real-time updates and event handling |
| 22 | +
|
| 23 | +Core Components: |
| 24 | + - ProjectX: Main client for API interactions and authentication |
| 25 | + - OrderManager: Order placement, modification, and tracking |
| 26 | + - PositionManager: Position monitoring, analytics, and risk management |
| 27 | + - OrderBook: Level 2 market depth analysis and order flow |
| 28 | + - RealtimeDataManager: Multi-timeframe real-time data processing |
| 29 | + - ProjectXRealtimeClient: WebSocket-based real-time connections |
| 30 | +
|
| 31 | +Trading Capabilities: |
| 32 | + - Market data retrieval and real-time streaming |
| 33 | + - Account management and authentication |
| 34 | + - Order placement, modification, and cancellation |
| 35 | + - Position management and portfolio analytics |
| 36 | + - Trade history and execution analysis |
| 37 | + - Advanced technical indicators and market analysis |
| 38 | + - Level 2 orderbook depth and market microstructure |
| 39 | + - Risk management and position sizing |
| 40 | +
|
| 41 | +Example Usage: |
| 42 | + ```python |
| 43 | + from project_x_py import ProjectX, OrderManager, PositionManager |
| 44 | +
|
| 45 | + # Basic client setup |
| 46 | + async with ProjectX.from_env() as client: |
| 47 | + await client.authenticate() |
| 48 | +
|
| 49 | + # Get market data |
| 50 | + bars = await client.get_bars("MGC", days=5) |
| 51 | + instrument = await client.get_instrument("MGC") |
| 52 | +
|
| 53 | + # Place orders |
| 54 | + order_manager = OrderManager(client) |
| 55 | + response = await order_manager.place_market_order( |
| 56 | + contract_id=instrument.id, |
| 57 | + side=0, # Buy |
| 58 | + size=1, |
| 59 | + ) |
| 60 | +
|
| 61 | + # Track positions |
| 62 | + position_manager = PositionManager(client) |
| 63 | + positions = await position_manager.get_all_positions() |
| 64 | +
|
| 65 | + # Create complete trading suite |
| 66 | + suite = await create_trading_suite( |
| 67 | + instrument="MGC", project_x=client, timeframes=["1min", "5min", "15min"] |
| 68 | + ) |
| 69 | + ``` |
| 70 | +
|
| 71 | +Architecture Benefits: |
| 72 | + - Async-first design for high-performance trading applications |
| 73 | + - Comprehensive error handling and retry logic |
| 74 | + - Rate limiting and connection management |
| 75 | + - Real-time data processing with WebSocket integration |
| 76 | + - Modular design for flexible trading system development |
| 77 | + - Type-safe operations with comprehensive validation |
15 | 78 |
|
16 | 79 | **Important**: This is a development toolkit/SDK, not a trading strategy itself. |
17 | 80 | It provides the infrastructure to help developers create their own trading applications |
18 | 81 | that integrate with the ProjectX platform. |
19 | 82 |
|
| 83 | +Version: 2.0.5 |
20 | 84 | Author: TexasCoding |
21 | | -Date: January 2025 |
| 85 | +
|
| 86 | +See Also: |
| 87 | + - `client`: Main client for API interactions |
| 88 | + - `order_manager`: Order management and tracking |
| 89 | + - `position_manager`: Position monitoring and analytics |
| 90 | + - `orderbook`: Level 2 market depth analysis |
| 91 | + - `realtime_data_manager`: Real-time data processing |
| 92 | + - `indicators`: Technical analysis and indicators |
| 93 | + - `utils`: Utility functions and calculations |
22 | 94 | """ |
23 | 95 |
|
24 | 96 | from typing import Any |
|
0 commit comments