Loading...
Loading...
Deploy a 24/7 price monitor, arbitrage detector, and alert system on a $6/month VPS. No coding experience required β just copy, paste, and run.
Track any market in real-time. Get price updates every 10 seconds.
Get notified when prices move beyond your threshold.
Log large orders ($10k+) to a CSV file for analysis.
Runs on a VPS while you sleep. Never miss an opportunity.
Any $5-6/month VPS works. We recommend Vultr London for lowest latency (12ms to Polymarket).
You should know how to SSH into a server and run commands.
For price alerts. Free to create via @BotFather.
Don't have a VPS yet?
Get a London VPS for $6/mo. 12ms latency to Polymarket.
After purchasing your VPS, SSH into it and run these commands to install Python:
# Update system sudo apt update && sudo apt upgrade -y # Install Python and pip sudo apt install python3 python3-pip -y # Install required packages pip3 install requests python-telegram-bot # Verify installation python3 --version
Create a new file called monitor.py:
#!/usr/bin/env python3
"""
Polymarket Market Monitor
Educational tool for learning API interactions.
For research and data analysis purposes only.
"""
import requests
import time
import csv
from datetime import datetime
# ============ CONFIGURATION ============
# Find market IDs at: https://gamma-api.polymarket.com/events
MARKETS_TO_WATCH = [
{
"name": "Trump 2028",
"condition_id": "0x...", # Replace with actual condition ID
"alert_threshold": 0.05 # Alert if price moves 5%
}
]
# Telegram alerts (optional)
TELEGRAM_BOT_TOKEN = "" # Get from @BotFather
TELEGRAM_CHAT_ID = "" # Your chat ID
# Whale tracking
WHALE_THRESHOLD_USD = 10000 # Log orders above this
# ============ API FUNCTIONS ============
CLOB_API = "https://clob.polymarket.com"
GAMMA_API = "https://gamma-api.polymarket.com"
def get_market_price(condition_id: str) -> dict:
"""Fetch current market price from Polymarket CLOB API."""
try:
# Get orderbook
url = f"{CLOB_API}/book"
params = {"token_id": condition_id}
response = requests.get(url, params=params, timeout=10)
data = response.json()
best_bid = float(data.get("bids", [{}])[0].get("price", 0))
best_ask = float(data.get("asks", [{}])[0].get("price", 1))
mid_price = (best_bid + best_ask) / 2
return {
"bid": best_bid,
"ask": best_ask,
"mid": mid_price,
"spread": best_ask - best_bid
}
except Exception as e:
print(f"Error fetching price: {e}")
return None
def get_recent_trades(condition_id: str, limit: int = 50) -> list:
"""Fetch recent trades to detect whale activity."""
try:
url = f"{CLOB_API}/trades"
params = {"asset_id": condition_id, "limit": limit}
response = requests.get(url, params=params, timeout=10)
return response.json()
except Exception as e:
print(f"Error fetching trades: {e}")
return []
def send_telegram_alert(message: str):
"""Send alert via Telegram bot."""
if not TELEGRAM_BOT_TOKEN or not TELEGRAM_CHAT_ID:
return
try:
url = f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/sendMessage"
requests.post(url, data={
"chat_id": TELEGRAM_CHAT_ID,
"text": message,
"parse_mode": "HTML"
})
except Exception as e:
print(f"Telegram error: {e}")
def log_whale_trade(trade: dict, market_name: str):
"""Log large trades to CSV for analysis."""
with open("whale_trades.csv", "a", newline="") as f:
writer = csv.writer(f)
writer.writerow([
datetime.now().isoformat(),
market_name,
trade.get("side"),
trade.get("size"),
trade.get("price"),
trade.get("maker_address", "")[:10] + "..."
])
# ============ MAIN MONITOR LOOP ============
def main():
print("=" * 50)
print("Polymarket Market Monitor")
print("For educational and research purposes only")
print("=" * 50)
# Track previous prices for alerts
prev_prices = {}
while True:
for market in MARKETS_TO_WATCH:
name = market["name"]
cid = market["condition_id"]
threshold = market["alert_threshold"]
# Get current price
price_data = get_market_price(cid)
if not price_data:
continue
current_price = price_data["mid"]
timestamp = datetime.now().strftime("%H:%M:%S")
# Print status
print(f"[{'{'}timestamp{'}'}] {'{'}name{'}'}: {'{'}current_price:.2%{'}'} (spread: {'{'}price_data['spread']:.4f{'}'})")
# Check for price movement alert
if name in prev_prices:
change = abs(current_price - prev_prices[name])
if change >= threshold:
alert_msg = f"π¨ <b>{name}</b>\n"
alert_msg += f"Price moved {'{'}change:.2%{'}'}\n"
alert_msg += f"Now: {'{'}current_price:.2%{'}'}"
send_telegram_alert(alert_msg)
print(f" β οΈ ALERT: Price moved {'{'}change:.2%{'}'}!")
prev_prices[name] = current_price
# Check for whale trades
trades = get_recent_trades(cid, limit=10)
for trade in trades:
size_usd = float(trade.get("size", 0)) * float(trade.get("price", 0))
if size_usd >= WHALE_THRESHOLD_USD:
log_whale_trade(trade, name)
print(f" π WHALE: {size_usd:,.0f{'}'} trade detected!")
# Wait before next check (10 seconds)
time.sleep(10)
if __name__ == "__main__":
main()gamma-api.polymarket.com/events to find the condition IDs for markets you want to track. Replace the placeholder in the script.Use PM2 to keep your script running even after you disconnect:
# Install PM2 sudo npm install -g pm2 # Start the monitor pm2 start monitor.py --interpreter python3 --name "polymarket-monitor" # View logs pm2 logs polymarket-monitor # Auto-start on reboot pm2 startup pm2 save # Other useful commands pm2 stop polymarket-monitor # Stop pm2 restart polymarket-monitor # Restart pm2 delete polymarket-monitor # Remove
Your monitor is now running 24/7. It will track prices, detect whale movements, and send you Telegram alerts when prices move significantly.
Want to detect arbitrage opportunities between Polymarket and Kalshi? Add this function:
def check_arbitrage(polymarket_yes: float, kalshi_no: float) -> dict:
"""
Check for arbitrage opportunity.
Arb exists when: Polymarket YES + Kalshi NO < 100%
Example:
- Polymarket YES: 55% (you pay 55Β’, win $1 if YES)
- Kalshi NO: 42% (you pay 42Β’, win $1 if NO)
- Combined: 97% -> 3% guaranteed profit!
"""
combined = polymarket_yes + kalshi_no
if combined < 1.0:
profit_margin = (1.0 - combined) * 100
return {
"has_arb": True,
"profit_percent": profit_margin,
"message": f"π― ARB FOUND: {'{'}profit_margin:.2f{'}'}% guaranteed profit!"
}
return {"has_arb": False, "overround": (combined - 1.0) * 100}
# Usage in your monitor loop:
# arb = check_arbitrage(polymarket_price, kalshi_price)
# if arb["has_arb"]:
# send_telegram_alert(arb["message"])For lowest latency to Polymarket (12ms), we recommend a London-based VPS. The $6/month tier from Vultr or DigitalOcean is more than enough for this script.