I could only find an example of this written in C#, so I figured it would be helpful to others to share a Python implementation of a custom scoring model using fundamental data. This is just an example but I threw in the 5 year normalized PE ratio as the final ranking metric, and used a FScore value of greater than 6 to filter down from the course universe. You can read the original white paper here:
Enjoy,
Aaron Gilman
Sdoof
Thank you so much Aaron for making the Python implementation available. This is indeed a seminal paper which seems to pass the test of time!
Aaron Gilman
You are welcome! I also have Altman Z Score and Beneish M Score (more beneficial for helping to filter out companies with high probability of bankruptcy/ruin) that I will share once I clean them up a bit.
Lexx7
Thanks for this Aaron. Would also be interested in the Z-Score.
Aaron Gilman
Lexx7,
Here you go:
DEVON
How to limited this strategy Leverage under 100% ?
Rasheduzzaman hridoy
Hi,
I am new for this forum & thanks for your post
Aaron Gilman
DEVON,
I actually ran into that problem repeatedly so I started tracking the Leverage within the algorithms using the Charting API (I left that part out in this sample code) and found that Leverage never goes above 1. I emailed support and they said it is a bug within the reports that they will fix. Not sure why it occurs as it is only with algorithms that use CourseSelection and FineSelection for the Universe screening. I added it to this backtest for you to see, just click on the strategy info chart button to plot it during the backtest. You can see it never goes above 1.
Thanks,
Aaron
DEVON
Aaron,
Thanks you kindly share this strategy and solve my issue.
Best Regard
Jon Quant
What is the purpose of flag1, flag2, and flag3 and what is the logic behind it?
Aaron Gilman
Jon,
It was in one of the example algos I started using initially (the coursefinecomboalgorithm) and it is so the Coarse and Fine Selection functions only run when they are scheduled, instead of daily like they are by default. The rebalance function is called monthly, which assigns a value to 1 to flag 1, so then the Course Selection runs, followed by Fine Selection, etc. Hope that makes sense.
Thanks,
Aaron
Rasheduzzaman hridoy
Thank you so much Aaron for making the Python implementation available. This is indeed a seminal paper which seems to pass the test of time!
Flame
Does anyone know why line 29 of the above backtest 'SecurityChanges.None' has a syntax error?
David Crofts
Jonathan -
Try changing line to:
self.changes = None
you will also need to fix lines
90 - if self.changes == None: return
99 - self.changes = None;
My build succeeds, but stuill working on backtest...
Flame
Hi David
Thanks for your help - as you say the build works but the backtest doesn't. I will look into it and let you know if I figure it out.
Thanks
Flame
For those looking for the answer. Change all the self._changes = SecurityChanges.None to self._changes = None
Caleb Mock
Thank you for that update Flame. You'll find the same code change is required on lines 84 and 93.
Flame
Hi Aaron
Have you made any further progress with the Beneish M Score algorithm?
Snoop dogg
 Aaron Gilman I was hoping you could share the beneish M Score Algo? Thanks!
Strongs
Shile Wen
Hi Strongs,
Please elaborate on your problem so that the community can help you with your problem.
Best,
Shile Wen
Aaron Gilman
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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!