Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a good way to extract only today' stock market date data from the Alpha Vantage API?

I'm using the Alpha Vantage API to fetch stock market data. However, this API seems to be geared towards only providing series of data which is also implied in its aptly named functions like TimeSeries. That means that if I request a quote from the API I get a series of different dates, times and so forth.

What I'm after is to get only data from a specific date and nothing else. I could get todays date and then use the "is in" if loop to check for it, but that does not seem like a good solution and it would waste quite a bit of resources, so I'm looking to see if there is another better solution available. I have not seen any mention of getting a single entry from their API and tring to get a slice of the dict returned does not seem to work good as the dict is unsorted.

Does someone know about a good way of fetching only stock market data from a single date from the TimeSeries class ?

like image 266
exceed Avatar asked Nov 07 '22 17:11

exceed


1 Answers

I came across this problem and this question, and after looking into the documentation I saw this Quote Endpoint that returns just the latest info. Here is the description:

A lightweight alternative to the time series APIs, this service returns the latest price and volume information for a security of your choice.

Example from the documentation:

https://www.alphavantage.co/query?function=GLOBAL_QUOTE&symbol=MSFT&apikey=demo

If you need data from another day in the past you can download all historical data once and cache it.

like image 146
klaus Avatar answered Nov 15 '22 13:11

klaus