# infinn — INFINN Python SDK

Simple Python client for the INFINN trading API.

- Default environment is **Sandbox** (`env="sandbox"`, also accepts `"uat"`).
- Sandbox = UAT / Test — **NOT live**. No real money.
- Live needs `env="live"` and prints a clear warning.
- Secrets from env vars `INFINN_API_KEY` / `INFINN_API_SECRET` (never hard-code).
- Tokens are never logged.

## Install

```bash
pip install ./infinn-0.1.2-py3-none-any.whl
# or from source
pip install .
```

Optional live ticker: `pip install "infinn[ticker]"` (adds `websocket-client`).

## 5-line Sandbox quickstart

```python
from infinn import Infinn

api = Infinn(env="sandbox")                 # Sandbox (UAT / Test — NOT live)
print(api.login_url())                      # open in browser, login, copy full URL
api.generate_session(input("Paste full redirect URL: "))
print(api.limits())                         # read-only check
```

User ID is uppercased automatically. A full redirect URL or just the `code=` value both work.

## Coming from another broker?

Method names are deliberately simple (`place_order`, `orders`, `positions`, `ltp`, …).
This is an original INFINN library — not a fork of any other broker SDK.

## Sandbox tested (5 Nov 2026)

Read-only Sandbox checks passed: login, user_details, search, quote, ticker. Known: Sandbox `Limits` may hang/time out (server-side); the client uses a request timeout.

## Options helpers (0.1.2)

```python
chain = api.option_chain("NFO", "NIFTY26NOV26C26000", 26000, count=5)  # GetOptionChain -> list of contracts
info  = api.security_info("NFO", chain[0]["token"])                      # GetSecurityInfo -> lot size, tick size, expiry
```

Full example with stoploss and profit booking: `examples/straddle_strangle.py`
(educational example — not investment advice; DRY_RUN and Sandbox by default).

## Safety

- Rate-limits write calls below 10 orders/sec.
- Retries only safe read endpoints on network errors.
- Never commits secrets or tokens to source control.
- Do **not** publish this package to PyPI until INFINN releases it officially.

## Changelog

- 0.1.2 — `option_chain()` (GetOptionChain) and `security_info()` (GetSecurityInfo); Straddle / Strangle example.
- 0.1.1 — Sandbox default, request timeouts, ticker, TOTP helper.

## Licence

MIT — HKKR Finserv Pvt Ltd (INFINN).
