Module type Strategy.S

val name : string
val version : string

Parameters

type params
val default_params : params
val params_of_assoc : (string * float) list -> (params, string) Stdlib.result

Validate and build params from the optimizer's flat representation. Return Error with a human-readable reason rather than clamping silently — a search that quietly clamps reports scores for points it never actually evaluated.

val params_to_assoc : params -> (string * float) list
val param_bounds : (string * float * float) list

(name, lo, hi) per tunable dimension. algostream.optimization builds its default search space from this.

Lifecycle

type state
val create : params:params -> symbols:string list -> state
val subscriptions : state -> subscription list
val on_event : state -> Context.t -> Event.t -> Action.t list

The callback. Returns the actions the strategy wants taken; the engine gates them against risk limits, assigns order ids, applies latency and routes them.

val on_stop : state -> Context.t -> Action.t list

Called once after the last market event. Emit flattening orders here if the strategy wants to end flat; the engine can also flatten unconditionally via its own config.

val diagnostics : state -> (string * float) list

Free-form counters surfaced in the backtest result — signals generated, entries skipped by a screen, and so on. Invaluable when a strategy does nothing and you need to know which gate closed.