Hello, I have coded this fundamental factor algo. The goal of the strategy is to pick up stocks that meet conditions with fundamental ratios such as EPS, ROE and Total Revenue. I define this conditions in the FineFundamentalFunction() and in CoarseFundamentalFunction() I filter stocks with high volume.
1- I'm interesting in track the stocks bought and sell of the algorithm. How this is possible? In the attached algorithm I added self.Log("Buy security %s" % str(security.Symbol)) but any stock is printed out. I have doubts also because in the console is printed "Buy security SPY", but SPY is not a stock that I include to trade here.
2- I need support to know if this algo is working correctly because I have a similar algo in Quantopian and the returns are widely different.
Many thanks!
Nicolás
Jing Wu
Hi Nicolás, you should use "self.Log("Buy security" + str(security.Symbol.Value)) " to log the ticker. The alternative method is "self.Log("Buy security {0}".format(security.Symbol.Value))".
If you use the research notebook to check the fundamental factor value, you'll find some of them always have zero value like "x.EarningReports.BasicEPS.OneMonth" which means one month EPS data are not available. If you use "x.EarningReports.BasicEPS.OneMonth != 0" condition to filter stocks, there are no symbols returned by FineSelectionFunction.
"SPY" is added manually to the universe with "self.AddEquity('SPY')". Therefore "self._changes.AddedSecurities" will contain "SPY". If you don't want to trade spy, you should add a check "if security.Symbol.Value != "SPY" ". If the FineSelectionFunction return empty list [], all symbols will be removed from the portfolio except for symbols which have open positions in the portfolio.
Please refer to the example algorithm.
Nicolas Ferrari
Hello Jing Wu,
I have a question with the algorithm attached. In one of the conditions of the FineSelectionFunction, specifically in the TotalRevenue filter, when this condition is activated the algo buy few stocks and when this condition is commented out the algo buy many stocks.
The condition is:
filtered_fine = [x for x in filtered_fine if (x.FinancialStatements.IncomeStatement.TotalRevenue.ThreeMonths !=0) and
(x.FinancialStatements.IncomeStatement.TotalRevenue.SixMonths !=0) and ((x.FinancialStatements.IncomeStatement.TotalRevenue.ThreeMonths -x.FinancialStatements.IncomeStatement.TotalRevenue.SixMonths)/ (x.FinancialStatements.IncomeStatement.TotalRevenue.SixMonths)) >0.20]
This imply that the behaviour of the algo changes significantly with this condition. The idea of this condition is to filter stocks with sales growth(higher than 20%) between the two last quarters.
You have an idea of what can be happened here?? Why this filter is so strong?
Jing Wu
The period fields of fundamental factors are the sum value of N months in a fiscal year.
"factor.ThreeMonths" is the quarterly value which is updated every quarter.
"SixMonths", "NineMonths" and "TwelveMonths" values are all updated yearly. For example, " SixMonths " value updates at the end of the second quarter every fiscal year (the end of June or the start of July). Before this date, the value is the total revenue for the first two quarters of the last fiscal year.
" NineMonths " factor value updates at the end of the third quarter. It is total revenue for the first three quarters of a fiscal year. "TwelveMonths" updates at the end of a fiscal year.
We don't have the history API to request the quarterly of fundamental values. Therefore it's not available to calculate the quarterly revenue growth with the formula above.
There is a "RevenueGrowth" factor in OperationRatios
"fine.OperationRatios.RevenueGrowth.ThreeMonths."
It is the quarterly revenue growth rate you can use here to filter stocks.
Nicolas Ferrari
Thanks a lot for your support Jing. You are an expert!
Your coments make sense and now, I come across about what the filter was so strong, as the sixmonths period is the sum of the 2 three months previous, so in normal conditions would be higher.
I would use the revenue growth rate that you point out.
Thanks!!!
Nicolas Ferrari
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!