Infrastructure
My Bot Signs 1,000 Trades a Day. Here's How I Sleep at Night.
A practical guide to securing high-frequency bots without sacrificing execution speed.
If you run a trading bot that executes dozens or hundreds of trades an hour, you’re constantly fighting a two-front war: Speed vs Security.
I run grid and momentum bots that sign roughly 1,000 trades over a typical 24-hour period. For a long time, my anxiety scaled linearly with my volume. Every API call was a cryptographic payload signed by a hot key sitting on an AWS server. If that server was breached, my $60,000 bankroll was gone.
Here is exactly how I re-architected my bot to eliminate that anxiety, permanently.
The Flawed “Best Practices”
If you ask ChatGPT how to secure a trading bot, it will tell you to use a secret manager like AWS Secrets Manager or HashiCorp Vault.
This is terrible advice for a trading bot.
Here’s what happens: Your Python bot starts, it makes an API call to Secrets Manager to fetch the API_SECRET, and then it holds that secret in the application’s memory for the lifetime of the process.
To an attacker with memory dumping tools, or an attacker who simply hijacks the running Python process, grabbing that key is trivial. The “secret manager” just moved the vulnerability from the disk to the RAM.
The Hardware Enclave Approach
You need an architecture where your bot never sees the key at all.
To do this, you split your infrastructure into two completely separate pieces:
- The Brain: Your bot (Python/Rust/Node.js) that decides when and what to trade.
- The Vault: An isolated environment that holds the key and signs payloads.
I use ZeroCopy, which deploys an AWS Nitro Enclave right next to my EC2 instance.
How the Flow Works Now
- My Python bot calculates that BTC is oversold and decides to market buy.
- It crafts the JSON payload required by Binance:
{"symbol":"BTCUSDT","side":"BUY","type":"MARKET","quantity":0.5}. - Instead of signing it, the bot sends this raw JSON over a local unix socket to the ZeroCopy Vault.
- The Vault, which holds the API key inside a hardware-isolated enclave with no external access, cryptographically signs the payload.
- The Vault returns the signature to the bot.
- The bot sends the signed payload to Binance.
Why This Lets Me Sleep
1. Zero Exposure: Even if I intentionally wrote a script to extract the key from my own bot, I couldn’t do it. The key isn’t there.
2. Ephemeral Isolation: The Vault runs exclusively in CPU and RAM allocated by the AWS Nitro hypervisor. There is no SSH access, no interactive shell, and no disk. If the underlying server is compromised and rebooted, the vault memory is wiped clean.
But What About the Latency?
This is the main reason traders avoid self-custody vaults. If you use a cloud HSM (AWS KMS, Azure Key Vault) or a service like Fireblocks, sending the payload to the vault and getting the signature back requires a network round-trip. AWS KMS adds at minimum ~10-25ms even within the same region. Institutional MPC providers are slower still — the signing happens across multiple parties over the network.
In momentum trading, 25ms is significant. It is the difference between getting the price you want and getting the price the market moved to.
Because ZeroCopy runs as a Nitro Enclave on the exact same physical hardware as the bot, there is no network round-trip — the communication happens over a local vsock via the hypervisor. The actual EdDSA signing takes 42 microseconds (measured on a c6i.metal instance).
I get hardware-isolated key security, and my bot still executes faster than the exchange can process the order — the exchange matching engine adds 2-10ms of latency that dwarfs the 42µs signing overhead.
If you’re running volume, stop playing Russian roulette with your keys. Isolate the signing layer, and you will sleep significantly better.
Continue Reading
Enjoyed this?
Get one deep infrastructure insight per week.
Free forever. Unsubscribe anytime.
You're in. Check your inbox.