Files
poly-maker/README.md
T

158 lines
4.1 KiB
Markdown
Raw Normal View History

2025-03-31 12:16:51 -04:00
# Poly-Maker
2025-04-02 09:33:32 -07:00
A market making bot for Polymarket prediction markets. This bot automates the process of providing liquidity to markets on Polymarket by maintaining orders on both sides of the book with configurable parameters. A summary of my experience running this bot is available [here](https://x.com/defiance_cr/status/1906774862254800934)
2025-03-31 12:16:51 -04:00
## Overview
Poly-Maker is a comprehensive solution for automated market making on Polymarket. It includes:
- Real-time order book monitoring via WebSockets
- Position management with risk controls
- Customizable trade parameters fetched from Google Sheets
- Automated position merging functionality
- Sophisticated spread and price management
## Structure
The repository consists of several interconnected modules:
- `poly_data`: Core data management and market making logic
- `poly_merger`: Utility for merging positions (based on open-source Polymarket code)
- `poly_stats`: Account statistics tracking
- `poly_utils`: Shared utility functions
- `data_updater`: Separate module for collecting market information
## Requirements
2025-11-03 09:26:42 -08:00
- Python 3.9.10 or higher
2025-03-31 12:16:51 -04:00
- Node.js (for poly_merger)
- Google Sheets API credentials
- Polymarket account and API credentials
## Installation
2025-11-03 09:26:42 -08:00
This project uses UV for fast, reliable package management.
### Install UV
```bash
# macOS/Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
# Windows
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
# Or with pip
pip install uv
2025-03-31 12:16:51 -04:00
```
2025-11-03 09:26:42 -08:00
### Install Dependencies
```bash
# Install all dependencies
uv sync
# Install with development dependencies (black, pytest)
uv sync --extra dev
```
### Quick Start
```bash
# Run the market maker (recommended)
uv run python main.py
# Update market data
uv run python update_markets.py
# Update statistics
uv run python update_stats.py
```
### Setup Steps
2025-11-03 09:28:34 -08:00
#### 1. Clone the repository
2025-11-03 09:26:42 -08:00
```bash
2025-03-31 12:16:51 -04:00
git clone https://github.com/yourusername/poly-maker.git
cd poly-maker
```
2025-11-03 09:28:34 -08:00
#### 2. Install Python dependencies
2025-11-03 09:26:42 -08:00
```bash
uv sync
2025-03-31 12:16:51 -04:00
```
2025-11-03 09:28:34 -08:00
#### 3. Install Node.js dependencies for the merger
```bash
2025-03-31 12:16:51 -04:00
cd poly_merger
npm install
cd ..
```
2025-11-03 09:28:34 -08:00
#### 4. Set up environment variables
```bash
2025-03-31 12:16:51 -04:00
cp .env.example .env
```
2025-11-03 09:28:34 -08:00
#### 5. Configure your credentials in `.env`
Edit the `.env` file with your credentials:
2025-03-31 12:16:51 -04:00
- `PK`: Your private key for Polymarket
- `BROWSER_ADDRESS`: Your wallet address
2025-11-03 09:28:34 -08:00
**Important:** Make sure your wallet has done at least one trade through the UI so that the permissions are proper.
#### 6. Set up Google Sheets integration
- Create a Google Service Account and download credentials to the main directory
- Copy the [sample Google Sheet](https://docs.google.com/spreadsheets/d/1Kt6yGY7CZpB75cLJJAdWo7LSp9Oz7pjqfuVWwgtn7Ns/edit?gid=1884499063#gid=1884499063)
- Add your Google service account to the sheet with edit permissions
- Update `SPREADSHEET_URL` in your `.env` file
#### 7. Update market data
Run the market data updater to fetch all available markets:
```bash
uv run python update_markets.py
```
This should run continuously in the background (preferably on a different IP than your trading bot).
2025-04-17 17:39:58 -07:00
2025-11-03 09:28:34 -08:00
- Add markets you want to trade to the "Selected Markets" sheet
- Select markets from the "Volatility Markets" sheet
- Configure parameters in the "Hyperparameters" sheet (default parameters that worked well in November are included)
2025-04-02 09:20:16 -07:00
2025-11-03 09:28:34 -08:00
#### 8. Start the market making bot
2025-04-02 09:20:16 -07:00
2025-11-03 09:26:42 -08:00
```bash
uv run python main.py
2025-03-31 12:16:51 -04:00
```
## Configuration
The bot is configured via a Google Spreadsheet with several worksheets:
- **Selected Markets**: Markets you want to trade
- **All Markets**: Database of all markets on Polymarket
- **Hyperparameters**: Configuration parameters for the trading logic
2025-06-06 17:20:59 -07:00
## Poly Merger
2025-03-31 12:16:51 -04:00
The `poly_merger` module is a particularly powerful utility that handles position merging on Polymarket. It's built on open-source Polymarket code and provides a smooth way to consolidate positions, reducing gas fees and improving capital efficiency.
## Important Notes
- This code interacts with real markets and can potentially lose real money
- Test thoroughly with small amounts before deploying with significant capital
- The `data_updater` is technically a separate repository but is included here for convenience
## License
2025-06-06 17:20:59 -07:00
MIT