Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

14 Commits

Folders and files

Repository files navigation

Polymarket Strategy Lab

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.

How to run this program

1. Clone the Repository

git clone https://github.com/Kharay33455/polymarket.git
cd polymarket

2. Create Environment File

Create 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.


3. Export Your Polymarket Private Key

  1. Log into your Polymarket account
  2. Navigate to your account settings
  3. Click Export Private Key
  4. Complete identity verification if required
  5. 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.


4. (Optional) Set Up MongoDB

If you want to persist trades, logs, or backtesting data:

  1. Create a MongoDB account (recommended: MongoDB Atlas)
  2. Create a new cluster
  3. Generate a connection string
  4. 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

5. Install Dependencies

npm install

6. Implement Your Strategy

Create 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)

7. Run the Program

For local development:

npm run dev

Deployment (Optional)

To run live:

  • Deploy to a VPS (e.g., DigitalOcean, AWS, etc.)
  • Copy your .env.development values to your production environment
  • Ensure MongoDB network access allows your VPS IP
  • Use pm2 or any other process managers you're familiar with.

Security Notes

  • 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

Finally...

If you discover a winning strategy…

Share it with me.

nosakharay@gmail.com

ARIGATO 🙏

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages