Mar-14-2020, 08:14 PM
Hi everyone , I'm trying to make an app that can show the price of a stock and also the graphics of the stock. The part of Graph is working but I could not pass the DATA variable into the Label that shows on the screen(You can see the results in terminal).So could you help me on this issue any contrubutions will help :)
import datetime as dt import matplotlib.pyplot as plt import pandas_datareader.data as web import tkinter as tk from PIL import ImageTk, Image import requests import pandas as pd from alpha_vantage.techindicators import TechIndicators from alpha_vantage.timeseries import TimeSeries root=tk.Tk() inputValue=tk.StringVar() DATA=tk.StringVar() def format_response(DATA): try: openn = DATA['open'] high = DATA['high'] low = DATA['low'] final_str = 'open: %s \nhigh: %s \nLow: %s' % (openn,high,low) except: final_str = 'There was a problem retrieving that information' return final_str def get_name(): inputValue=Entry.get() ts=TimeSeries(key='Q5PZV4ADMZIUI2VT',output_format='pandas') DATA, meta_data=ts.get_daily(symbol=inputValue) print(DATA) def open_graph(): inputValue=Entry.get() start=dt.datetime(2020,2,14) end=dt.datetime(2020,3,14) df=web.DataReader(inputValue,'yahoo',start,end) df['Open'].plot() df['Close'].plot(color='r') plt.show() tk.Canvas() photo = ImageTk.PhotoImage(Image.open("D:\\Profile\\Desktop\\Photos\\stockmrkt.jpg")) logo = tk.Label(root, image=photo) logo.pack() Frame=tk.Frame(root,bg="#80c1ff",bd=5) Frame.place(relx=0.5,rely=0.1,relwidth=0.75,relheight=0.1,anchor='n') Entry=tk.Entry(Frame,font=40,bd=4) Entry.place(relwidth=0.3,relheight=1) Button=tk.Button(Frame,text="Stock Values",bg="Grey",font=40,command=lambda:get_name()) Button.place(relx=0.48,rely=0.1,anchor='n',relwidth=0.32) Buttongraph=tk.Button(Frame,text="Stock Graphs",bg="Grey",font=40,command=lambda:open_graph()) Buttongraph.place(relx=0.83,rely=0.1,anchor='n',relwidth=0.32) lower_frame=tk.Entry(root,bg="#80c1ff",bd=5) lower_frame.place(relx=0.5,rely=0.25,relwidth=0.75,relheight=0.6,anchor='n') label=tk.Label(lower_frame,font=('courier',18),anchor='nw',justify='left',bd=4) label.place(relwidth=1,relheight=1) tk.mainloop()