eshan6704 commited on
Commit
177d114
·
verified ·
1 Parent(s): d454be6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -11
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
- date_str = date_str.strip()
63
 
64
  # ✅ Frontend may send empty date → auto yesterday
65
  if not date_str:
66
- date_str = today_date()
67
 
68
- date_start = last_year_date(date_str)
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(date_str,name)
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(date_str).to_html()
95
 
96
  elif req_type == "nse_bhav":
97
- return build_bhavcopy_html(date_str)
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", date_start, date_str).to_html()
113
 
114
  elif req_type == "largedeals_historical":
115
- return nse_largedeals_historical(date_start, date_str).to_html()
116
 
117
  elif req_type == "index_pe_pb_div":
118
- return index_pe_pb_div("NIFTY 50", date_start, date_str).to_html()
119
 
120
  elif req_type == "index_total_returns":
121
- return index_total_returns("NIFTY 50", date_start, date_str).to_html()
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(date_start, date_str, name).to_html()
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>")