|
| 1 | +# ProjectX Gateway API SDK for Python (Unofficial) |
| 2 | + |
| 3 | +A Python client library for the ProjectX Gateway API, enabling proprietary trading firms and evaluation providers to interact with ProjectX's trading platform programmatically. |
| 4 | + |
| 5 | +> **DISCLAIMER:** This is an **unofficial** SDK. The author(s) of this package are not affiliated with or endorsed by ProjectX. This is a community-developed tool to interact with their public API. |
| 6 | +
|
| 7 | +[](https://github.com/ChristianJStarr/projectx-sdk-python/actions/workflows/tests.yml) |
| 8 | +[](https://badge.fury.io/py/projectx-sdk) |
| 9 | +[](https://pypi.org/project/projectx-sdk/) |
| 10 | +[](https://opensource.org/licenses/MIT) |
| 11 | + |
| 12 | +## Features |
| 13 | + |
| 14 | +- Complete coverage of ProjectX Gateway API endpoints |
| 15 | +- Support for real-time WebSocket updates via SignalR |
| 16 | +- Pythonic interface with proper error handling |
| 17 | +- Support for all ProjectX environments |
| 18 | + |
| 19 | +## Installation |
| 20 | + |
| 21 | +```bash |
| 22 | +pip install projectx-sdk |
| 23 | +``` |
| 24 | + |
| 25 | +For development, you can install with additional tools: |
| 26 | + |
| 27 | +```bash |
| 28 | +pip install projectx-sdk[dev] |
| 29 | +``` |
| 30 | + |
| 31 | +## Quick Start |
| 32 | + |
| 33 | +```python |
| 34 | +from projectx_sdk import ProjectXClient, OrderType, OrderSide |
| 35 | + |
| 36 | +# Initialize with API key |
| 37 | +client = ProjectXClient( |
| 38 | + username="your_username", |
| 39 | + api_key="your_api_key", |
| 40 | + environment="topstepx" # Or another supported environment |
| 41 | +) |
| 42 | + |
| 43 | +# Get all active accounts |
| 44 | +accounts = client.accounts.search(only_active_accounts=True) |
| 45 | +account_id = accounts[0].id if accounts else None |
| 46 | + |
| 47 | +if account_id: |
| 48 | + # Search for contracts |
| 49 | + contracts = client.contracts.search(search_text="NQ", live=False) |
| 50 | + |
| 51 | + if contracts: |
| 52 | + contract_id = contracts[0].id |
| 53 | + |
| 54 | + # Place a market order |
| 55 | + order = client.orders.place( |
| 56 | + account_id=account_id, |
| 57 | + contract_id=contract_id, |
| 58 | + type=OrderType.MARKET, |
| 59 | + side=OrderSide.BUY, |
| 60 | + size=1 |
| 61 | + ) |
| 62 | + |
| 63 | + print(f"Order placed with ID: {order['orderId']}") |
| 64 | + |
| 65 | + # Set up real-time order updates |
| 66 | + def on_order_update(order_data): |
| 67 | + print(f"Order update: {order_data}") |
| 68 | + |
| 69 | + client.realtime.user.subscribe_orders(account_id, callback=on_order_update) |
| 70 | + client.realtime.start() |
| 71 | +``` |
| 72 | + |
| 73 | +## Environment Support |
| 74 | + |
| 75 | +The SDK supports all ProjectX environments: |
| 76 | + |
| 77 | +| Platform | SDK Key | Tested | |
| 78 | +|----------|---------|--------| |
| 79 | +| Alpha Ticks | `alphaticks` | ✅ | |
| 80 | +| Blue Guardian | `blueguardian` | ❓ | |
| 81 | +| Blusky | `blusky` | ❓ | |
| 82 | +| E8X | `e8x` | ❓ | |
| 83 | +| Funding Futures | `fundingfutures` | ❓ | |
| 84 | +| The Futures Desk | `futuresdesk` | ❓ | |
| 85 | +| Futures Elite | `futureselite` | ❓ | |
| 86 | +| FXIFY Futures | `fxifyfutures` | ❓ | |
| 87 | +| GoatFunded | `goatfunded` | ❓ | |
| 88 | +| TickTickTrader | `tickticktrader` | ❓ | |
| 89 | +| TopOneFutures | `toponefutures` | ❓ | |
| 90 | +| TopstepX | `topstepx` | ✅ | |
| 91 | +| TX3Funding | `tx3funding` | ❓ | |
| 92 | + |
| 93 | +> Note: ✅ = Tested and confirmed working, ❓ = Not officially tested yet |
| 94 | +
|
| 95 | +## API Components |
| 96 | + |
| 97 | +The SDK is organized into several components: |
| 98 | + |
| 99 | +- **Client**: The main entry point that provides access to all API functionality |
| 100 | +- **Authentication**: Handles authentication and token management |
| 101 | +- **Endpoints**: Service modules for each API endpoint (accounts, contracts, orders, etc.) |
| 102 | +- **Models**: Data classes for API entities (account, contract, order, etc.) |
| 103 | +- **Real-time**: WebSocket functionality for real-time updates |
| 104 | + |
| 105 | +## Development |
| 106 | + |
| 107 | +### Setup |
| 108 | + |
| 109 | +1. Clone the repository: |
| 110 | + ```bash |
| 111 | + git clone https://github.com/ChristianJStarr/projectx-sdk-python.git |
| 112 | + cd projectx-sdk-python |
| 113 | + ``` |
| 114 | + |
| 115 | +2. Create a virtual environment: |
| 116 | + ```bash |
| 117 | + python -m venv venv |
| 118 | + source venv/bin/activate # On Windows: venv\Scripts\activate |
| 119 | + ``` |
| 120 | + |
| 121 | +3. Install dependencies: |
| 122 | + ```bash |
| 123 | + pip install -e ".[dev]" |
| 124 | + ``` |
| 125 | + |
| 126 | +4. Set up pre-commit hooks: |
| 127 | + ```bash |
| 128 | + pre-commit install |
| 129 | + ``` |
| 130 | + |
| 131 | +### Running Tests |
| 132 | + |
| 133 | +Run the entire test suite: |
| 134 | + |
| 135 | +```bash |
| 136 | +pytest |
| 137 | +``` |
| 138 | + |
| 139 | +Run with coverage: |
| 140 | + |
| 141 | +```bash |
| 142 | +pytest --cov=projectx_sdk |
| 143 | +``` |
| 144 | + |
| 145 | +Run specific test files: |
| 146 | + |
| 147 | +```bash |
| 148 | +pytest tests/test_client.py |
| 149 | +``` |
| 150 | + |
| 151 | +### Code Quality Tools |
| 152 | + |
| 153 | +- **Black**: Code formatter |
| 154 | + ```bash |
| 155 | + black projectx_sdk tests |
| 156 | + ``` |
| 157 | + |
| 158 | +- **isort**: Import sorter |
| 159 | + ```bash |
| 160 | + isort projectx_sdk tests |
| 161 | + ``` |
| 162 | + |
| 163 | +- **Flake8**: Linter |
| 164 | + ```bash |
| 165 | + flake8 projectx_sdk tests |
| 166 | + ``` |
| 167 | + |
| 168 | +- **mypy**: Type checker |
| 169 | + ```bash |
| 170 | + mypy projectx_sdk |
| 171 | + ``` |
| 172 | + |
| 173 | +## Building and Publishing |
| 174 | + |
| 175 | +Build the package: |
| 176 | + |
| 177 | +```bash |
| 178 | +python -m build |
| 179 | +``` |
| 180 | + |
| 181 | +Check the distribution: |
| 182 | + |
| 183 | +```bash |
| 184 | +twine check dist/* |
| 185 | +``` |
| 186 | + |
| 187 | +Upload to PyPI: |
| 188 | + |
| 189 | +```bash |
| 190 | +twine upload dist/* |
| 191 | +``` |
| 192 | + |
| 193 | +## Contributing |
| 194 | + |
| 195 | +Contributions are welcome! Please feel free to submit a Pull Request. |
| 196 | + |
| 197 | +1. Fork the repository |
| 198 | +2. Create your feature branch (`git checkout -b feature/amazing-feature`) |
| 199 | +3. Run the tests to ensure they pass |
| 200 | +4. Commit your changes (`git commit -m 'Add some amazing feature'`) |
| 201 | +5. Push to the branch (`git push origin feature/amazing-feature`) |
| 202 | +6. Open a Pull Request |
| 203 | + |
| 204 | +Please remember that this is an unofficial SDK and not affiliated with ProjectX. |
| 205 | + |
| 206 | +## Documentation |
| 207 | + |
| 208 | +For detailed information about the ProjectX API that this unofficial SDK interacts with, please visit the [ProjectX API Documentation](https://gateway.docs.projectx.com/docs/intro). |
| 209 | + |
| 210 | +## License |
| 211 | + |
| 212 | +This project is licensed under the MIT License - see the LICENSE file for details. |
0 commit comments