Back to Community
first algo - screening for value and quality

I am trying to screen for value and quality. just barely started, trying to figure out how to rank a double sort on value and quality

Loading notebook preview...
Notebook previews are currently unavailable.
8 responses

How's this?

Loading notebook preview...
Notebook previews are currently unavailable.

Here's a back test

Clone Algorithm
28
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 57c206c8ab025b1009674082
There was a runtime error.

Sa Al, tried running this backtest and got a runtime error on line 89:

"TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''"

Python beginner here so maybe this is a relatively simple fix?

Hey Steve,

Could you tell me exactly at which point in time you are getting that error? I was able to run Sa's algorithm in the backtester with no issues.

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

Settings:
From 2010-01-01 to 2016-08-31 with $1,000,000 initial capital

Something went wrong. Sorry for the inconvenience. Try using the built-in debugger to analyze your code. If you would like help, send us an email.
TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
There was a runtime error on line 89.

Yes, it works in default dates but when I switch to 2010-01-01 to 2016-09-23, it throws the above error. The last transaction in the log occurs on 2015-02-02 13:00 WARN Your order for 81 shares of BF_A has been partially filled. 76 shares were successfully purchased. 5 shares were not filled by the end of day and were canceled.
End of logs.

So it looks like the backtest runs up until that point.

So, it seems that from the period of 05-20-2015 to 08-18 there are no stocks which pass the pipeline filter - leading the value sum(context.output.market_cap) to evaluate to 0, which results in your NaN error. You might want to fiddle around with the logic of your algorithm to buy something else when no stocks pass the filter or make the filter more lenient.

In any case - the modifications I made should make the algorithm work - although there will be no stocks purchased when no stocks pass the filter (hence the flat line).

Clone Algorithm
20
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 57f2d0f9739a10105c702982
There was a runtime error.

@Matt Great, thanks for the clarification!