Skip to main content

This Python Library is designed to fetch BhavCopy data (daily market reports) from a PostgreSQL database for specified symbols, date ranges, and series. The script provides utility functions to standardize data formats, parse dates, and retrieve data for Cash Market (CM), Futures and Options (FO), and Indices.

Project description

Welcome to RmoneyBhavcopy Library


Introduction

This Python Library is designed to fetch BhavCopy data (daily market reports) from a PostgreSQL database for specified symbols, date ranges, and series. The script provides utility functions to standardize data formats, parse dates, and retrieve data for Cash Market (CM), Futures and Options (FO), and Indices.

Features

  • Fetch Market Data Across Segments.

  • Standardize Data Formats.

  • Connects securely to a PostgreSQL database using configuration details.

  • Supports flexible defaults for date ranges and symbols.

  • Accepts ticker symbols in any case (lowercase, uppercase, or mixed).

  • Raises a ValueError if the start_date is greater than the end_date.

  • Defaults to January 1, 2016, as the start_date if none is specified.

  • Defaults to the current date as the end_date if none is specified.

  • Defaults to January 1, 2016, as the start_date and the current date as the end_date if neither is specified.

Installation

  • Create Virtual Environment (Optional)
python -m venv .venv
  • Install Library using pip
pip install http://pypi.rmoneyindia.in:8080/rmoney_bhavcopy-0.1.2-py3-none-any.whl
  • Install Library using uv
uv add --frozen http://192.168.50.40:8080/rmoney_bhavcopy-0.1.2-py3-none-any.whl
uv sync

Examples

Example 1:Fetching bhavcopy for Specific Stocks,Index and FNO.

from Rmoney_bhavcopy.Bhavcopy_Reteriver import get_CM_bhavcopy,get_FO_bhavcopy,get_indices_bhavcopy
from datetime import datetime

CM_data = get_CM_bhavcopy(
    start_date= datetime(2022,1,1),
    end_date=datetime(2022,1,31),
    symbols= ['TCS','TECHM'],
    series= ['EQ']
)
print(CM_data)

FO_data = get_FO_bhavcopy(
    start_date= datetime(2022,1,1),
    end_date=datetime(2022,1,31),
    symbols= ['TCS','TECHM'],
)
print(FO_data)

indices_data = get_indices_bhavcopy(
    start_date= datetime(2022,1,1),
    end_date=datetime(2022,1,31),
    symbols= ["Nifty 50","Nifty 100"]
)
print(indices_data)

Example 2: Fetching bhavcopy without marked the Starting Date (then the start_date = datetime(2016,1,1), By default).

from Rmoney_bhavcopy.Bhavcopy_Reteriver import get_CM_bhavcopy,get_FO_bhavcopy,get_indices_bhavcopy
from datetime import datetime

CM_data = get_CM_bhavcopy(
    end_date=datetime(2022,1,31),
    symbols= ['TCS','TECHM'],
    series= ['EQ']
)
print(CM_data)

FO_data = get_FO_bhavcopy(

    end_date=datetime(2022,1,31),
    symbols= ['TCS','TECHM'],
)
print(FO_data)

indices_data = get_indices_bhavcopy(
    end_date=datetime(2022,1,31),
    symbols= ["Nifty 50","Nifty 100"]
)
print(indices_data)

Example 3: Fetching bhavcopy without without marked the Ending Date (then the end_date = datetime.now(), By default).

from Rmoney_bhavcopy.Bhavcopy_Reteriver import get_CM_bhavcopy,get_FO_bhavcopy,get_indices_bhavcopy
from datetime import datetime

CM_data = get_CM_bhavcopy(
    start_date= datetime(2022,1,1),
    symbols= ['TCS','TECHM'],
    series= ['EQ']
)
print(CM_data)

FO_data = get_FO_bhavcopy(
    start_date= datetime(2022,1,1),
    symbols= ['TCS','TECHM'],
)
print(FO_data)

indices_data = get_indices_bhavcopy(
    start_date= datetime(2022,1,1),
    symbols= ["Nifty 50","Nifty 100"]
)
print(indices_data)

Example 4: Fetching bhavcopy without marked the Starting Date and Ending Date (then the start_date = datetime(2016,1,1) and end_date = datetime.now(), By default).

from Rmoney_bhavcopy.Bhavcopy_Reteriver import get_CM_bhavcopy,get_FO_bhavcopy,get_indices_bhavcopy
from datetime import datetime

CM_data = get_CM_bhavcopy(
    symbols= ['TCS','TECHM'],
    series= ['EQ']
)
print(CM_data)

FO_data = get_FO_bhavcopy(
    symbols= ['TCS','TECHM'],
)
print(FO_data)

indices_data = get_indices_bhavcopy(
    symbols= ["Nifty 50","Nifty 100"]
)
print(indices_data)

Output

Output

Note

get_CM_bhavcopy(start_date, end_date, symbols, series)

  • Purpose: Fetch Cash Market BhavCopy data for multiple symbols over a specified date range.

  • Parameters:

    • start_date (Optional[datetime.date]): Start date (default is 2016-01-01).
    • end_date (Optional[datetime.date]): End date (default is the current date).
    • symbols (Optional[List[str]]): List of symbols to fetch data for.
    • series (Optional[List[str]]): List of series types (e.g., 'EQ', 'GB').
  • Returns: A Pandas DataFrame containing the fetched data

  • Raises:

    • ValueError: If any arguments are invalid.
# Example 1: Fetching data for specific stocks
from Rmoney_bhavcopy.Bhavcopy_Reteriver import get_CM_bhavcopy
from datetime import datetime
data = get_CM_bhavcopy(
    start_date=datetime(2023, 1, 1),
    end_date=datetime(2023, 1, 31),
    symbols=['TCS', 'HDFCBANK'],
    series=['EQ']
)

Output

Output


get_FO_bhavcopy(start_date, end_date, symbols)

  • Purpose: Fetch FNO Market BhavCopy data for multiple symbols over a specified date range.

  • Parameters:

    • start_date (Optional[datetime.date]): Start date (default is 2016-01-01).
    • end_date (Optional[datetime.date]): End date (default is the current date).
    • symbols (Optional[List[str]]): List of symbols to fetch data for.
  • Returns: A Pandas DataFrame containing the fetched data

  • Raises:

    • ValueError: If any arguments are invalid.
from Rmoney_bhavcopy.Bhavcopy_Reteriver import get_FO_bhavcopy
from datetime import datetime
FO_data = get_FO_bhavcopy(
    start_date= datetime(2022,1,1),
    end_date=datetime(2022,1,31),
    symbols= ['TCS','TECHM'],
)
print(FO_data)

Output

get_indices_bhavcopy(start_date, end_date, symbols)

  • Purpose: Fetch Indices Market BhavCopy data for multiple symbols over a specified date range.

  • Parameters:

    • start_date (Optional[datetime.date]): Start date (default is 2016-01-01).
    • end_date (Optional[datetime.date]): End date (default is the current date).
    • symbols (Optional[List[str]]): List of symbols to fetch data for.
  • Returns: A Pandas DataFrame containing the fetched data.

  • Raises:

    • ValueError: If any arguments are invalid.
from Rmoney_bhavcopy.Bhavcopy_Reteriver import get_indices_bhavcopy
from datetime import datetime
Indices_data = get_indices_bhavcopy(
    start_date= datetime(2022,1,1),
    end_date=datetime(2022,1,31),
    symbols= ["Nifty 50","Nifty 100"]
)
print(Indices_data)

Output

Gitlab

GitLab Repository - RmoneyBhavcopy Library

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rmoney_bhavcopy-0.1.3.tar.gz (3.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rmoney_bhavcopy-0.1.3-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file rmoney_bhavcopy-0.1.3.tar.gz.

File metadata

  • Download URL: rmoney_bhavcopy-0.1.3.tar.gz
  • Upload date:
  • Size: 3.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.6

File hashes

Hashes for rmoney_bhavcopy-0.1.3.tar.gz
Algorithm Hash digest
SHA256 1b09d447e56779ac0c2e7622b159f904a119b43d3429af510e3c1445e5729f6c
MD5 09e6eabd4b02031275a56cdf2888b98f
BLAKE2b-256 1872987c9d9a8cd44318fe16c396ea4316e4d0cdb80aa162395fa5120e4248fb

See more details on using hashes here.

File details

Details for the file rmoney_bhavcopy-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for rmoney_bhavcopy-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d48ebb09a6c6b1179b63169a1e9d3428204fbbcc835fd1b2b0830c73ad65de5d
MD5 fcf3e572f9ea66dd0557cc33fa8048ad
BLAKE2b-256 44b95b876dd9e3d532fcdd7b0da7d6bd058daf6e1e605f34dddd1e396c933323

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page