Skip to main content

Strategies API Overview

The Strategies API lets you create, configure, deploy, and manage automated trading strategies on the PipAI platform.

A strategy is a parameterized template (entry rules, exit rules, risk caps) plus an execution context (symbol, timeframe, capital allocation). The API supports the full lifecycle: create → backtest → deploy → monitor → pause.

This module covers:

  • REST endpoints for strategy CRUD, deployment, and pause.
  • WebSocket subscription for real-time strategy status changes.

See Quick Start for an end-to-end example.

What is a strategy?

On PipAI, a strategy is composed of three things:

  1. A template — referenced by template_id (e.g. tpl_grid, tpl_dca, tpl_momentum, tpl_meanrev). Templates are vetted, versioned algorithms hosted by the platform; they encapsulate entry/exit logic, signal generation, and risk management.
  2. Params — a free-form JSON object passed straight to the template. Each template defines its own param schema (e.g. grid_levels, upper_price, rebalance_threshold).
  3. An execution context — the symbols, timeframe, capital, leverage, and dry_run flag that determine how and where the template runs.

The platform itself does not interpret params. They are validated against the template schema at deploy time and then forwarded to the template runtime.

Strategy lifecycle

A strategy moves through a small state machine:

draft → deployed → paused → stopped
↘ error ↗
StatusMeaning
draftCreated but not running. Editable. Safe to delete.
deployedLive; the engine is evaluating signals and may place real orders (or simulated orders if dry_run).
pausedThe engine has stopped opening new positions. Existing positions remain open unless close_positions was set on pause. Editable.
stoppedTerminated by the user. Not resumable.
errorThe engine halted due to an unrecoverable error (e.g. invalid params, exchange auth failure). Inspect via the WebSocket error event or the Get Strategy endpoint.

Transitions are driven by the Deploy, Pause, and Stop (covered in a later module) endpoints, plus internal engine events.

Key concepts

ConceptNotes
template_idSlug identifying the algorithm. Format: tpl_<name>.
paramsTemplate-specific JSON. Opaque to the platform.
symbolsExchange-style uppercase tickers (e.g. BTCUSDT). One or more.
timeframeCandle interval the template operates on (e.g. 1m, 5m, 1h, 1d).
capitalQuote-currency notional allocated to the strategy. Decimal string.
leverageInteger multiplier applied at deploy time. Default 1, max 20.
dry_runWhen true, the engine consumes live market data and emits the same WebSocket events as a live run, but no orders are placed on the exchange. Useful for paper-trading.

Common workflows

  • Backtest-then-deploy: Create a draft strategy, run a backtest job against it (see Backtesting module), inspect the report, then deploy with the same params.
  • Multi-symbol grid: Pass several symbols in one strategy; the engine allocates capital across them according to the template's allocation rule.
  • Paper-trade-via-dry-run: Deploy with dry_run: true to verify behaviour against live market data without exchange risk, then redeploy with dry_run: false once confirmed.