-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvix.py
45 lines (37 loc) · 1.76 KB
/
vix.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from tkinter import *
from yahoo_fin import stock_info as si
import pyttsx3
import speech_recognition as sr
janela: Tk = Tk() # create the window
janela.title('VIX monitor')
janela.resizable(False, False) # Prevents anyone from being able to resize the window
label1 = Label(janela, text='VIX = ', bg='white', fg='blue', font=("Arial", 20), padx=20, pady=20).grid(row=2, column= 2)
vix_cotacao = round(si.get_live_price('^VIX'),2) # get the current value of VIX
label2 = Label(janela, text=vix_cotacao, bg='white', fg='blue', font=("Arial", 20), padx=20, pady=20).grid(row=2, column= 3)
tempo_att = 1000 #ms
def neue_fenster(mensagem):
fenster: Tk = Tk() # create the new window
fenster.title('ALERT')
fenster.resizable(False, False) # Prevents anyone from being able to resize the window
Label(fenster, text=mensagem, bg='white', fg='blue', font=("Arial", 20), padx=20, pady=20).grid(row=2, column= 2)
def sprechen(mensagem):
engine = pyttsx3.init()
engine.say(mensagem)
engine.runAndWait()
def upd():
vix_cotacao = round(si.get_live_price('^VIX'),2)
label2 = Label(janela, text=vix_cotacao, bg='white', fg='blue', font=("Arial", 20), padx=20, pady=20, anchor = 'e').grid(row=2, column= 3)
if vix_cotacao > 25.1:
mensagem = 'Volatility requires attention'
neue_fenster(mensagem)
sprechen(mensagem)
elif vix_cotacao > 36.1:
mensagem = 'High volatility, be carefull'
neue_fenster(mensagem)
sprechen(mensagem)
elif vix_cotacao > 48.9:
mensagem = 'Critical volatility, urgently use hedging strategies'
neue_fenster(mensagem)
sprechen(mensagem)
janela.after(tempo_att, upd) # keeps Vix updated every 1000 millisecond interval
janela.mainloop()