@balibou Currently I have it set up so the timeframe I am testing is pulled from a DB (similar to pulling the data from a csv) and turned into the benchmark.
"""
You can assume parsed is a dict with datetime keys and close values
parsed = {
datetime.datetime(2014, 2, 3, 9, 30):176.74
datetime.datetime(2014, 2, 3, 9, 31): 177.01
...
}
"""
benchmark = (
pd.DataFrame.from_dict(parsed, orient="index")
.pct_change()
.fillna(0)
.replace([np.inf, -np.inf], float("NaN"))
.dropna()
) # All these functions on the datafame were involved in the quantstat util functions I mentioned
If your's isn't working as expected, I found it helpful to call _prepare_benchmark("SPY")
then turn it to a dict and see how the benchmark dataframe would look with TimeFrame.Days.
Also your df_values dataframe should have the same length, start & end dates as the benchmark.
Hopefully this helps.