This repository contains a FastAPI backend with a simple React frontend to interact with TopStepX. The backend exposes authentication routes using JWT and integrates existing TopStep login logic. The frontend allows users to log in and view a minimal dashboard.
cd frontend
npm install
npm run devpython -m venv venv
source venv/bin/activate
pip install -r requirements.txt
alembic upgrade head # run from project root to apply migrations
uvicorn app.main:app --reloadCreate a .env file with the following values:
DATABASE_URL=postgresql://postgres:password@localhost:5432/topstepdb
TOPSTEP_USER=your@email.com
TOPSTEP_API_KEY=your-api-key
SECRET_KEY=your-secret
CREDENTIALS_ENCRYPTION_KEY=your-32-byte-base64-fernet-key
CORS_ORIGINS=http://localhost:5173,http://127.0.0.1:5173
ACCOUNT_ID=your-topstep-account-id
TOPSTEP_ACCOUNT_ID=your-topstep-account-id
TRADINGVIEW_API_KEY=your-tradingview-api-key
TRADINGVIEW_BASE_URL=https://api.tradingview.com # optional
CREDENTIALS_ENCRYPTION_KEYis optional. If omitted, the backend derives an encryption key fromSECRET_KEY. Use an explicit Fernet key for production.
- Start the backend and frontend (see setup above).
- Visit
/registerto create a new account. - After registration you will be redirected to
/integrationsto connect platforms like TopStepX, Tradovate, NinjaTrader, TradingView, or Interactive Brokers. - Return to
/dashboardto run the trading bot.
alembic upgrade headA lightweight wrapper for the TradingView API lives in app/tradingview_api.py. It provides
helpers for fetching OHLC data and indicators while handling authentication and rate limits.
from app.tradingview_api import TradingViewClient
client = TradingViewClient()
data = client.get_ohlc("AAPL", "1", 1690000000, 1690003600)
print(data)Set TRADINGVIEW_API_KEY in your .env to authenticate requests. If no TradingView
credentials are available, the analysis and backtest endpoints will fall back to Topstep
history when a valid Topstep session token and contract lookup are available (supports 1m/3m
intervals).
The API now exposes richer TradingView-powered analysis under /analysis:
POST /analysis/market-analysis– fetch OHLC data from TradingView and return divergence, liquidity sweep, fair value gap, and supply/demand zone detections.POST /analysis/backtest– run the RSI-based strategy against historical candles (e.g., 1m or 3m) to see how it would have performed. Returns trade log, PnL, and pattern counts.
Example payload:
{
"symbol": "ES",
"resolution": "1",
"start": 1690000000,
"end": 1690003600,
"buy_threshold": 30,
"sell_threshold": 70
}The streaming bot can now fetch either 1-minute or 3-minute bars via the bar_interval_minutes parameter on /scheduler/run-bot, while still honoring the existing interval_seconds poll cadence.