LEAN is the open source
algorithmic trading engine powering QuantConnect. Founded in 2013 LEAN has been built by a
global community of 80+ engineers and powers more than a dozen hedge funds today.
Alpha League Competition: $1,000 Weekly Prize Pool
Qualifying Alpha Streams Reentered Weekly Learn
more
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:
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.
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.
Sdoof
180 Pro
,
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!
0
Aaron Gilman
8.5k Pro
,
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.
0
Lexx7
1.3k Pro
,
Thanks for this Aaron. Would also be interested in the Z-Score.
How to limited this strategy Leverage under 100% ?
0
Rasheduzzaman hridoy
39 Pro
,
Hi, I am new for this forum & thanks for your post
0
Aaron Gilman
8.5k Pro
,
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
0
DEVON
236 Pro
,
Aaron,
Thanks you kindly share this strategy and solve my issue.
Best Regard
0
Jon Quant
2.2k Pro
,
What is the purpose of flag1, flag2, and flag3 and what is the logic behind it?
0
Aaron Gilman
8.5k Pro
,
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
0
Rasheduzzaman hridoy
39 Pro
,
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!
0
Flame
4.7k Pro
,
Does anyone know why line 29 of the above backtest 'SecurityChanges.None' has a syntax error?
2
David Crofts
689 Pro
,
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...
2
Flame
4.7k Pro
,
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
0
Flame
4.7k Pro
,
For those looking for the answer. Change all the self._changes = SecurityChanges.None to self._changes = None
1
Caleb Mock
569 Pro
,
Thank you for that update Flame. You'll find the same code change is required on lines 84 and 93.
0
Flame
4.7k Pro
,
Hi Aaron
Have you made any further progress with the Beneish M Score algorithm?
1
Snoop dogg
63 Pro
,
 Aaron Gilman I was hoping you could share the beneish M Score Algo? Thanks!
0
Strongs
3.2k Pro
,
Hi Aron your post is really interesting. Unfortunately I have problems in the code and I cannot understand why
0
Shile Wen
63.4k Pro
,
Hi Strongs,
Please elaborate on your problem so that the community can help you with your problem.
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.
Loading...
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!