-
-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve ticker handling for multiple tickers #507
Labels
Difficulty: Medium 😐
This issue can be solved, but a decent amount of lines need to be changed
Improvement 📈
Improvement
Priority: Low 🥉
Assign this label if this issue is used once every few days
Comments
StephanAkkerman
added
Improvement 📈
Improvement
Priority: Low 🥉
Assign this label if this issue is used once every few days
Difficulty: Medium 😐
This issue can be solved, but a decent amount of lines need to be changed
labels
Feb 21, 2024
Yahoo: (from https://stackoverflow.com/questions/76065035/yahoo-finance-v7-api-now-requiring-cookies-python) import requests
apiBase = "https://query2.finance.yahoo.com"
headers = {"User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64)"}
def getCredentials(
cookieUrl="https://fc.yahoo.com", crumbUrl=apiBase + "/v1/test/getcrumb"
):
cookie = requests.get(cookieUrl).cookies
crumb = requests.get(url=crumbUrl, cookies=cookie, headers=headers).text
return {"cookie": cookie, "crumb": crumb}
def quote(symbols, credentials):
url = apiBase + "/v7/finance/quote"
params = {"symbols": ",".join(symbols), "crumb": credentials["crumb"]}
response = requests.get(
url, params=params, cookies=credentials["cookie"], headers=headers
)
quotes = response.json()["quoteResponse"]["result"]
return quotes
credentials = getCredentials()
quotes = quote(["GOOG", "TSLA"], credentials)
print(quotes) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Difficulty: Medium 😐
This issue can be solved, but a decent amount of lines need to be changed
Improvement 📈
Improvement
Priority: Low 🥉
Assign this label if this issue is used once every few days
We could make it quicker because many libraries support querying multiple tickers at the same time:
yahooquery:
tradingview_ta also supports it, ccxt might, coingecko?
The text was updated successfully, but these errors were encountered: