# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     name: python3
# ---

# + [markdown] id="view-in-github" colab_type="text"
# <a href="https://colab.research.google.com/github/ricospeloacaso/python_para_investimentos/blob/master/09_Alpha_Vantage_Python_para_Investimentos.ipynb" target="_parent"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>

# + [markdown] id="Vjr4Ro8xQll7" colab_type="text"
# # Ricos pelo Acaso
#
# *Link* para o vídeo: https://youtu.be/kB4jCoVyLRI

# + [markdown] id="XXN3-mNhxNOP" colab_type="text"
# # Bibliotecas

# + id="OHHEzZzwRRhx" colab_type="code" colab={}
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns; sns.set()

import matplotlib
matplotlib.rcParams['figure.figsize'] = (16, 8)

# + id="F336SM7MPniI" colab_type="code" colab={}
# !pip install alpha_vantage

# + id="B4w76OYeQLCP" colab_type="code" colab={}
from alpha_vantage.timeseries import TimeSeries

# + [markdown] id="uTu7q3p8QOrH" colab_type="text"
# # Chave de Acesso a API da Alpha Vantage

# + id="CidOSQf2QQ7_" colab_type="code" colab={}
ALPHAVANTAGE_API_KEY ='cole aqui sua chave obtida no site alphavantage.co'

# + [markdown] id="jauhh7l1QwMx" colab_type="text"
# # Acessando a API

# + id="aG8KOldPT7Jc" colab_type="code" colab={}
ts = TimeSeries(key=ALPHAVANTAGE_API_KEY, output_format='pandas')

# + id="jdtBezS8JzT6" colab_type="code" outputId="e3b796f7-29ad-4cb5-ca6f-720dd6705f10" colab={"base_uri": "https://localhost:8080/", "height": 260}
ts.get_symbol_search('itau')

# + id="m7CVaoEXJ4_k" colab_type="code" colab={}
dados, meta_dados = ts.get_daily(symbol='^BVSP', outputsize='full')

# + id="NJcSIuWoKHXj" colab_type="code" outputId="07e6a1f7-14ce-431d-ff43-f98c19263ed1" colab={"base_uri": "https://localhost:8080/", "height": 446}
dados

# + id="KDagA-X9KIyk" colab_type="code" outputId="d4d2a232-cfb2-4c56-c045-e7bfadf23dac" colab={"base_uri": "https://localhost:8080/", "height": 104}
meta_dados

# + id="0nBX9-U1KMr8" colab_type="code" outputId="b2b3af36-7f9c-4db9-f73f-1379f349dce4" colab={"base_uri": "https://localhost:8080/", "height": 489}
dados['4. close'].plot()

# + id="7GZlX0SoKR4e" colab_type="code" colab={}


StarcoderdataJupyterScriptsDedupFiltered