Skip to main content

Python SDK for the SettleRisk API — resolution risk scoring for prediction markets

Project description

SettleRisk Python SDK

Python client for the SettleRisk API — resolution risk scoring, dispute pricing, and settlement delay modeling for prediction markets.

Install

pip install settlerisk

Quick Start

from settlerisk import SettleRiskClient

client = SettleRiskClient(
    key_id="vx_yourkey_123",
    secret="your-base64-secret",
)

# Get risk score for a market
score = client.get_risk_score("polymarket", "0xabc123")
print(f"Risk: {score['aggregate_risk_score']} ({score['risk_tier']})")
print(f"P(dispute): {score['p_dispute']:.1%}")

# Get settlement delay estimate
delay = client.get_expected_delay("polymarket", "0xabc123")
print(f"Median delay: {delay['delay_distribution']['p50_hours']}h")

# Evaluate custom rules (no market required)
result = client.evaluate_rules({
    "platform": "polymarket",
    "rules_text": "This market resolves YES if BTC reaches $100,000 by Dec 31.",
    "resolution_sources": ["https://coingecko.com"],
})
print(f"Score: {result['aggregate_risk_score']}")

# Get dispute-adjusted pricing
pricing = client.price({
    "platform": "polymarket",
    "platform_market_id": "0xabc123",
    "mid_price": 0.65,
    "position_side": "YES",
    "position_notional_usd": 10000,
    "annual_capital_cost_apr": 0.12,
})
print(f"Fair price: {pricing['adjusted_fair_price']:.4f}")
print(f"Risk premium: {pricing['risk_premium']:.4f}")
print(f"Fair spread: {pricing['fair_spread_bps']} bps")

Authentication

All requests are signed with HMAC-SHA256. The SDK handles signing automatically — just provide your key_id and secret from the SettleRisk dashboard.

Context Manager

with SettleRiskClient(key_id="...", secret="...") as client:
    score = client.get_risk_score("polymarket", "0xabc")

Retry Behavior

The client automatically retries on 429 (rate limit) and 5xx errors with exponential backoff. Each retry uses a fresh timestamp and nonce. Idempotency keys are preserved across retries.

API Reference

Method Endpoint
get_risk_score(platform, market_id) GET /v1/markets/{platform}/{market_id}/risk-score
get_expected_delay(platform, market_id) GET /v1/markets/{platform}/{market_id}/expected-delay
evaluate_rules(request) POST /v1/evaluate-rules
batch_risk_scores(markets) POST /v1/risk-scores:batch
batch_expected_delays(markets) POST /v1/expected-delays:batch
price(request) POST /v1/pricing
batch_price(items) POST /v1/pricing:batch
create_webhook(url, events) POST /v1/webhooks
list_webhooks() GET /v1/webhooks
delete_webhook(webhook_id) DELETE /v1/webhooks/{webhook_id}
rotate_webhook_secret(webhook_id) POST /v1/webhooks/{webhook_id}/rotate-secret
list_webhook_deliveries() GET /v1/webhook-deliveries
replay_webhook_delivery(delivery_id) POST /v1/webhook-deliveries/{delivery_id}/replay
status() GET /v1/status

Development

pip install -e ".[dev]"
pytest tests/ -v

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

settlerisk-0.1.0.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

settlerisk-0.1.0-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file settlerisk-0.1.0.tar.gz.

File metadata

  • Download URL: settlerisk-0.1.0.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for settlerisk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d5d4175eed4530d7146d830ace160dba7b98b8f976cc68276b99a14cd20fe6cc
MD5 849bbbfbbb7d97bfe85e5152a62e7fb2
BLAKE2b-256 79154a94b655cdbf0344dd2abbe2d2e4734b91fe20afe671bdfb789204096ecf

See more details on using hashes here.

File details

Details for the file settlerisk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: settlerisk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for settlerisk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a7dca6df51ba33f7896ba54ca4547a973b2a7cae66177ece213fc7c4e9a2db38
MD5 f20272367bf9e9b3c6a9a6c81ddcf76b
BLAKE2b-256 1f7e6b541349dde99b177552874489bf3740d3ccde36282d6a619fef11f3bd8b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page