Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Need Help - Syntax Error

Hello All,

I'm new to python and algo strategies. I tried cloning someone else's source code as a start to see if a backtest would just work when I put it into my own. I get a syntax error at this area in the code. Does anyone have any idea what's going on? Any help would be much appreciated!

The error in the debugger states: "SyntaxError: invalid syntax (, line2)

#: Query for the data that we need from fundamentals  
fundamental_df = get_fundamentals(query(  
                                f.valuation.market_cap,f.operation_ratios.roa,  
                                f.cash_flow_statement.operating_cash_flow,  

f.cash_flow_statement.cash_flow_from_continuing_operating_activities,
f.operation_ratios.long_term_debt_equity_ratio,
f.operation_ratios.current_ratio,
f.valuation.shares_outstanding,
f.operation_ratios.gross_margin,
f.operation_ratios.assets_turnover,
f.valuation_ratios.ev_to_ebitda,
)

11 responses

missing a ")" at the end?

Well here is the rest of it - sorry. Can't you tell I'm a noob?

fundamental_df = get_fundamentals(query(f.valuation.market_cap,f.operation_ratios.roa,
f.cash_flow_statement.operating_cash_flow, f.cash_flow_statement.cash_flow_from_continuing_operating_activities,
f.operation_ratios.long_term_debt_equity_ratio,
f.operation_ratios.current_ratio,
f.valuation.shares_outstanding,
f.operation_ratios.gross_margin,
f.operation_ratios.assets_turnover,
f.valuation_ratios.ev_to_ebitda,
)

.filter(fundamentals.valuation.market_cap > 1.5e9) .filter(fundamentals.income_statement.ebit > 0) .filter(fundamentals.valuation_ratios.ev_to_ebitda > 0) .filter(fundamentals.valuation.enterprise_value > 0)
.order_by(fundamentals.valuation_ratios.ev_to_ebitda.asc()) .limit(100)
)

I think get_fundamentals has been deprecated.

I figured - due to the code being from 2015. Do you have any idea what I could use instead? Will the rest of that code work, if I were to just change that? Or would the entire syntax change for each ratio?

I am afraid so imho. Currently pipeline is being used to get the data you want. I would check some recent algos posted in the forum or go through the tutorial quantopian provides.

Thanks for your assistance. would it help if I link to the full source code? https://www.quantopian.com/posts/piotroskis-f-score-algorithm

Sorry - I linked you to a newer source code that I could adapt with what I want going forward. Could you help me get that running? This time it's an error with the update_unvierse global name, which I believe was changed to this:

context.assets = [sid(24), sid(8554), sid(5061)]
data.history(context.assets, 'low', 5, '1d')

But in this case, I want all tradeable stocks, not just a few securities.

from quantopian.pipeline.filters import QTradableStocksUS  

then
context.assets = QTradableStocksUS()

I get an error after adding these in to the code. I added in the From/import at the beginning, and the context.assets at row 159 instead of the update_universe. Do you have it working?

i am not sure... i would suggest post the entire codes for someone to see the whole picture...

I posted the link to the code above and made the 2 adjustments you suggested. here it is again: https://www.quantopian.com/posts/piotroskis-f-score-algorithm

Thanks again for your help. I'd love to know if you get that working.