MCPcopy Create free account
hub / github.com/kernc/backtesting.py / wrap_func

Function wrap_func

backtesting/lib.py:317–330  ·  view source on GitHub ↗
(resampled, *args, **kwargs)

Source from the content-addressed store, hash-verified

315 return func(*args, **kwargs)
316
317 def wrap_func(resampled, *args, **kwargs):
318 result = func(resampled, *args, **kwargs)
319 if not isinstance(result, pd.DataFrame) and not isinstance(result, pd.Series):
320 result = np.asarray(result)
321 if result.ndim == 1:
322 result = pd.Series(result, name=resampled.name)
323 elif result.ndim == 2:
324 result = pd.DataFrame(result.T)
325 # Resample back to data index
326 if not isinstance(result.index, pd.DatetimeIndex):
327 result.index = resampled.index
328 result = result.reindex(index=series.index.union(resampled.index),
329 method='ffill').reindex(series.index)
330 return result
331
332 wrap_func.__name__ = func.__name__
333

Callers

nothing calls this directly

Calls 1

funcFunction · 0.85

Tested by

no test coverage detected