Skip to content

Commit 6a47faa

Browse files
authored
Update NSE-Option-Chain-Analyzer.py
1 parent 4db774c commit 6a47faa

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

NSE-Option-Chain-Analyzer.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def about(self, event="empty"):
212212
heading.grid(row=0, column=0, columnspan=2, sticky=N + S + W + E)
213213
version_label = Label(self.info, text="Version:", relief=RIDGE)
214214
version_label.grid(row=1, column=0, sticky=N + S + W + E)
215-
version_val = Label(self.info, text="3.0", relief=RIDGE)
215+
version_val = Label(self.info, text="3.1", relief=RIDGE)
216216
version_val.grid(row=1, column=1, sticky=N + S + W + E)
217217
dev_label = Label(self.info, text="Developer:", relief=RIDGE)
218218
dev_label.grid(row=2, column=0, sticky=N + S + W + E)
@@ -593,7 +593,13 @@ def main(self):
593593
c2 = b2.get((index + 1), 'Change in Open Interest')
594594
b3 = df.iloc[:, 1]
595595
c3 = b3.get((index + 2), 'Change in Open Interest')
596+
if isinstance(c2, str):
597+
c2 = 0
598+
if isinstance(c3, str):
599+
c3 = 0
596600
self.call_sum = round((c1 + c2 + c3) / 1000, 1)
601+
if self.call_sum == -0:
602+
self.call_sum = 0.0
597603
self.call_boundary = round(c3 / 1000, 1)
598604

599605
o1 = a.iloc[:, 1]
@@ -606,21 +612,33 @@ def main(self):
606612
self.p5 = o3.get((index + 4), 'Change in Open Interest')
607613
self.p6 = o3.get((index - 2), 'Change in Open Interest')
608614
self.p7 = o2.get((index - 2), 'Change in Open Interest')
615+
if isinstance(p2, str):
616+
p2 = 0
617+
if isinstance(p3, str):
618+
p3 = 0
619+
if isinstance(self.p4, str):
620+
self.p4 = 0
621+
if isinstance(self.p5, str):
622+
self.p5 = 0
609623
self.put_sum = round((p1 + p2 + p3) / 1000, 1)
610624
self.put_boundary = round(p1 / 1000, 1)
611625
self.difference = round(self.call_sum - self.put_sum, 1)
612626
if self.p5 == 0:
613-
self.call_itm = 0
627+
self.call_itm = 0.0
614628
else:
615629
self.call_itm = round(self.p4 / self.p5, 1)
616630
if self.call_itm == -0:
617-
self.call_itm = 0
631+
self.call_itm = 0.0
632+
if isinstance(self.p6, str):
633+
self.p6 = 0
634+
if isinstance(self.p7, str):
635+
self.p7 = 0
618636
if self.p7 == 0:
619-
self.put_itm = 0
637+
self.put_itm = 0.0
620638
else:
621639
self.put_itm = round(self.p6 / self.p7, 1)
622640
if self.put_itm == -0:
623-
self.put_itm = 0
641+
self.put_itm = 0.0
624642

625643
if self.stop:
626644
return

0 commit comments

Comments
 (0)