Hi there,
I am getting an error reading "invalid syntax"
I was wondering if someone could tell me what is the cause of this error :)
I would be very greatful for any help, thank you.
def FineSelectionFunction(self, fine):
filtered_fine = [x for x in fine if x.FinancialStatements.IncomeStatement.EBIT.OneMonth
and x.FinancialStatements.BalanceSheet.InvestedCapital.OneMonth
and x.FinancialStatements.BalanceSheet.PreferedStockEquity.OneMonth]
ROIC = [map(lambda x: (FinancialStatements.IncomeStatement.EBIT.OneMonth)/((FinancialStatements.BalanceSheet.InvestedCapital.OneMonth)+(FinancialStatements.BalanceSheet.PreferedStockEquity.OneMonth)), filtered_fine)
sortedByROIC = sorted(ROIC, reverse=True)
Jing Wu
The FinancialStatements is the property of elements in filtered_fine. For example
def FineSelectionFunction(self, fine): filtered_fine = [x for x in fine if x.FinancialStatements.IncomeStatement.EBIT.OneMonth and x.FinancialStatements.BalanceSheet.InvestedCapital.OneMonth and x.FinancialStatements.BalanceSheet.PreferedStockEquity.OneMonth] sortedByROIC = sorted(filtered_fine, lambda x: (x.FinancialStatements.IncomeStatement.EBIT.OneMonth)/((x.FinancialStatements.BalanceSheet.InvestedCapital.OneMonth)+(x.FinancialStatements.BalanceSheet.PreferedStockEquity.OneMonth)), reverse=True) return [i.Symbol for i in sortedByROIC]
You should also make sure the value is non-zero before calculating the ROIC with the factor value. Financial statements data often released quarterly. Therefore, one month value might be zero. You should use "ThreeMonths" to obtain the quarterly value.
Alex Haseldine
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!