Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -59,13 +59,13 @@ def update_on_mode(mode):
|
|
| 59 |
def fetch_data(mode, req_type, name, date_str):
|
| 60 |
req_type = req_type.lower()
|
| 61 |
name = name.strip()
|
| 62 |
-
|
| 63 |
|
| 64 |
# ✅ Frontend may send empty date → auto yesterday
|
| 65 |
if not date_str:
|
| 66 |
-
|
| 67 |
|
| 68 |
-
|
| 69 |
|
| 70 |
if mode == "index":
|
| 71 |
|
|
@@ -79,7 +79,7 @@ def fetch_data(mode, req_type, name, date_str):
|
|
| 79 |
return build_preopen_html()
|
| 80 |
|
| 81 |
elif req_type == "nse_fno":
|
| 82 |
-
return nse_fno_html(
|
| 83 |
|
| 84 |
elif req_type == "nse_events":
|
| 85 |
return nse_events().to_html()
|
|
@@ -91,10 +91,10 @@ def fetch_data(mode, req_type, name, date_str):
|
|
| 91 |
return wrap(nse_future(name))
|
| 92 |
|
| 93 |
elif req_type == "nse_highlow":
|
| 94 |
-
return nse_highlow(
|
| 95 |
|
| 96 |
elif req_type == "nse_bhav":
|
| 97 |
-
return build_bhavcopy_html(
|
| 98 |
|
| 99 |
elif req_type == "nse_largedeals":
|
| 100 |
return nse_largedeals().to_html()
|
|
@@ -109,16 +109,16 @@ def fetch_data(mode, req_type, name, date_str):
|
|
| 109 |
return nse_most_active().to_html()
|
| 110 |
|
| 111 |
elif req_type == "index_history":
|
| 112 |
-
return index_history("NIFTY 50",
|
| 113 |
|
| 114 |
elif req_type == "largedeals_historical":
|
| 115 |
-
return nse_largedeals_historical(
|
| 116 |
|
| 117 |
elif req_type == "index_pe_pb_div":
|
| 118 |
-
return index_pe_pb_div("NIFTY 50",
|
| 119 |
|
| 120 |
elif req_type == "index_total_returns":
|
| 121 |
-
return index_total_returns("NIFTY 50",
|
| 122 |
|
| 123 |
else:
|
| 124 |
return wrap(f"<h3>No handler for {req_type}</h3>")
|
|
@@ -159,7 +159,7 @@ def fetch_data(mode, req_type, name, date_str):
|
|
| 159 |
return wrap(fetch_other(name))
|
| 160 |
|
| 161 |
elif req_type == "stock_hist":
|
| 162 |
-
return nse_stock_hist(
|
| 163 |
|
| 164 |
else:
|
| 165 |
return wrap(f"<h3>No handler for {req_type}</h3>")
|
|
|
|
| 59 |
def fetch_data(mode, req_type, name, date_str):
|
| 60 |
req_type = req_type.lower()
|
| 61 |
name = name.strip()
|
| 62 |
+
to_date = date_str.strip()
|
| 63 |
|
| 64 |
# ✅ Frontend may send empty date → auto yesterday
|
| 65 |
if not date_str:
|
| 66 |
+
to_date = today_str()
|
| 67 |
|
| 68 |
+
from_date = last_year_str(to_date)
|
| 69 |
|
| 70 |
if mode == "index":
|
| 71 |
|
|
|
|
| 79 |
return build_preopen_html()
|
| 80 |
|
| 81 |
elif req_type == "nse_fno":
|
| 82 |
+
return nse_fno_html(to_date,name)
|
| 83 |
|
| 84 |
elif req_type == "nse_events":
|
| 85 |
return nse_events().to_html()
|
|
|
|
| 91 |
return wrap(nse_future(name))
|
| 92 |
|
| 93 |
elif req_type == "nse_highlow":
|
| 94 |
+
return nse_highlow(to_date).to_html()
|
| 95 |
|
| 96 |
elif req_type == "nse_bhav":
|
| 97 |
+
return build_bhavcopy_html(to_date)
|
| 98 |
|
| 99 |
elif req_type == "nse_largedeals":
|
| 100 |
return nse_largedeals().to_html()
|
|
|
|
| 109 |
return nse_most_active().to_html()
|
| 110 |
|
| 111 |
elif req_type == "index_history":
|
| 112 |
+
return index_history("NIFTY 50", from_date, to_date).to_html()
|
| 113 |
|
| 114 |
elif req_type == "largedeals_historical":
|
| 115 |
+
return nse_largedeals_historical(from_date, to_date).to_html()
|
| 116 |
|
| 117 |
elif req_type == "index_pe_pb_div":
|
| 118 |
+
return index_pe_pb_div("NIFTY 50", from_date, to_date).to_html()
|
| 119 |
|
| 120 |
elif req_type == "index_total_returns":
|
| 121 |
+
return index_total_returns("NIFTY 50", from_date, to_date).to_html()
|
| 122 |
|
| 123 |
else:
|
| 124 |
return wrap(f"<h3>No handler for {req_type}</h3>")
|
|
|
|
| 159 |
return wrap(fetch_other(name))
|
| 160 |
|
| 161 |
elif req_type == "stock_hist":
|
| 162 |
+
return nse_stock_hist(from_date, to_date, name).to_html()
|
| 163 |
|
| 164 |
else:
|
| 165 |
return wrap(f"<h3>No handler for {req_type}</h3>")
|