Search code examples
pythonpandasfinance

Fighting with APIs in Python


I am trying to learn how to use APIs for financial analysis.

I have the following simple code:

import numpy as np
import pandas as pd 
from pandas_datareader import data as wb

PG = wb.DataReader('PG', data_source = 'morningstar', start = '1995-01-01')

So, I am trying to extract PandG data from morningstar. The problem is that I get back the following message:

    ImmediateDeprecationError: 
Morningstar has been immediately deprecated due to large breaks in the API without the
introduction of a stable replacement. Pull Requests to re-enable these data
connectors are welcome.

I tried the same with Google but I failed. Is there something wrong in my code or is it something else?

I do have some csv files, how can I use them as source in the code above?

Below you can see what my codes gives back: enter image description here


Solution

  • For now, I would recommend using other sources such as AlphaVantage, Quandl, or IEX. The simplest is IEX, which does not require an API key. The reason for that is because maybe MorningStar has discontinued their API services. MorningStar is a less-known API. Or Python won't run it because it is not stable enough. Google has also disabled their API services.