'How to get today's crypto data using yfinance

I am trying to predict the future of crypto currencys using the yfinance package in python. I use yf.download("crypto-name", start = "2020-06-24" , end = dt.datetime.now() ) to get a crypto price. However, the given prices do not include today's date.

In the example below, today's date is 2022-2-7. But the data stops at 2022-2-6.

Open    High    Low Close   Adj Close   Volume
Date                        
2020-06-24  2.539728    8.214714    2.521947    6.739848    6.739848    2474641
2020-06-25  6.749885    6.821954    6.237892    6.276334    6.276334    316601
2020-06-26  6.276523    6.360017    5.664151    5.807454    5.807454    306668
2020-06-27  5.791695    5.997406    5.013621    5.026706    5.026706    337452
2020-06-28  5.026706    5.214136    4.664291    5.063728    5.063728    335636
... ... ... ... ... ... ...
2022-02-02  6.231474    6.536989    6.019950    6.046986    6.046986    1519471
2022-02-03  6.048145    6.206626    5.933793    6.151821    6.151821    737245
2022-02-04  6.162454    6.441396    6.152613    6.427942    6.427942    819029
2022-02-05  6.427934    6.555094    6.371259    6.449496    6.449496    898056
2022-02-06  6.449254    6.529429    6.321094    6.483887    6.483887    890667

How can I get today's data?



Solution 1:[1]

#!pip install yfinance
import yfinance as yf
import datetime as dt

start = dt.datetime(2020,1,1)
end = dt.datetime.now()

eth = yf.download('ETH', start, end)

or

#!pip install pandas_datareader
import pandas_datareader as web
import datetime as dt

start = dt.datetime(2020,1,1)
end = dt.datetime.now()

ltc = web.DataReader('LTC-USD', 'yahoo', start, end)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 tomerar