Overall Statistics
Total Trades
30
Average Win
0.38%
Average Loss
-0.56%
Compounding Annual Return
3.020%
Drawdown
2.400%
Expectancy
0.119
Net Profit
0.980%
Sharpe Ratio
0.759
Probabilistic Sharpe Ratio
44.722%
Loss Rate
33%
Win Rate
67%
Profit-Loss Ratio
0.68
Alpha
-0.015
Beta
0.107
Annual Standard Deviation
0.041
Annual Variance
0.002
Information Ratio
-2.958
Tracking Error
0.135
Treynor Ratio
0.291
Total Fees
$381.44
Estimated Strategy Capacity
$240000000.00
from clr import AddReference
AddReference("System")
AddReference("QuantConnect.Algorithm")
AddReference("QuantConnect.Common")

from System import *
from QuantConnect import *
from QuantConnect.Algorithm import *
from QuantConnect.Indicators import *
from QuantConnect.Data.Market import TradeBar

class RollingWindowAlgorithm(QCAlgorithm):

    def Initialize(self):
        '''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.'''

        self.SetStartDate(2021,1,1)  #Set Start Date
        self.SetCash(1000000)           #Set Strategy Cash

        self.symbol = self.AddEquity("SPY", Resolution.Minute).Symbol#,Market.GDAX).Symbol

#################################
        self.SetBrokerageModel(BrokerageName.AlphaStreams)

 ##################################################### 
        self.Schedule.On(self.DateRules.Every(DayOfWeek.Monday),    self.TimeRules.AfterMarketOpen(self.symbol,1),     self.Compra)
                        
        self.Schedule.On(self.DateRules.EveryDay(),                 self.TimeRules.BeforeMarketClose(self.symbol,1),   self.Vende)                
                    
                     
      #########################################################################################
  
  
 ### ENTRY & EXIT ---------------------------------------------------------------------------------
    def Compra(self):
        if not self.Portfolio.Invested:
                self.SetHoldings(self.symbol, 1)

    def Vende(self):
        if self.Portfolio.Invested:
            self.Liquidate()