Metadata-Version: 2.4
Name: gamma-wall
Version: 0.1.0
Summary: Standalone Gamma Exposure CLI for FnO option chain JSON
Author: Akshay N
License-Expression: MIT
Project-URL: Homepage, https://github.com/akshayn-spec/gamma-wall
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.24
Requires-Dist: pandas>=2.0
Provides-Extra: http
Requires-Dist: requests>=2.31; extra == "http"
Provides-Extra: table
Requires-Dist: tabulate>=0.9; extra == "table"
Provides-Extra: all
Requires-Dist: requests>=2.31; extra == "all"
Requires-Dist: tabulate>=0.9; extra == "all"
Dynamic: license-file

# gamma-wall

Standalone Python tool for calculating Gamma Exposure (GEX) from option-chain snapshots.

This tool does not use Streamlit, React, or any frontend. The package core does not require the Nubra SDK; users can pass either a Nubra SDK `option_chain()` result object or raw option-chain data.

## Install

```bash
pip install gamma-wall
```

For URL loading and prettier tables:

```bash
pip install "gamma-wall[all]"
```

## Run

Local JSON:

```bash
python gamma_wall.py --symbol NIFTY --expiry 2026-05-28 --spot 24512 --json-file examples/nifty_option_chain.json
```

After package install:

```bash
gamma-wall --symbol NIFTY --expiry 2026-05-28 --spot 24512 --json-file examples/nifty_option_chain.json
```

Multiple symbols:

```bash
gamma-wall --symbol NIFTY,BANKNIFTY --expiry 2026-05-28 --spot NIFTY=24512,BANKNIFTY=53200 --json-file "data/{symbol}.json"
```

URL input:

```bash
gamma-wall --symbol NIFTY --expiry 2026-05-28 --spot 24512 --url "https://example.com/option-chain/{symbol}?expiry={expiry}"
```

## Python Usage

Offline JSON example:

```bash
python examples/quickstart.py
```

Minimal Nubra snapshot integration:

```python
from nubra_python_sdk.marketdata.market_data import MarketData
from nubra_python_sdk.start_sdk import InitNubraSdk, NubraEnv

from gamma_wall import print_gex

nubra = InitNubraSdk(NubraEnv.UAT, env_creds=True)
market_data = MarketData(nubra)

result = market_data.option_chain("NIFTY", exchange="NSE")
print_gex(result, symbol="NIFTY")
```

`print_gex()` reads `result.chain.current_price`, `result.chain.ce`, and `result.chain.pe` from the Nubra SDK response. If you want to override spot manually, pass `spot_price=24512`.

For local editable development:

```bash
python -m pip install -e .
```

Live Nubra SDK example:

```bash
python nubra_live_gex.py
```

The live script is standalone and can be opened directly in IDLE. Edit the constants at the top:

```python
SYMBOL = "NIFTY"
EXCHANGE = "NSE"
EXPIRY = ""
SPOT_PRICE = None
```

If `SPOT_PRICE` is `None`, the script asks for the current spot price when it runs. It does not use spot fallback inference.

The live script imports Nubra SDK, fetches:

```python
result = market_data.option_chain("NIFTY", exchange="NSE")
```

Then feeds `result` directly into its local GEX functions:

```python
gex_df = calculate_gex(result, spot_price)
aggregated = aggregate_by_strike(gex_df)
print_report(...)
```

## Expected JSON

The script supports flat contract rows:

```json
[
  {
    "strike": 24500,
    "option_type": "CE",
    "gamma": 0.00035,
    "oi": 700000,
    "ltp": 180.5,
    "iv": 13.2
  }
]
```

It also handles common option-chain wrappers such as `data`, `option_chain`, `records`, `contracts`, and strike rows with nested `CE` / `PE` objects.

## Calculation

```text
GEX = gamma * OI * spot_price^2
```

Put GEX is multiplied by `-1`.

Net GEX per strike:

```text
net_gex = call_gex + put_gex
```

## Output

The report includes:

- Top gamma walls sorted by absolute net gamma
- Strongest positive gamma wall
- Strongest negative gamma wall
- Gamma flip zone
- Dealer positioning bias
- Total market gamma
- Top 5 call walls
- Top 5 put walls

## Build for PyPI

```bash
python -m pip install --upgrade build twine
python -m build
python -m twine upload dist/*
```
