Building a Polymarket RSI/MACD Trading Bot in TypeScript
The Problem
Predictive trading on Polymarket's 15-minute markets isn’t exactly beginner-friendly. You’ve got RSI, MACD, and momentum signals to juggle, all while figuring out how to execute trades on their decentralized CLOB (Central Limit Order Book). Sure, you could YOLO your way through it, but manual strategies are slow, error-prone, and frankly, a pain in the ass to scale.
What This Does
This bot automates trading decisions using technical indicators like RSI, MACD, and Momentum, with clear separation of concerns in the codebase. The entry point (src/main.ts) handles authentication, market discovery, and running your chosen mode—either simulation or live trading.
The heavy lifting happens in src/indicators.ts and src/strategies.ts. Indicators like RollingRSI and RollingMACD crunch market data, while decide() in strategies.ts applies strategy logic to generate buy/sell signals. Meanwhile, src/monitor.ts takes care of market data snapshots, and src/api.ts wraps Polymarket's Gamma API and CLOB functionality into a neat little package.
Configuration is managed in config.json. You’ll define stuff like your private key, API URLs, trading thresholds, and strategy settings (rsi, macd, etc.). There’s even flexibility to toggle between simulation and live modes with a simple CLI flag.
Real-World Use
Let’s say you want to run a momentum strategy on ETH’s 15-minute markets. You’d start by cloning the repo, running npm install, and copying config.json.example to config.json. Then, set your polymarket.private_key for live mode or leave it blank for simulations.
The bot will use your config to fetch market data (src/monitor.ts), calculate momentum signals (src/indicators.ts), and log trading decisions (simulation.ts). Want to go live? Swap --simulation for --live and watch it place actual orders via src/clob.ts.
The Bottom Line
Look, it’s a solid bot if you’re into algo trading on Polymarket. The code is clean, modular, and reasonably documented, though the lack of stars suggests it’s either underused or overshadowed by the original Rust version. If you’re comfortable with TypeScript and want a framework for experimenting with RSI/MACD strategies, this is worth cloning. Just don’t expect hand-holding—this is DIY trading, not a plug-and-play solution.