Desic Terminal

Documentation

Systematic Strategy

Python strategy authoring, backtests, parameter tuning and live Profiles end to end.

English (current) · 简体中文

Write Python strategies → backtest on history → tune parameters → live Profiles: Desic Terminal's systematic research takes a strategy from idea to auditable automated execution — without installing Python.


1. Core Concepts#

ConceptMeaning
StrategyPython source + parameters, executed locally through a controlled protocol
VersionAn immutable snapshot of strategy source and parameters; backtests and Profiles bind specific versions
BacktestSimulates the strategy over historical candles under fill assumptions, producing an equity curve, fills and statistics
OptimizationDeterministic sampling across a parameter space, evaluated by Calmar on train/validation splits to find robust parameters
ProfileBinds a strategy version, contract, account and risk budgets into a live signal executor
SignalThe result of each 1-minute close evaluation: action, block reason or execution error

The six workflow tabs:

text
Strategy (write/version) → Backtest → Tuning → Review (result library) → Profiles (live) → Signals (history)

2. Runtime Environment#

  • No Python install: the installer ships a checksum-verified CPython runtime; opening Systematic Research for the first time prepares a local environment and installs a fixed dependency set (numpy, pandas, scikit-learn, …) automatically, with progress shown under the workspace header.
  • The environment is dependency isolation: strategies can only import the allowlisted libraries and have no network, file-system or subprocess access.
  • Failures get actionable guidance; development builds without the bundled runtime fall back to a system Python 3.12–3.13.

3. Create a Strategy#

The strategy research workbench: Python editor, parameter panel and immutable version history, with AI assistance available alongside.

Strategy → New, starting from one of four templates:

TemplateFits
blank.pyEmpty skeleton, write from scratch
ema-trend.pyDual-EMA trend following
macd-volume-atr.pyMACD + volume + ATR protection
bollinger-reversion.pyBollinger mean reversion

Editing experience

  • Built-in CodeMirror editor; every save creates a new version.
  • AI strategy assistant: the right-hand panel supports multi-turn discussion of strategy ideas, lets the AI edit code and runs bounded tests in the controlled environment; its sessions are saved under the "AI strategies" category.
  • Backtests, tuning and Profiles always reference a specific version — older results are never affected by new edits.

4. Strategy Programming Model#

A strategy is a Python module implementing on_bar:

python
def on_bar(ctx):
    # ctx: read-only context at the current decision point (after a confirmed 1m close)
    close = ctx.market_series("1m").close(-1)          # latest close
    ema_fast = ctx.indicator("ema", period=13).value(-1)
    ema_slow = ctx.indicator("ema", period=26).value(-1)

    fast = float(ctx.params.get("fastPeriod", "13"))
    slow = float(ctx.params.get("slowPeriod", "26"))

    if ema_fast > ema_slow and ctx.flat():
        return ctx.open_long(reason="fast crossed above slow")
    if ema_fast < ema_slow and ctx.position("long"):
        return ctx.close(reason="fast crossed below slow")
    return ctx.no_action(reason="waiting for a cross")

Capabilities

CapabilityMeaning
ctx.market_series(interval)Candles of any built-in timeframe (1m – 1M), containing only bars confirmed up to the decision point
ctx.indicator(...)Rolling built-in indicator computation, no full recomputation per bar
ctx.params.get(key, default)Parameter access, strings or numbers
ctx.flat() / ctx.position(side)Current position state
ctx.open_long / open_shortOpen intents, optionally with protection parameters
ctx.closeClose intent
ctx.no_action(reason)Explicit idle

Hard constraints

  • One action per bar; actions are intents — fills and sizing are decided by the host.
  • No future data: a bar's close time must never exceed the decision point (double-checked by host and runtime).
  • No imports outside the allowlist, no file/network/subprocess access.

See the strategy protocol for the full specification.


5. Historical Backtesting#

Backtest results and replay: evaluation window, ending equity, maximum drawdown and the fill ledger, replayable candle by candle.

Backtest → configure → Run backtest

ParameterMeaning
Strategy & versionPick the strategy and a concrete version
ContractThe backtest symbol (e.g. BTC-USDT-SWAP)
Initial equity / leverageStarting account and leverage
Evaluation rangeFormal evaluation start and end (up to one year)
Preload historyContext candles before evaluation start (indicator warm-up only — excluded from equity and statistics)
Fill assumptionsEntry/exit slippage and fees, margin safety multiplier
End-of-run policyMark to last close / force close

Results land in the Review tab:

  • Equity curve, max drawdown, win rate, profit factor and more
  • Fill details and closed trades
  • Bar-by-bar replay: drag the timeline to inspect equity, position, actions and signal reasons at any moment

6. Replay and Review#

The replay view in Review is the key tool for debugging strategy behavior:

  1. Drag the timeline to the target range (pages load on demand; timeouts prompt a retry).
  2. Inspect the position, orders, equity and the strategy's action reason at that exact bar.
  3. Cross-check the right-hand parameters and fills to understand why the strategy decided as it did.

7. Parameter Tuning#

Tuning → configure the parameter space → Run tuning

SettingMeaning
Candidate budget30 / 100 / 300 candidate parameter sets (deterministic sampling)
Parameter spaceMin / max / step per parameter
Train/validationThe evaluation range splits 7:3 — search on train, confirm on validation
MetricValidation Calmar (annualized return / max drawdown)

After tuning finishes:

  • The workbench shows candidates, train/validation metrics and estimated time remaining; cancel anytime.
  • Adopt best parameters: writes the best set into the current draft and saves a new version in one click (run an independent backtest afterwards to confirm).
  • Tuning only works on the draft — it never silently modifies a saved version.

8. Live Strategy Profiles#

A Profile turns a strategy version into a live signal executor:

Bound at creation (fixed while enabled)

  • Strategy and exact version, contract
  • Account and environment (demo / live)
  • Cross/isolated margin, target leverage, direction permissions
  • Per-entry margin budget and same-side total budget
  • Daily realized-loss limit, entry cooldown
  • Protections: TP/SL directions statically declared by the strategy source (market or trigger-after-limit)

How it runs

  • Reuses the subscribed 1-minute candles: one on_bar evaluation per confirmed close.
  • Before evaluating, the host waits for the just-closed candle to settle locally and re-verifies the confirmed cutoff; a failed repair skips the cycle with a real diagnostic — it never evaluates a partial window.
  • The strategy only returns open/close intents; the host converts eligible opens into contract counts from fresh equity, the execution price, instrument value and lot-size rules, then routes through risk checks and idempotent submission.

Activation requirements

  • The strategy version and contract have a completed backtest
  • Local Python environment ready
  • Account read and trade permissions
  • Conflict review against enabled AI automation on the same account
  • Explicit confirmation every time a live Profile is enabled

9. Signal History#

The Signals tab shows every evaluation, filterable by Profile:

FieldMeaning
TimeConfirmed close time of the 1-minute candle
ActionOpen long/short, close intent, or idle
Block reasonThe risk rule that blocked the action (budget, loss limit, cooldown, …)
OrderOrder identifiers after submission
ErrorThis cycle's strategy, snapshot or execution error

A single-cycle error does not stop the Profile immediately (normal risk rules still block the affected action); consecutive failures trigger an auto-stop safeguard. Strategy signals and blocked actions can be pushed to Feishu per notification settings.


10. Best Practices#

  1. Backtest before live: no version binds a Profile without a completed backtest.
  2. Few parameters first: fix most parameters and tune only 2–3 key ones to avoid dimension explosion.
  3. Out-of-sample validation: beware overfitting when validation results differ sharply from the search range.
  4. Protections live in the source: TP/SL directions are statically declared by the strategy source — the host never invents a missing protection.
  5. Start small live: begin with a minimal margin budget and a strict daily loss limit; scale after accumulating signal history.
  6. Read signal history regularly: blocked actions and errors matter more than fills — they show whether risk controls work as intended.

11. FAQ#

Q: Do I need to install Python? No. The runtime ships inside the installer; Systematic Research prepares the environment on first open (network needed for dependencies).

Q: Why do backtests differ from live? Backtests use confirmed 1-minute candles and fill assumptions (slippage, fees, mark policy); live matching, order queues and funding all differ.

Q: Can a strategy hold long and short at once? No. The runtime keeps a single position state, and a strategy returns exactly one action per decision point.

Q: Can tuning results go live directly? Recommended: adopt the best parameters as a new version → confirm with an independent backtest → then create a Profile from that version.

Q: Does a Profile modify my strategy version? No. Profiles bind immutable version snapshots; editing the source creates a new version while enabled Profiles keep the old one.

View source on GitHub