This lightweight lab environment allows you to for test and trade strategies on Polymarket.
This project allows you to:
- Connect to your Polymarket account
- Execute custom trading logic on every market signal. There's about 100 every second
- Optionally persist trade data to MongoDB
- Run strategies locally or deploy to a VPS for live execution or long running tests.
git clone https://github.com/Kharay33455/polymarket.git
cd polymarketCreate a file named:
.env.development
Inside the file, add your Polymarket private key:
NODE_PRIVATE_KEY=<your_private_key>
See information on how to get this key in next step.
- Log into your Polymarket account
- Navigate to your account settings
- Click Export Private Key
- Complete identity verification if required
- Copy the private key and paste it into
.env.development
NOTE:
Never commit your private key to version control. Confirm that .env.development is in your .gitignore.
If you want to persist trades, logs, or backtesting data:
- Create a MongoDB account (recommended: MongoDB Atlas)
- Create a new cluster
- Generate a connection string
- Add it to your
.env.development:
NODE_MONGO=<your_connection_string>
Using Atlas allows you to:
- Use the same database locally
- Deploy the same configuration to your VPS
- Seamlessly switch between local and vps environments
npm installCreate your trading logic function and put in it bactesters. See backtesters/ahedge.ts for example on how to do this.
Your function would:
- Execute on every socket signal message
- Contain your entry/exit logic
- Manage risk and position sizing
- Whatever else you want to observer.
Then pass your function into createConn inside:
index.ts
Example structure:
createConn(ahedge)For local development:
npm run devTo run live:
- Deploy to a VPS (e.g., DigitalOcean, AWS, etc.)
- Copy your
.env.developmentvalues to your production environment - Ensure MongoDB network access allows your VPS IP
- Use pm2 or any other process managers you're familiar with.
- Never expose your private key to anybody.
- Use environment variables only
- Restrict MongoDB network access to your IP.
- Consider using a wallet with little to no money for experimentation
If you discover a winning strategy…
Share it with me.
nosakharay@gmail.com
ARIGATO 🙏