Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
First attempt - Beneish plus Piotroski.

Howdy,

Long time lurker and first time poster.

New to Quantopian & Python so apologies in advanced for lack of coding etiquette etc.

Accountant by trade so thought I would take a stab at something that uses fundamentals.

Strategy looks to go long equities that are in good health as measured by the F Score (Piotroski) and appear to not be manipulating earnings as measured by the M Score (Beneish).

Short securities in bad health and manipulating earnings once you get some price action moving your way.

Re-balances quarterly and optimized with a stop loss at 50%.

Please help, critique, discuss.

Question - does Quantopian have the functionality to have this run for securities listed on the NZX. (Kiwi here).

4 responses

Is there a way to record a cumulative PnL generated from Longs and Shorts on a daily basis?

@Varun Khanna. Nice algorithm. Thank you for sharing. You asked if this algo could be run on the NZX. Unfortunately no. Quantopian currently only supports backtesting of US securities. There are several hurdles including getting the minute data for non-US markets as well as supporting separate trading calendars and currencies for each. All doable just not done yet.

One can get the PnL generated from longs and shorts by setting round_trips=True when running a full tear sheet in Pyfolio. That may be what you are looking for. There is some info in the docs here. Run the following code in a notebook

# Enter the desired backtest ID below  
my_backtest_id = '123456799'  
bt = get_backtest(my_backtest_id)  
bt.create_full_tear_sheet(round_trips=True)

Good luck.

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.

@Dan Whitnable. Thanks Dan, that worked a treat.

@Dan Whitnable. Hi Dan, I am a little bit stumped and getting progressively more lost as I try to figure out a way to combine these factors. I've gone for a scoring approach referencing one of your replies in the archives (see attached notebook). I am now at a complete loss as to how this would translate from research to the algorithm. The issue is compounded as I'm not sure if this is the best mode of attack. The final desired output is to get the top & bottom 25 stocks as per the Piotroski & Beneish to go long and short. Any assistance/point in the right direction as to how to approach getting top/bottom x number of securities would be great.