Created
April 12, 2021 11:48
-
-
Save 18182324/31c3c986fa92e2c47b02c5a636a7b5eb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def CoarseSelectionFunction(self, coarse): | |
if self.yearly_rebalance: | |
self.filtered_coarse = [x.Symbol for x in coarse if (x.HasFundamentalData) | |
and (x.Market == "usa")] | |
return self.filtered_coarse | |
else: | |
return [] | |
def FineSelectionFunction(self, fine): | |
if self.yearly_rebalance: | |
fine = [x for x in fine if (float(x.FinancialStatements.BalanceSheet.CurrentAssets.Value) > 0) | |
and (float(x.FinancialStatements.BalanceSheet.CashAndCashEquivalents.Value) > 0) | |
and (float(x.FinancialStatements.BalanceSheet.CurrentLiabilities.Value) > 0) | |
and (float(x.FinancialStatements.BalanceSheet.CurrentDebt.Value) > 0) | |
and (float(x.FinancialStatements.BalanceSheet.IncomeTaxPayable.Value) > 0) | |
and (float(x.FinancialStatements.IncomeStatement.DepreciationAndAmortization.Value) > 0)] | |
if not self.previous_fine: | |
self.previous_fine = fine | |
self.yearly_rebalance = False | |
return [] | |
else: | |
self.filtered_fine = self.CalculateAccruals(fine,self.previous_fine) | |
sorted_filter = sorted(self.filtered_fine, key=lambda x: x.bs_acc) | |
self.filtered_fine = [i.Symbol for i in sorted_filter] | |
self.previous_fine = fine | |
return self.filtered_fine | |
else: | |
return [] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment