Bots & Automation

Security for Trading Bots: Accounts, Tokens and Servers

Practical security for algorithmic traders: protecting trading accounts, API tokens and VPS servers, installing third-party bots safely, and limiting the damage if something leaks.

By AlgoXP3 min readUpdated

Layers of protection around a trading bot: least data, encryption and access control

A trading bot is software with access to money. That makes its environment - the trading account, the computer it runs on, the tokens it uses to send alerts - a target. Most security incidents in retail algorithmic trading are not sophisticated attacks; they are leaked passwords, reused tokens and unpatched servers. A few habits prevent almost all of them.

Protect the trading account

  • Unique, strong password and two-factor authentication where your broker or platform supports it.
  • Separate accounts for testing and live trading. A bot under development should never run on the live account.
  • Separate accounts for separate strategies if you run several, so a bug in one cannot drain capital allocated to another.
  • Check account activity regularly: logins, trades you do not recognise, changes to settings.

Treat tokens and keys as passwords

Bots often use secrets: a Telegram bot token for alerts, API keys for data services, credentials for a database.

  • Never put secrets in code that is shared, uploaded or shown in screenshots.
  • Never paste them into chats or forums when asking for help.
  • Store them as bot parameters or in protected settings files readable only by the user that runs the bot.
  • One secret per purpose. If the alert token leaks, it should not also unlock your data provider.
  • Rotate secrets when people leave a project, after a suspected leak, and periodically.

Install third-party bots carefully

Bots and indicators from other developers run with the permissions you give them.

  • Prefer official marketplaces with reviews and seller verification, such as the cTrader Store.
  • Look at access rights. On cTrader, algorithms declare an access-rights level. Network functions are available without elevated rights in recent versions; a bot that asks for full access to your computer should have a good reason.
  • Test on demo first and watch what it does: trades, files, network activity.
  • Keep copies of the exact version you tested, so an update cannot silently change behaviour.

Secure the server

If bots run on a VPS or dedicated server:

  • SSH with keys, not passwords; disable root login with a password.
  • Firewall: allow only the ports you need.
  • Automatic security updates for the operating system.
  • Run bots under a normal user, not as administrator.
  • Back up configuration, not secrets in plain text to shared storage.
  • Monitor the server - disk space, memory, unexpected logins.

Limit the blast radius

Assume something will go wrong one day, and decide how much it can cost:

  • Account-level limits: daily and total loss limits enforced by a risk bot.
  • Position limits: maximum size and number of positions per bot.
  • Capital allocation: keep only the capital a strategy needs on its account.
  • Alerting: unusual activity should reach you quickly - see monitoring trading bots.

Keep less data

Logs and journals are useful, but they can contain account numbers, balances and personal details.

  • Log what you need to debug and evaluate - signals, orders, results - not everything.
  • Avoid writing full credentials or tokens to logs, even partially.
  • Delete old logs on a schedule.

A short checklist

  • Two-factor authentication on platform and broker accounts.
  • Separate demo/live and per-strategy accounts.
  • No secrets in code, screenshots or chats.
  • Third-party bots tested on demo, access rights checked.
  • Server: SSH keys, firewall, automatic updates, non-root user.
  • Loss and position limits enforced automatically.
  • Logs free of secrets, rotated regularly.

Key takeaways

  • Most incidents come from leaked secrets and careless setups, not clever attacks.
  • Keep tokens out of code and chats; one secret per purpose; rotate after any doubt.
  • Test third-party bots on demo and check their access rights.
  • Limit how much any single failure can cost with account and position limits.

FAQ

Is it safe to run a bot from an unknown developer?

Treat it like any software that can trade your money. Prefer official stores, check what access rights the bot requests, test it on a demo account first, and never give it more than the account it needs.

What should I do if a token or password leaks?

Revoke or change it immediately, check recent activity on the affected account or service, and replace it everywhere it was used. Rotating a secret is cheap; waiting is not.

Does a VPS need special security?

Yes: key-based SSH login, a firewall that only opens needed ports, automatic security updates, and no secrets stored in shared folders or code repositories.

Sources and further reading

  1. OWASP: Secrets Management Cheat Sheet - cheatsheetseries.owasp.org
  2. cTrader Help: Network access for algos (access rights) - help.ctrader.com