API documentation for tradingstrategy.pair.filter_for_stablecoins Python function.

filter_for_stablecoins(pairs, mode)[source]#

Filter dataset so that it only contains data for the trading pairs that are either stablecoin pairs or not.

Trading logic might not be able to deal with or does not want to deal with stable -> stable pairs. Trading stablecoin to another does not make sense, unless you are doing high volume arbitration strategies.

Uses internal stablecoin list from tradingstrategy.stablecoin.


from tradingstrategy.pair import filter_for_stablecoins, StablecoinFilteringMode

# Remove pairs with expensive 1% fee tier
# Remove stable-stable pairs
tradeable_pairs_df = pairs_df.loc[pairs_df["fee"] <= 30]
tradeable_pairs_df = filter_for_stablecoins(tradeable_pairs_df, StablecoinFilteringMode.only_volatile_pairs)

# Narrow down candle data to pairs that are left after filtering
candles_df = candles_df.loc[candles_df["pair_id"].isin(tradeable_pairs_df["pair_id"])]

print(f"We have {len(tradeable_pairs_df)} tradeable pairs")

Filtered DataFrame

Return type: