Search code examples
pythonalpha-vantage

Alpha Vantage pulling data from income statement library using python


apologies for noobie question but I am completely lost on how to get any data from the Fundamental Data library in Alpha Vantage. I just started learning to code this month >.<

For example, if I wanted to get 'totalRevenue' from the most recent quarterly report. https://www.alphavantage.co/query?function=INCOME_STATEMENT&symbol=IBM&apikey=demo

I was able to find an answer online on how to get requests from the Time series. I did the following

import pandas as pd
from alpha_vantage.timeseries import TimeSeries
import time
import random
import math
import datetime as dt

ts = TimeSeries (key='apikey', output_format = "pandas")

stock_ticker = "MSFT"

data_daily, meta_data = ts.get_daily_adjusted(symbol=stock_ticker, outputsize ='compact')

last_adjusted_price = data_daily['5. adjusted close'][0]

print(last_adjusted_price)

Does anyone know what the library would be called for this? And if someone could provide an example of how to get the 'totalRevenue' from the last quarterly entree, that would be a lifesaver. This is day 3 of trying to figure out how to get this lol I can't seem to find the documentation anywhere and I don't understand what it says on here www.alphavantage.co/documentation/


Solution

  • Ok just as soon as I posted that question, I found the answer through brute force trying combinations haha

    base_url = 'https://www.alphavantage.co/query?'
    params = {'function': 'OVERVIEW',
             'symbol': 'IBM',
             'apikey': keys}
    
    response = requests.get(base_url, params=params)
    
    print(response.json())
    test = response.json()['Name']
    print(test)

    Hopefully this helps someone else in the future if they are a newbie like me haha