Overall Statistics
Total Trades
0
Average Win
0%
Average Loss
0%
Compounding Annual Return
0%
Drawdown
0%
Expectancy
0
Net Profit
0%
Sharpe Ratio
0
Probabilistic Sharpe Ratio
0%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0
Beta
0
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
0
Tracking Error
0
Treynor Ratio
0
Total Fees
$0.00
Estimated Strategy Capacity
$0
Lowest Capacity Asset
class StockSelectionStrategyBasedOnFundamentalFactorsAlgorithm(QCAlgorithm):

    def Initialize(self):

        self.SetStartDate(2009, 1, 2)  # Set Start Date
        self.SetEndDate(2017, 5, 2)    # Set End Date
        self.SetCash(50000)          # Set Strategy Cash

        self.AddUniverse(self.CoarseSelectionFunction, self.FineSelectionFunction)

    def CoarseSelectionFunction(self, coarse):
        selected = [x for x in coarse if x.HasFundamentalData]
        sorted_by_dollar_volume = sorted(selected, key=lambda x: x.DollarVolume, reverse=True)
        return [i.Symbol for i in sorted_by_dollar_volume[:10]]

    def FineSelectionFunction(self, fine):
        ratio_by_symbol = {}
        for f in fine:
            assets = f.FinancialStatements.BalanceSheet.TotalAssets.ThreeMonths
            investments = f.FinancialStatements.IncomeStatement.OtherTaxes.ThreeMonths
            if investments != 0:
                ratio_by_symbol[f.Symbol] = assets / investments

        sorted_by_ratio = dict(sorted(ratio_by_symbol.items(), key=lambda x: x[1]))
        symbols = [symbol for symbol, ratio in sorted_by_ratio.items()][:5]
        
        self.Quit(f"Top symbols: {[str(s) for s in symbols]}")
        
        return symbols