snap_to_previous_tick#

snap_to_previous_tick(ts, tick_size, offset=datetime.timedelta(0))[source]#

Calculate what should the tick time for given real time.

If ts matches the tick, do nothing.

If cycle duration is unknown do nothing.

Parameters:
  • ts (datetime) – Current timestamp

  • tick_size (CycleDuration) – How big leaps we are taking

  • offset (timedelta) – How many minutes of offset we assume to ensure we have candle data generated after the timestamp

Returns:

What tick are we living in

Return type:

datetime