Skip to content

z-purr/polymarket-hedge-tool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Polymarket Stocks Hedging

A smart tool to identify and capitalize on inefficient prediction markets for stock hedging opportunities on Polymarket.

Table of Contents

Overview

Polymarket provides prediction markets on stock prices, allowing users to bet YES or NO on outcomes like "Will GOOGL close above $200 by end of February?"

The Opportunity

Buying NO shares on price targets well above the current stock price effectively bets against the stock reaching that level. If correct, you earn $1 per share at expiration. If wrong but you own the stock, gains in your holdings can offset losses.

Why It Works

Prediction markets, particularly those with low liquidity, often exhibit inefficiencies. This enables discovering opportunities with 20-50%+ APY on relatively safe bets (e.g., wagering a stock won't rise 30% in two weeks).

Example Scenario

  • GOOGL at $180
  • Market: "Will GOOGL hit $250 by March?"
  • NO shares at $0.92

If GOOGL stays below $250, profit $0.08/share (~8.7% in weeks = high APY). If GOOGL reaches $250, lose $0.92/share but stock gains ~39%.

This tool scans Polymarket, ranks opportunities, and enables direct trade execution.

Features

  • Market Scanner: Identifies stock prediction markets based on price delta, expiry time, and APY.
  • Portfolio Dashboard: Displays positions, balance, and portfolio analytics.
  • Stock Holdings Tracker: Integrates holdings for hedge scenario analysis.
  • Trade Execution: Direct trading with configurable limits (wallet setup required).
  • Position Redemption: Automates redemption of winning positions.

Quick Start

Run the scanner in view-only mode without wallet configuration.

Prerequisites

  • Node.js (v18+ recommended)
  • npm or yarn

Installation

  1. Install Dependencies

    npm install
  2. Configure Scanner

    Edit config/config.json:

    {
      "stocks": ["GOOGL", "AMZN"],
      "opportunities": {
        "opportunityAPY": 25,
        "minDisplayAPY": 8,
        "minDeltaPercent": 7
      }
    }
    Field Description
    stocks Stock tickers to scan
    opportunityAPY APY threshold for highlighting opportunities
    minDisplayAPY Minimum APY to display opportunities
    minDeltaPercent Minimum price delta percentage
  3. Run the Application

    npm run dev

    Visit http://localhost:3000

Trading Setup

Enable trading by configuring your Polymarket wallet.

⚠️ Important: Review the Security section before proceeding.

1. Environment Configuration

Create a .env file in the project root:

# Wallet Credentials (required for trading)
POLYGON_PRIVATE_KEY=your_wallet_private_key
POLYMARKET_FUNDER_ADDRESS=your_polymarket_proxy_wallet_address
POLYGON_RPC_URL=https://polygon-rpc.com

# Authentication
TRADE_PASSWORD=your_secure_password

# Mode
READONLY_MODE=true

Locating Proxy Address: Find your Polymarket proxy address in account settings or deposit details.

2. Enable Trading

  • Click Login in the app header.
  • Enter your TRADE_PASSWORD to unlock trading features.

Usage

Dashboard Overview

  • Positions: Total value and count of open positions.
  • Balance: Available USDC for trading.
  • Opportunities: Count of high-APY opportunities.
  • Stock Holdings: Input owned shares for hedge calculations.

Opportunities Table

Sortable columns:

Column Description
Market Event title with Polymarket link
Strike Target price
Delta Percentage from current price
NO Price Best ask for NO shares
APY Annualized yield if NO wins
Score Opportunity rating (0-100)
Expires Days to resolution

Trading Process

  1. Select Trade on an opportunity.
  2. Set Max Price and Max Amount.
  3. Review cost, APY, and profit projections.
  4. For holdings integration: View hedge scenarios (profit if below strike, cost if above).
  5. Execute the trade.

Skipping Opportunities

  • Snooze (24h): Temporarily hide for 24 hours.
  • Dismiss Forever: Permanently remove.

Scoring Formula

Opportunities are scored out of 100:

Score = APY Score (max 30) + Delta Score (max 70)

APY Score = min(APY, 200) / 200 * 30
Delta Score = min(|delta|, 50) / 50 * 70

Higher delta indicates safer bets (lower probability of reaching strike).

Security

  • Private Key: Grants full wallet access. Use a dedicated wallet with limited funds. Never share or commit.
  • Trade Password: Secure access to trading. Use strong passwords for internet-exposed instances.
  • Readonly Mode: Default enabled. Requires authentication to modify data.
  • Stock Holdings: Stored locally in browser (localStorage). Not transmitted.
  • Self-Hosting: Designed for personal infrastructure. Avoid third-party hosting with credentials.

Deployment

Docker Deployment

docker compose up -d --build

Runs on port 50003 by default.

VPN Setup (Optional)

Required for restricted regions (e.g., France). Remove VPN service from docker-compose.yml if unnecessary.

1. Obtain OpenVPN Config

Using Proton VPN as example:

  1. Access Proton VPN Dashboard.
  2. Go to Downloads > OpenVPN configuration files.
  3. Select Linux, UDP/TCP, specific server (e.g., Ireland).
  4. Download .ovpn file.
  5. Retrieve OpenVPN credentials from Account section.

2. Prepare Files

mkdir -p vpn
mv ~/Downloads/your-server.ovpn vpn/vpn.ovpn

3. Authentication File

Create vpn/vpn.auth:

your-openvpn-username
your-openvpn-password

4. Update Config

Edit vpn/vpn.ovpn:

  • Change auth-user-pass to auth-user-pass /vpn/vpn.auth
  • Comment out update-resolv-conf lines if present.

5. Deploy

docker compose up -d

About

Analysis of High-Yield Hedging Opportunities on Polymarket’s Stock Prediction Markets

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages