A ChatGPT-powered trading assistant backend for cTrader that can analyze markets, journal setups, and place trades through Custom GPT Actions.
The default implementation ships with a Smart Money Concepts (SMC) strategy, but the real point of the repo is broader:
- use ChatGPT as the trader-facing interface
- use FastAPI as the action backend
- use cTrader Open API as the market and execution layer
- swap the strategy logic and GPT instructions for your own system
This repo is best understood as a reusable pattern for building strategy-specific trading assistants, not just a single SMC bot.
Most trading bot repos focus on one of these:
- backtesting only
- broker execution only
- prompt experiments with no real broker integration
This project connects all three layers that people actually want:
- a ChatGPT Custom GPT with Actions
- a live market and execution backend
- strategy-specific analysis logic
That makes it useful both as a working SMC prototype and as a template for other trading workflows such as:
- breakout systems
- trend-following systems
- Fibonacci or indicator-based systems
- session-based scalping
- news-aware discretionary assistants
- portfolio monitoring or journaling assistants
- Fetches live OHLC data from cTrader Open API
- Runs structured multi-timeframe analysis through
/analyze - Returns machine-usable action payloads for ChatGPT
- Places market, limit, and stop orders via
/place-order - Lists open positions and pending orders
- Logs setups to Notion through
/journal-entry - Optionally renders price charts for the GPT or the user
Current default strategy signals include:
- CHOCH
- BOS
- order blocks
- fair value gaps
- session sweeps
- candle confirmations
- weighted confluence scoring
This repo is intentionally built around Smart Money Concepts. The current:
are meant to work together as an SMC-specific stack.
If someone wants a different strategy, such as SMA crossover, RSI divergence, or breakout trading, the right approach is not to keep these exact SMC files and make them vague. The right approach is to create a new strategy-specific set of:
- backend analysis logic
- backend response contract
- Custom GPT instructions
- Custom GPT action schema
Then replace the SMC versions in the backend and in the ChatGPT Custom GPT configuration.
So the reusable asset is not "one universal instruction file." The reusable asset is:
- ChatGPT Action flow
- broker integration
- analysis endpoint contract
- journaling and execution plumbing
- EMA pullback strategy: Create EMA-specific analysis logic, EMA-specific GPT instructions, and an EMA-specific action schema.
- RSI divergence strategy: Create divergence-specific backend detection, divergence-specific instructions, and a schema that exposes those fields.
- breakout strategy: Create breakout-specific market structure fields, breakout instructions, and a breakout action contract.
- swing trend strategy: Create a trend-strategy backend, trend-strategy instructions, and a matching schema.
Concrete example:
If you want to reuse the repo for a different strategy, keep the plumbing and replace the strategy layer.
What usually stays the same:
- cTrader connectivity in ctrader_client.py
- FastAPI app structure in app.py
- order placement and journaling endpoints
- ChatGPT Actions workflow
What usually changes:
- strategy logic in analysis.py
/analyzeresponse shape in app.py- Custom GPT instructions in gpt_instructions.md
- action schema in gpt-schema.yaml
If you want an SMA crossover assistant, do not keep the SMC instructions and just rename things. Replace the strategy layer with SMA-specific outputs such as:
- fast SMA value
- slow SMA value
- crossover direction
- trend filter
- pullback state
- invalidation price
- take-profit logic
- confidence or confluence score
In practice, the steps are:
- Rewrite analysis.py so it computes SMA signals instead of CHOCH, BOS, OB, and FVG.
- Update app.py so
/analyzereturns SMA-specific fields. - Replace gpt_instructions.md with instructions telling ChatGPT how to interpret the SMA payload and when to place or avoid trades.
- Replace gpt-schema.yaml so the Custom GPT Action matches the new SMA response contract.
- Paste the new instructions and schema into your Custom GPT configuration.
That keeps the architecture while making the strategy implementation honest and internally consistent.
The intended ChatGPT setup is:
- You create a Custom GPT in ChatGPT.
- You paste gpt_instructions.md into the GPT Instructions field.
- You paste gpt-schema.yaml into the Actions schema field.
- You point the action base URL to your deployed backend.
At runtime, the GPT should:
- call
/analyze - read structured fields like
HTF_Bias,Checklist, andConfluence - decide whether a setup qualifies
- optionally place or journal the trade
The latest backend contract now includes:
MTF_Zoneswith OB, BOS, and FVG dataChecklistwith CHOCH, BOS, OB, FVG, Sweep, and CandleConfluencewith weighted score and qualification status
chatgpt-trading-strategy-assistant/
|-- app.py
|-- analysis.py
|-- charts.py
|-- ctrader_client.py
|-- gpt_instructions.md
|-- gpt-schema.yaml
|-- requirements.txt
|-- Dockerfile
|-- docker-compose.yml
|-- .env.example
|-- images/
|-- examples/
| `-- analyze-response.sample.json
| `-- sma-strategy-pack-outline.md
|-- scripts/
| `-- smoke_test.py
`-- tests/
`-- test_analysis.py
- app.py: FastAPI app and action endpoints
- analysis.py: strategy analysis logic
- ctrader_client.py: broker connectivity and order execution
- gpt_instructions.md: Custom GPT prompt behavior
- gpt-schema.yaml: Actions schema for ChatGPT
The /analyze endpoint is the main decision engine. It is designed to return structured technical analysis that the GPT can cite directly instead of re-deriving logic from raw candles.
Current top-level fields:
HTF_BiasMTF_ZonesLTF_EntryPrevious_Day_HighPrevious_Day_LowSession_LevelsChecklistConfluenceNews
Sample response:
This matters for forks because if you change the strategy, you should keep the response contract coherent enough that the GPT can reason over it without hidden assumptions.
- Python 3.10+
- Docker and Docker Compose, if you want containerized runs
- cTrader Open API credentials
- ChatGPT Plus or another ChatGPT plan that supports Custom GPT Actions
- Notion integration credentials, if you want journaling
Copy .env.example to .env and fill in your values:
NOTION_SECRET=your_notion_integration_token
NOTION_DB_ID=your_notion_database_id
CTRADER_CLIENT_ID=your_ctrader_client_id
CTRADER_CLIENT_SECRET=your_ctrader_client_secret
CTRADER_HOST_TYPE=demo
CTRADER_ACCESS_TOKEN=your_ctrader_access_token
CTRADER_ACCOUNT_ID=your_ctrader_account_id
NGROK_TOKEN=your_ngrok_auth_tokenpython -m pip install -r requirements.txt
python app.pyOr with Docker:
docker-compose up --buildInside ChatGPT:
- Go to
Explore GPTs->Create - Open the
Configuretab - Paste gpt_instructions.md into Instructions
- Add a new Action
- Paste gpt-schema.yaml
- Set the API base URL to your deployed backend URL
If you fork this repo and replace the strategy:
- update the instructions first
- then update the schema if endpoint inputs or outputs changed
- then validate the GPT behavior against a real
/analyzeresponse
Use the included smoke test to validate a running backend before wiring it into ChatGPT:
python scripts/smoke_test.py --base-url http://127.0.0.1:8000 --symbol EURUSDIt checks:
/health/fetch-data/analyze
The script uses only Python standard library modules, so it does not require extra dependencies.
- Analyze EURUSD using SMC
- What is the HTF bias on NAS100?
- Has New York swept the London high?
- Reevaluate my GBPUSD long
- Place a buy limit on EURUSD
- Log this NAS100 trade
- Return all open positions
- Return all pending orders
| Endpoint | Purpose |
|---|---|
/analyze |
Full multi-timeframe strategy analysis |
/fetch-data |
Fetch raw OHLC data |
/tag-sessions |
Label candles by session |
/session-levels |
Compute session highs and lows |
/place-order |
Submit orders through cTrader |
/open-positions |
View active positions |
/pending-orders |
View pending orders |
/journal-entry |
Save trade notes to Notion |
- This repo is educational and experimental software.
- Do not treat ChatGPT output as a guaranteed trading edge.
- Do not deploy against live funds until you have verified strategy logic, execution semantics, and failure handling.
- Always test on demo first.
This project is licensed under the MIT License.





