alpha_vantage | A python wrapper for Alpha Vantage API for financial data | REST library

 by   RomelTorres Python Version: 2.3.1 License: MIT

kandi X-RAY | alpha_vantage Summary

kandi X-RAY | alpha_vantage Summary

alpha_vantage is a Python library typically used in Web Services, REST, Bitcoin applications. alpha_vantage has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has medium support. You can install using 'pip install alpha_vantage' or download it from GitHub, PyPI.

Alpha Vantage delivers a free API for real time financial data and most used finance indicators in a simple json or pandas format. This module implements a python interface to the free API provided by Alpha Vantage. It requires a free API key, that can be requested from You can have a look at all the API calls available in their API documentation. For code-less access to the APIs, you may also consider the official Google Sheet Add-on or the Microsoft Excel Add-on by Alpha Vantage. Check out this guide for some common tips on working with financial market data.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              alpha_vantage has a medium active ecosystem.
              It has 3939 star(s) with 690 fork(s). There are 176 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 5 open issues and 260 have been closed. On average issues are closed in 225 days. There are 5 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of alpha_vantage is 2.3.1

            kandi-Quality Quality

              alpha_vantage has 0 bugs and 0 code smells.

            kandi-Security Security

              alpha_vantage has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              alpha_vantage code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              alpha_vantage is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              alpha_vantage releases are available to install and integrate.
              Deployable package is available in PyPI.
              Build file is available. You can build the component from source.
              Installation instructions, examples and code snippets are available.
              alpha_vantage saves you 920 person hours of effort in developing the same functionality from scratch.
              It has 2099 lines of code, 252 functions and 25 files.
              It has high code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed alpha_vantage and discovered the below as its top functions. This is intended to give you an instant insight into alpha_vantage implemented functionality, and help decide if they suit your requirements.
            • Decorator to call API on a function
            • Handle the API call
            • Convert to integer
            Get all kandi verified functions for this library.

            alpha_vantage Key Features

            No Key Features are available at this moment for alpha_vantage.

            alpha_vantage Examples and Code Snippets

            How to insert the correct stock name into a list
            Pythondot img1Lines of Code : 19dot img1License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            def getIntraday():
                for ticker in tickers[2]:
                    print(ticker)
                    date = 'year1month1'
                    apiKey = '5MACTR59FOK093UR'
            
                    CSV_URL = f'https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY_EXTENDED&symbo
            Iterate in a link and save the data
            Pythondot img2Lines of Code : 23dot img2License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            ticker = 'IBM'
            periods=['year1month1','year1month2','year1month3','year1month4','year1month5','year1month6','year1month7','year1month8',
                    'year1month9','year1month10','year1month11','year1month12','year2month1','year2month2','year2m
            Getting a "KeyError" in my currency converter
            Pythondot img3Lines of Code : 6dot img3License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
                alpha_url = r"https://www.alphavantage.co/query?function=CURRENCY_EXCHANGE_RATE"
            
                final_url = alpha_url + "&from_currency=" + from_currency + "&to_currency=" + to_currency + "&apikey=" + api_key 
                req_ob = requests.g
            How to show time of data downloaded by mplfinance (index type datetime)
            Pythondot img4Lines of Code : 6dot img4License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import pandas_datareader as web
            import datetime as dt
            data = web.DataReader(...)
            download_time = dt.datetime.now().strftime("%D %H:%M:%S")
            print(download_time)
            
            Convert Alphavantage API Response to DataFrame
            Pythondot img5Lines of Code : 4dot img5License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            data_dict = json.loads(data_str)
            df = pd.DataFrame(data_dict["Time Series (Daily)"])
            df = df.T  # Transpose Dataframe for desired results
            
            Python: use asyncio to hit api and output .csv's
            Pythondot img6Lines of Code : 29dot img6License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import multiprocessing
            
            # PROCESSES = multiprocessing.cpu_count()
            PROCESSES = 4  # number of parallel process
            CHUNKS = 6  # one process handle n symbols
            
            # 7.5k symbols
            TICKERS = ["BCDA", "WBAI", "NM", "ZKIN", "TNXP", "FLY", "MYSZ", "GASX"
            Alpha Vantage Python API for Fundamentals
            Pythondot img7Lines of Code : 13dot img7License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            ts = TimeSeries(key=api_key, output_format='pandas') 
            FundamentalData.get_income_statement_annual(ts,symbol='IBM')
            
              fiscalDateEnding  ...    netIncome
             date                                            ...             
             1970-01-01 00:00:00
            Alpha Vantage API time series intraday for foreign stocks into a pandas df
            Pythondot img8Lines of Code : 2dot img8License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            data, meta_data = ts.get_daily(symbol='DGE.LON', outputsize='compact')
            
            Why Intraday data from Alpha Advantage start at 4:00 am and finish at 20:00 pm?
            Pythondot img9Lines of Code : 25dot img9License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            > aapl <- av_get("AAPL", av_fun="TIME_SERIES_INTRADAY", interval="30min")
            > head(aapl)
            # A tibble: 6 x 6
              timestamp                   open  high   low close volume
                                        
            1 2021-03-23 18:30:00.000000  123.  
            how do you set alpha vantage date as a column?
            Pythondot img10Lines of Code : 8dot img10License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            Index(['1. open', '2. high', '3. low', '4. close', '5.
                adjusted close', '6. volume', dtype='object')
            
            data = pd.read_excel(file)
            data = data[::-1]
            data.columns = ['open', 'high', 'low', 'close', 'adjusted close'

            Community Discussions

            QUESTION

            Because every version of alpha_vantage_package depends on http ^0.12.0+4 and front depends on http ^0.13.4, alpha_vantage_package is forbidden
            Asked 2022-Feb-21 at 05:40

            I tried to install alpha_vantage and got the following error:

            Because every version of alpha_vantage_package depends on http ^0.12.0+4 and front depends on http ^0.13.4, alpha_vantage_package is forbidden. So, because front depends on alpha_vantage_package ^1.0.0, version solving failed. pub get failed (1; So, because front depends on alpha_vantage_package ^1.0.0, version solving failed.) exit code 1

            This is my pubspec.yaml file:

            ...

            ANSWER

            Answered 2022-Feb-21 at 05:37

            if you get this error which is very common as the packages get updated frequently and not every version matches with other packages. It means alpha_vantage_package depends on a dependency with a version lower than you specified in another dependency.

            To solve this, open pubspec.yaml, and remove the version number of the problem dependency:

            Example:

            Change

            alpha_vantage_package : ^1.0.0 --> remove this number To:

            Source https://stackoverflow.com/questions/71201443

            QUESTION

            Python: use asyncio to hit api and output .csv's
            Asked 2021-Apr-17 at 03:16

            I'm trying to think of how to rewrite some code asynchroniously. I have to download ~7500 datasets from an api and write them to .csv's. Here is a reproducible example (assuming you have a free api key for alpha vantage):

            ...

            ANSWER

            Answered 2021-Apr-17 at 03:16

            Without changing your function get_ts, it might look like this:

            Source https://stackoverflow.com/questions/67132953

            QUESTION

            Alpha Vantage Python API for Fundamentals
            Asked 2021-Apr-11 at 04:30

            I'm trying to access fundamental data from Alpha Vantage's python API, but it's not working. My imports:

            ...

            ANSWER

            Answered 2021-Apr-09 at 08:53

            I checked the source of getting the annual income statement, and it requires specifying self, so in this case, I was able to get it correctly by giving the ts with the APIkey set.

            Source https://stackoverflow.com/questions/67015422

            QUESTION

            Alpha Vantage API time series intraday for foreign stocks into a pandas df
            Asked 2021-Apr-09 at 05:07

            I need to compile stock price data for ADR and ORD pairs (and the currency between them) into a Pandas dataframe. I just started using the Alpha Vantage API for this, which works great for getting the US-listed stock prices (at the minute timescale) and the currency rate, but I haven't figured out how to get the foreign-listed stock prices (ORDs). I was almost positive it would've simply been a ticker.exchange type input, but that hasn't seemed to work.

            The code below is what I've used in my Jupiter Notebook to get the ADR for Diageo Plc.

            ...

            ANSWER

            Answered 2021-Apr-09 at 05:07

            I don't believe Alpha Vantage has intraday data for all foreign stocks. They have daily for some though, the following call worked for me:

            Source https://stackoverflow.com/questions/66374095

            QUESTION

            Why Intraday data from Alpha Advantage start at 4:00 am and finish at 20:00 pm?
            Asked 2021-Mar-28 at 16:03

            This is my code to get 2 years intraday data from Alpha Vantage API.

            ...

            ANSWER

            Answered 2021-Mar-28 at 16:03

            This is documented at their site:

            This API returns intraday time series of the equity specified, covering extended trading hours where applicable (e.g., 4:00am to 8:00pm Eastern Time for the US market).

            I do not see a switch to limit to (core) market hours but you could subset to market hours yourself after the retrieval. I get the same from R (which I use more often) using one of the accessor packages:

            Source https://stackoverflow.com/questions/66843210

            QUESTION

            How do you use the python alpha_vantage API to return extended intraday data?
            Asked 2021-Mar-23 at 21:59

            I have been working with the alpha vantage python API for a while now, but I have only needed to pull daily and intraday timeseries data. I am trying to pull extended intraday data, but am not having any luck getting it to work. Trying to run the following code:

            ...

            ANSWER

            Answered 2021-Jan-10 at 16:53

            Seems like TIME_SERIES_INTRADAY_EXTENDED can return only CSV format, but the alpha_vantage wrapper applies JSON methods, which results in the error.

            My workaround:

            Source https://stackoverflow.com/questions/65622323

            QUESTION

            How do I apply my function which returns a pandas dataframe, to a range of inputs so it returns individual dataframes?
            Asked 2021-Feb-07 at 12:49

            I am using the alpha_vantage API in python which returns a Pandas dataframe table.

            I have written a function, below, which takes a stock name, resets the index of the dataframe and renames it. How do I apply this function to a few inputs so it brings back individual dataframes for them? At the moment, I have to do this manually and run the function individually for each input.

            Would it work if I create a pandas series with the list of stocks, and apply the function to the series?

            ...

            ANSWER

            Answered 2021-Feb-07 at 12:49

            You could use the globals variable to create different variables:

            Source https://stackoverflow.com/questions/66087983

            QUESTION

            Pandas moving average calculation missing dates?
            Asked 2021-Feb-04 at 14:57

            I am trying to make a simple moving average using the live forex data from Alpha Vantage (API key can be registered for free from Alpha Vantage). Everything seems to work fine except that the period for the SMA is not complete.

            For example, if I set data[:'2020-1-1'], it should return data from 1.1.2020 up to current date. However, what happens is that the the period from December 2020 to January 2021 is gone.

            I tried plotting the graph and realize that the larger my moving average period is, the more recent data are being removed. The plot on my graph is as follows:

            GBP USD

            Dataframe for beginning period 2020-1-1

            Dataframe period fixed but NAN values

            Below are my codes in 3 separate files:

            This is the execution.py file:

            ...

            ANSWER

            Answered 2021-Feb-02 at 12:50

            This isn't because of pandas or Python, rather, it's because of how the SMA is calculated. Unless you do the computation yourself just to see what's going on, it can be kind of tricky.

            The formula for the simple moving average is to take n amount of closing prices at n interval. And divide by n. Where P is the closing price and the number is an even interval in your n-day SMA, one period of a 5-day SMA would look something like this:

            Source https://stackoverflow.com/questions/66009577

            QUESTION

            Plot pandas-data from Alpha Vantage
            Asked 2021-Jan-05 at 13:18

            I just installed the alpha_vantage module in addition to pandas, and have gotten the api-key etc. I now want to plot som data regarding a stock. Written in the module readme (see here) this is how you do it:

            ...

            ANSWER

            Answered 2021-Jan-05 at 13:18

            I had an Alpah-Vantage APIKEY, so I used the following code to check. It didn't come back with an error as you asked. When I checked the output format, it was not the normal pandas format, but an extended format.

            Source https://stackoverflow.com/questions/65578997

            QUESTION

            alpha_vantage API (python) not giving adjusted data
            Asked 2020-Oct-23 at 21:47

            I`m trying to access the TSLA stock data but the data doesn't seem to have accounted for the split earlier this year. The Alpha_Vantage website claims that it will be set to adjust=true as default but this doesn't seem to be the case, I tried to specify adjust=true but this returned an unexpected keyword error.

            ...

            ANSWER

            Answered 2020-Oct-23 at 21:47
            from alpha_vantage.timeseries import TimeSeries
            import pandas as pd
            ts = TimeSeries(key= api_key, output_format='pandas')
            data, meta_data = ts.get_daily_adjusted(self.symbol, outputsize='full')

            Source https://stackoverflow.com/questions/64505334

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install alpha_vantage

            To install the package use:.

            Support

            From version 2.2.0 on, asyncio support will now be available. This is only for python versions 3.5+. If you do not have 3.5+, the code will break. The syntax is simple, just mark your methods with the async keyword, and use the await keyword. Here is an example of a for loop for getting multiple symbols asyncronously. This greatly improving the performance of a program with multiple API calls. We have written a much more in depth article to explain asyncio for those who have never used it but want to learn about asyncio, concurrency, and multi-threading. Check it out here: Which Should You Use: Asynchronous Programming or Multi-Threading?.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/RomelTorres/alpha_vantage.git

          • CLI

            gh repo clone RomelTorres/alpha_vantage

          • sshUrl

            git@github.com:RomelTorres/alpha_vantage.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link