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 17.424 Tracking Error 0.002 Treynor Ratio 0 Total Fees $0.00 Estimated Strategy Capacity $0 Lowest Capacity Asset |
import pandas as pd import numpy as np class TestingAlgorithm(QCAlgorithm): def Initialize(self): self.SetStartDate(2021,4,26) self.SetEndDate(2021,4,28) self.SetCash(10000) self.UniverseSettings.Resolution = Resolution.Minute self.AddUniverse(self.CoarseFilterFunction, self.FineFilterFunction) self.spy = self.AddEquity("SPY") self.Schedule.On(self.DateRules.EveryDay("SPY"), self.TimeRules.AfterMarketOpen("SPY", 60), self.MainFunction) # Set display option for logging purposes pd.set_option('display.float_format', '{:.7E}'.format) # Coarse filter def CoarseFilterFunction(self, coarse): self.Log("Running coarse filter function") self.coarsefilter = [x.Symbol for x in coarse if x.DollarVolume > 100000000 and x.HasFundamentalData] return self.coarsefilter # Fine filter def FineFilterFunction(self, fine): self.Log("Running fine filter function") self.stocks = sorted(fine, key=lambda x: x.MarketCap, reverse=True) finefilter = [x.Symbol for x in self.stocks] self.tickers = [x.Symbol.Value for x in self.stocks] return finefilter def MainFunction(self): self.Log("Running main function") shares = [x.FinancialStatements.BalanceSheet.OrdinarySharesNumber.ThreeMonths for x in self.stocks] mktcap = [x.MarketCap for x in self.stocks] self.df = pd.DataFrame({ 'shares': shares, 'mktcap': mktcap, }, index = self.tickers) self.df = self.df.dropna() self.LoggingFunction() return def LoggingFunction(self): for index, row in self.df.head(10).iterrows(): self.Log(str(row)) return