forward_fill#

API documentation for tradingstrategy.utils.forward_fill Python module in Trading Strategy.

Module description#

OHLCV data forward fill.

Forward fill missing OHLCV candles in market data feeds.

  • Trading Strategy market data feeds are sparse by default, to save bandwidth

  • DEXes small cap pairs see fewtrades and if there are no trades in a time frame, no candle is generated

  • Forward-filled data is used on the client side

  • We need to forward fill to make price look up, especially for stop losses faster, as forward-filled data can do a simple index look up to get a price, instead of backwinding to the last available price

Functions#

fill_future_gap(df, timestamp, columns[, ...])

Add a virtual OHLCV value at the end of the pair OHLCV data series if there is no real value.

fill_future_gap_multi_pair(grouped_df, ...)

forward_fill(single_or_multipair_data, freq)

Forward-fill OHLCV data for single or multiple trading pairs.

forward_fill_ohlcv_single_pair(df, freq, ...)

Forward-fill OHLCV data in a Pandas DataFrame, ensuring OHCLV logical consistency.

generate_future_filler_data(last_valid_row, ...)

Create a new placeholder OHLCV entry based on the last valid entry.

pad_dataframe_to_frequency(df, freq, ...)

Pads a Pandas DataFrame with NaN entries for all columns up to a given end timestamp, using the inferred frequency of the DataFrame.

resample_candles(df, resample_freq[, shift, ...])

Downsample or upsample OHLCV candles or liquidity samples.

resample_candles_multiple_pairs(df, frequency)

Upsample a OHLCV trading pair data to a lower time bucket.

xxx_forward_fill(single_or_multipair_data, freq)

Forward-fill OHLCV data for multiple trading pairs.