From ae90b7b15c8720aaf1ef052ee1bac7d7b4e3f201 Mon Sep 17 00:00:00 2001 From: warproxxx Date: Wed, 2 Apr 2025 09:20:16 -0700 Subject: [PATCH] Update ReadMe and add sample sheet --- .python-version | 1 + README.md | 28 ++++--- data_updater/README.md | 78 ------------------- data_updater/credentials.json.example | 12 --- data_updater/requirements.txt | 4 - data_updater/trading_utils.py | 3 +- requirements.txt | 13 +++- .../update_markets.py => update_markets.py | 6 +- 8 files changed, 35 insertions(+), 110 deletions(-) create mode 100644 .python-version delete mode 100644 data_updater/README.md delete mode 100644 data_updater/credentials.json.example delete mode 100644 data_updater/requirements.txt rename data_updater/update_markets.py => update_markets.py (95%) diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..43077b2 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.9.18 diff --git a/README.md b/README.md index 474194c..cd0181f 100644 --- a/README.md +++ b/README.md @@ -31,39 +31,49 @@ The repository consists of several interconnected modules: ## Installation -1. Clone the repository: +1. **Clone the repository**: ``` git clone https://github.com/yourusername/poly-maker.git cd poly-maker ``` -2. Install Python dependencies: +2. **Install Python dependencies**: ``` pip install -r requirements.txt ``` -3. Install Node.js dependencies for the merger: +3. **Install Node.js dependencies for the merger**: ``` cd poly_merger npm install cd .. ``` -4. Set up your environment variables by copying the example file: +4. **Set up environment variables**: ``` cp .env.example .env ``` -5. Edit the `.env` file with your credentials: +5. **Configure your credentials in `.env`**: - `PK`: Your private key for Polymarket - `BROWSER_ADDRESS`: Your wallet address -- `SPREADSHEET_URL`: URL to your Google Sheets configuration -6. Create a Google Service Account and download credentials: +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 `python update_markets.py` to fetch all available markets + - This should run continuously in the background (preferably on a different IP than your trading bot) + - Add markets you want to trade to the "Selected Markets" sheet. You'd wanna select markets from the "Volatility Markets" sheet. + - Configure corresponding parameters in the "Hyperparameters" sheet. Default parameters that worked well in November are there. + +8. **Start the market making bot**: ``` -cp data_updater/credentials.json.example credentials.json +python main.py ``` -Edit the credentials.json with your Google service account details. ## Configuration diff --git a/data_updater/README.md b/data_updater/README.md deleted file mode 100644 index ea04c4a..0000000 --- a/data_updater/README.md +++ /dev/null @@ -1,78 +0,0 @@ -# Polymarket Market Maker Data Updater - -This tool analyzes Polymarket prediction markets to identify profitable market making opportunities. It fetches market data, calculates potential rewards, analyzes price volatility, and updates a Google Spreadsheet with the results. - -## Features - -- Fetches all available Polymarket markets -- Calculates rewards based on market maker formulas -- Analyzes price volatility over different time windows -- Updates Google Sheets with market opportunities sorted by profitability -- Automatically runs every 5 minutes - -## Prerequisites - -- Python 3.7+ -- A Google Cloud project with Sheets API enabled -- Polymarket account with an API key - -## Setup - -1. Clone the repository -2. Install dependencies: - ``` - pip install -r requirements.txt - ``` -3. Create a `.env` file with your private key (see example below) -4. Create a Google service account and download `credentials.json` -5. Set up your Google Spreadsheet with the following worksheets: - - "All Markets" - - "Volatility Markets" - - "Full Markets" - - "Selected Markets" - -## Running the Tool - -``` -python update_markets.py -``` - -This will start the continuous update process, refreshing market data every 5 minutes. - -## Configuration Files - -### .env Example - -``` -PK=your_polygon_wallet_private_key -SPREADSHEET_URL=https://docs.google.com/spreadsheets/d/your_spreadsheet_id/edit -``` - -### credentials.json Example - -This is a Google service account credentials file. Create one at the [Google Cloud Console](https://console.cloud.google.com/): - -```json -{ - "type": "service_account", - "project_id": "your-project-id", - "private_key_id": "abc123...", - "private_key": "-----BEGIN PRIVATE KEY-----\nYOUR_PRIVATE_KEY_HERE\n-----END PRIVATE KEY-----\n", - "client_email": "your-service-account@your-project-id.iam.gserviceaccount.com", - "client_id": "123456789", - "auth_uri": "https://accounts.google.com/o/oauth2/auth", - "token_uri": "https://oauth2.googleapis.com/token", - "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", - "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/your-service-account%40your-project-id.iam.gserviceaccount.com" -} -``` - -## Security Notes - -- Keep your private key and credentials.json secure -- Never commit sensitive files to public repositories -- Use environment variables for sensitive information - -## Disclaimer - -This tool is for educational purposes only. Trading cryptocurrency involves significant risk. This is not financial advice. \ No newline at end of file diff --git a/data_updater/credentials.json.example b/data_updater/credentials.json.example deleted file mode 100644 index 148503a..0000000 --- a/data_updater/credentials.json.example +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "service_account", - "project_id": "your-project-id", - "private_key_id": "abc123...", - "private_key": "-----BEGIN PRIVATE KEY-----\nYOUR_PRIVATE_KEY_HERE\n-----END PRIVATE KEY-----\n", - "client_email": "your-service-account@your-project-id.iam.gserviceaccount.com", - "client_id": "123456789", - "auth_uri": "https://accounts.google.com/o/oauth2/auth", - "token_uri": "https://oauth2.googleapis.com/token", - "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", - "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/your-service-account%40your-project-id.iam.gserviceaccount.com" -} \ No newline at end of file diff --git a/data_updater/requirements.txt b/data_updater/requirements.txt deleted file mode 100644 index 9aba353..0000000 --- a/data_updater/requirements.txt +++ /dev/null @@ -1,4 +0,0 @@ -py-clob-client -gspread -gspread-dataframe -pandas diff --git a/data_updater/trading_utils.py b/data_updater/trading_utils.py index 2612547..1a28a85 100644 --- a/data_updater/trading_utils.py +++ b/data_updater/trading_utils.py @@ -3,7 +3,6 @@ from py_clob_client.client import ClobClient from py_clob_client.clob_types import OrderArgs, BalanceAllowanceParams, AssetType from py_clob_client.order_builder.constants import BUY -from web3.constants import MAX_INT from web3 import Web3 from web3.middleware import geth_poa_middleware @@ -16,6 +15,8 @@ import time import os +MAX_INT = 2**256 - 1 + def get_clob_client(): host = "https://clob.polymarket.com" key = os.getenv("PK") diff --git a/requirements.txt b/requirements.txt index 51c2b0d..0f227fa 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,12 +1,19 @@ -py-clob-client +py-clob-client==0.20.0 python-dotenv pandas gspread gspread-dataframe sortedcontainers -websockets==12.0.0 +black==24.4.2 +eth-account===0.13.0 +eth-utils===4.1.1 +poly_eip712_structs==0.0.1 +py_order_utils==0.3.2 +pytest==8.2.2 +python-dotenv==0.19.2 +requests==2.32.3 +websockets==12.0 cryptography==42.0.8 -web3==5.3.1 asyncio requests google-auth \ No newline at end of file diff --git a/data_updater/update_markets.py b/update_markets.py similarity index 95% rename from data_updater/update_markets.py rename to update_markets.py index dbd3ae2..ce1d19e 100644 --- a/data_updater/update_markets.py +++ b/update_markets.py @@ -1,8 +1,8 @@ import time import pandas as pd -from trading_utils import get_clob_client -from google_utils import get_spreadsheet -from find_markets import get_sel_df, get_all_markets, get_all_results, get_markets, add_volatility_to_df +from data_updater.trading_utils import get_clob_client +from data_updater.google_utils import get_spreadsheet +from data_updater.find_markets import get_sel_df, get_all_markets, get_all_results, get_markets, add_volatility_to_df from gspread_dataframe import set_with_dataframe import traceback