Metadata-Version: 2.4
Name: nepseman-api
Version: 1.0.1
Summary: Unofficial async Python client for Nepal Stock Exchange (NEPSE)
License: MIT License
        
        Copyright (c) 2025 nepse_scrapper contributors
        
        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.
        
        ---
        
        This project is unofficial and not affiliated with, endorsed by, or officially connected to
        the Nepal Stock Exchange (NEPSE) or nepalstock.com. Use at your own risk.
        
Project-URL: Homepage, https://github.com/dipalkatuwal/nepseman-api
Project-URL: Repository, https://github.com/dipalkatuwal/nepseman-api
Keywords: nepse,nepal,stock,market,finance,api
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Office/Business :: Financial
Classifier: Framework :: AsyncIO
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: httpx>=0.27.0
Requires-Dist: wasmtime>=45.0.0
Dynamic: license-file

# nepseman-api

> Unofficial async Python client for Nepal Stock Exchange (NEPSE) market data.
> Not affiliated with NEPSE or nepalstock.com.np. Use at your own risk.

Reverse-engineers the authentication layer of `nepalstock.com.np` — including WASM-based token obfuscation and salt-based payload signing — with no dependency on any third-party NEPSE library.

## Installation

```bash
pip install nepseman-api
```

## Quick Start

```python
import asyncio
from nepseman_api import NepseClient

async def main():
    async with NepseClient() as nepse:
        # Market status
        status = await nepse.market_status()
        print(status)

        # Today's prices
        prices = await nepse.today_price()
        print(prices[:5])

        # Price history for a stock
        history = await nepse.price_history("NABIL")
        print(history[:5])

asyncio.run(main())
```

## Available Methods

### Market
```python
await nepse.market_status()       # Open/closed status
await nepse.is_market_open()      # Returns True/False
await nepse.market_summary()      # Today's summary (turnover, transactions)
await nepse.supply_demand()       # Market-wide supply & demand
```

### Prices
```python
await nepse.today_price()                        # All stock prices
await nepse.today_price(business_date="2026-06-10")  # Specific date
await nepse.live_market()                        # Live ticker (trading hours only)
await nepse.price_volume()                       # Price/volume stats
```

### Top Lists
```python
await nepse.top_gainers()      # Top gaining stocks
await nepse.top_losers()       # Top losing stocks
await nepse.top_turnover()     # Top by turnover
await nepse.top_trade()        # Top by trade count
await nepse.top_transaction()  # Top by transactions
```

### Indices
```python
await nepse.nepse_index()          # NEPSE index value
await nepse.nepse_subindices()     # All sector subindices
await nepse.index_graph("banking") # Historical graph data
```

### Securities
```python
await nepse.company_list()              # All listed companies
await nepse.security_list()             # All securities with IDs
await nepse.sector_scrips()             # Grouped by sector
await nepse.company_details("NABIL")    # Company details
await nepse.daily_graph("NABIL")        # Intraday graph
await nepse.price_history("NABIL")      # OHLCV history (1 year default)
await nepse.price_history(
    "NABIL",
    start_date="2025-01-01",
    end_date="2025-12-31",
    size=500,
)
await nepse.market_depth("NABIL")       # Bid/ask depth (trading hours only)
```

### Bulk History
```python
# Fetch history for multiple stocks in parallel
results = await nepse.bulk_price_history(
    ["NABIL", "NICA", "ADBL"],
    start_date="2025-01-01",
    concurrency=5,
)
# {"NABIL": [...], "NICA": [...], "ADBL": [...]}
```

### Floorsheet
```python
await nepse.floor_sheet()                    # All trade records (paginated)
await nepse.floor_sheet(page=1, size=500)
await nepse.floor_sheet_of("NABIL")         # Filtered by symbol (first 500 rows only)
```

> **Note:** `floor_sheet_of()` scans only the first `size` floorsheet records.
> NEPSE does not expose a per-symbol endpoint. For complete results,
> iterate `floor_sheet(page=N)` and filter manually.

## Index Names

Valid values for `index_graph()`:

`nepse`, `sensitive`, `float`, `sensitive_float`, `banking`, `dev_bank`,
`finance`, `hotel_tourism`, `hydro`, `investment`, `life_insurance`,
`manufacturing`, `microfinance`, `mutual_fund`, `non_life_insurance`,
`others`, `trading`

## Notes

- **Trading hours** — `live_market()` and `market_depth()` only return data Sun–Thu 11:00–15:00 NST
- **Floorsheet** — `floor_sheet_of()` filters client-side from the general floorsheet (NEPSE does not expose a per-symbol endpoint)
- **SSL** — NEPSE serves an incomplete certificate chain; the client bypasses SSL verification automatically

## Live API

Don't want to run Python? Use the hosted REST API:

**Base URL:** `https://nepseman-api-production.up.railway.app`

```bash
curl https://nepseman-api-production.up.railway.app/api/v1/market/status
curl https://nepseman-api-production.up.railway.app/api/v1/prices/today
curl https://nepseman-api-production.up.railway.app/api/v1/securities/NABIL
```

Interactive docs: `https://nepseman-api-production.up.railway.app/docs`

## Disclaimer

This project is **unofficial** and **not affiliated with NEPSE** or nepalstock.com.np. It reverse-engineers the public-facing web interface for educational and personal use. Data accuracy is not guaranteed. Do not use in production trading systems.

## License

MIT
