Bharat-sm-data-avinash 4.1.0
Bharat SM Data stands for Bharat(India) Stock Market Data.
License: Apache License 2.0
Requires Python: >=3.7

# Bharat (India) Stock Market Data Collection / Fetch Library - Avinash's Fork

Bharat_SM_Data stands for Bharat(India) Stock Market Data.

**This is a fork of the original project by Sampad Hegde with additional NSE Charting API v2 features.**

```shell
pip install Bharat-sm-data-avinash
```

<p align="center">
  <img src="https://github.com/avinashsahu/Bharat-SM-Data-Avinash/raw/master/Logo.png" alt="Logo" width="500" height="400">
</p>

## 🆕 What's New in This Fork (v4.1.0)

### NSE Charting API v2 Support
- **Dynamic Symbol Search** with segment filtering
- **Support for All Instruments**: Index, Equity, Futures, Options
- **Segment Filters**: IDX (Index), EQ (Equity), FO (Futures & Options)
- **Multiple Timeframes**: 1Min to 1Month
- **Enhanced Error Handling** and input validation
- **No Mapping Files Required** - everything is dynamic

### Quick Example
```python
from Bharat_sm_data.Base.NSEBase import NSEBase
from datetime import datetime, timedelta

nse = NSEBase()

# Get NIFTY 50 data with new API
df = nse.get_ohlc_from_charting_v2(
    symbol="NIFTY 50",
    timeframe="1Day",
    start_date=datetime.now() - timedelta(days=30),
    symbol_type="Index",
    segment="IDX"  # Filter to indices only
)

# Search with segment filtering
result = nse.search_charting_symbol("RELIANCE", segment="EQ")  # Equity only

# Get futures data
fo_result = nse.search_charting_symbol("NIFTY", segment="FO")  # F&O only
```

## Original Project

This fork is based on the excellent work by **Sampad Hegde**:
- Original Repository: https://github.com/Sampad-Hegde/Bharat-SM-Data
- Original Documentation: https://bharat-sm-data.readthedocs.io/en/latest/

## Installation

### Install This Fork
```bash
pip install Bharat-sm-data-avinash
```

### Install Original Package
```bash
pip install Bharat-sm-data
```

## !!! Disclaimer !!!
**Disclaimer: Use Caution and Consider Legal Implications**
  This project employs third-party private APIs and deals with stock market investing,
both of which come with inherent risks and legal considerations.
Users must ensure
they have the appropriate permissions to use the data obtained from these APIs to avoid potential copyright issues.
Additionally, stock market investing carries financial risks, and users should exercise caution,
conduct thorough research, and seek professional advice before making investment decisions.
The accuracy of third-party data cannot be guaranteed, and this project does not offer financial advice.
Users are responsible for complying with all applicable laws and regulations,
and any unauthorized or illegal use may lead to legal consequences.
This package is strictly for educational purposes,
and any practical applications should be done with careful consideration of the aforementioned risks.
By using this project, users acknowledge and accept these risks and responsibilities,
with the project developers and contributors not liable for any damages,
legal issues, or financial losses resulting from its use.
It is essential to exercise caution and seek legal and financial advice when necessary.


## Library Description
📈 Explore the dynamic world of the Indian Stock Market with our powerful open-source stock market scraping library. 
Effortlessly access real-time and historical data for derivatives, equities, currencies, commodities, ETFs, and more, 
enabling you to make informed investment decisions, develop trading strategies, and stay ahead of market trends.
Our user-friendly API facilitates seamless integration,
making it a valuable tool for traders, investors, and data enthusiasts.
Join Me in harnessing the power of data
to unlock new opportunities in the ever-evolving landscape of the Indian financial markets.
Start scraping today and gain a competitive edge in your financial ventures!
💼📊🚀

### Documentation : [Readthedoc](https://bharat-sm-data.readthedocs.io/en/latest/index.html)

## Table of Contents

- [Installation](#installation)
- [Usage](#usage)
- [Features](#features)
- [License](#license)

## Important Note:
```text
Pass  `is_index=true` whenever calling get_ohlc function for any Indices, Future Contracts and Options Contracts
```

## Installation
Install the package using this command

```bash
pip install Bharat-sm-data
```

## Usage

### Read the Documentation here: [Readthedoc](https://bharat-sm-data.readthedocs.io/en/latest/index.html)

### Quick Start - NSE Charting API v2 (NEW in v4.1.0)

```python
from Bharat_sm_data.Base.NSEBase import NSEBase
from datetime import datetime, timedelta

# Initialize
nse = NSEBase()

# Get historical data for NIFTY 50
df = nse.get_ohlc_from_charting_v2(
    symbol="NIFTY 50",
    timeframe="1Day",
    start_date=datetime.now() - timedelta(days=30),
    end_date=datetime.now(),
    symbol_type="Index",
    segment="IDX"  # Filter to indices only
)

# Search for symbols with filtering
result = nse.search_charting_symbol("RELIANCE", segment="EQ")  # Equity only

# Get futures data
result = nse.search_charting_symbol("NIFTY", segment="FO")  # F&O only
futures = [s for s in result['data'] if 'FUT' in s['symbol']]
df_futures = nse.get_ohlc_from_charting_v2(
    symbol=futures[0]['symbol'],
    timeframe="1Day",
    symbol_type="Futures",
    segment="FO"
)
```

### Example Notebooks

Refer below example Jupyter Notebooks to get know how to use this library :
- [NSE Technical](https://github.com/avinashsahu/Bharat-SM-Data-Avinash/blob/master/examples/Technical_NSE.ipynb)
- [NSE Derivatives](https://github.com/avinashsahu/Bharat-SM-Data-Avinash/blob/master/examples/Derivatives_NSE.ipynb)
- [Sensibull  Derivatives](https://github.com/avinashsahu/Bharat-SM-Data-Avinash/blob/master/examples/Derivatives_Sensibull.ipynb)
- [Tickertape Fundamentals](https://github.com/avinashsahu/Bharat-SM-Data-Avinash/blob/master/examples/Fundementals_Tickertape.ipynb)
- [Moneycontrol Fundamentals](https://github.com/avinashsahu/Bharat-SM-Data-Avinash/blob/master/examples/Fundementals_Moneycontrol.ipynb)

### New API v2 Examples
- [Charting API v2 Examples](https://github.com/avinashsahu/Bharat-SM-Data-Avinash/blob/master/USAGE_EXAMPLE.py)
- [Segment Filtering Examples](https://github.com/avinashsahu/Bharat-SM-Data-Avinash/blob/master/SEGMENT_FILTERING_EXAMPLES.py)
- [Derivatives Examples](https://github.com/avinashsahu/Bharat-SM-Data-Avinash/blob/master/DERIVATIVES_EXAMPLES.py)
 

## Features

- Some basic NSE Data:
  - Last Traded date of Exchange
  - Current Market Status (open/close) and a Nifty 50 current value.
  - Equity Meta data
  - NSE turn-over for the day
  - OHLC data

- **NEW: NSE Charting API v2** (Added in v4.1.0):
  - Dynamic symbol search with segment filtering
  - Historical OHLC data for all instrument types
  - Support for Index, Equity, Futures, and Options
  - Multiple timeframes (1Min to 1Month)
  - Segment filters: IDX (Index), EQ (Equity), FO (Futures & Options)
  - No mapping files required
  - Faster and more accurate data fetching

- Technical Data:
  - Important NSE Reports   
  - All indices data
  - Indices composites
  - OHLC of Indices & Equities
  - Trade Info of Equity
  - Corporate Disclosures
  - SME Data
  - SGB Data
  - ETF
  - Block Deals
  - VIX

- Derivatives (Applicable for both Index and Equity options):
  - Options Expiry Dates
  - Option Chain
  - OHLC of Option contracts
  - PCR (Put Call Ratio)
  - List all Equities allowed for Derivative trading.
  - Option Trade info (Equities Only)
  - Trade Info of Futures
  - OHLC of Future Contracts
  - Currency and commodities Futures
  - Currency and commodities Future contracts OHLC
  - Option Chain with Greeks (From Sensibull)

- Fundamentals :
  - Moneycontrol :
    - Mini Statements from Moneycontrol (some commonly used data out of `annual reports` of few timeframes)
      - overview
      - Income
      - Balance sheet
      - Cash flow
      - Ratios
    - Complete Statements (you get complete data of common reports of all annual/quarter reports)
      - Balance Sheet
      - P & L
      - Quarterly results (25th Percentile)
      - Half-Yearly results (50th Percentile)
      - Nine months (75th Percentile)
      - Yearly results (100th percentile)
      - Cash Flow Statement
      - Ratios
      - Capital Structure
  - Tickertape
    - Index Constituents (Tickertape)
    - Annual Report/ Quarterly Results extracted data
      - Income
      - Balance Sheet
      - Cash flow
    - Peers Comparison (Technical Bsed and Valuation Based)
    - Tickertape Scorecard
    - Share Holding Pattern
    - Mutual Fund Holdings
    - Small Case Holdings
    - Dividend History (paid out + Upcoming which is confirmed)
    - Key Ratios of Stocks and Indices
    - All ETFs under an Index
    - Tickertape Screeners
  - BSE :
    - Download Annual Reports in PDF format

## License

This project is licensed under the Apache License.
See the [LICENSE](https://github.com/avinashsahu/Bharat-SM-Data-Avinash/blob/master/LICENSE) for more details.

## Acknowledgments
- **Original Author**: Sampad Hegde (https://github.com/Sampad-Hegde/Bharat-SM-Data)
- Pandas
- Requests
- All the websites used for collecting data
- pydash
- BS4

## Contact

### Fork Maintainer
- **Avinash Sahu**
- GitHub: [avinashsahu](https://github.com/avinashsahu)
- Repository: [Bharat-SM-Data-Avinash](https://github.com/avinashsahu/Bharat-SM-Data-Avinash)

### Original Author
- **Sampad Hegde**
- Email: [me@sampadhegde.in | sampadhegde@gmail.com]
- LinkedIn: [sampad-hegde](https://www.linkedin.com/in/sampad-hegde)
- Instagram: [@sampad_hegde](https://www.instagram.com/sampad_hegde)
- Facebook: [sampad.hegde](https://www.facebook.com/sampad.hegde)