Metadata-Version: 2.4
Name: bangertrades
Version: 0.1.1
Summary: Banger: write, test, and run prediction-market strategies that hit.
Project-URL: Homepage, https://bangertrades.com
Project-URL: Documentation, https://bangertrades.com/docs
Project-URL: Repository, https://github.com/vijayvkrishnan/banger
Author: Vijay Krishnan
License: Proprietary
Keywords: automation,kalshi,polymarket,prediction-markets,trading
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Financial and Insurance Industry
Classifier: License :: Other/Proprietary License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.11
Requires-Dist: anyio>=4.4
Requires-Dist: click>=8.1
Requires-Dist: cryptography>=43
Requires-Dist: httpx-sse>=0.4
Requires-Dist: httpx>=0.27
Requires-Dist: platformdirs>=4.3
Requires-Dist: pydantic>=2.8
Requires-Dist: redis>=5.2
Requires-Dist: rich>=13.9
Requires-Dist: structlog>=24.4
Requires-Dist: websockets>=13.1
Provides-Extra: dev
Requires-Dist: mypy>=1.13; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
Requires-Dist: pytest>=8.3; extra == 'dev'
Requires-Dist: ruff>=0.7; extra == 'dev'
Provides-Extra: modal
Requires-Dist: modal>=0.66; extra == 'modal'
Provides-Extra: polymarket-live
Requires-Dist: eth-account>=0.13; extra == 'polymarket-live'
Requires-Dist: py-clob-client>=0.21; extra == 'polymarket-live'
Description-Content-Type: text/markdown

# banger (Python SDK)

> Strategies that hit.

The Python SDK for [Banger](../../README.md). Write a strategy as a Python class, ship it with `banger deploy strategy.py --paper`, watch it run.

## Install

```bash
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:

```bash
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

```python
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))
```

```bash
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.
