-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathB_CAT_0.py
More file actions
69 lines (45 loc) · 1.69 KB
/
B_CAT_0.py
File metadata and controls
69 lines (45 loc) · 1.69 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import datetime as dt
import matplotlib.pyplot as plt
import pandas_datareader as pdr
import yfinance as yf
from tkinter import Button, Entry, Tk, mainloop
current_date = str(dt.date.today())
start_date_ode = str(str(current_date[0:-2]) + str(int(current_date[-2::]) - 1))
start_date_fye = str(str(int(current_date[0:4]) - 5) + str(current_date[4::]))
def get_change(current, previous):
if current == previous:
return 0
try:
return (abs(current - previous) / previous) * 100.0
except ZeroDivisionError:
return float('INF')
def get_commands_gui():
command_entered = []
root = Tk()
root.title('TICKER SYMBOL ENTRY')
root.geometry('300x30')
command = Entry(root)
command.grid(row=0, column=1)
def get_command_globals():
command_entered.append(command.get())
root.destroy()
button_entry = Button(root, text='SUBMIT', command=get_command_globals)
button_entry.grid(row=0)
def enter_press(*args, **kwargs):
button_entry.invoke()
command.bind('<Return>', enter_press)
mainloop()
return command_entered[0].upper()
coin_ticker_symbol = get_commands_gui()
def create_graph_from_yf_data():
yf_data = yf.download(coin_ticker_symbol, start_date_fye, current_date)
yf_data['Adj Close'].plot(figsize=(10, 6))
plt.title(str(coin_ticker_symbol), fontsize=12)
plt.ylabel('PRICE', fontsize=8)
plt.xlabel('YEAR', fontsize=8)
plt.grid(which="major", color='k', linestyle='-', linewidth=0.5)
plt.show()
create_graph_from_yf_data()
"""
pdr_data = pdr.DataReader(coin_ticker_symbol, 'yahoo', start_date_fye, current_date)
"""