resample_candles#

resample_candles(df, new_timedelta)[source]#

Downsample OHLCV candles or liquidity samples to less granular time bucket.

E.g. transform 1h candles to 24h candles.

Example:

single_pair_candles = raw_candles.loc[raw_candles["pair_id"] == pair.pair_id]
single_pair_candles = single_pair_candles.set_index("timestamp", drop=False)
monthly_candles = upsample_candles(single_pair_candles, TimeBucket.d30)
assert len(monthly_candles) <= len(single_pair_candles) / 4
Parameters:
Return type:

DataFrame