@dark-pidgeot Actually there could be some hidden problem.
Your code fails on the very last day, let us say 2022-09-01 as you sent in a previous screenshot.
Are you sure that no forward looking is going on? Let us suppose that we are on 2022-09-01, and on that day your code is looking into the future. Then it will fail, as it will have no data at all.