RomelTorres / alpha_vantage

A python wrapper for Alpha Vantage API for financial data.
MIT License
4.2k stars 731 forks source link

Alpha Vantage API Review #13

Closed wickenden-g closed 4 years ago

wickenden-g commented 6 years ago

Alpha Vantage API Review from a Python Developer

@RomelTorres congratulations on your wonderful python library for Alpha Vantage!

I am a full-stack python developer who uses the Alpha Vantage API to develop trading strategies for stocks, ETFs, and OTCs. I am wondering whether you are affiliated with Alpha Vantage, and whether this is a good place for me to leave a 360° review on their API service for future reference by the developer community.

So technically this is not a bug report or feature request - hope it's OK with you :)

The Experience

I was one of the "yahoo refugees" who stumbled upon Alpha Vantage via Google search. My first interactions with their website could be summarized by the good-old term WYSIWYG (what-you-see-is-what-you-get). Their documentation promised three things: (1) time series data with various resolutions, (2) over 50 technical signals, (3) sector data, and they kept their promise by providing demo URLs for all the said API functions.

image

They promised free API keys, and they also delivered. They promised "no promotional materials to your inbox," and indeed the only email I got from them so far was the announcement email for their new CSV feature.

This being said, there are a couple areas they could optimize upon.

The Data

Of the thousands of US-based equities I have analyzed so far, their historical data and technical indicators seem to match other reputable data sources. Their intraday data is realtime up to the current minute, which is fine for my research purposes but may not satisfy users who want to beat the market with millisecond precision. Perhaps a premium feature for this down the road?

Their JSON output is easily readable and python-parsable. For the daily time series, however, I understand that their most recent data point is the cumulative information of the current trading day (updated realtime), but why is the first timestamp in YYYY-MM-DD HH:MM:SS format while all the others are in the normal YYYY-MM-DD format typical of the EOD data?

"Meta Data": { "1. Information": "Daily Prices (open, high, low, close) and Volumes", "2. Symbol": "MSFT", "3. Last Refreshed": "2017-08-18 16:00:00", "4. Output Size": "Compact", "5. Time Zone": "US/Eastern" }, "Time Series (Daily)": { "2017-08-18 16:00:00": { "1. open": "72.2700", "2. high": "72.8400", "3. low": "71.9300", "4. close": "72.4900", "5. volume": "18215276" }, "2017-08-17": { "1. open": "73.5800", "2. high": "73.8700", "3. low": "72.4000", "4. close": "72.4000", "5. volume": "21834250" },

I would love to see a consistent YYYY-MM-DD format across all the timestamps. The "last refreshed" timestamp can be specified in Meta Data instead:

"Meta Data": { "1. Information": "Daily Prices (open, high, low, close) and Volumes", "2. Symbol": "MSFT", "3. Last Refreshed": "2017-08-18 16:00:00", "4. Output Size": "Compact", "5. Time Zone": "US/Eastern" }, "Time Series (Daily)": { "2017-08-18": { "1. open": "72.2700", "2. high": "72.8400", "3. low": "71.9300", "4. close": "72.4900", "5. volume": "18215276" }, "2017-08-17": { "1. open": "73.5800", "2. high": "73.8700", "3. low": "72.4000", "4. close": "72.4000", "5. volume": "21834250" },

In addition to the data presentation aspects, below are couple other data-related proposals:

In Summary

It is always a pleasure to have an API service that is well documented, platform/language-agnostic, and easily integratable. The fact that we have several third-party libraries built on top of Alpha Vantage on GitHub is in a sense testament to its developer-friendly nature. While there is still room for them to become a better version of themselves, I hope they thrive and stay true to the description on their home page - "driven by rigorous research, cutting edge technology, and a disciplined focus on democratizing access to data."

RomelTorres commented 6 years ago

@wickenden-g Thank you very much for your incredible review.

Sadly I am not related to Alpha Vantage. One day I also discovered their API while googling and decided to write the python wrapper for it as my first step in playing around with financial algorithms. I am very happy and grateful for the acceptance it has had in the community since this is my first open source project.

I would contact them directly on their website. They actually write back quickly and are always open to suggestions. Yours seem pretty reasonable. I was thinking on suggesting them on having some sort of company account in Github.

Thanks again for the Romel

frederic-adda commented 6 years ago

Is it only US-stocks?

coryleuck commented 6 years ago

@frederic-adda According to my experience with Alpha Vantage, it covers US-based stocks, ETFs, and mutual funds AND stocks traded on major global stock exchanges. Perhaps @RomelTorres could shed some light on this?

thecodeflash commented 6 years ago

@frederic-adda @RomelTorres @coryleuck If you want to get data of Stocks from other exchanges other then US-Stock exchanges then you need to do something like this, If I wanted to get the stock value for TITAN from Indian Exchange NSE, then I need to use this in symbol NSE:TITAN .

Ex:

ts = TimeSeries(key='API_KEY', output_format='pandas')
data, meta_data = ts.get_daily_adjusted(symbol='NSE:TITAN', outputsize='full')
data['close'].plot()
plt.title('Daily Adjusted for the TITAN stock ')
plt.show()
frederic-adda commented 6 years ago

OK, good to know! Thanks for the info What I find disturbing is that the ticker symbol are standardized. For example, in the US, the symbol would be like « AAPL », and, for other markets than the US, like « AI.PA » (where .PA stands for Paris stock exchange). So AlphaVantage seems to do it differently than the standard way? Weird … Is there a list of their codes for the Stock exchanges around the world, so I could try to do the matching with the « standard » codes?

Thanks Fred

Le 16 nov. 2017 à 08:31, Vishwajeet Srivastava notifications@github.com a écrit :

@frederic-adda https://github.com/frederic-adda @RomelTorres https://github.com/romeltorres If you want to get data of Stocks from other exchanges from US-Stock exchanges then you need to do something like this, If I wanted to get the stock value for TITAN from Indian Exchange NSE, then I need to use this in symbol NSE:TITAN .

Ex: ts = TimeSeries(key='API_KEY', output_format='pandas') data, meta_data = ts.get_daily_adjusted(symbol='NSE:TITAN', outputsize='full') data['close'].plot() plt.title('Daily Adjusted for the TITAN stock ') plt.show()

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/RomelTorres/alpha_vantage/issues/13#issuecomment-344839209, or mute the thread https://github.com/notifications/unsubscribe-auth/AQxqPoBwzewFodfiIAtkn6iO1B_koVKIks5s2-TagaJpZM4O8Ovr.

thecodeflash commented 6 years ago

@frederic-adda I doubt that there is an API which will provide you the list of all Stock Exchanges around the world.

But still are here some links that might help you out, http://www.wikinvest.com/wiki/List_of_Stock_Exchanges http://www.eoddata.com/

frederic-adda commented 6 years ago

Yahoo Finance used to do it. I’m looking for a replacement for their API.

Le 16 nov. 2017 à 15:27, Vishwajeet Srivastava notifications@github.com a écrit :

@frederic-adda I doubt that there is an API which will provide you the list of all Stock Exchanges around the world.

But still are here some links that might help you out, http://www.wikinvest.com/wiki/List_of_Stock_Exchanges http://www.eoddata.com/

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

kevingebert commented 6 years ago

HI, great python framework. Thank you so much for putting it together. I would love to see the adjusted data as an option

RomelTorres commented 6 years ago

Hi @kevingebert; what do you mean by adjusted data? Any call from the API I am missing?

kevingebert commented 6 years ago

Maybe I am missing it. I'm talking about the split adjusted data.

samperd commented 6 years ago

@RomelTorres ,

Great work on the API wrapper. I use the yahoo python wrapper ystocks a number of years ago. now that I have returned to a financial project I learned about the changes at yahoo. And then i found Alpha Vantage and then your API.

I will poke through the basics and see what is there right now.

The first thing I have not been able to find is the dividend event data. See issue #27

Great work so far.

vignesh989 commented 6 years ago

Hi Guys, @RomelTorres,@wickenden-g This is a really amazing API, now that Google API is no longer supporting APIs. This seems to be the next best thing. I have two major concerns, I'm creating a Machine Learning algorithm to predict trends. So for this, I require Intraday data ( 5Mins ) for a stock for the past let's say 200 days, as a training set for my algorithm.

  1. Is there a way to specify past x days, or specify the date on which I want the intraday data for ?

  2. @VJ-Vicky What seems to be wrong with my query? https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol=NSE:TITAN&outputsize=compact&interval=5min&datatype=json&apikey=Key The Solution you suggested for the specifying the EXchange is not working it is returning me an error.

RomelTorres commented 6 years ago

Hi @vignesh989 if it is not specified in the API by alphavantage, it is not doable direct in the python wrapper, nevertheless once you have the data in a pandas data frame. It should be easy to slice it. I would say first do the intraday call with full size and then slice it from there.

vignesh989 commented 6 years ago

@RomelTorres Thank you, I get a max for past 3 days even if I get the full size, I guess I should try a different data source.

ellissitzky commented 6 years ago

Hi, I am currently developing a basic Java (Android) app for portfolios management. Alpha Vantage data are very good for my purpose. I am wondering if i can load this applet on GooglePlay (free with little advertising) each user should request his own ApiKey. Could it be compatible with the terms of usage?Thank you.

RomelTorres commented 6 years ago

Hi @ellissitzky. That I cannot answer you, since here in github I just habe the python wrapper. Please send an email to the people from alphavantage on their website.

Thanks,

Romel

ellissitzky commented 6 years ago

@RomelTorres, thank you for your answer, i first asked to this blog in order to know if this info were already clear.. I read everything on AlphaVantage site, but the only part that may be about the topic is : https://www.alphavantage.co/terms_of_service/ - Intellectual Property. It's no clearly expressed a prohibition of use in apps, etc, but not even an encouragement to it. So, I will ask them by email . Thanks, Giuseppe

team-alphavantage commented 6 years ago

@ellissitzky Thank you for developing the Java application on top of Alpha Vantage. We have addressed your request via support@alphavantage.co

ellissitzky commented 6 years ago

@team-alphavantage, I just read (and answered) it! Thanks, Great!

RobertFlatt commented 6 years ago

Wonderful piece of work, thank you.

One small issue using "get_digital_currency_daily()". The result is returned in two currencies, market and USD, OK. But if I set the market to USD I get duplicate Pandas labels.

So indexing a row ( row['. close (USD)'] ) results in a two element series for USD, and a scalar for other markets. I can special case USD, but it would be nice if you did as this might be a surprise for somebody.

RomelTorres commented 6 years ago

Hi @Ham-Merhead, I will have to check it out, I have been super busy lately and have not had a chance to sit down and solve some of the issues that have arisen in the past few weeks. Could you please post this in a separate issue with the piece of code and the resulting pandas data frame?

I am planning to do a rework of the unittests, since they are not working well anymore, although most of the calls are correct (because I was a noob and did not know better when I wrote that part of code)

I will try to get some free time and sit and do it properly.

Saludos Romel

RobertFlatt commented 6 years ago

Done. Thanks for the the response. I have a workaround for now. Interesting question as to if any change would happen here or by AV.......

igorcc commented 6 years ago

What's about Swiss Exchange (SIX) ? I tried to request SIX:NESN but with no success.. Is there a way to request data from SIX, LSE, Xetra? Thanks!

ChillarAnand commented 6 years ago

@vignesh989 Did you manage to get data from NSE? I am not able to pull the data. Here is the sample code.

import os

from alpha_vantage.timeseries import TimeSeries

key = os.environ.get('ALPHAVANTAGE_KEY')
print(key)
ts = TimeSeries(key=key)

data, meta_data = ts.get_intraday('NSE:TITAN')
# data, meta_data = ts.get_intraday('NSE:RELIANCE')
# data, meta_data = ts.get_intraday('GOOGL')
print(meta_data)
igorcc commented 6 years ago

I cannot retrieve data for NSE. Just TITAN works well. NSE:TITAN produces following error: "ValueError: Invalid API call. Please retry or visit the documentation (https://www.alphavantage.co/documentation/) for TIME_SERIES_INTRADAY."

RomelTorres commented 6 years ago

Hi people, you can try directly in a web browser and see if it works. If it does create a new issue and I will work on it. If not we can ask in the alphavantage forum.

igorcc commented 6 years ago

Browser produces the same error. I think the problem is in alphavantage data.

vignesh989 commented 6 years ago

@ChillarAnand @igorcc No Guys they do not support it as of now, So this is workaround. So you can determine if the data is coming from NYSE or NSE the following way. You can convert date column to your local time. DateTime estTime = Convert.ToDateTime(item.Key.ToString()); TimeZoneInfo estZone = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time"); TimeZoneInfo istZone = TimeZoneInfo.Local; DateTime yourLocalTime = TimeZoneInfo.ConvertTime(estTime, estZone, istZone);

If the market Start Time/End Time syncs with your market time it means its from your market, else its from NYSE.

image If you look at the image above you will see that the closing time for HDFC ( NSE ) and INFY ( NYSE ) is different. If you convert it to IST it translates to 3:30 PM ( NSE closing time )

So the best bet for people who are working with other markets is ignore stocks that have the same symbol as the stocks in NYSE.

image

@ChillarAnand this is still a very good set of stocks, in NIFTY50 only 3 gets eliminated this way, rest of the stock data works as expected.

@team-alphavantage It would be wonderful if you can add a parameter to your API to specify the market.

@RomelTorres I'm so sorry to hijack your thread like this.

dotnet22 commented 6 years ago

Does it provide futuers and options data? If yes, How do I get symbols for it?

me-shivaprasad commented 6 years ago

@vignesh989 @RomelTorres Is there is the way to extract the NIFTY and SENSEX data ex Index price

raghav1320 commented 6 years ago

Can we change the Time Zone in alphavantage ?

rollnlearn commented 6 years ago

How do we get stock and indices ticker symbol for Indian Stock Exchanges. Nothing is mentioned related to that in the documentation. What is the ticker symbol I need to to get data for infosys stock in National Stock Exchange (NSE) and Yes Bank stock in Bombay Stock Exchange (BSE).

vignesh989 commented 6 years ago

@rollnlearn I think there was a recent update, not 100% sure. But now I'm able to specify the market details: for example, if I need Infosys from (NSE) I symbol=INFY.NS. if I want from (BSE). symbol=INFY.BO.

But then again it does not work on all the stocks, I found it pulls an errors some stocks like L&T. Even if a market is specified. You can give it a try. Let us know if you are able to identify the issue.

@raghav1320 No, you will not be able to change the time zone. The data is always given in EST, you can convert it to your respective time zone via code.

@me-shivaprasad No, I'm not aware of any such option.

ghost commented 6 years ago

@rollnlearn You can find the ticker index for NSE here https://www.nseindia.com/corporates/corporateHome.html?id=equity

gautamlaungani commented 6 years ago

for NSE use the Yahoo Codes or for any ticker in the world, Yahoo codes work.

eg to download csv files

https://www.alphavantage.co/query?function=TIME_SERIES_DAILY_ADJUSTED&symbol=EICHERMOT.NS&apikey="Your_API_Key"&datatype=csv&outputsize=full

https://www.alphavantage.co/query?function=TIME_SERIES_DAILY_ADJUSTED&symbol=HEROMOTOCO.NS&apikey="Your_API_Key"&datatype=csv&outputsize=full https://www.alphavantage.co/query?function=TIME_SERIES_DAILY_ADJUSTED&symbol=M&M.NS&apikey="Your_API_Key"&datatype=csv&outputsize=full https://www.alphavantage.co/query?function=TIME_SERIES_DAILY_ADJUSTED&symbol=MARUTI.NS&apikey="Your_API_Key"&datatype=csv&outputsize=full https://www.alphavantage.co/query?function=TIME_SERIES_DAILY_ADJUSTED&symbol=TATAMOTORS.NS&apikey="Your_API_Key"&datatype=csv&outputsize=full

the adjustments can be done via the formula

Adj Open = Open / (Close/AdjustedClose) Adj High = High / (Close/AdjustedClose) Adj Low = Low / (Close/AdjustedClose)

Volume is adjusted for Splits

i have back tested the results with data from Exchange Data International (premium service) and post the adjustment, the data is almost 99% accurate for Open/High/Low.

if anyone cares for a VBA code which can be used to cure data for x number of csv files in a particular folder, hit me up.

Prchakr commented 6 years ago

I am not sure what is the issue with NSE market. As far i read i see issue with getting intraday quote for NSE market i am able to fetch it without any issue I am trying something like below & works fine for me https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol=SBIN&interval=1min&apikey=APIKey tried other symbold like GAIL, YESBANK etc., & it looks good.

tried all the combinations to fetch batch quote & none of it working, https://www.alphavantage.co/query?function=BATCH_STOCK_QUOTES&symbols=SBIN&apikey=APIKEY https://www.alphavantage.co/query?function=BATCH_STOCK_QUOTES&symbols=NSE:SBIN&apikey=APIKEY https://www.alphavantage.co/query?function=BATCH_STOCK_QUOTES&symbols=SBIN,GAIL&apikey=APIKEY

My Output for batch quote is as follows,

{ "Meta Data": { "1. Information": "Batch Stock Market Quotes", "2. Notes": "IEX Real-Time Price provided for free by IEX (https://iextrading.com/developer/).", "3. Time Zone": "US/Eastern" }, "Stock Quotes": [] }

And, this batchquote works well for USstocks, i tried with AAPL & output is as expected. I belive batch quote is not supported for all the markets. Anyway, if anyone got luck, please post it.

feresm commented 6 years ago

Is there any way I can get funds from their ISIN using alpha vantage?

HyperionSounds commented 5 years ago

Hi Romel,

This is just what I've been looking for. And as someone that's relatively new to python, the documentation is extremely appreciated.

My best regards.

anniew86 commented 5 years ago

@igorcc For Swiss stock use suffix VX, like NESN.VX

anniew86 commented 5 years ago

oops, there are huge data gaps with missing data, do you know any reason for it?

https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=NESN.VX&apikey=XXX

"Meta Data": {
        "1. Information": "Daily Prices (open, high, low, close) and Volumes",
        "2. Symbol": "NESN.VX",
        "3. Last Refreshed": "2018-08-08",
        "4. Output Size": "Compact",
        "5. Time Zone": "US/Eastern"
    },
    "Time Series (Daily)": {
        "2018-08-08": {
            "1. open": "81.8600",
            "2. high": "82.0600",
            "3. low": "81.7000",
            "4. close": "81.8600",
            "5. volume": "2758215"
        },
        "2018-06-12": {
            "1. open": "74.3600",
            "2. high": "74.8000",
            "3. low": "74.2800",
            "4. close": "74.5400",
            "5. volume": "6568048"
        },
        "2018-06-11": {
            "1. open": "73.7600",
            "2. high": "74.5000",
            "3. low": "73.7200",
            "4. close": "74.2000",
            "5. volume": "5416673"
        },
...
tarioch commented 5 years ago

You can also use .SW suffix which for Swiss stocks and from a quick search looks like SW is the better one: https://assets.bwbx.io/documents/users/iqjWHBFdfxIU/rH89yROZwbeA/v0

anniew86 commented 5 years ago

not for Alphavantage, NOVN.SW doesn't work: https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=NESN.SW&apikey=XXX

tarioch commented 5 years ago

Looks like for Stocks it's VX and for others such as ETFs it's SW, e.g. https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=CSBGC7.SW&apikey=XXX

dokmaister commented 5 years ago

@anniew86: .SW and .VX are for Swiss stocks whereas .VX is for blue chips like Roche, Nestlé etc and .SW is for mid- and small caps and ETFs. It's the same on yahoo (e.g. NOVN.VX vs. KARN.SW). VX stands for former VIRT-X I believe. So use VX for SMI Index companies and SW for the rest, think that should work.

Cloudmersive commented 5 years ago

What are the rate limits? And what are the license restrictions on the data? None of this is documented

davepaiva commented 5 years ago

Hey guys, if you'll are having trouble with localizing the timezone of the data, check out my code stock_data_alphavantage.py

https://github.com/davepaiva/StockAnalysis

sanjes1 commented 5 years ago

Hi, Just started to use alphavantage. Trying https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol=MSFT&interval=1min&outputsize=full&apikey="MyKey"

It only returns few days of data and not all. Is there a limit or am I missing something. Any help is appreciated. Thanks

pshirlyn commented 5 years ago

There is a soft limit on intraday calls to make the amount of data reasonably efficient, but you can always reach out to them on their website if you need more data! If you do not need 1-minute interval data points, you should use the daily time series (TIME_SERIES_DAILY) instead.

sanjes1 commented 5 years ago

Thanks for the response. I did tried sending an email to them, no response yet. I will need the 1 minute data. Not sure if i will get the data by subscribing to the premium key.

mark100net commented 5 years ago

@sanjes1 They have never responded to me. They don't believe in support apparently.