Overall Statistics
Total Trades
2327
Average Win
0.01%
Average Loss
-0.03%
Compounding Annual Return
13.201%
Drawdown
5.000%
Expectancy
0.089
Net Profit
10.367%
Sharpe Ratio
1.601
Loss Rate
12%
Win Rate
88%
Profit-Loss Ratio
0.24
Alpha
0.109
Beta
-0.028
Annual Standard Deviation
0.065
Annual Variance
0.004
Information Ratio
-0.725
Tracking Error
0.142
Treynor Ratio
-3.766
Total Fees
$2347.52
from Execution.ImmediateExecutionModel import ImmediateExecutionModel
from Portfolio.EqualWeightingPortfolioConstructionModel import EqualWeightingPortfolioConstructionModel

class TransdimensionalResistanceAtmosphericScrubbers(QCAlgorithm):

    def Initialize(self):
        # Set Start Date so that backtest has 5+ years of data
        self.SetStartDate(2019, 1, 1)

        # No need to set End Date as the final submission will be tested
        # up until the review date

        # Set $1m Strategy Cash to trade significant AUM
        self.SetCash(1000000)

        # Add a relevant benchmark, with the default being SPY
        self.AddEquity('SPY', Resolution.Daily)
        self.SetBenchmark('SPY')

        # Use the Alpha Streams Brokerage Model, developed in conjunction with
        # funds to model their actual fees, costs, etc.
        # Please do not add any additional reality modelling, such as Slippage, Fees, Buying Power, etc.
        self.SetBrokerageModel(AlphaStreamsBrokerageModel())

        self.SetExecution(ImmediateExecutionModel())

        self.SetPortfolioConstruction(InsightWeightingPortfolioConstructionModel())

        self.SetUniverseSelection(TechnologyETFUniverse())

        self.universe = { }
        
        self.Schedule.On(self.DateRules.EveryDay(), self.TimeRules.AfterMarketOpen('SPY', 0), self.ResetTrades)
        self.traded = 0

    def OnData(self, data):
        '''OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
            Arguments:
                data: Slice object keyed by symbol containing the stock data
        '''
    
    def ResetTrades(self):
        if self.traded == 0:
            for symbol, assetData in self.universe.items():
                
                ins = Insight(symbol, timedelta(400), InsightType.Price, InsightDirection.Up, None, None)
                ins.Weight = 0.03
                self.EmitInsights(ins)
            self.traded = 1
        
    # Initializing ETF Universe Securities
    def OnSecuritiesChanged(self, changes):
        for s in changes.AddedSecurities:
            if s.Symbol not in self.universe:
                self.universe[s.Symbol] = s.Symbol