Skip to main content
alpha\_vantage
==============

*Python module to get stock data from the Alpha Vantage API*

Alpha Vantage delivers a free API for real time financial data and most
used finance indicators in a simple json format. This module implements
a python interface to the free API provided by Alpha Vantage
(http://www.alphavantage.co/). It requires a free API, that can be
requested on http://www.alphavantage.co/support/#api-key.

Install
-------

To install the package use:

.. code:: shell

pip install alpha_vantage

If you want to install from source, then use:

.. code:: shell

git clone https://github.com/RomelTorres/alpha_vantage.git
pip install -e alpha_vantage

Usage
-----

To get data in a python, simply import the library and call the object
with your api key and get ready for some awesome free realtime finance
data.

.. code:: python

from alpha_vantage.timeseries import TimesSeries
ts = TimesSeries(key='YOUR_API_KEY')
# Get json object with the intraday data and another with the call's metadata
data, meta_data = ts.get_intraday('GOOGL')

Internally there is a retries counter, that can be used to minimize
connection errors (in case that the api is not able to respond in time),
the default is set to 5 but can be increased or decreased whenever
needed.

.. code:: python

ts = TimesSeries(key='YOUR_API_KEY',retries='YOUR_RETRIES')

Finally the library supports giving its results as json dictionaries
(default) or as pandas dataframe, simply pass the parameter
output\_format='pandas' to change the format of the output for all the
api calls.

.. code:: python

ts = TimesSeries(key='YOUR_API_KEY',output_format='pandas')

Plotting
--------

Using pandas support we can plot the intra-minute value for 'MSFT' stock
quite easily:

.. code:: python

from alpha_vantage.timeseries import TimesSeries
import matplotlib.pyplot as plt

ts = TimesSeries(key='YOUR_API_KEY', output_format='pandas')
data, meta_data = ts.get_intraday(symbol='MSFT',interval='1min', outputsize='full')
data['close'].plot()
plt.title('Intraday Times Series for the MSFT stock (1 min)')
plt.show()

Giving us as output: |alt text|

The same way we can get pandas to plot technical indicators like
Bolliger Bands®

.. code:: python

from alpha_vantage.techindicators import TechIndicators
import matplotlib.pyplot as plt

ti = TechIndicators(key='YOUR_API_KEY', output_format='pandas')
data, meta_data = ti.get_bbands(symbol='MSFT', interval='60min', time_period=60)
data.plot()
plt.title('BBbands indicator for MSFT stock (60 min)')
plt.show()

Giving us as output: |alt text|

Finally we can also plot sector performance just as easy:

.. code:: python

from alpha_vantage.sectorperformance import SectorPerformances
import matplotlib.pyplot as plt

sp = SectorPerformances(key='YOUR_API_KEY', output_format='pandas')
data, meta_data = sp.get_sector()
data['Rank A: Real-Time Performance'].plot(kind='bar')
plt.title('Real Time Performance (%) per Sector')
plt.tight_layout()
plt.grid()
plt.show()

Giving us as output: |alt text|

Tests
-----

In order to run the tests you have to first export your API key so that
the test can use it to run.

.. code:: shell

export API_KEY=YOUR_API_KEY
cd alpha_vantage
nosetests

Documentation
-------------

To find out more about the available api calls, visit the alpha-vantage
documentation at http://www.alphavantage.co/documentation/


.. |alt text| image:: images/docs_ts_msft_example.png?raw=True
.. |alt text| image:: images/docs_ti_msft_example.png?raw=True
.. |alt text| image:: images/docs_sp_rt_example.png?raw=True

Release files for alpha-vantage 1.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for alpha-vantage 1.1.3
File Size Uploaded
alpha_vantage-1.1.3.tar.gz 12.7 kB Details

Release files / alpha_vantage-1.1.3.tar.gz

Download URL alpha_vantage-1.1.3.tar.gz
Size 12.7 kB
Tags Source
SHA-256 checksum
How to use checksums
26c967b30b1b785ccba2facbbd051d34e97ce2fd89f750504d1662cd3ee98f8c
BLAKE2b-256 checksum
How to use checksums
e504363477c6e97440565aa5acfb13fb703cdc1adc0a3f19f8aff479d624840e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

3.0.0

2 release files

2.3.1

2 release files

2.3.0

2 release files

2.2.0

1 release file

2.1.3

1 release file

2.1.2

1 release file

2.1.1

2 release files

2.1.0

3 release files

2.0.0

1 release file

1.9.0

1 release file

1.8.1

1 release file

1.8.0

1 release file

1.6.0

1 release file

1.3.6

1 release file

1.3.5

1 release file

1.3.3

1 release file

1.3.1

1 release file

1.3.0

1 release file

1.2.1

1 release file

1.2.0

1 release file

1.1.4

1 release file

This release

1.1.3 This release

1 release file

1.1.2

1 release file

1.1.0

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.9

1 release file

0.1.8

1 release file

0.1.6

1 release file

0.1.5

1 release file

0.1.3

1 release file

0.1.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page