Testing strategies
Because a strategy is a normal executable, you can poke it directly. The SDK gives every strategy three flags for free.
--algolang-describe prints the self-reported schema as JSON – name, description, and the inputs reflected from your struct tags:
$ bin/smacross --algolang-describe
{
"name": "SMA Crossover",
"description": "Goes long one unit when the fast SMA crosses above the slow SMA and ...",
"multi_symbol": false,
"inputs": [
{
"name": "Fast",
"type": "int",
"default": "3",
"description": "Fast SMA period in bars",
"min": "2",
"max": "200"
},
...
]
}--algolang-version prints the SDK version (go-0.1.0).
--algolang-selftest pushes a canned, deterministic 200-bar synthetic series through your strategy with no engine and no handshake – the quickest smoke test there is:
$ bin/smacross --algolang-selftest
processed 200 bars, emitted 0 orders
selftest OK(Zero orders is correct here: the synthetic series ramps monotonically, so the SMAs never cross. Your ctx.Log lines come out on stderr during a selftest, as bin/hello --algolang-selftest will happily demonstrate 200 times.)
Raw-CSV replay: pipe bars in by hand
The deepest engine-free test: when the first line on stdin is not an engine handshake, the SDK drops into replay mode and treats stdin as raw CSV protocol lines, one response line per bar, until EOF. Build a fixture from the sample bars and pipe it in:
{ echo 'init,replay,1970-01-01T00:00:00Z,1970-01-01T00:00:00Z,[],[Fast:3|Slow:8]'
awk -F, 'NR > 1 { printf "bar,%s,%s,%s,%s,%s,%s,%s\n", $1, $3, $4, $5, $6, $7, $8 }' \
testdata/msft-1m.csv
} > /tmp/replay.csv
bin/smacross < /tmp/replay.csvALGO/1 protocols=stdio-pb-v1,stdio-csv-v2,stdio-csv-v1 sdk=go-0.1.0
init_ack,9,[],true,false,SMA Crossover,Goes long one unit when the fast SMA ...
noop
noop
...
log,INFO,smacross: fast SMA(3) crossed below slow SMA(8); selling 1 MSFT
order,MSFT,sell,1,market
log,INFO,smacross: fast SMA(3) crossed above slow SMA(8); buying 1 MSFT
order,MSFT,buy,1,market
noop
...
Note the first stdout line is always the SDK’s hello line – it is written before the SDK can know there is no engine listening. Pipe consumers should sed 1d it away (or filter for ^(order,|noop$) as the cross-language parity script scripts/smacross-crosscheck.sh does). Replay mode is how the Go, Python, and Rust smacross implementations are proven decision-identical.