Strategy inputs

A strategy’s tunable parameters are exported struct fields with an algolang: tag:

type SmaCross struct {
    Fast int `algolang:"default=3,min=2,max=200,desc=Fast SMA period in bars"`
    Slow int `algolang:"default=8,min=3,max=400,desc=Slow SMA period in bars (expected greater than Fast)"`
    // untagged fields are private state, invisible to the engine
}

The SDK reflects over the tags at startup, applies defaults, then applies whatever the engine sends (--inputs Fast=2,Slow=6 on the CLI, or an inputs object in a config file). Try it:

bin/algo run ... --strategy bin/smacross --inputs Fast=2,Slow=6 --symbol MSFT --interval 1m

That run produced 6 orders instead of 3 – a twitchier crossover.

The full tag grammar – a comma-separated list of key=value elements:

ElementMeaning
default=VValue applied before the engine’s inputs arrive. Without it the field keeps its Go zero value.
values=[a,b,c]Enumerated allowed set. Any other supplied value is a fatal init error. Mutually exclusive with min/max/by.
min=V, max=VNumeric (or duration) bounds, enforced on supplied values.
by=VStep hint, reported to optimizers in the input schema. Not enforced.
desc=textHuman description, shown by --algolang-describe and in the init handshake.
requiredBare marker (no =): a fatal error if the engine does not supply the input.

Supported field types: int, int64, float64, bool, string, and time.Duration. An engine-supplied input that names no tagged field is a warning and is skipped; a type or constraint violation is fatal.

The single-quote rule. Go struct tags are themselves double-quoted, so the tag grammar uses single quotes to protect free text that contains commas – otherwise the comma would end the element:

MaxPos int `algolang:"default=2,desc='Max positions, long and short'"`

Quoting is optional everywhere else, and the elements inside a values=[...] list can never be quoted. One thing tags cannot express is a cross-field constraint; smacross enforces Fast < Slow in OnInit instead, turning a silent misconfiguration into a clean init failure.