Skip to content

codiebyheaart/Polymarket-Trading-Bot-Automated-CLOB-Strategy-in-JavaScript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Polymarket Trading Bot: Automated CLOB Strategy in JavaScript

Description

This project provides a robust, automated trading bot for Polymarket, the world's leading prediction market. Built with JavaScript (Node.js) and the official Polymarket CLOB (Central Limit Order Book) Client, this script enables developers and traders to programmatically enter and exit positions based on custom strategies.

It is designed as a foundational template for algorithmic trading on prediction markets, featuring secure wallet authentication, limit order management, and a modular architecture for implementing sophisticated Entry and Exit logic.

Use Cases

  • Algorithmic Betting: Automate your betting strategy based on real-time probabilities.
  • Market Making: Provide liquidity to specific outcome tokens.
  • Arbitrage: Detect and exploit price inefficiencies.
  • Copy Trading: Adapt the logic to mirror other successful wallets.

Features

  • Direct CLOB Integration: Interacts directly with the Polymarket exchange for low-latency execution.
  • Entry & Exit Logic: Modular functions to define exact conditions for buying and selling shares.
  • Secure Authentication: Uses local environment variables to manage private keys securely.
  • Verification Support: Includes syntax checking and error handling for reliable operation.

Prerequisites

  • Node.js (v18 or higher recommended)
  • A Polygon-compatible wallet (e.g., MetaMask) with:
    • MATIC for gas fees.
    • USDC (Polygon) for trading capital.
  • A Polymarket account (your wallet must be connected to Polymarket).

Installation

  1. Clone the repository or download the source code.
  2. Navigate to the project directory.
    cd polymarket-trading-bot
  3. Install the required dependencies.
    npm install

Configuration

  1. Locate the env.example file in the root directory.
  2. Rename it to .env.
    mv env.example .env
  3. Open .env in a text editor and add your wallet Private Key.
    PRIVATE_KEY=your_private_key_here
    
    Note: Ensure this key is kept private. Do not commit your .env file to version control.

Usage

To start the bot, run the following command in your terminal:

node index.js

The script will initialize the CLOB client, derive your API credentials, and begin executing the logic defined in index.js.

Customization

Trading Strategy

Modify strategy.js to implement your custom logic.

  • shouldEnter(marketData): Define conditions to buy shares (e.g., "Price < 0.30").
  • shouldExit(positionData, marketData): Define conditions to sell shares (e.g., "Profit > 15%").

Market Settings

Edit index.js to configure:

  • MARKET_ID: The Token ID of the specific outcome you wish to trade.
  • SHARE_AMOUNT: The size of the order to place.
  • ENTRY_PRICE / EXIT_PRICE: The limit prices for your orders.

Disclaimer

This software is for educational purposes only. Trading prediction markets involves significant risk. You are solely responsible for any financial losses incurred while using this software. Always test with small amounts before scaling up.

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published