The most important feature of a successful multi factor stock selection model is its ability to differentiate potential factor winners and losers. Here I developed a tool algorithm to help us choose the most effective factors.
At the begining of each month I get the factor value of stocks after coarse selection and rank those stocks by factor value. Then I divide them into 5 portfolios and calculate the monthly returns. Monthly returns are converted to an annual return for analysis.
There are three metrics to judge the significance of different fundamental factors:
a. The correlation between ranked portfolio series and their annual returns (A significant factor should have higher corrlation coefficient)
b. The probability that win portfolio outperforms the benchmark and the probability that loss portfolio underperforms the benchmark
(A significant factor should have high value of these two probability)
c. The excess return of the win and loss portfolios
(For significant factors, portfolios should have much higher excess returns than loss factor)
The algorithm is an example of PERatio.
DEVON
after I clone this strategy, then backtest it, but I got following error message:
12 | 04:02:59:
Runtime Error: Python.Runtime.ConversionException: could not convert Python result to System.Object[]
at __System_Func`2\[\[System_Collections_Generic_IEnumerable`1\[\[QuantConnect_Data_UniverseSelection_CoarseFundamental\, QuantConnect_Common\, Version=2_4_0_1\, Culture=neutral\, PublicKeyToken=null\]\]\, mscorlib\, Version=4_0_0_0\, Culture=neutral\, PublicKeyToken=b77a5c561934e089\]\,\[System_Object\[\]\, mscorlib\, Version=4_0_0_0\, Culture=neutral\, PublicKeyToken=b77a5c561934e089\]\]Dispatcher.Invoke (System.Collections.Generic.IEnumerable`1[T] ) [0x0000f] in <111a608f95244ae2acf3507718a14362>:0
at QuantConnect.Algorithm.QCAlgorithm+<>c__DisplayClass271_0.<AddUniverse>b__0 (System.Collections.Generic.IEnumerable`1[T] c) [0x00000] in <846439c3a3364182b7526754ce14b0fe>:0
at QuantConnect.Data.UniverseSelection.CoarseFundamentalUniverse.SelectSymbols (System.DateTime utcTime, QuantConnect.Data.UniverseSelection.BaseDataCollection data) [0x00012] in <6bcbc3da68d64c519c164c71cbf54ce0>:0
at QuantConnect.Data.UniverseSelection.SelectSymbolsUniverseDecorator.SelectSymbols (System.DateTime utcTime, QuantConnect.Data.UniverseSelection.BaseDataCollection data) [0x00001] in <6bcbc3da68d64c519c164c71cbf54ce0>:0
at QuantConnect.Lean.Engine.DataFeeds.UniverseSelection.ApplyUniverseSelection (QuantConnect.Data.UniverseSelection.Universe universe, System.DateTime dateTimeUtc, QuantConnect.Data.UniverseSelection.BaseDataCollection universeData) [0x0005f] in <ad8d580904aa4064b1b6b07230bc34a9>:0
at QuantConnect.Lean.Engine.DataFeeds.SubscriptionSynchronizer.Sync (System.Collections.Generic.IEnumerable`1[T] subscriptions) [0x002be] in <ad8d580904aa4064b1b6b07230bc34a9>:0
at QuantConnect.Lean.Engine.DataFeeds.FileSystemDataFeed+<GetEnumerator>d__30.MoveNext () [0x000c7] in <ad8d580904aa4064b1b6b07230bc34a9>:0 (Open Stacktrace)
Alexandre Catarino
DEVON , please checkout the following thread:
[Important] Universe Selection in Python Algorithms
This algorithm was written before the changes we explain in the previous link.
Basically this operation:
# we need to return only the symbol objects list = List[Symbol]() for x in top: list.Add(x.Symbol) return list
is no longer required, just return the list of symbols:
return [ x.Symbol for x in top ]
Jing Wu
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!