Metadata-Version: 2.4
Name: hedgehog-cli
Version: 0.2.0
Summary: Hedgehog — CLI and Python SDK for the futures paper trading API
Project-URL: Homepage, https://hedgehog.up.railway.app
Project-URL: Documentation, https://hedgehog.up.railway.app/docs
Project-URL: API, https://hedgeapi.up.railway.app/docs
Author: Mohit Varikuti
License-Expression: MIT
License-File: LICENSE
Keywords: cli,cme,futures,paper-trading,sdk,trading
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Financial and Insurance Industry
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Office/Business :: Financial :: Investment
Classifier: Typing :: Typed
Requires-Python: >=3.11
Requires-Dist: httpx>=0.27
Requires-Dist: typer>=0.15
Requires-Dist: websockets>=13
Provides-Extra: dev
Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
Requires-Dist: pytest>=8.3; extra == 'dev'
Requires-Dist: respx>=0.21; extra == 'dev'
Requires-Dist: ruff>=0.7; extra == 'dev'
Description-Content-Type: text/markdown

# hedgehog-cli

Paper trade futures from your terminal, or from Python.

A client for [Hedgehog](https://hedgehog.up.railway.app), a paper trading
brokerage for CME futures with real margin accounting, resting orders and
auto-liquidation. This package is the CLI (`hh`) and the Python SDK
(`import hedgehog_cli`); the API it talks to lives at
`https://hedgeapi.up.railway.app`.

```bash
pip install hedgehog-cli
hh login                      # paste an API key from the dashboard
hh accounts create main -b 100000
```

## From the terminal

```bash
hh quote ES MNQ GC            # bid / ask / last
hh bars ES -t 5m              # ASCII candles, drawn in your terminal
hh buy MES 2                  # market order, fills on the request
hh sell MES 1 --limit 7400    # resting limit order
hh positions && hh account
```

Every command takes `--json` for scripting. `hh health` reports API, database
and engine status.

## From Python

```python
from hedgehog_cli import Hedgehog, dec

hh = Hedgehog(api_key="hh_…")
account = hh.accounts()[0]["id"]

if dec(hh.quote("MES")["last"]) < dec("7400"):
    hh.buy(account, "MES", 2, client_order_id="tick-1")

print(hh.positions(account))
```

### Money is exact

Prices and balances cross the wire as JSON **strings**, because a JSON number is
an IEEE-754 double in every mainstream parser and account balances have no
business going through one. `dec()` parses them into `Decimal`:

```python
dec("7211.00") * 2        # Decimal('14422.00'), not 14422.000000000002
```

### Configuration

| Variable            | Meaning                                          |
| ------------------- | ------------------------------------------------ |
| `HEDGEHOG_API_KEY`  | API key; overrides the one saved by `hh login`   |
| `HEDGEHOG_API_URL`  | API base URL, for self-hosted instances          |
| `HEDGEHOG_ACCOUNT`  | Default account, as `hh accounts use` would set  |

`hh login` stores the key in `$XDG_CONFIG_HOME/hedgehog/config.json`, which is
`~/.config/hedgehog/config.json` unless you have set `XDG_CONFIG_HOME`.

## Notes

- Paper trading only. No order ever reaches an exchange.
- `client_order_id` makes a submission idempotent: retrying the same id returns
  the original order instead of doubling your position.
- Requires Python 3.11 or newer.

### Upgrading from 0.1.0

0.1.0 installed its module as `hedgehog` and a console script also named
`hedgehog`. Both names are already taken on PyPI by an unrelated `hedgehog`
distribution, and pip reports no conflict when the two are installed together —
it simply overwrites, so `from hedgehog import Hedgehog` would break with an
`ImportError` depending on install order.

0.2.0 renames both to match this distribution. There is deliberately no
`hedgehog` compatibility shim, because a shim would have to occupy the very name
that causes the clash:

```python
from hedgehog import Hedgehog, dec       # 0.1.0
from hedgehog_cli import Hedgehog, dec   # 0.2.0
```

```bash
hedgehog quote ES      # 0.1.0
hh quote ES            # 0.2.0 (or `hedgehog-cli quote ES`)
```

Full API reference: <https://hedgehog.up.railway.app/docs>
