
TopStep ProjectX Connector — Automation Setup Kit
Stop losing an afternoon to ProjectX's first-run gotchas
The ProjectX Gateway API (TopStep / TopstepX and other prop firms) is powerful, but
the first time you wire it up you hit a wall of undocumented quirks: a login that
rejects your email, bracket orders that get rejected until the ticks are signed a
very particular way, a token that quietly expires, and contract searches that hand
you a spread instead of the front month.
This is the connector I wish I'd had — a small, strategy-agnostic Python client plus
a read-only preflight tester that gets you from "I subscribed to the API" to a green
connection and a safe first order.
Prerequisite (paid, not included): you must already have ProjectX API access on
your own account. For TopStep/TopstepX that is a separate paid add-on, roughly
US$29/month. This kit does not include or waive that cost — it makes the
connection painless once you have access.
What you get
projectx_client.py— auth (with auto re-login on token expiry), account and
front-month contract discovery, historical bars, market/limit orders, correctly
signed stop/take-profit brackets, position management, order cancel/replace,
and real fill readback with price / P&L / fees. Only dependency:requests.preflight.py— a read-only connection test. Run it first; green across the
board means auth, account, and market data are wired right. It never places an order.- Full API reference — every endpoint's body and response, enums, and the
CON.F.US.ENQ.U25contract id format. - Troubleshooting map — the errorCodes and what they actually mean.
- Offline test suite — the connector is itself tested (signed brackets, contract
resolution, drawdown rule). - Ops helpers — a Windows keep-awake for overnight sessions, and a
TrailingDrawdown
tracker that implements the public prop-firm trailing-drawdown rule.
The gotchas it saves you from
| Symptom | Cause | This kit |
|---|---|---|
errorCode 3 on login |
userName set to your email |
Uses your username; preflight tells you if it's wrong |
errorCode 2 on an order |
Bracket tick sign wrong | Signs them for you: long TP +/SL -, short TP -/SL + |
401 mid-session |
Token expired (~24h) | Re-authenticates once, automatically |
| Order rejected / duplicated | Retried an order after a dropped response | Only read-only calls retry; orders never do |
| Contract search returns a spread | Matched several instruments | Picks the shortest active name = front month |
What this is not
Not a trading strategy, not a signal service, and not a promise that you pass any
evaluation. It contains no strategy at all — you bring your own logic and your own
API key. It only moves orders safely to and from the gateway.
Compliance
TopStep and many prop firms require automation to run on your own machine and
forbid VPS / VPN / cloud — run this locally. This connector is independent and not
affiliated with TopStep or ProjectX; those are trademarks of their respective owners.
Read your firm's current terms of use. Requires Python 3.9+.


