Module Algostream_domain_common.Timestamp

type t = private Base.float
val now : Base.unit -> t

Wall-clock read. Backed by Unix.time (), so the resolution is whole seconds — adequate for stamping long-lived records, useless for intra-second ordering. Event-time-deterministic layers (backtest, analytics, time_series, pairs, …) must never call this; they pass explicit ts_ns through of_ns.

val of_float : Base.float -> t
val of_sec_float : Base.float -> t
val of_ms_float : Base.float -> t
val of_us_float : Base.float -> t
val of_ns : Base.int64 -> t

Build a timestamp from nanoseconds since the epoch — the event-time representation carried by Event.t.timestamp_ns, Bar.t.open_ts, and every ~ts_ns parameter in the analytical layers.

Precision. t is a float64 count of seconds since the epoch. At present-day epoch values (~1.8e9 s) the 53-bit mantissa resolves to roughly 240 ns, so of_ns is not exactly invertible by to_ns at nanosecond granularity. That is well inside bar- and tick-level backtesting needs; do not use these for latency accounting, where Time_utils.Clock.now_monotonic_ns and raw int64 ns are the right tools.

val to_float : t -> Base.float
val to_sec_float : t -> Base.float
val to_ms_float : t -> Base.float
val to_us_float : t -> Base.float
val to_ns : t -> Base.int64

Inverse of of_ns, rounded to nearest. Subject to the same ~240 ns precision floor.

val to_string : t -> Base.string
val epoch : t
val diff : t -> t -> Base.float
val add : t -> Base.float -> t
val sub : t -> Base.float -> t
val (+) : t -> Base.float -> t
val (-) : t -> Base.float -> t
val equal : t -> t -> Base.bool
val (=) : t -> t -> Base.bool
val (<>) : t -> t -> Base.bool
val (<) : t -> t -> Base.bool
val (<=) : t -> t -> Base.bool
val (>) : t -> t -> Base.bool
val (>=) : t -> t -> Base.bool
val compare : t -> t -> Base.int
val min : t -> t -> t
val max : t -> t -> t
module Span : sig ... end
module Span_constants : sig ... end