Set up cTrader CLI¶
This article covers installing cTrader CLI, creating a credentials file and confirming the connection on Windows, macOS or Linux, from a terminal or a Docker container.
Prerequisites¶
- A cTrader ID with at least one trading account.
- A supported package manager: WinGet on Windows, Homebrew on macOS and Linux.
- For cBots, .NET 8. Recompile older cBots in the latest cTrader desktop application before running them with cTrader CLI.
Install with a package manager¶
Package manager installation is the recommended method. It downloads the correct build for your operating system and adds the ctrader-cli command to your PATH, so you can run it from any folder.
Open Windows PowerShell as an administrator and run:
winget install Spotware.cTrader.CLI
Open a terminal and run:
brew tap spotware/tap https://github.com/spotware/homebrew-tap
brew install spotware/tap/ctrader-cli
If Homebrew is not installed, follow the instructions on the Homebrew website first.
Open a terminal and run:
brew tap spotware/tap https://github.com/spotware/homebrew-tap
brew install spotware/tap/ctrader-cli
If Homebrew is not installed, follow the instructions on the Homebrew website first.
Warning
Install cTrader CLI only from the official Spotware package identifiers above. Installing from an unverified source can put your credentials and funds at risk.
Install with the Docker image¶
cTrader CLI is published as a Linux Docker image, which is convenient for hosting cBots on a Linux VPS, a high-performance server or a cloud platform. The image also runs on Windows through Docker Desktop with WSL.
docker pull ghcr.io/spotware/ctrader-console:latest
The cBot run walkthrough includes how to mount host folders and pass configuration through environment variables.
Tip
cTrader CLI ships with the cTrader desktop application, so you can launch a cBot in an external process without a separate install.
Install manually on Windows¶
If you prefer not to use a package manager on Windows, the ctrader-cli executable is bundled with the cTrader desktop application. It is usually located in:
C:\Users\{username}\AppData\Local\Spotware\cTrader\{installationId}
To run cTrader CLI from any folder, add this directory to your PATH:
- Copy the path to the folder that contains
ctrader-cli. - Search for Environment variables in the Windows Start menu, then select Edit the system environment variables.
- In the System properties window, select Environment variables.
- Under User variables, double-click Path.
- Select New, paste the copied path, then select OK on each dialogue to save.
Note
After you add the folder to PATH, you can run ctrader-cli followed by any command from any location.
Verify the installation¶
After installation, confirm that cTrader CLI is available. Neither command requires you to sign in.
ctrader-cli --version
ctrader-cli --help
If your terminal reports that the command cannot be found, close and reopen the terminal so that it picks up the updated PATH, then try again.
Create a credentials file¶
Most commands act on an account, so they need three values: a cTrader ID, a password and an account number.
| Detail | Option | Description |
|---|---|---|
| cTrader ID | --ctid or -c | cTID username or email |
| Password | --pwd-file | Path to a file that contains the cTID password |
| Account | --account or -a | Trading account number |
For security, do not type your cTrader ID password directly into a command. Save it in a file and point --pwd-file at that file.
- Open a plain-text editor, such as Notepad.
- Type your cTrader ID password on a single line, with no leading or trailing spaces.
- Save the file with a
.pwdor.txtextension, for examplepassword.pwd. - Reference the file from your command:
--pwd-file=C:/test/password.pwd.
With the credentials file ready, pass it to commands using one of the two authentication conventions.
Warning
A password file stores your password in plain text. Keep it outside shared or version-controlled folders, restrict who can read it and delete it when it is no longer needed.
Docker run example¶
In a container, host paths map into the container through --mount and configuration values come in through -e. A short example that starts a cBot in a container:
docker run -d -it \
--name ctrader.console.run.mybot \
--mount type=bind,src=/cAlgo/Robots,dst=/mnt/Robots \
-e CTID='mycid' \
-e PWD-FILE='/mnt/Robots/ctrader-cli.pwd' \
-e ACCOUNT='9102302' \
-e SYMBOL='EURUSD' \
-e PERIOD='H1' \
ghcr.io/spotware/ctrader-console:latest run "/mnt/Robots/My bot.algo" --environment-variables
For the full Docker walkthrough, including how each option maps, see how to run and manage cBots.