jarvisx17 commited on
Commit
1e8402a
·
verified ·
1 Parent(s): 82a9e3e

Update utils.py

Browse files
Files changed (1) hide show
  1. utils.py +8 -1
utils.py CHANGED
@@ -83,10 +83,17 @@ class StockDataFetcher:
83
  return None
84
 
85
  def fetch_option_chain(self, symbol):
 
 
86
  response = requests.get(self.option_chain + symbol, headers=self.headers)
87
  data = response.json()['optionChain']['optionChains']
88
  ltp = response.json()['livePrice']['value']
89
- index_ltp = requests.get(self.latest_index_price + symbol.upper() + "/latest", headers=self.headers).json()['value']
 
 
 
 
 
90
 
91
  chain = []
92
  for i in range(len(data)):
 
83
  return None
84
 
85
  def fetch_option_chain(self, symbol):
86
+ if symbol.upper() == "BANKNIFTY":
87
+ symbol = "nifty-bank"
88
  response = requests.get(self.option_chain + symbol, headers=self.headers)
89
  data = response.json()['optionChain']['optionChains']
90
  ltp = response.json()['livePrice']['value']
91
+
92
+ if symbol == "nifty-bank":
93
+ index_ltp = requests.get(self.latest_index_price + "BANKNIFTY" + "/latest", headers=self.headers).json()['value']
94
+
95
+ if symbol.upper() == "NIFTY":
96
+ index_ltp = requests.get(self.latest_index_price + "NIFTY" + "/latest", headers=self.headers).json()['value']
97
 
98
  chain = []
99
  for i in range(len(data)):