Hi everyone
I've been trying to resample the daily history data into a biweekly fashion. To be specific, for any day in the week, get the high, low, and close price of the past two weeks (not including this current week, this weeks HLC will be included next week)
However, while the data is resampled into a two-weekly fashion, the resampled data always changes on different days, sometime Thursday, sometimes Friday. This is very confusing. Can someone help me on this?
Take an example, as the code listed, if you run the backtest from 02/01/2020 to 04/28/2020, you will get the following results (marked in Bold italic). Suddenly during the week, 2020-02-05 biweekly data changes into a different date. Realy confusing.
2020-02-03 15:59 myfunc:27 INFO SPY biweekly close = 2019-12-20 00:00:00+00:00 321.120
2020-01-03 00:00:00+00:00 322.440
2020-01-17 00:00:00+00:00 332.010
2020-01-31 00:00:00+00:00 321.750
2020-02-14 00:00:00+00:00 324.085
Freq: 2W-FRI, Name: Equity(8554 [SPY]), dtype: float64
2020-02-04 15:59 myfunc:27 INFO SPY biweekly close = 2019-12-20 00:00:00+00:00 321.12
2020-01-03 00:00:00+00:00 322.44
2020-01-17 00:00:00+00:00 332.01
2020-01-31 00:00:00+00:00 321.75
2020-02-14 00:00:00+00:00 328.98
Freq: 2W-FRI, Name: Equity(8554 [SPY]), dtype: float64
2020-02-05 15:59 myfunc:27 INFO SPY biweekly close = 2019-12-27 00:00:00+00:00 322.860
2020-01-10 00:00:00+00:00 325.700
2020-01-24 00:00:00+00:00 328.670
2020-02-07 00:00:00+00:00 332.595
Freq: 2W-FRI, Name: Equity(8554 [SPY]), dtype: float64
2020-02-06 15:59 myfunc:27 INFO SPY biweekly close = 2019-12-27 00:00:00+00:00 322.86
2020-01-10 00:00:00+00:00 325.70
2020-01-24 00:00:00+00:00 328.67
2020-02-07 00:00:00+00:00 334.02
Freq: 2W-FRI, Name: Equity(8554 [SPY]), dtype: float64
2020-02-07 15:59 myfunc:27 INFO SPY biweekly close = 2019-12-27 00:00:00+00:00 322.86
2020-01-10 00:00:00+00:00 325.70
2020-01-24 00:00:00+00:00 328.67
2020-02-07 00:00:00+00:00 332.29