ranaroussi / yfinance

Download market data from Yahoo! Finance's API
https://aroussi.com/post/python-yahoo-finance
Apache License 2.0
14.85k stars 2.44k forks source link

how to download CVOL-USD data #1902

Closed aixuedegege closed 7 months ago

aixuedegege commented 7 months ago

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 ?

ValueRaider commented 7 months ago

Your code doesn't work:

NameError: name 'start' is not defined

JennyCon commented 7 months ago

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())

aixuedegege commented 7 months ago

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'
aixuedegege commented 7 months ago

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"?

JennyCon commented 7 months ago

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

aixuedegege commented 7 months ago

ok thks a lot

paulmcq commented 7 months ago

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

ValueRaider commented 7 months ago

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

I've removed it.

JennyCon commented 7 months ago

Thanks!!!

Dr. Jennifer I Considine

221A Casale Place

Canmore, AB

Canada

403 807 6894

[University of Dundee shield logo]http://uod.ac.uk/sig-home

Jennifer Considine Senior Research Fellow School of Social Sciences, University of Dundee @.*** | +44(0)1382 384300<mailto:+44(0)1382%20384300>

[University of Dundee Facebook]http://uod.ac.uk/sig-fb [University of Dundee Twitter] http://uod.ac.uk/sig-tw [University of Dundee LinkedIn] http://uod.ac.uk/sig-li [University of Dundee YouTube] http://uod.ac.uk/sig-yt [University of Dundee Instagram] http://uod.ac.uk/sig-ig [University of Dundee Snapchat] http://uod.ac.uk/sig-sc We're Scottish University of the Year again!http://uod.ac.uk/sig-strapline The Times / Sunday Times Good University Guide 2016 and 2017


From: ValueRaider @.> Sent: April 15, 2024 7:42 AM To: ranaroussi/yfinance @.> Cc: JennyCon @.>; Mention @.> Subject: Re: [ranaroussi/yfinance] how to download CVOL-USD data (Issue #1902)

CAUTION: This email originated from outside the University of Dundee. Do not click links or open attachments unless you recognise the sender's email address and know the content is safe.

@JennyConhttps://github.com/JennyCon You should remove or mask the API key when you post that.

I've removed it.

— Reply to this email directly, view it on GitHubhttps://github.com/ranaroussi/yfinance/issues/1902#issuecomment-2056891561, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A5OKTM5IO5D73OTZCFIDESDY5PKL5AVCNFSM6AAAAABF7T3DFKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANJWHA4TCNJWGE. You are receiving this because you were mentioned.Message ID: @.***>

The University of Dundee is a registered Scottish Charity, No: SC015096