Python alpha_vantage module not returning all quotes for 'get_batch_stock_quotes'
By Emma Payne •
When using alpha_vantage to pull batch stock quotes for some reason get_batch_stock_quotes does not return the quote for symbol "ARRS". However, if the function is called using only "ARRS" in the symbols list, the quote is returned. I don't want to make several individual calls if I can get all the quotes returned in one request.
Here's the test code:
import pandas as pd
from alpha_vantage.timeseries import TimeSeries
import time
api_key = '12BHXD9VVA9M1PUM'
ts = TimeSeries(key=api_key, output_format = 'pandas')
stocklist = ("ARRS","PCG","AAPL","ACB")
STOCK=""
PRICE=0
data, meta_data =ts.get_batch_stock_quotes(symbols=stocklist)
for label, row in data.iterrows(): STOCK=row[0] PRICE=p=round(float(row[1]),2) print (STOCK,PRICE)Results:
$ python3 test8.py
PCG 11.67
AAPL 212.3
ACB 5.79If I just use stocklist = ("ARRS")the result is:
$ python3 test8.py
ARRS 31.64Why does this happen? Thanks in advance.
1 Answer
Why does this happen?
Unfortunately, this seems to possibly be something specific to your environment. Copying and pasting your code on Windows 7 with Python 3.7.4 yielded all four symbols with prices, as expected:
ARRS 31.64
PCG 11.03
AAPL 202.79
ACB 5.64