8/5/2023 0 Comments Yfinance documentation![]() To get all the data from the first day of the year to the current day of the year, we can pass period = "ytd". Here we will look at a some general time periods that can be passed to the yf.download() argument, period. Often times we do not want the entire stock exchange history for a ticker symbol, but rather a date range. It is a highly customized wrapper, centered on the pandas. The following is the code for fancy_plot(), which I use for many of my visualizations. Plotting the last 60+ years of stock fluctuations for GE reveals some soaring prices and some unfortunate declines as well. ![]() The following is the code for head_tail_vert() and head_tail_horz(), which I use with dataframes extensively to present more easily digestible, labeled data. So with yf.download() and a ticker symbol alone, it is possible to get a great deal of data. By default, if we only pass the ticker name, we receive the data for every trading day in the history of the company, which as you can see below for GE, dates back to January 2, 1962. To dive right in, after importing yfinance as yf, we will create a ticker variable for "GE" and pass it to yf.download(). There is no API key needed, and the yfinance module can return an incredible wealth of data with just one line of code. One of the most beneficial aspects of Yahoo Finance is how quick and easy it is to access data. Special thanks to Alexander Hagmann for his thorough instruction.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |