resample_price_series#
API documentation for tradingstrategy.utils.groupeduniverse.resample_price_series Python function.
- resample_price_series(series, resample_freq, shift=None, price_series_type='close')[source]#
Resample a price series to a lower frequency.
See test_price_series_resample_and_shift_binance for some example output how shift works. Shift -1 means that any strategy decision is 1h delayed (close price is chosen 1h later).
See also
resample_candles()
.TODO: Add forward-fill.
- Parameters:
series (Series) –
Price series, e.g. close series.
If the series.index is multi-index, assume it is (pair id, timestamp) for a single pair.
resample_freq (Timedelta) –
Resample frequency.
E.g.`pd.Timedelta(days=1)` create daily candles from hourly candles.
Before resampling, shift candles to left or right.
The shift is measured in number of candles, not time. Make sure the DataFrame is forward filled first, see
forward_fill()
.Set to 1 to shift candles one step right, -1 to shift candles one step left.
There might not be enough rows to shift. E.g. shift=-1 or shift=1 and len(df) == 1. In this case, an empty data frame is returned.
price_series_type – One of “open”, “close”, “high”, “low”
- Return type: