BinanceElixir.Clock (binance_elixir v0.2.1)

Copy Markdown View Source

A supervised clock with a Binance server-time offset.

Supply clock: fn -> BinanceElixir.Clock.now(clock) end when constructing a client. Synchronize before signed requests and periodically thereafter.

Summary

Functions

Returns a specification to start this module under a supervisor.

Reads /api/v3/time and applies the midpoint offset estimate.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

now(clock)

@spec now(GenServer.server()) :: non_neg_integer()

offset_ms(clock)

@spec offset_ms(GenServer.server()) :: integer()

start_link(opts \\ [])

@spec start_link(keyword()) :: GenServer.on_start()

synchronize(client, clock)

@spec synchronize(BinanceElixir.t(), GenServer.server()) ::
  {:ok, integer()} | {:error, BinanceElixir.Error.t()}

Reads /api/v3/time and applies the midpoint offset estimate.