def show_risks(self, root):
top_level = tk.Toplevel(root)
scr_frame = ScrolledFrame(top_level)
fields = ['Name', 'Underlying', 'Contract', 'Otype', 'Stike', 'Price', 'BidPrice', 'BidIV', 'AskPrice', 'AskIV', 'PV', 'Delta','Gamma','Vega', 'Theta']
for idx, field in enumerate(fields):
tk.Label(scr_frame.frame, text = field).grid(row=0, column=idx)
idy = 0
for i, cmth in enumerate(self.cont_mth):
for strike in self.strikes[i]:
for otype in ['C','P']:
key = (cmth, otype, strike)
if key in self.opt_dict:
idy += 1
inst = self.opt_dict[key]
for idx, field in enumerate(fields):
if idx == 0:
txt = inst
elif idx == 1:
txt = self.underliers[i]
elif idx in [2, 3, 4]:
txt = key[idx-2]
else:
factor = 1
if field in ['delta', 'gamma', 'BidIV', 'AskIV']:
factor = 100
txt = self.curr_insts[inst][field]*factor
tk.Label(scr_frame.frame, text = keepdigit(txt,3)).grid(row=idy, column=idx)
评论列表
文章目录