CandleFeed#

API documentation for tradingstrategy.direct_feed.candle_feed.CandleFeed Python class in Trading Strategy framework.

class CandleFeed[source]#

Bases: object

Create candles for certain time frame for multiple pairs.

  • Takes TradeFeed as input

  • Generates candles based on this feed

  • Can only generate candles of one timeframe

  • May contain multiple pairs in one candle feed

__init__(pairs, timeframe)[source]#
Parameters:
  • pairs (List[str]) –

    List of pairs this address contains.

    Symbolic names or addresses.

  • freq – Pandas frequency string e.g. “1H”, “min”

  • candle_offset

  • timeframe (Timeframe) –

Methods

__init__(pairs, timeframe)

param pairs:

apply_delta(delta[, initial_load, label_candles])

Add new candle data generated from the latest blockchain input.

get_candles_by_pair(pair)

get_last_block_number()

Get overall last block number for which we have valid data.

iterate_pairs()

Get candles for all pairs we are tracking.

__init__(pairs, timeframe)[source]#
Parameters:
  • pairs (List[str]) –

    List of pairs this address contains.

    Symbolic names or addresses.

  • freq – Pandas frequency string e.g. “1H”, “min”

  • candle_offset

  • timeframe (Timeframe) –

apply_delta(delta, initial_load=False, label_candles=True)[source]#

Add new candle data generated from the latest blockchain input.

Parameters:
  • delta (TradeDelta) – New trades coming in

  • initial_load

    This is not an incremental snapshot, but initial buffer fill.

    Ignore delta.start_ts and fill the candle buffer as long as we get data.

  • label_candles

    Create and update label column.

    Label column contains tooltips for the visual candle viewer. This must be done before candle data is grouped by pairs.

get_last_block_number()[source]#

Get overall last block number for which we have valid data.

Returns:

block number (inclusive)

Return type:

int

iterate_pairs()[source]#

Get candles for all pairs we are tracking.

Return type:

Iterable[DataFrame]