We've written a cool little Alpha Model, Standardized Unexpected Earnings (SUE), as an example of how you can incorporate Fundamental Data into your own Alpha Models. SUE is a measurement of the difference between a company's reported earnings per share (EPS) and its forecasted (expected) EPS, which is then scaled by the standard deviation of the difference. While our Fundamental Data library is extensive, we don't provide earnings expectations reports, and so the SUE Alpha Model attached below uses historical EPS instead. So, our SUE measures the growth of corporate EPS over the past 12 months, scaled by volatility.
The Alpha Model takes in a Coarse Universe of the top 1000 stocks according to Dollar Volume, and then extracts the necessary Fundamental Data for each security: most recent EPS, EPS from 12 months ago, and any EPS reported in between. This information then gets pumped into the Alpha's Update() method were we calculate each security's SUE ranking and emit insights according to whether we want to buy or sell (short) the security. We take a long position in the top 20 assets by SUE ranking and short the bottom 20, and while 20 is an arbitrary number, it allows for broader sector exposure and minimizes some risk by not over-concentrating our position in just a few securities.
One of the limitations with this model, however, is that it isn't very effective as a continuous-time Alpha. New earnings data for each company gets uploaded to the Fundamental Data library once it is reported and available via Morningstar, but an SUE ranking is better viewed as a snapshot of a company in time rather than an indicator that can be continuously updated. Additionally, this model could be improved if expected earnings and earnings release dates are available and can be imported as custom data, which would then allow the model to emit more continuous insights as new data flows in for individual companies. If this data is available, then the true SUE score of a company could be calculated.
Have a look below and let us know your thoughts! This is open-source and available to anyone who wants to use or expand upon it.
Ernest Shaggleford
re: "Additionally, this model could be improved if expected earnings and earnings release dates are available and can be imported as custom data, which would then allow the model to emit more continuous insights as new data flows in for individual companies. If this data is available, then the true SUE score of a company could be calculated."
Having a data set with future expected earnings and earnings release dates is something I raised sometime ago but wasn't seen as important. This type of data can provide the basis for many types of strategies related to earnings releases such as pre-earnings, day of earnings and post-earnings strategies.
Emilio Freire
Thanks a lot Jack! And 100% agree with Ernest though I think QC is already working on that
Emilio
Jared Broad
Hey Ernest, please don't see it as "but wasn't seen as important". Ouch. Honestly, we do take your requests seriously and are all working 12 hours a day, 5-6 days a week, there's just an enormous volume of basics to get right first before we extend deeper. The data you're mentioning is not free; so we need to find a vendor who can let us use it for a reasonable price - in backtesting and live trading... It's a hard challenge that just takes time.
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.
Ernest Shaggleford
HI Jared - I didn't mean "not seen as important" as a negative criticism. As a developer I understand that tasks have to be prioritised so it was meant in that context. I understand that this type of data is not cheap but I'm hoping that with the scale of QC that this data could eventually be made available which will move QC further along the path of democratising finance :)
Thanks,
E.
The starrrrr
Jared - Contact us @ Wall Street Horizon if you are looking for earnings release dates and revisions. We have the most accurate, comprehensive, and timely dates - and the only firm with date revisions and timestamps.
www.wallstreethorizon.com/earnings-calendar
Artem Seredyuk
Spacetime
Hi Jack, I just wanted to inform that I was receiving a key error when running the above algo. From the above code, I do see we are skipping slice if we do not have data. I am uncertain where else do I need to check if data exists. Thanks!!
if symbol not in data.Keys or not data.Bars.ContainsKey(symbol): continue
System.Collections.Generic.KeyNotFoundException: Trying to retrieve an element from a collection using a key that does not exist in that collection throws a KeyError exception. To prevent the exception, ensure that the key exist in the collection and/or that collection is not empty. ---> Python.Runtime.PythonException: KeyError : ( ,)
at Python.Runtime.PyObject.Invoke (Python.Runtime.PyTuple args, Python.Runtime.PyDict kw) [0x00033] in <98f91910fe1045c6b12a6d01d5601476>:0
at Python.Runtime.PyObject.InvokeMethod (System.String name, Python.Runtime.PyTuple args, Python.Runtime.PyDict kw) [0x00007] in <98f91910fe1045c6b12a6d01d5601476>:0
at Python.Runtime.PyObject.TryInvokeMember (System.Dynamic.InvokeMemberBinder binder, System.Object[] args, System.Object& result) [0x0003e] in <98f91910fe1045c6b12a6d01d5601476>:0
at (wrapper dynamic-method) System.Object.CallSite.Target(System.Runtime.CompilerServices.Closure, System.Runtime.CompilerServices.CallSite, object, QuantConnect.Data.UniverseSelection.SecurityChanges)
at QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.OnFrameworkSecuritiesChanged (QuantConnect.Data.UniverseSelection.SecurityChanges changes) [0x0004f] in <2365c5d701e3477793c7164a4a3e5df3>:0
at QuantConnect.Lean.Engine.AlgorithmManager.Run (QuantConnect.Packets.AlgorithmNodePacket job, QuantConnect.Interfaces.IAlgorithm algorithm, QuantConnect.Lean.Engine.DataFeeds.ISynchronizer synchronizer, QuantConnect.Lean.Engine.TransactionHandlers.ITransactionHandler transactions, QuantConnect.Lean.Engine.Results.IResultHandler results, QuantConnect.Lean.Engine.RealTime.IRealTimeHandler realtime, QuantConnect.Lean.Engine.Server.ILeanManager leanManager, QuantConnect.Lean.Engine.Alpha.IAlphaHandler alphas, System.Threading.CancellationToken token) [0x008ef] in Lean.Engine.Alpha.IAlphaHandler alphas, System.Threading.CancellationToken token) [0x008ef] in :0
--- End of inner exception stack trace ---
Alexandre Catarino
Hi spacetime ,
Please add None to the default parameter of dict.pop:
self.fundamentalData.pop(symbol, None)
Since the addition of elements to self.fundamentalData depends on not None elements, some securities that were added to the algorithm were not added to self.fundamentalData.
Spacetime
Hi Alex, I appreciate the fix and explanation of it. It makes sense to me now.
Charles Liebenberg
Hi Jack,
I am currently running into the following error message when running this algo:
Runtime Error: AttributeError : 'NoneType' object has no attribute 'FinancialStatements' AttributeError : 'NoneType' object has no attribute 'FinancialStatements'
Any help you could give me would be greatly appreciated.
Shile Wen
Hi Charles,
To address this, we also need to make sure that the .Fundamentals field for a Security is not None as well. I've shown this in the attached backtest.
Best,
Shile Wen
Jack Simonson
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!