Skip to main content

Banger Python SDK for writing prediction-market strategies that hit.

Project description

banger (Python SDK)

Strategies that hit.

The Python SDK for Banger. Write a strategy as a Python class, ship it with banger deploy strategy.py --paper, watch it run.

Install

uv pip install bangertrades
# Plus the venue adapters you need:
uv pip install bangertrades-adapter-polymarket
uv pip install bangertrades-adapter-kalshi

For local development on this monorepo:

uv pip install -e packages/sdk-python
uv pip install -e packages/adapters/polymarket
uv pip install -e packages/adapters/kalshi

The 30-second tour

from decimal import Decimal
from banger import Strategy, signals
from banger.venues.kalshi import Kalshi
from banger.risk import RiskEnvelope


class MyStrategy(Strategy):
    name = "my_strategy"
    venues = [Kalshi()]
    universe = signals.kalshi_markets(category="NFL", time_to_resolution_lt="24h")
    risk = RiskEnvelope(
        max_position_usd=Decimal("200"),
        max_daily_loss_usd=Decimal("500"),
        max_open_positions=5,
    )

    def on_market_tick(self, market, tick, ctx):
        if tick.yes_price and tick.yes_price < Decimal("0.45") and ctx.can_open_position():
            ctx.place(Kalshi(), market, side="yes", size=ctx.kelly(edge=0.05))
banger deploy my_strategy.py --paper

That's it. The runtime will:

  1. Resolve universe against Kalshi to get the live market list.
  2. Subscribe to ticks for all matching markets.
  3. Call on_market_tick for each update.
  4. Risk-gate every order before it leaves your machine.
  5. Show you P&L, drawdown, and per-position attribution in real time.

Core concepts

  • Strategy — base class. Subclass and declare name, venues, universe, risk.
  • Venue — abstract execution venue. Provided by adapter packages.
  • Universe — declarative spec of which markets to subscribe to (signals.kalshi_markets(...)).
  • RiskEnvelope — declarative risk limits enforced before orders ship.
  • Context — passed to event handlers; provides place(), cancel(), kelly(), log(), positions, can_open_position().

Examples

See examples/:

  • kalshi_nfl_arb.py — Kalshi vs DraftKings spread arb (illustrative)
  • polymarket_simple_fade.py — Fade overconfident Polymarket markets

Status

Pre-alpha. Interface is settling. Expect breaking changes on the path to v0.1.

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

bangertrades-0.1.0.tar.gz (19.4 kB view details)

Uploaded Source

Built Distribution

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

bangertrades-0.1.0-py3-none-any.whl (19.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bangertrades-0.1.0.tar.gz
  • Upload date:
  • Size: 19.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for bangertrades-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1235c4bda31a44844e43be00afef50b4e3494e5209cec2312d42fc5125f72c65
MD5 ec3a14070feff0886914a2feb73fb9a4
BLAKE2b-256 9535a9a9969f05e536703cef2bdc3aa5cc1a7a7b4aeffcaefb3ef4f9742ad2e9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bangertrades-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 19.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for bangertrades-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 85a00e709ebe2d0412ec2f9b7cbe763e99a599e66362dd493365111359b6e015
MD5 ee86fac868800560d1bf094bc7bb1b7f
BLAKE2b-256 0d510e04ed77c5822ef1741716b07137f1b5b21a82c6fe67a36464f33e9de441

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