Thanks. I have upgraded to paid account. I am running same program. It was stuck at one point. So I forced closed it and below is the message:
12:47 ~/Trade $ python3 straddle.py
^CTraceback (most recent call last):
File "/home/csomkuwar/Trade/straddle.py", line 20, in <module>
atmstrike = getatmStrike()
File "/home/csomkuwar/Trade/straddle.py", line 16, in getatmStrike
ltp = oi_chain_builder(symbol,"latest","full")[1]
File "/home/csomkuwar/.local/lib/python3.10/site-packages/nsepython/rahu.py", line 90, in oi_chain_builder
payload = nse_optionchain_scrapper(symbol)
File "/home/csomkuwar/.local/lib/python3.10/site-packages/nsepython/rahu.py", line 82, in nse_optionchain_scrapper
payload = nsefetch('https://www.nseindia.com/api/option-chain-indices?symbol='+symbol)
File "/home/csomkuwar/.local/lib/python3.10/site-packages/nsepython/rahu.py", line 33, in nsefetch
output = requests.get(payload,headers=headers).json()
File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 73, in get
return request("get", url, params=params, **kwargs)
File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 59, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 587, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 701, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 489, in send
resp = conn.urlopen(
File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 703, in urlopen
httplib_response = self._make_request(
File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 449, in _make_request
six.raise_from(e, None)
File "<string>", line 3, in raise_from
File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 444, in _make_request
httplib_response = conn.getresponse()
File "/usr/local/lib/python3.10/http/client.py", line 1374, in getresponse
response.begin()
File "/usr/local/lib/python3.10/http/client.py", line 318, in begin
version, status, reason = self._read_status()
File "/usr/local/lib/python3.10/http/client.py", line 279, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/local/lib/python3.10/socket.py", line 705, in readinto
return self._sock.recv_into(b)
File "/usr/local/lib/python3.10/ssl.py", line 1274, in recv_into
return self.read(nbytes, buffer)
File "/usr/local/lib/python3.10/ssl.py", line 1130, in read
return self._sslobj.read(len, buffer)
KeyboardInterrupt
Code that I am running is below:
from nsepython import*
symbol = "BANKNIFTY"
# to get atmstrike using nsepython
def getatmStrike():
ltp = oi_chain_builder(symbol,"latest","full")[1]
atmstrike=round(ltp/100)*100
return atmstrike
atmstrike = getatmStrike()
print(atmstrike)
ceStrike = atmstrike + 300
peStrike = atmstrike - 300
ceLTP = nse_quote_ltp(symbol,"latest","CE",ceStrike)
peLTP = nse_quote_ltp(symbol,"latest","PE",peStrike)
combineFirstPremium = ceLTP+peLTP
print("combined initial premium is:", combineFirstPremium)