Review the last month of trading¶
A monthly review answers three questions: how many trades closed, what did they return, and where is the risk still sitting. This guide pulls deals, completed order history and current exposure into a dated folder, then chains them into one script you can rerun at the end of every month.
Tip
Define your credentials in shell variables once. Every interactive command below reuses them, so the steps stay short and the script stays portable.
export CTID=letstrade
export ACC=7654321
export PWD_FILE=$HOME/.ctrader/pwd
1. Pull the closed trades for the month¶
deals returns closed trades only: one record per closing deal, with realised P&L. This is the same data as in the History tab in cTrader. --from and --to filter the trades by close time; --count returns the most recent closed trades. Opening fills are not included, so a position appears in deals only after it is fully or partly closed.
ctrader-cli deals --ctid=$CTID --pwd-file=$PWD_FILE --account=$ACC -q \
--from=01/06/2025 --to=30/06/2025
The output includes symbol, side, volume, execution price and realised profit for every closed trade.
2. Pull the completed order history¶
orders-history lists the orders that finished in the same range, with their final status (filled, expired, cancelled or error). Pending orders are excluded.
ctrader-cli orders-history --ctid=$CTID --pwd-file=$PWD_FILE --account=$ACC -q \
--from=01/06/2025 --to=30/06/2025
Pair the deal list with the order history to see which entries triggered which exits.
deals and orders-history have the following history limits:
- The CLI loads the full
--from/--torange with no length limit. - One call returns only the latest 200 deals (
deals) or the latest 500 orders (orders-history) in the range. - Without
--from/--to, both commands return only the last 30 days.
For a busy month, split the range into parts and run each command once per part.
3. Read the current exposure¶
exposure summarises the open exposure on the account, grouped by symbol. It is the snapshot of the risk you are still carrying the day after the review.
ctrader-cli exposure --ctid=$CTID --pwd-file=$PWD_FILE --account=$ACC -q
4. Save each result to a dated file¶
Each command prints JSON, so redirection is enough to keep a record of the review.
MONTH=2025-06
ctrader-cli deals --ctid=$CTID --pwd-file=$PWD_FILE --account=$ACC -q --from=01/06/2025 --to=30/06/2025 > ${MONTH}_deals.json
ctrader-cli orders-history --ctid=$CTID --pwd-file=$PWD_FILE --account=$ACC -q --from=01/06/2025 --to=30/06/2025 > ${MONTH}_orders.json
ctrader-cli exposure --ctid=$CTID --pwd-file=$PWD_FILE --account=$ACC -q > ${MONTH}_exposure.json
Three files, one per question, all dated and easy to diff against next month's review.
5. Combine into a monthly review script¶
Save the full sequence as monthly-review.sh. The script computes the first and last day of the previous month automatically, so it works whenever you run it.
#!/usr/bin/env bash
set -euo pipefail
CTID=letstrade
ACC=7654321
PWD_FILE=$HOME/.ctrader/pwd
MONTH=$(date -d "last month" +%Y-%m)
FROM=$(date -d "last month" +01/%m/%Y)
TO=$(date -d "last month" +$(date -d "last day of last month" +%d)/%m/%Y)
mkdir -p ${MONTH}
cd ${MONTH}
ctrader-cli deals --ctid=$CTID --pwd-file=$PWD_FILE --account=$ACC -q --from=$FROM --to=$TO > ${MONTH}_deals.json
ctrader-cli orders-history --ctid=$CTID --pwd-file=$PWD_FILE --account=$ACC -q --from=$FROM --to=$TO > ${MONTH}_orders.json
ctrader-cli exposure --ctid=$CTID --pwd-file=$PWD_FILE --account=$ACC -q > ${MONTH}_exposure.json
echo "Review for ${MONTH} saved to $(pwd)/${MONTH}_*.json"
Run it once a month and you have a timestamped folder per period. On Linux, date -d accepts the last month and last day of last month expressions directly. On macOS, replace them with the equivalent gdate from coreutils or use fixed --from and --to values.
6. Spot patterns from the data¶
The JSON files are structured for a notebook or a quick shell pipeline. Common checks include:
- Win rate: count deals with positive profit versus deals with negative profit.
- Symbol breakdown: group the deals by symbol and sum the profit per group.
- Largest single loss: sort the deals by profit and read the smallest entry.
- Open risk: read the exposure file to see which symbols still carry positions.
Pair these checks with the account-stats snapshot from the same day for a complete view of how the month changed the account.
The CLI references lists all available options for the commands used in this workflow.
Warning
cTrader CLI is a tool for trading and automation. It does not provide financial, investment, legal or tax advice. Past performance does not guarantee future results. Verify every command before you run it, test on a demo account first and protect your credentials.