Overall Statistics
Total Trades
1
Average Win
0%
Average Loss
0%
Compounding Annual Return
0.147%
Drawdown
1.100%
Expectancy
0
Net Profit
3.177%
Sharpe Ratio
0.48
Probabilistic Sharpe Ratio
0.514%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0.001
Beta
-0.001
Annual Standard Deviation
0.003
Annual Variance
0
Information Ratio
-0.411
Tracking Error
0.177
Treynor Ratio
-0.943
Total Fees
$1.00
Estimated Strategy Capacity
$17000000000.00
import numpy as np

class RollingWindowAlgorithm(QCAlgorithm):

    def Initialize(self):

        self.SetStartDate(2000,1,1)  #Set Start Date
        #self.SetEndDate(2020,12,31)    #Set End Date
        self.SetCash(10000)           #Set Strategy Cash

        self.symbol = self.AddEquity('SPY', Resolution.Daily).Symbol

#################################
        self.SetBrokerageModel(BrokerageName.AlphaStreams,AccountType.Margin)

 #####################################################       
      #########################################################################################
    # monthly----
        self.Schedule.On(self.DateRules.MonthStart("SPY"), \
                 self.TimeRules.AfterMarketOpen("SPY"), \
                 self.Rebalance)
        
        self.weight= 0

    def Rebalance(self):
        self.weight = self.weight + 0.0001
        self.SetHoldings(self.symbol,self.weight)
        
        if self.Portfolio.Invested:
            self.Plot("Exposure", "BUY% ", 100*self.Portfolio.TotalHoldingsValue/self.Portfolio.TotalPortfolioValue)
            
        self.Plot("Exposure", "Weight", self.weight*100)