Skip to content

AdelanSoulX/PM-Sniper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 Polymarket Endcycle Sniper Bot

AdelanX + SoulCrancer = AdelanSoulX
Adelan fully supports SoulCrancer. Seeking serious investors.

Live on Polymarket: 👤 @adelan

Telegram: @adelanx@soulcrancerdev
AdelanX: 0xec47cb4e0a4f4e375d9787debf7c874214f21119

DISCLAIMER: This software is for educational and research purposes only. Trading prediction markets involves substantial risk of loss. This is not financial advice. Do your own research, comply with all applicable laws, and never risk capital you cannot afford to lose. You are solely responsible for securing your private keys and wallet funds.

Python License Status Dry Run

polymarket-endcycle-sniper is a production-grade Python bot that scans Polymarket for tail-end / endcycle sniper opportunities — markets nearing resolution where heavily favored outcomes (typically priced $0.88–$0.98) may still offer small but consistent positive expected value when held to resolution.

Polymarket profile dashboard

AdelanBot.Proof.mp4

Overview

Prediction markets converge toward $0 or $1 as resolution approaches. In the final days/hours of a market's lifecycle, the dominant outcome often trades at $0.88–$0.98 — implying 88–98% probability. The endcycle sniper strategy buys these favored outcomes and holds to resolution, capturing the remaining 2–12% edge when the market resolves as expected.

This bot automates:

  1. Discovery — Scan active markets resolving within a configurable window (default: 0–7 days)
  2. Filtering — Apply liquidity, spread, volume, and probability thresholds
  3. Scoring — Rank opportunities by conviction (probability × edge × liquidity)
  4. Execution — Place limit buy orders slightly below best ask via CLOB V2
  5. Risk management — Position sizing, exposure limits, daily loss caps, cooldowns
  6. Audit — Full SQLite logging of every opportunity and trade

Safe by default: dry-run mode is enabled out of the box. No real orders are placed until you explicitly disable it.


Core Strategy

Tail-End Sniper Logic

Parameter Default Description
End window 0–7 days Only markets resolving soon
Min probability 88% Favored outcome must be ≥ $0.88
Max probability 98% Skip near-certain (low ROI)
Min edge 1.5% Minimum ROI if held to $1.00
Max spread Reject illiquid/wide markets

Example: A market "Will X happen by July 15?" resolves in 3 days. "Yes" trades at $0.93 ask. Buying at $0.92 limit yields ~8.7% ROI if Yes resolves ($1.00 payout). Win rate is high but losses on wrong calls are large — hence strict position sizing.

Philosophy

  • Hold to resolution for the small percentage edge
  • Limit orders below ask to improve entry
  • Diversify across multiple markets
  • Risk-first — one bad tail-end loss can wipe many small wins

Features

  • Professional Typer + Rich CLI (scan, run, backtest, positions, config, health)
  • Gamma API market discovery with end-date filtering
  • CLOB V2 order book + order placement via py-clob-client-v2
  • Pydantic v2 typed models throughout
  • SQLite persistence for opportunities, trades, and PnL
  • YAML + .env configuration
  • Paper trading / dry-run mode (default ON)
  • Telegram alerts (optional)
  • Structured logging with rotation (loguru)
  • Backtesting module (proxy replay)
  • Risk management — position limits, daily loss, cooldowns
  • Graceful shutdown on SIGINT/SIGTERM

How It Works

sequenceDiagram
    participant CLI
    participant Scanner
    participant Gamma
    participant CLOB
    participant Analyzer
    participant Executor
    participant DB

    CLI->>Scanner: scan / run
    Scanner->>Gamma: GET /markets (endDate filter)
    Gamma-->>Scanner: market metadata + clobTokenIds
    loop Each candidate
        Scanner->>CLOB: get_order_book(token_id)
        CLOB-->>Scanner: bids / asks
        Scanner->>Analyzer: score opportunity
        Analyzer-->>Scanner: ScoredOpportunity
    end
    Scanner->>Executor: approved opportunities
    Executor->>Executor: risk checks
    Executor->>CLOB: place_limit_buy (or dry-run log)
    Executor->>DB: save trade + audit log
Loading

See docs/architecture.md for full system design.


Installation

Prerequisites

  • Python 3.12+
  • A Polymarket account with funded wallet (for live trading only)
  • Polygon mainnet wallet private key (for live trading only)

Setup

# Clone the repository
git clone https://github.com/your-org/polymarket-endcycle-sniper.git
cd polymarket-endcycle-sniper

# Create virtual environment
python -m venv .venv
source .venv/bin/activate   # Windows: .venv\Scripts\activate

# Install with dev dependencies
pip install -e ".[dev]"

# Copy environment template
cp .env.example .env

# Initialize database
polymarket-sniper init-db

Quick Start

1. Configure environment

Edit .envkeep DRY_RUN=true for testing:

DRY_RUN=true
POLYMARKET_PRIVATE_KEY=          # Only needed for live trading
POLYMARKET_FUNDER_ADDRESS=       # Deposit wallet address (type 3)
POLYMARKET_SIGNATURE_TYPE=3

2. Scan for opportunities (no orders)

polymarket-sniper scan

3. Scan and simulate execution

polymarket-sniper scan --execute

4. Run continuous bot loop (dry-run)

polymarket-sniper run

5. Check simulated positions

polymarket-sniper positions

6. Go live (only after thorough testing)

DRY_RUN=false
polymarket-sniper run --execute

Warning: Live trading uses real funds. Start with minimal position sizes in config/default.yaml.


Configuration

Environment variables (.env)

Variable Required Description
DRY_RUN No true = simulate orders (default)
POLYMARKET_PRIVATE_KEY Live only Wallet private key (never commit)
POLYMARKET_FUNDER_ADDRESS Live only Proxy/deposit wallet holding funds
POLYMARKET_SIGNATURE_TYPE No 0=EOA, 3=deposit wallet (recommended)
CLOB_API_KEY/SECRET/PASS_PHRASE No Pre-derived API creds (optional)
TELEGRAM_BOT_TOKEN No Telegram bot token for alerts
TELEGRAM_CHAT_ID No Telegram chat ID
DATABASE_URL No SQLite URL (default: ./data/sniper.db)

YAML config (config/default.yaml)

strategy:
  end_window_max_days: 7
  min_implied_probability: 0.88
  max_spread: 0.05
  min_edge_pct: 0.015

risk:
  max_position_size_usd: 50
  max_concurrent_positions: 5
  max_daily_loss_usd: 100

Override with custom path: SNIPER_CONFIG_PATH=/path/to/custom.yaml

View merged config:

polymarket-sniper config

Usage

Command Description
polymarket-sniper scan One-shot market scan
polymarket-sniper scan --execute Scan + execute (respects dry-run)
polymarket-sniper scan --json JSON output
polymarket-sniper run Continuous scan/execute loop
polymarket-sniper run --interval 60 Custom scan interval (seconds)
polymarket-sniper backtest --days 30 Run backtest proxy
polymarket-sniper positions List open/simulated positions
polymarket-sniper config Show current configuration
polymarket-sniper health Check CLOB API connectivity
polymarket-sniper init-db Initialize SQLite database
polymarket-sniper version Print version

Examples

# Scan with JSON output for scripting
polymarket-sniper scan --json | jq '.[0]'

# Run bot with 3-minute scan interval
polymarket-sniper run --interval 180

# Backtest over 14 days
polymarket-sniper backtest --days 14

# Run example backtest script
python scripts/example_backtest.py

Strategy Parameters & Tuning

More aggressive

  • Lower min_implied_probability to 0.85
  • Increase end_window_max_days to 14
  • Lower min_edge_pct to 0.01
  • Increase max_position_size_usd

More conservative

  • Raise min_implied_probability to 0.92
  • Shorten end_window_max_days to 3
  • Tighten max_spread to 0.02
  • Lower max_concurrent_positions to 2
  • Increase min_volume_usd and min_liquidity_usd

Risk Management & Disclaimers

THIS SOFTWARE CAN LOSE MONEY. USE AT YOUR OWN RISK.

  • Not financial advice — for research and automation only
  • Tail-end losses are asymmetric — a $0.95 bet that loses costs ~19× a typical win
  • Private key security — never commit .env, use a dedicated trading wallet
  • Regulatory compliance — ensure prediction market trading is legal in your jurisdiction
  • No guarantees — past performance does not predict future results
  • Smart contract / API risk — Polymarket infrastructure may change without notice

Built-in safeguards:

  • Dry-run default
  • Max position size per trade
  • Max concurrent markets
  • Daily loss limit with cooldown
  • Full audit trail in SQLite + logs

Backtesting

polymarket-sniper backtest --days 30

The backtest module replays current market conditions as a proxy — it does not have historical order book archives. Use it for strategy calibration, not performance guarantees.

For production backtesting, integrate archived CLOB snapshots or the Polymarket Data API trade history.


Monitoring & Alerts

Logs

Structured logs write to stderr and logs/sniper.log (rotating, 10 MB, 30-day retention).

Telegram

TELEGRAM_BOT_TOKEN=your_bot_token
TELEGRAM_CHAT_ID=your_chat_id

Alerts fire on: new opportunities, fills, and errors (configurable in config/default.yaml).


Architecture & Code Structure

polymarket-endcycle-sniper/
├── README.md
├── .env.example
├── pyproject.toml
├── config/default.yaml
├── src/polymarket_sniper/
│   ├── config.py          # YAML + env settings
│   ├── models.py          # Pydantic domain models
│   ├── gamma_client.py    # Async Gamma API
│   ├── clob_wrapper.py    # CLOB V2 wrapper
│   ├── scanner.py         # End-of-cycle scanner
│   ├── analyzer.py        # Opportunity scoring
│   ├── executor.py        # Order execution + risk
│   ├── database.py        # SQLite persistence
│   ├── alerts.py          # Telegram notifications
│   ├── backtest.py        # Backtest module
│   ├── utils.py           # Logging, helpers
│   └── main.py            # Typer CLI
├── tests/
├── scripts/example_backtest.py
└── docs/architecture.md

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Add tests for new logic
  4. Run pytest and ruff check .
  5. Submit a pull request

License

MIT License — see LICENSE for details.


Disclaimer

TRADING INVOLVES SUBSTANTIAL RISK OF LOSS AND IS NOT SUITABLE FOR EVERY INVESTOR. The authors and contributors of this project are not registered financial advisors. This software is provided "as is" without warranty of any kind. By using this software, you acknowledge that you are solely responsible for any financial losses, legal compliance, and security of your private keys and funds. Never trade with money you cannot afford to lose.

About

No description, website, or topics provided.

Resources

License

Stars

284 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages