Polymarket Bot Tutorial · Chapter 24 of 32
Polymarket perpetual futures (perps) bot: native 2-25x leverage, funding rate carry, liquidation distance math, ATR-based sizing, vs Binance/Bybit perps. Production-grade rules and code skeleton.
اس باب میں کیا شامل ہے
Polymarket Perps ایک نسبتاً نیا instrument ہے جس میں native 2-25x leverage اور funding rates شامل ہیں۔ یہ binary markets سے مختلف انداز میں کام کرتے ہیں - liquidation حقیقی ہے، sizing math مختلف ہے، اور edge sources prediction-market side جیسے نہیں ہوتے۔ اس باب میں perps-specific bot patterns شامل ہیں۔
- Perps کیا ہیں اور یہ مختلف کیوں ہیں
- Polymarket پر native leverage (2-25x)
- Funding rate mechanics
- Liquidation distance math
- ATR-based position sizing
- Comparison: Polymarket perps vs Binance/Bybit
- Risk: liquidation cascade scenarios
- Code: stop کے ساتھ leveraged perp order place کرنا
Perps کیا ہیں اور یہ مختلف کیوں ہیں
Polymarket Perpetual Futures (late 2025 میں launched) binary prediction markets سے مختلف instrument ہیں۔ Perps کسی underlying - BTC، ETH، یا دیگر - پر continuous price exposure دیتے ہیں، native leverage اور funding rate کے ساتھ۔
Binaries سے فرق:
- Continuous: کوئی expiration date نہیں، کوئی resolution نہیں۔
- Leveraged: 2x-25x native طور پر available ہے، proxy contract gymnastics کی ضرورت نہیں۔
- Funded: positive funding shorts کو pay کرتا ہے؛ negative funding longs کو pay کرتا ہے۔ Funding مسلسل accrue ہوتا ہے۔
- Liquidatable: اگر margin ختم ہو جائے تو exchange آپ کی position force-close کر دیتا ہے۔ حقیقی loss۔
Strategy کے لحاظ سے، perps CFD trading ہیں، prediction market trading نہیں۔ Edge sources بالکل مختلف ہیں - technicals، funding-arb، basis trades، جن میں سے کوئی بھی binaries پر apply نہیں ہوتا۔
Polymarket پر native leverage (2-25x)
Polymarket Perps 2x سے 25x تک leverage offer کرتے ہیں۔ جتنا زیادہ leverage ہوگا، اتنی ہی چھوٹی price move آپ کو liquidate کر دے گی۔
10x leverage پر، 10% adverse price move position کو wipe کر دیتا ہے۔ BTC ہفتے بھر میں 10% باقاعدگی سے move کر سکتا ہے، اس لیے days تک held 10x+ positions میں liquidation odds معمولی نہیں ہوتیں۔
Practical guidance: days-to-weeks held swing trades کے لیے 2-5x leverage؛ day trades کے لیے 5-10x؛ 10x+ صرف sub-hour trades کے لیے tight stops کے ساتھ۔ 10x سے اوپر retail کے لیے gambling ہے؛ funding cost + liquidation tail expected return کو کھا جاتی ہے۔
Funding rate mechanics
Funding وہ per-hour payment ہے جو longs shorts کو pay کرتے ہیں (یا vice versa) تاکہ perp price spot price سے tether رہے۔ Rate price gap سے compute ہوتا ہے: positive gap → longs pay; negative gap → shorts pay۔
Typical magnitudes: normal conditions میں 0.01-0.05% per 8-hour period؛ extreme moves میں 0.5% per period تک۔ Annualized، یہ 1-50% بنتا ہے - ایک ایسی strategy کے لیے کافی significant جو positions کو days تک hold کرتی ہے۔
Funding کسی strategy میں پورا edge ہو سکتا ہے: وہ side enter کریں جو paid ہو رہی ہو، اور price exposure کو spot یا دوسرے perp کے ساتھ hedge کریں۔ Classic basis-trade arb یہی ہے۔
Liquidation distance math
Long کے لیے liquidation price: entry × (1 - 1/leverage)۔ 10x پر، $50,000 BTC پر entered long $45,000 پر liquidate ہوتا ہے (10% adverse)۔
Short کے لیے: entry × (1 + 1/leverage)۔ $50k پر 10x short، liquidation $55k پر۔
یہ math maintenance margin buffer کو ignore کر کے simplify کیا گیا ہے (عام طور پر theoretical liquidation price سے 0.5-1% آپ کے حق میں)۔ سمجھنے کے لیے simple math استعمال کریں؛ precise number کے لیے exchange کی actual maintenance margin check کریں۔
Practical: position size + leverage ایسا ہونا چاہیے کہ liquidation distance underlying کی daily volatility کے 2x سے زیادہ ہو۔ BTC کی تقریباً 3% daily volatility کے لیے، no-stop position پر leverage ≤ 16x ہونا چاہیے۔
ATR-based position sizing
Average True Range (ATR) volatility measure ہے: پچھلے N days میں average daily price range۔ ATR-based position sizing risk کو current market conditions سے tie کرتا ہے۔
Pattern: ہر trade پر fixed dollar amount (مثلاً $50) risk کریں۔ Position size = risk / (ATR × leverage)۔ اگر BTC کا daily ATR $1,500 ہے ($50k کا 3%)، اور آپ 10x leveraged ہیں، تو position size = $50 / (1500 × 0.1) = تقریباً $3,300 notional۔
اس سے high-vol regimes میں positions خود بخود چھوٹی ہو جاتی ہیں اور low-vol regimes میں بڑھ جاتی ہیں۔ Key benefit: market regime سے قطع نظر ایک خراب دن آپ کی equity کو bounded amount تک ہی move کرتا ہے۔
Comparison: Polymarket perps vs Binance/Bybit
May 2026 کے مطابق Polymarket Perps اور major CEX perp venues کا comparison۔
| Polymarket Perps | Binance Perps | Bybit Perps | |
|---|---|---|---|
| Max leverage | 10x | 125x | 100x |
| Settlement | USDC on Polygon | USDT on BSC/internal | USDT |
| KYC required | region کے لحاظ سے مختلف | yes (most regions) | yes |
| API maturity | new, growing | mature, deep | mature |
| Liquidity (BTC) | moderate | extremely deep | deep |
Polymarket Perps تب بہترین choice ہیں جب آپ پہلے ہی Polymarket پر ہوں اور ایک venue کی operational simplicity اہم ہو۔ صرف-perp strategies at scale کے لیے liquidity کے لحاظ سے CEXes بہتر ہوتے ہیں۔ جن builders کو ہم جانتے ہیں ان میں سے اکثر Polymarket Perps کو اپنی binary positions کے ساتھ basis-arb کے لیے استعمال کرتے ہیں، standalone perp venue کے طور پر نہیں۔
Risk: liquidation cascade scenarios
Perp failure کا catastrophic scenario: ایک ایسا adverse move جو liquidate کرنے کے لیے کافی بڑا ہو، اور liquidation خود مزید positions liquidate کرنے والی book pressure پیدا کرے۔
2024-25 CEX history میں BTC نے multiple 10-20% intraday moves دیکھے ہیں جہاں 10x+ longs چند گھنٹوں میں cascade ہو کر نکل گئے۔ Polymarket Perps اس سے immune نہیں ہیں؛ liquidity thinner ہے اور ایسا move اور بھی تیزی سے liquidate کرے گا۔
Defenses:
- Liquidation price سے اوپر manual stop: hard limit 30-50% اندر رکھیں، تاکہ auto-liquidator سے پہلے آپ exit کر جائیں (جس میں liquidation fee لگتی ہے)۔
- Position size limits: ایک single perp position پر کبھی بھی equity کا 10% سے زیادہ risk نہ کریں۔
- Regime change پر halt: اگر 24h volatility baseline کے 2x سے بڑھ جائے، position sizes کم کریں یا نئے entries pause کریں۔
Code: stop کے ساتھ leveraged perp order place کرنا
Reference: hard stop کے ساتھ Polymarket Perp position کے لیے order-placement skeleton۔
def open_long_with_stop(symbol, entry_px, leverage, risk_usd):
# Compute position size from risk budget
liquidation_px = entry_px * (1 - 1/leverage)
stop_px = entry_px * (1 - 0.7/leverage) # 70% to liquidation
risk_per_share = entry_px - stop_px
shares = risk_usd / risk_per_share
# Place long entry
long_order = perp_api.place_order(
symbol=symbol, side="long", size=shares, leverage=leverage,
order_type="market"
)
if long_order.status != "filled": return None
# Place hard stop just below entry
stop_order = perp_api.place_order(
symbol=symbol, side="close", size=shares, stop_price=stop_px,
order_type="stop_market", reduce_only=True
)
return {"long": long_order, "stop": stop_order}
Reduce-only stop اس بات کو یقینی بناتا ہے کہ وہ صرف existing position کو close کر سکے، آپ کو short میں flip نہ کرے۔ Production additions: profit پر trailing stop، funding-cost monitor، position-size halt۔





