Skip to main content

UnofficialPython SDK for the ProjectX Gateway API

Project description

ProjectX Gateway API SDK for Python (Unofficial)

A Python client library for the ProjectX Gateway API, enabling proprietary trading firms and evaluation providers to interact with ProjectX's trading platform programmatically.

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.

Python Tests PyPI version Python Version License: MIT

Features

  • Complete coverage of ProjectX Gateway API endpoints
  • Support for real-time WebSocket updates via SignalR
  • Pythonic interface with proper error handling
  • Support for all ProjectX environments

Installation

pip install projectx-sdk

For development, you can install with additional tools:

pip install projectx-sdk[dev]

Quick Start

from projectx_sdk import ProjectXClient, OrderType, OrderSide

# Initialize with API key
client = ProjectXClient(
    username="your_username",
    api_key="your_api_key",
    environment="topstepx"  # Or another supported environment
)

# Get all active accounts
accounts = client.accounts.search(only_active_accounts=True)
account_id = accounts[0].id if accounts else None

if account_id:
    # Search for contracts
    contracts = client.contracts.search(search_text="NQ", live=False)

    if contracts:
        contract_id = contracts[0].id

        # Place a market order
        order = client.orders.place(
            account_id=account_id,
            contract_id=contract_id,
            type=OrderType.MARKET,
            side=OrderSide.BUY,
            size=1
        )

        print(f"Order placed with ID: {order['orderId']}")

        # Set up real-time order updates
        def on_order_update(order_data):
            print(f"Order update: {order_data}")

        client.realtime.user.subscribe_orders(account_id, callback=on_order_update)
        client.realtime.start()

Environment Support

The SDK supports all ProjectX environments:

Platform SDK Key Tested
Alpha Ticks alphaticks
Blue Guardian blueguardian
Blusky blusky
E8X e8x
Funding Futures fundingfutures
The Futures Desk futuresdesk
Futures Elite futureselite
FXIFY Futures fxifyfutures
GoatFunded goatfunded
TickTickTrader tickticktrader
TopOneFutures toponefutures
TopstepX topstepx
TX3Funding tx3funding

Note: ✅ = Tested and confirmed working, ❓ = Not officially tested yet

API Components

The SDK is organized into several components:

  • Client: The main entry point that provides access to all API functionality
  • Authentication: Handles authentication and token management
  • Endpoints: Service modules for each API endpoint (accounts, contracts, orders, etc.)
  • Models: Data classes for API entities (account, contract, order, etc.)
  • Real-time: WebSocket functionality for real-time updates

Development

Setup

  1. Clone the repository:

    git clone https://github.com/ChristianJStarr/projectx-sdk-python.git
    cd projectx-sdk-python
    
  2. Create a virtual environment:

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
    
  3. Install dependencies:

    pip install -e ".[dev]"
    
  4. Set up pre-commit hooks:

    pre-commit install
    

Running Tests

Run the entire test suite:

pytest

Run with coverage:

pytest --cov=projectx_sdk

Run specific test files:

pytest tests/test_client.py

Code Quality Tools

  • Black: Code formatter

    black projectx_sdk tests
    
  • isort: Import sorter

    isort projectx_sdk tests
    
  • Flake8: Linter

    flake8 projectx_sdk tests
    
  • mypy: Type checker

    mypy projectx_sdk
    

Building and Publishing

Build the package:

python -m build

Check the distribution:

twine check dist/*

Upload to PyPI:

twine upload dist/*

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Run the tests to ensure they pass
  4. Commit your changes (git commit -m 'Add some amazing feature')
  5. Push to the branch (git push origin feature/amazing-feature)
  6. Open a Pull Request

Please remember that this is an unofficial SDK and not affiliated with ProjectX.

Documentation

For detailed information about the ProjectX API that this unofficial SDK interacts with, please visit the ProjectX API Documentation.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

projectx_sdk-0.2.5.tar.gz (36.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

projectx_sdk-0.2.5-py3-none-any.whl (36.2 kB view details)

Uploaded Python 3

File details

Details for the file projectx_sdk-0.2.5.tar.gz.

File metadata

  • Download URL: projectx_sdk-0.2.5.tar.gz
  • Upload date:
  • Size: 36.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.0

File hashes

Hashes for projectx_sdk-0.2.5.tar.gz
Algorithm Hash digest
SHA256 b9bda574fbe203af1e76f7e50bc3271a65a7197ae5e7760661f249e23a6c401e
MD5 f0211adfda6e25a8cab4c4f8a94d82d0
BLAKE2b-256 9e2370eea7ee34abf1f2caa584a3b9a3955c6fe904c608380a52e69778474f87

See more details on using hashes here.

File details

Details for the file projectx_sdk-0.2.5-py3-none-any.whl.

File metadata

  • Download URL: projectx_sdk-0.2.5-py3-none-any.whl
  • Upload date:
  • Size: 36.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.0

File hashes

Hashes for projectx_sdk-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 3276990fc4912f9ba5ff04f34ff612a5ee9f8e66342544846cb15bd6705dd06b
MD5 988c7f950080866c21b7b45310480d9e
BLAKE2b-256 1caeb47a1350be165989ab49a7b3937a5d9a1b75420f76fa6eead4b42a1b7970

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page