MarketDeck docs
strategies
Generate, validate, inspect, test, and remove user-defined backtest strategies.
User-defined strategies are JSON files compiled into runnable init / evaluate functions by the backtester. The CLI can generate starter JSON, lint and validate it, smoke-test it against historical data, and persist it for marketdeck backtest.
Usage#
marketdeck strategies <subcommand> [args]
Subcommands#
| Subcommand | What it does | ||
|---|---|---|---|
list | Strategy names + parameter summary. | ||
add --file PATH / add --stdin | Validate and persist a strategy JSON file. | ||
show <id> | Full JSON source pre-compile. | ||
validate <id> / validate --file P | Compile plus synthetic smoke test. | ||
test <id> / test --file P | Run the strategy through the backtester. | ||
| `generate --id ID --name NAME [--style trend | mean-reversion] [--save]` | Emit or save a starter strategy. | |
| `template [--style trend | mean-reversion]` | Emit generic starter JSON. | |
lint <id> / lint --file P | Structural checks without saving. | ||
explain <id> / explain --file P | Plain-language summary and parameter defaults. | ||
version <id> [--tag T] | Snapshot a custom strategy JSON into an immutable versions folder. | ||
| `diff <id | file> <id | file>` | Compare two strategy JSON sources field-by-field. |
remove <id> | Delete the JSON file. Built-ins cannot be removed. |
Examples#
marketdeck strategies list --format text
marketdeck strategies template --style trend --format text
marketdeck strategies generate --id btc-trend --name "BTC Trend" --save
marketdeck strategies lint btc-trend
marketdeck strategies validate btc-trend
marketdeck strategies test btc-trend --coin BTC --interval 1h --lookback-days 30
marketdeck strategies version btc-trend --tag pre-prod
marketdeck strategies diff btc-trend ./candidate.json
marketdeck strategies show my-rsi --format json
marketdeck strategies remove my-rsi
Where strategies live#
Built-ins ship with the CLI under core/strategies/. Custom strategies live as one JSON file each at:
~/.local/share/marketdeck/custom-strategies/<id>.json
The compiler in core/custom-strategies.js reads the init_body and evaluate_body strings, wraps them in Function(...), and runs them inside the same backtester loop the built-ins use.
Generated templates use the same trade-decision contract as built-ins: return {direction: "long"|"short", stop_loss, take_profits, leverage} to open a position, {close: true} to exit, or null to do nothing.