Today let's build a simple cryptocurrency price tracker using Python. In less than 15 lines of code you can have a graph with historical data of DogeCoin!
Import your libraries
import yfinance as yf #get the historical data import plotly.express as px # draw the graph import datetime as date # manipulate date's
Get DogeCoin Price's
Now We'll call the yf varible and pass the DogeCoin Ticker and the Currency of your country, in my case I use EUR.
tkr_str = 'DOGE-EUR' #If you want In USD change to 'DOGE-USD' tkr = yf.Ticker(tkr_str) dateStart = date.datetime.now() - date.timedelta(days=1*365) # set the begin date from a year ago dateToday = date.datetime.now().strftime("%Y-%m-%d") #get Today's Date graph = tkr.history(start=dateStart,end=dateToday,interval="1h") #Get the Historical data for the graph
Build the Graph
Now that we got the data, let's build the Graph with the prices of DogeCoin ! Use the head from the yf library to name the X and Y axis.
graph.head() graph = graph.reset_index() fig = px.line(graph, x="index", y="Open", title='Doge Price Tracker') fig.show()
Run your code and see Doge going to the moon !