Skip to main content

Banger: write, test, and run 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

The comprehensive distribution includes the SDK, CLI, runtime, and paper-mode venue adapters.

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,
    )

    async def on_market_tick(self, market, tick, ctx):
        if tick.yes_price and tick.yes_price < Decimal("0.45") and ctx.can_open_position():
            await 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 simulated paper order before recording its fill.
  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(), reduce-only close(), cancel(), kelly(), log(), positions, and can_open_position(). place(size=...) accepts USD notional while close(contracts=...) accepts held contract quantity; contracts=None closes the full position.

Examples

See examples/:

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

Status

Public paper beta. Historical venue datasets and live execution are not shipped. The interface is still settling; expect reviewed breaking changes.

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.4.tar.gz (76.9 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.4-py3-none-any.whl (87.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bangertrades-0.1.4.tar.gz
  • Upload date:
  • Size: 76.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for bangertrades-0.1.4.tar.gz
Algorithm Hash digest
SHA256 db7cc3856681ce28ad14a077c120075878376161642ea0517829678c2a4369de
MD5 a3a3ba6cee5557cef1574b7772716394
BLAKE2b-256 50efc165f85225293da7f328754d2ba228a35eda35ea5e27428fac2e320a7518

See more details on using hashes here.

Provenance

The following attestation bundles were made for bangertrades-0.1.4.tar.gz:

Publisher: publish-python.yml on vijayvkrishnan/banger

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: bangertrades-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 87.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for bangertrades-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 691111ac299427c385fa8d0c82b3eeffca9cc625dcf382bf03b18f1eaafefc2f
MD5 a2db0d2c24b31252a5804a4d6895c056
BLAKE2b-256 78462fda0a083e9b5bff92c0bdd700520b07096ecd66889bc0717526efb1121d

See more details on using hashes here.

Provenance

The following attestation bundles were made for bangertrades-0.1.4-py3-none-any.whl:

Publisher: publish-python.yml on vijayvkrishnan/banger

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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