wrangle#

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

Module description#

Wrangle DEX market data to be better suitable for algorithmic trading.

  • Wrangle is a process where we “massage” incoming price/liquidity data for the isseus we may have encountered during the data collection

  • Common DEX data issues are absurd price high/low spikes due to MEV trades

  • We also have some open/close values that are “broken” in a sense that they do not reflect the market price you would be able to trade, again likely due to MEV

  • See fix_dex_price_data() for fixing

Functions#

examine_anomalies(pair_universe, price_df[, ...])

Check the price dataframe for data issues.

examine_price_between_time_anomalies(...[, ...])

Find bad open/close prices where the open price is very different from the value of previous and next day.

filter_bad_wicks(df[, threshold])

Mark the bad wicks.

fix_bad_wicks(df[, threshold, ...])

Correct out bad high/low values in OHLC data.

fix_dex_price_data(df[, freq, forward_fill, ...])

Wrangle DEX price data for all known issues.

fix_prices_in_between_time_frames(dfgb[, ...])

Fix MEV bots breaking open/price.

normalise_volume(df)

Clean volume data columns.

remove_min_max_price(df[, min_max_price])

Remove candles where open value is outside the floating point range detector.

remove_zero_candles(df)

Remove any candle that has a zero value for OHLC