load_pair_data_for_single_exchange#

load_pair_data_for_single_exchange(client, execution_context, time_bucket, chain_id, exchange_slug, pair_tickers, liquidity=False)[source]#

Load pair data for a single decentralised exchange.

If you are not trading the full trading universe, this function does a much smaller dataset download than load_all_data().

  • This function uses optimised JSONL loading via fetch_candles_by_pair_ids().

  • Backtest data is never reloaded. Furthermore, the data is stored in Client disk cache for the subsequent notebook and backtest runs.

  • Live trading purges old data fields and reloads data

Example:

# Time bucket for our candles
candle_time_bucket = TimeBucket.d1

# Which chain we are trading
chain_id = ChainId.bsc

# Which exchange we are trading on.
exchange_slug = "pancakeswap-v2"

# Which trading pair we are trading
trading_pairs = {
    ("WBNB", "BUSD"),
    ("Cake", "WBNB"),
}

# Load all datas we can get for our candle time bucket
dataset = load_pair_data_for_single_exchange(
    client,
    execution_context,
    candle_time_bucket,
    chain_id,
    exchange_slug,
    trading_pairs,
)
Parameters
  • client (Client) – Trading Strategy client instance

  • time_bucket (TimeBucket) – The candle time frame

  • chain_id (ChainId) – Which blockchain hosts our exchange

  • exchange_slug (str) – Which exchange hosts our trading pairs

  • exchange_slug – Which exchange hosts our trading pairs

  • pair_tickers (Set[Tuple[str, str]]) – List of trading pair tickers as base token quote token tuples. E.g. [(‘WBNB’, ‘BUSD’), (‘Cake’, ‘BUSD’)].

  • liquidity – Set true to load liquidity data as well

  • execution_context (ExecutionContext) – Defines if we are live or backtesting

Return type

Dataset