Error in .view() in _plotting._group_trades(column)
Expected Behavior
When I pass too big dataframe and the system tries to resample it I have the error in the next screenshot
Actual Behavior
I think the screenshot should be more informative

I tried .view(int) and .view('uint8') from the pandas documentation and got a little different error messages
...Length of values (16)... and ...Length of values(maybe 8, I forgot)...
Steps to Reproduce
I can't share data with you, sorry. In case you don't have enough information you can close the ticket.
- Backtesting version: 0.3.3
I've found the source of the problem

Backtest.plot(resample=True) works fine with my dataset when I reset my date-time index.
Indeed, a small sample of the data with which to reproduce the bug sure would help.
Also have this issue, in debugger the place with error was in call .view(int)
Managed to solve it locally, changed view(int) to view('int64') but then we need to changes nanoseconds to seconds, so result is divided by 1e9
my versions
- Backtesting==0.3.3
- numpy==1.22.2
- pandas==1.4.0
In _plotting.py replaced function _group_trades
def _group_trades(column):
def _series_to_int(s):
return s.view('int64').apply(lambda x: x / 1e9)
def _array_to_int(a):
return np.array([xi / 1e9 for xi in a.view('int64')])
def f(s, new_index=pd.Index(_array_to_int(df.index)), bars=trades[column]):
if s.size:
# Via int64 because on pandas recently broken datetime
mean_time = int(_series_to_int(bars.loc[s.index]).mean())
# Because of FutureWarning: Passing method to Float64Index.get_loc is deprecated and will raise in a future version. Use index.get_indexer([item], method=...) instead.
new_bar_idx = new_index.get_indexer([mean_time], method='nearest')[0]
return new_bar_idx
return f