fundamentals stock screening using a formula

Dear all,

I am new to Quantopian and I am trying to create a screening to pick up the 50 stocks from the Q500US with the most negative factor: "Cash flow from financing / Market Cap".

Up until now, I managed to draft the following code:

fundamental_df = get_fundamentals(
query(
fundamentals.cash_flow_statement.financing_cash_flow, fundamentals.valuation.market_cap
)
.filter([fundamentals.cash_flow_statement.financing_cash_flow / fundamentals.valuation.market_cap] < 0)
.order_by([fundamentals.cash_flow_statement.financing_cash_flow / fundamentals.valuation.market_cap].asc())
.limit(context.num_stocks)
)


where: num_stocks = 50.

When I run I get an error:
"AttributeError: 'list' object has no attribute 'asc' .order_by([fundamentals.cash_flow_statement.financing_cash_flow / fundamentals.valuation.market_cap].asc())"

I also need to filter only from Q500US universe but I don't know how to code this part yet.

Can anybody assist in this.

1 response

I have managed to solve this! Below is the corrected code:

fundamental_df = get_fundamentals(
query(
fundamentals.cash_flow_statement.financing_cash_flow, fundamentals.valuation.market_cap
)
.filter((fundamentals.cash_flow_statement.financing_cash_flow / fundamentals.valuation.market_cap) < 0)
.filter(fundamentals.valuation.market_cap > 2000000000)
.order_by((fundamentals.cash_flow_statement.financing_cash_flow / fundamentals.valuation.market_cap).asc())
.limit(context.num_stocks)
)


Now I need to filter only from the Q500US and I would prefer to use the 5-year average Cash Flow from Financing instead of just the last 12 months.

Any ideas how to code this?