In this article
- 1. Give API keys the least access possible
- 2. Lock the key to your server's IP address
- 3. Store keys like passwords
- 4. Protect the account itself
- 5. Run the bot somewhere secure
- 6. Build in risk limits and an off switch
- 7. Watch it closely at the start
- A quick security checklist
- Want a bot built with security in mind?
To trade for you, a bot needs access to your exchange or brokerage account. That access is powerful, so it needs to be set up carefully. The good news is that a few simple steps remove most of the risk.
1. Give API keys the least access possible
When you create an API key on an exchange, you choose what it's allowed to do. For a trading bot:
- Allow: reading balances, and placing and cancelling orders.
- Never allow: withdrawals.
- Turn off: anything else the bot doesn't need, such as transfers between accounts.
A key without withdrawal permission can't send your funds anywhere else, even if someone steals it.
2. Lock the key to your server's IP address
Most exchanges let you restrict an API key to specific IP addresses. If your bot runs on a server with a fixed IP address, allow only that address. A stolen key then won't work from anyone else's computer.
3. Store keys like passwords
- Never put API keys in your code, in a shared document, or in a chat message.
- Keep them in encrypted storage or in protected settings on the server, readable only by the bot.
- Never send your secret key to someone who says they need it to "check" or "fix" your account. Real exchanges and real developers don't ask for it over a message.
4. Protect the account itself
- Turn on two-factor authentication (2FA) with an authenticator app rather than SMS.
- Use a strong password that you don't use anywhere else.
- Turn on withdrawal address whitelisting if your exchange offers it.
- Consider a separate sub-account for the bot, holding only the funds it trades with.
5. Run the bot somewhere secure
A bot that runs around the clock usually lives on a server, not on your laptop. That server should have:
- Regular security updates.
- Logins by SSH key only, with password logins turned off.
- A firewall that blocks everything the bot doesn't need.
- Monitoring that alerts you if the bot stops, restarts, or behaves strangely.
6. Build in risk limits and an off switch
Security isn't only about hackers. A bug or a sudden market move can also do damage. A well-built bot includes:
- A maximum position size, so no single trade can be too large.
- A maximum daily loss, after which the bot stops trading for the day.
- Sanity checks, such as refusing to trade when prices look wrong or data stops updating.
- An emergency off switch you can use from your phone, with a way to cancel all open orders at once.
If you can't stop your bot within a minute, it isn't ready to trade real money.
7. Watch it closely at the start
In the first weeks, check the bot's trades and logs every day. Set up alerts for every order, every error, and any loss above your limit. Small surprises are much easier to fix early.
A quick security checklist
- The API key has no withdrawal permission.
- The API key only works from your server's IP address.
- Keys are stored encrypted, never in code or chats.
- Two-factor authentication is on for the exchange account.
- The bot trades from a sub-account with limited funds.
- Position size and daily loss limits are set.
- You can switch the bot off from your phone.
Want a bot built with security in mind?
We set up trading bots with trade-only API keys, encrypted key storage, IP restrictions, risk limits, monitoring and an off switch from day one. If you'd like help, see our trading bot development service or talk to us. Before you start, it's worth reading what trading bots can and can't do. We build and secure the software; we don't give investment advice.

Written by
MD Salman Farshi
COO and Technical Project Manager
Salman runs day-to-day operations and plans each project with clients, then leads the team from first idea to launch, keeping the work clear, on time and on budget.




