Skip to content

Commit

Permalink
fix: Market Activity report particulary parsed
Browse files Browse the repository at this point in the history
  • Loading branch information
shivam2502 committed May 12, 2024
1 parent bd0824c commit e53fb1d
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions nsedt/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
REPORT_URL, MARKET_ACTIVITY_REPORT,
BHAV_COPY_REPORT, SEC_BHAV_COPY_REPORT, NSCCL_REPORTS, NSCCL_VOLT)

import pandas as pd
from io import BytesIO

log = logging.getLogger("root")

# tbd
Expand All @@ -23,8 +26,8 @@ def get_market_activity_report(date: str):
Args:\n
date (str): date for which to download market activity report\n
Returns:
string: string content of the file as right now its not possible
to format the content to json or pandas df
df = Returns dataframe for market activity report for sectors
for the given date
Expects:
date to be in format of "dd-mm-yyyy" eg: 30-04-2024
all other cases will be invalidated
Expand All @@ -35,8 +38,11 @@ def get_market_activity_report(date: str):

cookies = get_cookies()
url = f"{REPORT_URL}{MARKET_ACTIVITY_REPORT}{date}.csv"
return fetch_csv(url, cookies, response_type="raw")

response = fetch_csv(url, cookies, response_type="raw")
df = pd.read_csv(BytesIO(response), skiprows=8)
df.drop(columns=['Unnamed: 0'], inplace=True)
df = df[:77]
return df

def get_volatility_report(date: str, response_type: str="panda_df"):
"""
Expand Down

0 comments on commit e53fb1d

Please sign in to comment.