alpha_vantage | A python wrapper for Alpha Vantage API for financial data | REST library
kandi X-RAY | alpha_vantage Summary
kandi X-RAY | alpha_vantage Summary
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
Top functions reviewed by kandi - BETA
- Decorator to call API on a function
- Handle the API call
- Convert to integer
alpha_vantage Key Features
alpha_vantage Examples and Code Snippets
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
ticker = 'IBM'
periods=['year1month1','year1month2','year1month3','year1month4','year1month5','year1month6','year1month7','year1month8',
'year1month9','year1month10','year1month11','year1month12','year2month1','year2month2','year2m
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
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)
data_dict = json.loads(data_str)
df = pd.DataFrame(data_dict["Time Series (Daily)"])
df = df.T # Transpose Dataframe for desired results
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"
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
data, meta_data = ts.get_daily(symbol='DGE.LON', outputsize='compact')
> 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.
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
Trending Discussions on alpha_vantage
QUESTION
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:37if 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:
QUESTION
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:16Without changing your function get_ts
, it might look like this:
QUESTION
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:53I 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.
QUESTION
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:07I don't believe Alpha Vantage has intraday data for all foreign stocks. They have daily for some though, the following call worked for me:
QUESTION
This is my code to get 2 years intraday data from Alpha Vantage API.
...ANSWER
Answered 2021-Mar-28 at 16:03This 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:
QUESTION
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:53Seems 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:
QUESTION
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:49You could use the globals variable to create different variables:
QUESTION
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:
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:50This 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:
QUESTION
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:18I 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.
QUESTION
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:47from 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')
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install alpha_vantage
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page