Overall Statistics
Total Trades
397
Average Win
0.59%
Average Loss
-0.06%
Compounding Annual Return
12.628%
Drawdown
41.500%
Expectancy
9.118
Net Profit
715.407%
Sharpe Ratio
0.76
Probabilistic Sharpe Ratio
9.876%
Loss Rate
3%
Win Rate
97%
Profit-Loss Ratio
9.43
Alpha
0.125
Beta
-0.093
Annual Standard Deviation
0.152
Annual Variance
0.023
Information Ratio
0.078
Tracking Error
0.242
Treynor Ratio
-1.25
Total Fees
$0.00
from execution import *
from alpha import *

class NadionCalibratedCircuit(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2003, 1, 1)
        self.SetCash(100000)
        self.Resolution = Resolution.Daily
        self.UniverseSettings.Resolution = Resolution.Daily
        
        self.risk = "QQQ"
        self.safe = "SHY"
        
        symbols = [
            Symbol.Create(self.risk, SecurityType.Equity, Market.USA),
            Symbol.Create(self.safe, SecurityType.Equity, Market.USA)
        ]
        self.AddUniverseSelection(ManualUniverseSelectionModel(symbols))
        
        self.AddAlpha( RiskBalance(symbols[0], symbols[1], self, self.Resolution) )
        
        self.Settings.RebalancePortfolioOnInsightChanges = False
        self.Settings.RebalancePortfolioOnSecurityChanges = False
        self.SetPortfolioConstruction( InsightWeightingPortfolioConstructionModel(self.RebalanceFunction) )
        
        self.SetExecution( SlowExecutionModel() )
        
        self.AddRiskManagement( MaximumDrawdownPercentPortfolio(0.03) )
        
        self.month = -1

    def RebalanceFunction(self, time):
        if self.month == -1:
            self.month = time.month
            return time
            
        if self.month != time.month:
            self.month = time.month
            return time
        return None
    
    def OnSecuritiesChanged(self, changes):
        self.Securities[self.risk].FeeModel = ConstantFeeModel(0)
        self.Securities[self.safe].FeeModel = ConstantFeeModel(0)