Skip to content

Tick Provider

A tick provider is an object that listen to your data source (database, api etc.) to stream Tick instances to your epics.


Base TickProvider Class

Abstract representation of a Tick Generator.

Attributes:

Name Type Description
epics List[estrade.epic.Epic]

list of Epics that can be used to generate Ticks in the run method.

__init__(self, epics) special

Define a Tick generator.

Parameters:

Name Type Description Default
epics List[estrade.epic.Epic]

A list of Epic instances

required
Source code in estrade/tick_provider.py
def __init__(self, epics: List[Epic]):
    """
    Define a [`Tick`][estrade.tick.Tick] generator.

    Arguments:
        epics: A list of Epic instances

    """
    # store epics in a dict with ref as key
    self.epics = {}
    for epic in epics:
        self.epics[epic.ref] = epic

get_epic_by_ref(self, ref)

Get an Epic by its reference.

Parameters:

Name Type Description Default
ref str

reference of Epic

required

Returns:

Type Description
Optional[estrade.epic.Epic]

Epic instance

Source code in estrade/tick_provider.py
def get_epic_by_ref(self, ref: str) -> Optional[Epic]:
    """
    Get an [`Epic`][estrade.epic.Epic] by its reference.

    Arguments:
        ref: reference of [`Epic`][estrade.epic.Epic]

    Returns:
        [`Epic`][estrade.epic.Epic] instance
    """
    return self.epics.get(ref)

run(self)

Run the tick provider.

Method to be implemented to generate Tick objects and attach them to the corresponding Epic.

Source code in estrade/tick_provider.py
def run(self) -> Generator[Tick, None, None]:
    """
    Run the tick provider.

    Method to be implemented to generate [`Tick`][estrade.tick.Tick] objects and
    attach them to the corresponding Epic.
    """
    raise NotImplementedError()