DiskIndicatorStorage#

API documentation for tradeexecutor.strategy.pandas_trader.indicator.DiskIndicatorStorage Python class in Trading Strategy framework.

class DiskIndicatorStorage[source]#

Bases: IndicatorStorage

Store calculated indicator results on disk.

Used in

  • Backtesting

  • Grid seacrh

Indicators are calculated once and the calculation results can be recycled across multiple backtest runs.

How to initialise in the notebook:

indicator_storage = DiskIndicatorStorage.create_default(strategy_universe)

TODO: Cannot handle multichain universes at the moment, as serialises trading pairs by their ticker.

__init__(path, universe_key)[source]#
Parameters:
  • path (Path) –

  • universe_key (str) –

Methods

__init__(path, universe_key)

create_default(universe[, default_path])

Get the indicator storage with the default cache path.

get_disk_cache_path()

get_indicator_path(key)

Get the Parquet file where the indicator data is stored.

get_universe_cache_path()

is_available(key)

load(key)

Load cached indicator data from the disk.

save(key, df)

Atomic replacement of the existing data.

__init__(path, universe_key)[source]#
Parameters:
  • path (Path) –

  • universe_key (str) –

get_indicator_path(key)[source]#

Get the Parquet file where the indicator data is stored.

Returns:

Example /tmp/…/test_indicators_single_backtes0/ethereum,1d,WETH-USDC-WBTC-USDC,2021-06-01-2021-12-31/sma(length=21).parquet

Parameters:

key (IndicatorKey) –

Return type:

Path

load(key)[source]#

Load cached indicator data from the disk.

Parameters:

key (IndicatorKey) –

Return type:

IndicatorResult

save(key, df)[source]#

Atomic replacement of the existing data.

  • Avoid leaving partially written files

Parameters:
  • key (IndicatorKey) –

  • df (pandas.core.frame.DataFrame | pandas.core.series.Series) –

Return type:

IndicatorResult

static create_default(universe, default_path=PosixPath('/home/runner/.cache/indicators'))[source]#

Get the indicator storage with the default cache path.

Parameters:

universe (TradingStrategyUniverse) –

Return type:

DiskIndicatorStorage