DirectFeedStore#

tradingstrategy.direct_feed.store.DirectFeedStore Python class in Trading Strategy framework.

class DirectFeedStore[source]#

Bases: object

Manage on-disk block header and trade cache for direct feeds.

Internally uses partitioned Parquet dataset storage. Each partition is a range of blocks and goes to different folder/file.

__init__(base_path, partition_size)[source]#

Initialise a new store.

Parameters:
  • base_path (Path) – Base folder where data is dumped. Both headers and trades get their own Parquet datasets as folders.

  • partition_size (int) – Partition size for the store. Expressed as number of blocks per parquet file.

Methods

__init__(base_path, partition_size)

Initialise a new store.

clear()

Clear cache.

is_empty()

Have we written anything to this store yer.

load_trade_feed(trade_feed)

Load trade and block header data.

save_trade_feed(trade_feed)

Save the trade and block header data.

__init__(base_path, partition_size)[source]#

Initialise a new store.

Parameters:
  • base_path (Path) – Base folder where data is dumped. Both headers and trades get their own Parquet datasets as folders.

  • partition_size (int) – Partition size for the store. Expressed as number of blocks per parquet file.

is_empty()[source]#

Have we written anything to this store yer.

Return type:

bool

clear()[source]#

Clear cache.

save_trade_feed(trade_feed)[source]#

Save the trade and block header data.

Parameters:

trade_feed (TradeFeed) – Save trades and block headers from this feed.

Returns:

Last saved header block number, last saved trade number

Return type:

Tuple[int, int]

load_trade_feed(trade_feed)[source]#

Load trade and block header data.

Parameters:

trade_feed (TradeFeed) – Save trades and block headers from this feed.

Returns:

True if any data was loaded.

Return type:

bool