pythonstatsmodelsyahoo-financeyahoo-apipyalgotrade

Downloading fundamental data from Yahoo Finance


I'm trying to download fundamental data from Yahoo Finance like PE ratios, PB ratios, EV/EBITDA, etc. This is what I've done so far:

#import required libraries
import pandas as pd
import numpy as np
import requests
import xlsxwriter
from scipy import stats
import math
import secrets
import yfinance as yf
import matplotlib.pyplot as plt
import datetime as dt
import statsmodels.api as sm

pip install requests_html
stocks = pd.read_csv('constituents.csv')
from yahoo_fin.stock_info import get_data
sm.get_stats_valuation("aapl")

I get this error:

AttributeError                            Traceback (most recent call last)
<ipython-input-17-7a641ee9069d> in <module>
----> 1 sm.get_stats_valuation("aapl")

AttributeError: module 'statsmodels.api' has no attribute 'get_stats_valuation'

What do I do?


Solution

  • I checked the website you specified in comment. I think you can get stats valuation from stock_info module itself of the yahoo_fin package. Please check:

    import yahoo_fin.stock_info as si
    si.get_stats_valuation("aapl")