Overall Statistics
Total Trades
24
Average Win
8.76%
Average Loss
-1.15%
Compounding Annual Return
807.879%
Drawdown
10.200%
Expectancy
4.016
Net Profit
65.099%
Sharpe Ratio
10.616
Probabilistic Sharpe Ratio
98.100%
Loss Rate
42%
Win Rate
58%
Profit-Loss Ratio
7.60
Alpha
5.783
Beta
-0.005
Annual Standard Deviation
0.545
Annual Variance
0.297
Information Ratio
7.103
Tracking Error
0.789
Treynor Ratio
-1244.382
Total Fees
$907.50
from datetime import datetime, timedelta

class MultidimensionalOptimizedCompensator(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2020, 3, 1)  # Set Start Date
        self.SetCash(100000)  # Set Strategy Cash
        
        tickers = ['GILD', 'MRNA', 'JNJ', 'INO', 'PFE',
                   'NVAX', 'URGN', 'CODX', 'SNGX',
                   'EGRX', 'GRFS', 'SRNE']
        
        dates = [[datetime(2020, 4, 29)], [datetime(2020,3,15), datetime(2020,5,15)],
                 [datetime(2020, 3, 16), datetime(2020, 5, 15)], [datetime(2020, 4, 15)],
                 [datetime(2020, 5, 4)], [datetime(2020,4,15), datetime(2020,5,11)],
                 [datetime(2020,4,15)], [datetime(2020, 4, 15)], [datetime(2020, 4, 15)],
                 [datetime(2020,4,15)], [datetime(2020,4,15)], [datetime(2020,3,25)],
                 [datetime(2020,5,8), datetime(2020,5,15)], [datetime(2020,3,25)]]
        
        symbols = {Symbol.Create(ticker, SecurityType.Equity, Market.USA):date for ticker, date in zip(tickers, dates)}
        
        self.UniverseSettings.Resolution = Resolution.Daily
        self.SetUniverseSelection(ManualUniverseSelectionModel([*symbols]))
        
        self.SetAlpha(BiotechNewsAlpha(symbols))
        
        self.SetExecution(ImmediateExecutionModel())
        
        self.SetPortfolioConstruction(EqualWeightingPortfolioConstructionModel(lambda time: None))


class BiotechNewsAlpha:
    
    def __init__(self, symbols):
        self.symbols = symbols
        
    def Update(self, algorithm, data):
        ## swap out for notebook code after first backtest
        insights = []
        
        for symbol, date in self.symbols.items():
            for d in date:
                if (algorithm.Time + timedelta(1)).date() == d.date():
                    insights += [Insight(symbol, timedelta(1), InsightType.Price,
                                         InsightDirection.Up)]
        return insights
        
    
    def OnSecuritiesChanged(self, algorithm, changes):
        ## Add tiingo data
        pass