You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
for i in range(len(targets)):
letter = get_column_letter(i * 3 + 1)
df = investpy.get_stock_historical_data(stock=targets[i], country="united states", from_date="01/01/2016", to_date=datetime.date.today().strftime('%d/%m/%Y'),order="desc",interval="Daily")
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there,
I keep getting the "Connection Error" message for some of my requests on investpy.
Could you tell me what I have done wrong?
=================================================================
targets = ["AAPL", "AXP", "BA", "CAT", "CSCO", "CVX", "DIS", "DOW",
"GS", "HD", "IBM", "INTC", "JNJ", "JPM", "KO", "MCD",
"MMM", "MRK", "MSFT", "NKE", "PFE", "PG", "TRV", "UNH",
"V", "VZ", "WBA", "WMT", "XOM", "TSLA", "MU", "AMZN",
"NFLX","GOOGL", "FB",
"ABBV", "ABT", "ACN", "ADBE", "AMD", "AMGN", "AMT", "APD","AVGO", "AXP", "BABA", "BAC", "BAM", "BIIB",
"BKNG", "BLK", "BRKa","BYND", "C", "CAT", "CMCSA", "CME", "COP", "COST", "CRM", "CSCO", "CSX", "DAL",
"DG", "DHI", "DIS", "DUK", "ECL", "EL", "EQIX", "EXR", "FCX", "FDS", "FDX", "GE", "GILD", "GM", "GOLD",
"GT", "HCA", "HON", "HUM", "IBM", "IR", "ISRG", "KHC", "LEN", "LIN", "LLY", "LULU", "LYB", "MA", "MDLZ",
"MO", "MPC", "MRO", "MS", "NEE", "NVDA", "NXPI", "OLED", "PEP", "PLD", "PM", "PNC", "QCOM",
"SAN", "SBUX", "SCHW", "SRE", "STZ", "T", "TGT", "TMUS", "TXN", "UNP", "USB", "VLO", "WELL",
"WFC", "WLK", "WM", "X", "XLNX", ]
writer = pd.ExcelWriter("stock_data.xlsx", engine="openpyxl")
for i in range(len(targets)):
letter = get_column_letter(i * 3 + 1)
df = investpy.get_stock_historical_data(stock=targets[i], country="united states", from_date="01/01/2016", to_date=datetime.date.today().strftime('%d/%m/%Y'),order="desc",interval="Daily")
writer.save()
=======================================
ConnectionError Traceback (most recent call last)
in
27 for i in range(len(targets)):
28 letter = get_column_letter(i * 3 + 1)
---> 29 df = investpy.get_stock_historical_data(stock=targets[i], country="united states", from_date="01/01/2016", to_date=datetime.date.today().strftime('%d/%m/%Y'),order="desc",interval="Daily")
30
31 df["Close"].to_excel(writer, sheet_name="Sheet1", startrow=1, startcol=i * 3)
~\anaconda3\lib\site-packages\investpy\stocks.py in get_stock_historical_data(stock, country, from_date, to_date, as_json, order, interval)
662
663 if req.status_code != 200:
--> 664 raise ConnectionError(
665 "ERR#0015: error " + str(req.status_code) + ", try again later."
666 )
ConnectionError: ERR#0015: error 429, try again later.
Beta Was this translation helpful? Give feedback.
All reactions