forward_fill#

forward_fill(df, freq, columns=('open', 'close'), drop_other_columns=True)[source]#

Forward-fill OHLCV data for multiple trading pairs.

Forward fill certain candle columns.

If multiple pairs are given as a GroupBy, then the data is filled only for the min(pair_timestamp), max(timestamp) - not for the range of the all data.

Note

timestamp and pair_id columns will be deleted in this process
  • do not use these columns, but corresponding indexes instead.

Parameters:
  • df (pandas.core.frame.DataFrame | pandas.core.groupby.generic.DataFrameGroupBy) –

    Candle data for single or multiple trading pairs

    • GroupBy DataFrame containing candle data for multiple trading pairs (grouped by column pair_id).

    • Normal DataFrame containing candle data for a single pair

  • freq (DateOffset) – The target frequency for the DataFrame.

  • columns (Tuple[str]) –

    Columns to fill.

    To save memory and speed, only fill the columns you need. Usually open and close are enough and also filled by default.

  • drop_other_columns

    Remove other columns before forward-fill to save memory.

    The resulting DataFrame will only have columns listed in columns parameter.

    The removed columns include ones like high and low, but also Trading Strategy specific columns like start_block and end_block. It’s unlikely we are going to need forward-filled data in these columns.

Returns:

DataFrame where each timestamp has a value set for columns.