I am trying to trade based on valuation ratios using the following code cloned from one of the 7 best 2015 strategy competition (GrahamFundmantals algo). However, errors popped up saying " The get_fundamentals method has been removed. To use fundamental data in your notebooks and algorithms, use Pipeline". So the problem is in the below lines. But I don't really know how to modify it to make it work. Could someone help?
def before_trading_start(context):
"""
Called before the start of each trading day.
It updates our universe with the
securities and values found from fetch_fundamentals.
"""
num_stocks = 50
# Setup SQLAlchemy query to screen stocks based on PE ration
# and industry sector. Then filter results based on
# market cap and shares outstanding.
# We limit the number of results to num_stocks and return the data
# in descending order.
fundamental_df = get_fundamentals(
query(
# put your query in here by typing "fundamentals."
fundamentals.valuation_ratios.pe_ratio,
fundamentals.valuation_ratios.peg_ratio,
fundamentals.valuation_ratios.pb_ratio,
fundamentals.earnings_report.diluted_eps,
fundamentals.valuation_ratios.book_value_per_share,
fundamentals.asset_classification.morningstar_sector_code
)
.filter(fundamentals.valuation.market_cap != None)
.filter(fundamentals.valuation.shares_outstanding != None)
.filter(fundamentals.operation_ratios.quick_ratio >= 1.0)
.filter(fundamentals.valuation_ratios.pe_ratio < 15.0)
.filter(fundamentals.valuation_ratios.pb_ratio < 1.5)
# .filter(fundamentals.valuation_ratios.peg_ratio < 1.5)
.order_by(fundamentals.valuation.market_cap.desc())
.limit(num_stocks)
)