Metadata-Version: 2.4
Name: naradh
Version: 1.0.0
Summary: Python client for the Naradh OHLC data API
Author-email: Finvigna <mohithreddyseelam@gmail.com>
License: MIT License
        
        Copyright (c) 2026 Finvigna
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://naradh.finvigna.com
Project-URL: Documentation, https://naradh.finvigna.com/docs
Project-URL: Source, https://github.com/finvigna/naradh
Keywords: ohlc,trading,nifty,sensex,crudeoil,naturalgas,india,market-data
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Financial and Insurance Industry
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Office/Business :: Financial
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.28
Requires-Dist: pandas>=2.0
Dynamic: license-file

# Naradh

Python client for the **Naradh OHLC Data API** — 1-minute bar data for Indian markets (NIFTY50, SENSEX, CRUDEOIL, NATURALGAS), served from `naradh.finvigna.com`.

## Installation

```bash
pip install naradh
```

## Quick Start

```python
from naradh import Naradh

client = Naradh(api_key="nrd_...")

# List available instruments and date ranges
df = client.instruments()

# Today's 1-minute bars
df = client.today("NIFTY50")

# Latest N bars
df = client.latest("CRUDEOIL", n=500)

# 1-minute bars for a date range
df = client.ohlc("SENSEX", from_date="2026-05-01", to_date="2026-05-11")

# Resampled to any timeframe
df = client.historical("NIFTY50",    from_date="2026-05-01", to_date="2026-05-11", timeframe="5")
df = client.historical("CRUDEOIL",   from_date="2026-05-01", to_date="2026-05-11", timeframe="1h")
df = client.historical("NATURALGAS", from_date="2026-05-01", to_date="2026-05-11", timeframe="1d")
```

All methods return a **pandas DataFrame** with `datetime` as the index.

## Instruments

| Instrument  | Exchange | Session (IST)     |
|-------------|----------|-------------------|
| NIFTY50     | NSE      | 09:15 – 15:30     |
| SENSEX      | BSE      | 09:15 – 15:30     |
| CRUDEOIL    | MCX      | 09:00 – 23:30     |
| NATURALGAS  | MCX      | 09:00 – 23:30     |

## Timeframes

| Input | Resolution |
|-------|-----------|
| `1`, `3`, `5`, `10`, `15`, `30` | Minutes |
| `1h`, `2h`, `4h` | Hours |
| `1d` | Daily |
| `1w` | Weekly |

## API Reference

### `Naradh(api_key, host, timeout)`

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `api_key` | str | — | Your API key (required) |
| `host` | str | `https://naradh.finvigna.com` | API server URL |
| `timeout` | int | `30` | Request timeout in seconds |

### Methods

#### `instruments() → DataFrame`
Returns all instruments with available date ranges.
```
Columns: instrument, from, to, total_days
```

#### `today(instrument) → DataFrame`
All 1-minute bars collected so far today.

#### `latest(instrument, n=100) → DataFrame`
Latest N bars (max 5000) across all available dates.

#### `ohlc(instrument, from_date, to_date) → DataFrame`
Raw 1-minute bars for a date range. Dates in `YYYY-MM-DD` format.

#### `historical(instrument, from_date, to_date, timeframe="5") → DataFrame`
OHLC data resampled to the requested timeframe.

All DataFrames have:
```
Index:   datetime
Columns: open, high, low, close, volume
```

## Exceptions

```python
from naradh import (
    NaradhException,     # base class
    InstrumentNotFound,  # invalid instrument name
    DataNotFound,        # no data for the requested date/instrument
    InvalidTimeframe,    # unsupported timeframe string
    InvalidDateRange,    # from_date > to_date or bad format
    APIError,            # unexpected server error
)
```

## Getting an API Key

Contact [finvigna.com](https://finvigna.com) to request an API key.

## License

MIT
