Analyse your cTrader trade history using Jupyter Notebooks. This tool fetches your order history via the cTrader Open API and calculates key performance metrics like Win Rate, Average Win/Loss, and Trade Expectancy.
- Python 3.11+
- cTrader Open API Credentials: Register your application at openapi.ctrader.com to get your Client ID and Secret.
-
Install Dependencies: This project uses
uvfor fast package management.uv sync
-
Configure Credentials: Create a
credentials.jsonfile in the root directory:{ "accountId": 123456, "clientId": "your_client_id", "clientSecret": "your_client_secret", "accessToken": "your_access_token" }
-
Fetch Data & Analyse: Open
analysis.ipynbin Jupyter (or PyCharm).- The first cell uses
fetch_orders.pyto download your trade history intodata/orders.json. - Update the
from_tsvariable in the notebook to filter the start date of your analysis. - Run the subsequent cells to process the data with
pandasand view the metrics.
- The first cell uses
-
(Optional) Update OA Models: If the cTrader API definitions change, regenerate the local JSON models by running:
uv run python -c "from oa_model import create_model; create_model()"
analysis.ipynb: The main playground for data processing and visualization.fetch_orders.py: Async client to interface with the cTrader WebSocket API.models/: Contains custom JSON mappings for Open API messages and payload types.data/: Local storage for fetched order history.