convert_to_ohlcv_candles

Documentation for eth_defi.research.candle.convert_to_ohlcv_candles function.

convert_to_ohlcv_candles(df, time_frame=Timedelta('1 days 00:00:00'), price_column='price', value_column='value', timestamp_index_column='timestamp')[source]

Create OHLCV candles based on raw trade events.

Example:

candles = convert_to_ohlcv_candles(df, time_bucket=pd.Timedelta("4h"))

See the full example in Uniswap v3 OHLCV notebook.

Parameters
  • df (pandas.core.frame.DataFrame) – Input data frame.

  • time_frame (pandas._libs.tslibs.timedeltas.Timedelta) – What’s the duration of a single candle.

  • price_column (str) – The dataframe column containing the price of a trade. Used to generate open, high, low and close columns.

  • value_column (str) – The dataframe column containing the price of a trade. Used to generate volume column.

  • timestamp_index_column (Optional[str]) – If given then convert this timestamp column to an index. It can contain ISO8601 string timestamp, or be a timestamp column.

Returns

pd.DataFrame with open, high, low, close and volume columns. Index is resampled timestamp.

Return type

pandas.core.frame.DataFrame