Update nse.py
Browse files
nse.py
CHANGED
|
@@ -40,7 +40,7 @@ def clean_dataframe(df):
|
|
| 40 |
# ---------------------------------------------------
|
| 41 |
# Bhavcopy Fetch β DataFrame
|
| 42 |
# ---------------------------------------------------
|
| 43 |
-
def
|
| 44 |
"""Returns Cleaned Bhavcopy DF for EQ / BE / SM"""
|
| 45 |
date_str = date.strftime("%d-%m-%Y")
|
| 46 |
print(f"Attempting to fetch bhavcopy for date: {date_str}")
|
|
@@ -67,7 +67,7 @@ def fetch_bhavcopy_df(date):
|
|
| 67 |
# ---------------------------------------------------
|
| 68 |
# Stock Deliverable DF (security-wise archive)
|
| 69 |
# ---------------------------------------------------
|
| 70 |
-
def
|
| 71 |
"""Return DF for security-wise archive (deliverable + all columns)"""
|
| 72 |
|
| 73 |
df = nse_module.security_wise_archive(start, end, stock, series)
|
|
@@ -78,7 +78,7 @@ def fetch_stock_df(nse_module, stock, start, end, series="ALL"):
|
|
| 78 |
# ---------------------------------------------------
|
| 79 |
# All NSE Indices β DataFrames
|
| 80 |
# ---------------------------------------------------
|
| 81 |
-
def
|
| 82 |
url = "https://www.nseindia.com/api/allIndices"
|
| 83 |
data = fetch_data(url)
|
| 84 |
if data is None:
|
|
@@ -165,7 +165,7 @@ def fetch_option_chain_df(symbol="NIFTY"):
|
|
| 165 |
# ---------------------------------------------------
|
| 166 |
# Pre-open market β DataFrame
|
| 167 |
# ---------------------------------------------------
|
| 168 |
-
def
|
| 169 |
url = f"https://www.nseindia.com/api/market-data-pre-open?key={key}"
|
| 170 |
data = fetch_data(url)
|
| 171 |
if not data:
|
|
@@ -184,7 +184,7 @@ def preopen(key="NIFTY"):
|
|
| 184 |
# ---------------------------------------------------
|
| 185 |
# FNO Quote β DataFrames
|
| 186 |
# ---------------------------------------------------
|
| 187 |
-
def
|
| 188 |
payload = nsepython.nse_quote(symbol)
|
| 189 |
if not payload:
|
| 190 |
return None
|
|
|
|
| 40 |
# ---------------------------------------------------
|
| 41 |
# Bhavcopy Fetch β DataFrame
|
| 42 |
# ---------------------------------------------------
|
| 43 |
+
def nse_bhavcopy(date):
|
| 44 |
"""Returns Cleaned Bhavcopy DF for EQ / BE / SM"""
|
| 45 |
date_str = date.strftime("%d-%m-%Y")
|
| 46 |
print(f"Attempting to fetch bhavcopy for date: {date_str}")
|
|
|
|
| 67 |
# ---------------------------------------------------
|
| 68 |
# Stock Deliverable DF (security-wise archive)
|
| 69 |
# ---------------------------------------------------
|
| 70 |
+
def nse_stock(nse_module, stock, start, end, series="ALL"):
|
| 71 |
"""Return DF for security-wise archive (deliverable + all columns)"""
|
| 72 |
|
| 73 |
df = nse_module.security_wise_archive(start, end, stock, series)
|
|
|
|
| 78 |
# ---------------------------------------------------
|
| 79 |
# All NSE Indices β DataFrames
|
| 80 |
# ---------------------------------------------------
|
| 81 |
+
def nse_indices():
|
| 82 |
url = "https://www.nseindia.com/api/allIndices"
|
| 83 |
data = fetch_data(url)
|
| 84 |
if data is None:
|
|
|
|
| 165 |
# ---------------------------------------------------
|
| 166 |
# Pre-open market β DataFrame
|
| 167 |
# ---------------------------------------------------
|
| 168 |
+
def nse_preopen(key="NIFTY"):
|
| 169 |
url = f"https://www.nseindia.com/api/market-data-pre-open?key={key}"
|
| 170 |
data = fetch_data(url)
|
| 171 |
if not data:
|
|
|
|
| 184 |
# ---------------------------------------------------
|
| 185 |
# FNO Quote β DataFrames
|
| 186 |
# ---------------------------------------------------
|
| 187 |
+
def nse_fno(symbol):
|
| 188 |
payload = nsepython.nse_quote(symbol)
|
| 189 |
if not payload:
|
| 190 |
return None
|