Overall Statistics
Total Trades
0
Average Win
0%
Average Loss
0%
Compounding Annual Return
0%
Drawdown
0%
Expectancy
0
Net Profit
0%
Sharpe Ratio
0
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0
Beta
0
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
0
Tracking Error
0
Treynor Ratio
0
Total Fees
$0.00
from QuantConnect.Data.Market import TradeBar
from datetime import timedelta
from System import *
from QuantConnect import *
from QuantConnect.Algorithm import *
from QuantConnect.Indicators import *
import decimal as d 

class MyAlgorithm(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(2017,1,1) #Set Start Date
        self.SetEndDate(2017,6,6)
        self.SetCash(100000) #Set Strategy Cash
        self.AddEquity("SPY", Resolution.Second)
        
        consolidator = TradeBarConsolidator(timedelta(1))
        consolidator.DataConsolidated += self.OnMonthlyData
        self.SubscriptionManager.AddConsolidator("SPY", consolidator)
        
        self.monthly = RollingWindow[TradeBar](2)
     
    def OnData(self, data):

     pass  

    # Add monthly bar to monthly rolling window
    def OnMonthlyData(self, sender, bar):
      
        self.monthly.Add(bar)
        monthlyhigh = self.monthly[0].High
        self.Debug(str(monthlyhigh))