Mastering Risk Management: The Secret to Robust Trading BotsMastering Risk Management: The Secret to Robust Trading Bots
The network for creativity
Join 1.25M professional creatives like you
Connect with clients, get discovered, and run your business 100% commission-free
Creatives on Contra have earned over $150M and we are just getting started
๐Ÿด ๐—Ÿ๐—ฎ๐˜†๐—ฒ๐—ฟ๐˜€ ๐—ผ๐—ณ ๐—ฅ๐—ถ๐˜€๐—ธ โš  They can have the perfect signal. The bot's going to burn anyway โ€” because signal isn't the bottleneck.
The bottleneck is risk governance.
I built a copytrading bot for Polymarket that follows "smart money" wallets in real time: 3 signal engines running in parallel (Polygon WSS, Polymarket WS Market, Data API polling), dedup by trade_id, execution via CLOB with FAK orders.
The hardest part was NOT getting the signals. It was building the 8 risk layers that decide whether a trade actually gets placed:
๐—Ÿ๐Ÿญ โ€” ๐—ฃ๐—ฒ๐—ฟ-๐˜๐—ฟ๐—ฎ๐—ฑ๐—ฒ ๐˜€๐—ถ๐˜‡๐—ถ๐—ป๐—ด ยท Max 2% of wallet capital per trade. Protects against the classic "one bad trade".
๐—Ÿ๐Ÿฎ โ€” ๐—ง๐—ผ๐˜๐—ฎ๐—น ๐—ฒ๐˜…๐—ฝ๐—ผ๐˜€๐˜‚๐—ฟ๐—ฒ ๐—ฐ๐—ฎ๐—ฝ ยท Max 60% of equity open at once. So you're not over-exposed when the market flips.
๐—Ÿ๐Ÿฏ โ€” ๐—ฆ๐—ถ๐—ป๐—ด๐—น๐—ฒ ๐—บ๐—ฎ๐—ฟ๐—ธ๐—ฒ๐˜ ๐—ฐ๐—ฎ๐—ฝ ยท Max 15% of equity in any single market. Against accidental concentration ("the wallet's favorite market").
๐—Ÿ๐Ÿฐ โ€” ๐—–๐—ฎ๐˜๐—ฒ๐—ด๐—ผ๐—ฟ๐˜† ๐—ฐ๐—ผ๐—ป๐—ฐ๐—ฒ๐—ป๐˜๐—ฟ๐—ฎ๐˜๐—ถ๐—ผ๐—ป ยท Per-category caps (Crypto, Sports, Politicsโ€ฆ) with per-wallet overrides. Against implicit correlation.
๐—Ÿ๐Ÿฑ โ€” ๐—ฃ๐—ผ๐˜€๐—ถ๐˜๐—ถ๐—ผ๐—ป ๐—ฐ๐—ผ๐˜‚๐—ป๐˜ ๐—ฐ๐—ฎ๐—ฝ ยท Max 8 open positions per wallet. Against the bot going crazy on an active day and opening 30 trades nobody can track.
๐—Ÿ๐Ÿฒ โ€” ๐— ๐—ฎ๐—ฟ๐—ธ๐—ฒ๐˜ ๐—ฐ๐—ผ๐˜‚๐—ป๐˜ ๐—ฐ๐—ฎ๐—ฝ ยท Max 4 distinct markets open at once. Against cognitive dispersion.
๐—Ÿ๐Ÿณ โ€” ๐——๐—ฟ๐—ฎ๐˜„๐—ฑ๐—ผ๐˜„๐—ป ๐—ฝ๐—ฎ๐—ป๐—ถ๐—ฐ ยท Auto-pause at wallet and portfolio level. Smart wallets ALSO have bad streaks โ€” copying them means knowing when to cut them off.
๐—Ÿ๐Ÿด โ€” ๐—ฆ๐˜‚๐—ฏ & ๐—”๐˜€๐˜€๐—ฒ๐˜ ๐—ณ๐—ถ๐—น๐˜๐—ฒ๐—ฟ ยท Whitelist of subcategories and assets. Against catching the random trades a smart wallet places outside its real edge.
Pre-filters before any of this fires: excluded categories, signal age (don't copy stale trades), slippage control, resize ratio, minimum trade size.
๐—ง๐—ต๐—ฟ๐—ฒ๐—ฒ ๐—ถ๐—บ๐—ฝ๐—น๐—ฒ๐—บ๐—ฒ๐—ป๐˜๐—ฎ๐˜๐—ถ๐—ผ๐—ป ๐—ฑ๐—ฒ๐˜๐—ฎ๐—ถ๐—น๐˜€ ๐˜„๐—ผ๐—ฟ๐˜๐—ต ๐—ป๐—ผ๐˜๐—ถ๐—ป๐—ด:
โ†’ Every layer is ๐˜๐—ผ๐—ด๐—ด๐—น๐—ฒ๐—ฎ๐—ฏ๐—น๐—ฒ ๐—ผ๐—ป/๐—ผ๐—ณ๐—ณ ๐—ณ๐—ฟ๐—ผ๐—บ ๐˜๐—ต๐—ฒ ๐—ฑ๐—ฎ๐˜€๐—ต๐—ฏ๐—ผ๐—ฎ๐—ฟ๐—ฑ ๐—ถ๐—ป ๐—ฟ๐—ฒ๐—ฎ๐—น ๐˜๐—ถ๐—บ๐—ฒ. No restart. No redeploy.
โ†’ Config update is ๐˜‡๐—ฒ๐—ฟ๐—ผ-๐—ฝ๐—ผ๐—น๐—น๐—ถ๐—ป๐—ด: the dashboard writes straight to the in-memory singleton + persists to DB. The bot reads via dict lookup (sub-nanosecond).
โ†’ When panic fires, it's not a kill: marks DB status, cancels pending orders, fires a Telegram alert. Reversible if it was a false alarm.
What I take away after months running it:
๐—ง๐—ต๐—ฒ ๐˜€๐—ถ๐—ด๐—ป๐—ฎ๐—น ๐—ถ๐˜€ ๐—ก๐—ข๐—ง ๐˜๐—ต๐—ฒ ๐—บ๐—ผ๐—ฎ๐˜. ๐—ง๐—ต๐—ฒ ๐˜€๐—ถ๐—ด๐—ป๐—ฎ๐—น ๐—ถ๐˜€ ๐—ฐ๐—ผ๐—บ๐—บ๐—ผ๐—ฑ๐—ถ๐˜๐˜† ๐˜๐—ผ๐—ฑ๐—ฎ๐˜†. What separates a bot that survives from one that blows up in its first month is the risk engine.
If you build bots and you only have 1-2 risk layers, add L3, L5 and L7 tomorrow โ€” those three alone save you from the most common failure modes.
More of what I'm building: niv-labs.dev
DM open.
#AlgorithmicTrading #Polymarket #Quant #RiskManagement #Python
Post image
Back to feed
The network for creativity
Join 1.25M professional creatives like you
Connect with clients, get discovered, and run your business 100% commission-free
Creatives on Contra have earned over $150M and we are just getting started