Epic

Class used to define an Epic

Parameters

Name Type Description Default
ref str reference/name of the epic required
candle_sets List[CandleSet] list of CandleSets attached to market required
timezone str epic timezone 'UTC'
ticks_in_memory int nb ticks kept in the ticks attribute 1

candle_sets: List[_ForwardRef('CandleSet')] (property, writable)

Returns

Type Description
List[_ForwardRef('CandleSet')] List of CandleSet attached to epic

timezone: str (property, writable)

Returns

Type Description
str epic timezone (see pytz.all_timezones)

get_candle_set(self, timeframe)

Show source code in estrade/epic.py
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
    def get_candle_set(self, timeframe: str) -> 'CandleSet':  # noqa: F821
        """
        Get candle_set by timeframe in this instance candle_set

        Arguments:
            timeframe: timeframe of CandleSet to find in epic

        Returns:
            CandleSet associated with the required timeframe

        """
        for cs in self.candle_sets:
            if cs.timeframe == timeframe:
                return cs
        raise EpicException(
            'No candleSet found with timeframe %s in epic %s' % (timeframe, self.ref)
        )

Get candle_set by timeframe in this instance candle_set

Parameters

Name Type Description Default
timeframe str timeframe of CandleSet to find in epic required

Returns

Type Description
CandleSet CandleSet associated with the required timeframe

on_new_tick(self, tick)

Show source code in estrade/epic.py
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
    def on_new_tick(self, tick: 'Tick') -> None:  # noqa: F821
        """
        Method used to handle every new tick received by market.

        Its purpose is to:

         - check the tick received
         - update the epic/max min
         - dispatch tick to CandleSets

        Arguments:
            tick: tick received by epic

        """
        if tick.epic != self:
            raise EpicException(
                'Invalid tick epic: cannot update epic {}({}) with '
                'tick attached to epic {}({})'.format(
                    self.ref, id(self), tick.epic.ref, id(tick.epic)
                )
            )

        logger.debug(
            'Add new tick to epic %s (%s): %f' % (self.ref, id(self), tick.value)
        )
        self._check_timezone(tick)

        # set tick as the current tick
        self._add_tick(tick)

        # dispatch tick to all candle sets
        for candle_set in self.candle_sets:
            logger.debug('dispatch tick to candle set %s' % candle_set.timeframe)
            candle_set.on_new_tick(tick)

Method used to handle every new tick received by market.

Its purpose is to:

  • check the tick received
  • update the epic/max min
  • dispatch tick to CandleSets

Parameters

Name Type Description Default
tick Tick tick received by epic required