stockdaq.data.alpha_vantage_downloader.AlphaVantageDownloader¶
-
class
stockdaq.data.alpha_vantage_downloader.AlphaVantageDownloader(apikey, output_format='pandas')¶ Bases:
stockdaq.data.downloader.DownloaderDownloader using Alpha Vantage API
- Parameters
apikey (str) – The API key for Alpha Vantage.
output_format (str, optional) – The output_format of the getters. Only “pandas” avilable now.
-
apikey¶ The API key for Alpha Vantage.
- Type
str
-
output_format¶ The output_format of the getters. Only “pandas” avilable now.
- Type
str, optional
-
ts¶ The Alpha Vantage timeseries instance for getting data.
- Type
alpha_vantage.timeseries.TimeSeries
-
dataframe¶ The obtained data. Update using getters.
- Type
pandas.core.frame.DataFrame
-
__init__(apikey, output_format='pandas')¶ Constructor
- Parameters
apikey (str) – The API key for Alpha Vantage.
output_format (str, optional) – The output_format of the getters. Only “pandas” avilable now.
Methods
__init__(apikey[, output_format])Constructor
download(symbol[, frequency])Get data from API
export([criterion, prefix, suffix, …])Export self.dataframe to hdf5 files, names derive from criterion.
formatter(datadump)Convert Alpha Vantage dataframe to standard stockdaq format
get_daily(symbol[, outputsize])Get daily data, set self.dataframe
get_intraday(symbol[, interval, outputsize])Get intraday data, set self.dataframe
get_monthly(symbol)Get weekly data, set self.dataframe
get_weekly(symbol)Get weekly data, set self.dataframe
-
download(symbol, frequency='intraday', **kwargs)¶ Get data from API
- Parameters
symbol (str) – Stock symbol
frequency (str, optional) – “intraday”, “daily”, “weekly”, “monthly”.
**kwargs – Keyword arguments passed to the getter methods.
-
export(criterion='date', prefix='', suffix='', extension='.h5', conflict='merge', mergehow='keep old')¶ Export self.dataframe to hdf5 files, names derive from criterion.
- Parameters
criterion (str, optional) – Data in same file has same “date” or “year”. Defaults to date.
prefix (str, optional) – Prefix to the filename.
suffix (str, optional) – suffix to the filename, before the extension.
extension (str, optional) – Extension of the files. Defaults to “.h5”.
conflict (str, optional) – How to resolve conflicts. options are [“merge”, “overwrite”, “ignore”]. “merge”: append non-duplicating data to the existing datafile. “overwrite”: replace the existing file. “ignore”: don’t do anything.
mergehow (str, optional) – Only effective when conflict == “merge”. “keep old”: If there are duplicated indexes, keep old data. “update”: If there are duplicated indexes, keep new data.
-
formatter(datadump)¶ Convert Alpha Vantage dataframe to standard stockdaq format
- Parameters
datadump (pandas.core.frame.DataFrame) – Dataframe from Alpha Vantage.
- Returns
dataframe – Formated dataframe.
- Return type
pandas.core.frame.DataFrame
-
get_daily(symbol, outputsize='full')¶ Get daily data, set self.dataframe
- Parameters
symbol (str) – Stock symbol
outputsize (str, optional.) – Defaults to “full”. Options are [“compact”, “full”]. “compact” only returns last 100 data points. “full” returns full-length intraday times.
- Returns
The daily data.
- Return type
pandas.core.frame.DataFrame
-
get_intraday(symbol, interval='1min', outputsize='full')¶ Get intraday data, set self.dataframe
- Parameters
symbol (str) – Stock symbol
interval (str, optional.) – Interval between data. Defaults to “1min”. Options are [“1min”, “5min”, “15min”, “30min”, “60min”].
outputsize (str, optional.) – Defaults to “full”. Options are [“compact”, “full”]. “compact” only returns last 100 data points. “full” returns full-length intraday times.
- Returns
The intraday data.
- Return type
pandas.core.frame.DataFrame
-
get_monthly(symbol)¶ Get weekly data, set self.dataframe
- Parameters
symbol (str) – Stock symbol
- Returns
The weekly data.
- Return type
pandas.core.frame.DataFrame
-
get_weekly(symbol)¶ Get weekly data, set self.dataframe
- Parameters
symbol (str) – Stock symbol
- Returns
The weekly data.
- Return type
pandas.core.frame.DataFrame