Metadata-Version: 2.4
Name: nubra_ref_data
Version: 0.1.0
Summary: Reference-data helpers for Nubra InstrumentData option, future, and underlying DataFrames
Author: Akshay N
License-Expression: MIT
Project-URL: Homepage, https://github.com/akshayn-spec/nubra_ref_data
Project-URL: Repository, https://github.com/akshayn-spec/nubra_ref_data
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pandas>=2.0
Dynamic: license-file

# nubra_ref_data

`nubra_ref_data` is a small helper package for Nubra `InstrumentData` users who want filtered pandas DataFrames for:

- the underlying row
- futures rows
- option rows by expiry bucket and strike levels
- one combined DataFrame containing all of the above

It is designed to work with:

```python
from nubra_python_sdk.refdata.instruments import InstrumentData

instruments = InstrumentData(nubra)
```

## Install

```bash
pip install nubra_ref_data
```

## Functions

- `underlying_data(instruments, underlying, exchange="NSE")`
- `futures_data(instruments, underlying, exchange="NSE")`
- `options_data(instruments, underlying, exchange="NSE", expiry_bucket="week0", levels=10, option_side="BOTH")`
- `all_data(instruments, underlying, exchange="NSE", expiry_bucket="week0", levels=10, option_side="BOTH")`

## Example

```python
from nubra_python_sdk.start_sdk import InitNubraSdk, NubraEnv
from nubra_python_sdk.refdata.instruments import InstrumentData

from nubra_ref_data import all_data, options_data


nubra = InitNubraSdk(NubraEnv.UAT, env_creds=True)
instruments = InstrumentData(nubra)

df_all = all_data(
    instruments=instruments,
    underlying="NIFTY",
    exchange="NSE",
    expiry_bucket="week0",
    levels=8,
    option_side="BOTH",
)

df_ce = options_data(
    instruments=instruments,
    underlying="NIFTY",
    exchange="NSE",
    expiry_bucket="month",
    levels=5,
    option_side="CE",
)

df_sensex = all_data(
    instruments=instruments,
    underlying="SENSEX",
    exchange="BSE",
    expiry_bucket="week0",
    levels=6,
    option_side="BOTH",
)
```

## Behavior

- `week0`, `week1`, `week2`, `week3`, and `week4` resolve against the sorted available option expiries for that underlying.
- `month` resolves to the first month-end expiry available in the option data.
- `levels` picks the nearest strikes using `underlying_prev_close`.
- `option_side="BOTH"` only selects strikes where both `CE` and `PE` exist.
- `all_data()` returns rows in this order: underlying, futures, then options.
- If the underlying cash/index row is missing from the instruments master, a placeholder `UNDERLYING` row is added.
- The returned DataFrames preserve the original instrument columns only. No helper columns are added.
