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 am trying to create my own funamental indicator for stocks named ROIC, which involves taking 3 existing funamental data and then for each company dividing one by the addition e.g ROIC = a/b+c.
However, I am having trouble with the for loop involved in this, if someone could help me, it would be much appreciated.
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.
Alex Haseldine
412
,
def FineSelectionFunction(self, fine):
if self.flag1:
self.flag1 = 0
filtered_fine = [x for x in fine if x.FinancialStatements.IncomeStatement.EBIT.ThreeMonths
and x.FinancialStatements.BalanceSheet.InvestedCapital.ThreeMonths
and x.FinancialStatements.BalanceSheet.PreferredStock.ThreeMonths]
ROIC = [for x in filtered_fine: (x.FinancialStatements.IncomeStatement.EBIT.ThreeMonths/FinancialStatements.BalanceSheet.InvestedCapital.ThreeMonths+FinancialStatements.BalanceSheet.PreferredStock.ThreeMonths)]
sorted_by_ROIC = sorted(ROIC, reverse=True)
# The FinancialStatements is the property of elements in filtered_fine, so you need to basically say "from the data in filtered_fine, take x, y and z and do this function, and return the answer as sortedbyROIC.
sortedByROIC = sorted(filtered_fine, key=lambda x: (x.FinancialStatements.IncomeStatement.EBIT.ThreeMonths/FinancialStatements.BalanceSheet.InvestedCapital.ThreeMonths+FinancialStatements.BalanceSheet.PreferredStock.ThreeMonths), reverse=True)
#financial data comes in quaters i.e Three Month periods, therefore make sure it is three months so that there is no 0 on denominator.
self.sorted_stock = sorted(stock_dict.items(), key=lambda d:d[1],reverse=True)
sorted_symbol = [self.sorted_stock[i][0] for i in range(len(self.sorted_stock))]
topFine = sorted_symbol[:self.numberOfSymbolsFine]
else:
return []
0
Alex Haseldine
412
,
Sorry, I had to add the code seperately.
0
Alexandre Catarino
100.5k
,
In the first comment, you added an unrelated notebook. Could you please share/attach the backtest with the FineSelectionFunction method above? By the way, what do you mean by "having trouble with the for loop involved in this"?
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!