Polygon API: Stock Financials

In [1]:
import requests
import json
import pandas as pd

# retrieve alpaca keys
%run alpaca_keys.py
In [2]:
ticker = 'MSFT'

request_string = (
    f'https://api.polygon.io/v2/reference/'
    f'financials/{ticker}?apiKey={KEY_ID}'
)

msft_financials_df = pd.DataFrame(
    requests.get(request_string).json()['results']
)

columns = ['ticker', 'calendarDate', 'freeCashFlow', 'enterpriseValue', 'grossProfit']
msft_financials_df[columns].head()
Out[2]:
ticker calendarDate freeCashFlow enterpriseValue grossProfit
0 MSFT 2020-03-31 1.373700e+10 1.281762e+12 2.404600e+10
1 MSFT 2020-03-31 4.336200e+10 1.281762e+12 9.454800e+10
2 MSFT 2020-03-31 1.373700e+10 1.142077e+12 2.404600e+10
3 MSFT 2020-03-31 4.336200e+10 1.142077e+12 9.454800e+10
4 MSFT 2019-12-31 3.826000e+10 9.739651e+11 8.293300e+10