I am trying to buy stocks only when the PE is between 5-15 and the current ratio>1.75. How does this work? And what is going wrong with my code.
def intialize(context):
set_long_only()
context.security=sid(24)
def before_trading_start(context):
fundamental_df= get_fundamentals(
query(
fundamentals.valuation_ratios.pe_ratio,
fundamentals.operation_ratios.current_ratio,
)
.filter(fundamentals.valuation_ratios.pe_ratio > 5)
.filter(fundamentals.valuation_ratios.pe_ratio < 15)
.filter(fundamentals.operation_ratios.current_ratio > 1.75)
.order_by(fundamentals.valuation_ratios.pe_ratio.desc()).limit(20)
)
context.fundamental_df = fundamental_df
update_universe(context.fundamental_df.columns.values)
def handle_data(context,data):
for stock in context.fundamental_df:
if stock in data:
print(stock)