ranaroussi / yfinance

Download market data from Yahoo! Finance's API

Home Page:https://aroussi.com/post/python-yahoo-finance

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how to download CVOL-USD data

aixuedegege opened this issue · comments

commented

Can I download CVOL data from this link? https://finance.yahoo.com/quote/CVOL-USD/
I hava tried this code:

df = yf.download('CVOL-USD', start=start, end=end, progress=False, interval = f'1d')

but i got Exception('%ticker%: No price data found, symbol may be delisted ?

Your code doesn't work:

NameError: name 'start' is not defined

It does look like the code is being blocked. You can get a Yahoo finance API and run that
import requests

url = "https://yahoo-finance15.p.rapidapi.com/api/v1/markets/options"

querystring = {"ticker":"CVX"}

headers = {
"X-RapidAPI-Key": "REDACTED",
"X-RapidAPI-Host": "yahoo-finance15.p.rapidapi.com"
}

response = requests.get(url, headers=headers, params=querystring)

print(response.json())

commented

Your code doesn't work:

NameError: name 'start' is not defined

sorry, i forgot it, you can define it by:

start='2023-12-11', end='2023-12-12'
commented

It does look like the code is being blocked. You can get a Yahoo finance API and run that import requests

url = "https://yahoo-finance15.p.rapidapi.com/api/v1/markets/options"

querystring = {"ticker":"CVX"}

headers = { "X-RapidAPI-Key": "REDACTED", "X-RapidAPI-Host": "yahoo-finance15.p.rapidapi.com" }

response = requests.get(url, headers=headers, params=querystring)

print(response.json())

thank you ! but where should i get the information about "CVX"?

The information about the stock is returned in the json file, and you have to extract it... You can log onto rapidapi and get your own api for free.
https://rapidapi.com/sparior/api/yahoo-finance15/pricing

commented

ok thks a lot

@JennyCon You should remove or mask the API key when you post that.

@JennyCon You should remove or mask the API key when you post that.

I've removed it.