Overall Statistics
Total Trades
5696
Average Win
0.12%
Average Loss
-0.07%
Compounding Annual Return
16.996%
Drawdown
37.700%
Expectancy
1.052
Net Profit
800.544%
Sharpe Ratio
0.619
Sortino Ratio
0.662
Probabilistic Sharpe Ratio
5.876%
Loss Rate
22%
Win Rate
78%
Profit-Loss Ratio
1.63
Alpha
0
Beta
0
Annual Standard Deviation
0.197
Annual Variance
0.039
Information Ratio
0.692
Tracking Error
0.197
Treynor Ratio
0
Total Fees
$5704.28
Estimated Strategy Capacity
$800000.00
Lowest Capacity Asset
GLD T3SKPOF94JFP
Portfolio Turnover
0.98%
from AlgorithmImports import *

class ETFRotationAlgorithm(QCAlgorithm):

    def Initialize(self):
        self.UniverseSettings.Resolution = Resolution.Minute

        if not self.LiveMode:
            self.SetStartDate(2010, 1, 1)
            self.SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage, AccountType.Margin)

        self.spy = self.AddEquity("SPY", self.UniverseSettings.Resolution).Symbol
        self.gld = self.AddEquity("GLD", self.UniverseSettings.Resolution).Symbol

        self.Schedule.On(self.DateRules.EveryDay(self.spy),
                         self.TimeRules.BeforeMarketClose(self.spy, 45),
                         self.Rebalance)

    def Rebalance(self):
        targets = [PortfolioTarget(self.spy, 1), PortfolioTarget(self.gld, 1)]
        self.SetHoldings(targets)