My first post here, so hello to everyone:)

I'm trying to learn backtesting in LEAN + Python. Maybe you could answer some of my questions:
1. I searched through the forum but couldn't find a good explanation how to backtest using a weekly or monthly resolution. I've tried to use Consolidators to merge daily bars into monthly bars and a monthly Scheduler to do actions based on those consolidated monthly bars, but it doesn't work well. Here is my code:

from AlgorithmImports import *

class MyProject1(QCAlgorithm):
    def Initialize(self):
        self.SetStartDate(2021, 1, 1)
        self.SetEndDate(2021, 4, 1)
        self.Schedule.On(self.DateRules.MonthStart(), self.TimeRules.At(1,0), self.Monthly)
        self.monthlyBar = {}
        for ticker in ['AAPL']:
            self.AddEquity(ticker, Resolution.Daily)
            indicator = MonthlyBar(self)
            self.monthlyBar[ticker] = indicator
            tbc = TradeBarConsolidator(Calendar.Monthly)
            self.RegisterIndicator(ticker, indicator, tbc)

    def Monthly(self):
        bar = self.monthlyBar['AAPL'].Bar
        self.Log(f"Monthly:: time={self.Time} bar={bar}")

    def OnData(self, data):
        bar = data['AAPL']
        self.Log(f"OnData:: time={self.Time} bar={bar}")

class MonthlyBar:
    def __init__(self, algo):
        self.Algo = algo
        self.Value = None
        self.IsReady = True

    def Update(self, bar):
        self.Algo.Log(f"Update:: time={bar.EndTime} algotime={self.Algo.Time} bar={bar}")
        self.Bar = bar
        self.Value = bar.Close
        return True

 

The output log is:

20220222 14:48:05.943 TRACE:: Log: OnData:: time=2021-02-27 00:00:00 bar=AAPL: O: 122.61 H: 124.85 L: 121.2 C: 121.26 V: 149612830
20220222 14:48:05.943 TRACE:: Log: Monthly:: time=2021-03-01 01:00:00 bar=AAPL: O: 133.3607 H: 146.0318 L: 126.1914 C: 131.7631 V: 2087459953
20220222 14:48:05.943 TRACE:: Log: Update:: time=2021-03-01 00:00:00 algotime=2021-03-02 00:00:00 bar=AAPL: O: 133.4506 H: 137.875 L: 118.38 C: 121.26 V: 1727742132
20220222 14:48:05.943 TRACE:: Log: OnData:: time=2021-03-02 00:00:00 bar=AAPL: O: 123.78 H: 127.93 L: 122.79 C: 127.79 V: 110211547

The order of operation is not something I would expect - first we have the daily bar for the last day of Feb (OK), but then the monthly scheduler is called, and my indicator (consolidator based) is called last. So my scheduler does NOT have access to the latest monthly bar.

I'd expect it to be: last daily bar, then consolidator for February, and lastly the scheduler to make orders for March based on Feb data.

2. Is there some setting to do something about the dates in OnData? Right now it's a little awkward - a bar from Friday has a date from Saturday and 00:00:00 hour. I'd rather have Friday date. Hour and minutes don't matter as I'm working on a daily resolution.