Skip to content

LiveTimer fires immediately regardless of the interval if start time is not set #2270

Closed
@bartolootrit

Description

@bartolootrit

Bug Report

Expected Behavior

LiveTimer fires after the user-defined interval if start time is not set

Actual Behavior

LiveTimer fires immediately

Steps to Reproduce the Problem

Start a timer in a strategy: self.clock.set_timer('test', interval, callback=self.on_time_event).
The callback is called immediately.

Start a timer in a different way: self.clock.set_timer('test', interval, start_time=self.clock.utc_now(), callback=self.on_time_event).
The callback is called after interval.

start_time_ns is explicitly set to zero (if empty) here: start_time_ns=maybe_dt_to_unix_nanos(start_time) or 0,
but zero value isn't expected here: next_time_ns: Arc::new(AtomicU64::new(start_time_ns.as_u64() + interval_ns.get())),
and here: let start = if next_time_ns <= now_ns { Instant::now() }

Specifications

  • OS platform: Docker image python:3.12
  • Python version: 3.12
  • nautilus_trader version: develop branch

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions