Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 19054

Python : Getting current Bitcoin price from Yahoo finance with yfinance module

$
0
0

I'm trying to read and display the current Bitcoin market price in Python, using the yfinance module/library.
It works fine for currency pairs or market indices but BTC-USD doesn't seem to have any returned data which contains the current price.

For other indices there's a bid/ask price and I just take the average but I guess BTC has no spread...but I can't figure out which field has the 'current market price'
Suggestions please.

Thanks,

This code works but it's showing the opening price, not the current market price:

BTC = yF.Ticker("BTC-GBP")print("Bitcoin Current : ", round(BTC.info['open'],0))print("        Day     : ", round(BTC.info['dayLow'], 0), "-", round(BTC.info['dayHigh'], 0))print("        52 Week : ", round(BTC.info['fiftyTwoWeekLow'], 0), "-", round(BTC.info['fiftyTwoWeekHigh'], 0))

Viewing all articles
Browse latest Browse all 19054

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>