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:
- 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. - 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). - An execution context — the
symbols,timeframe,capital,leverage, anddry_runflag 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 ↗
| Status | Meaning |
|---|---|
draft | Created but not running. Editable. Safe to delete. |
deployed | Live; the engine is evaluating signals and may place real orders (or simulated orders if dry_run). |
paused | The engine has stopped opening new positions. Existing positions remain open unless close_positions was set on pause. Editable. |
stopped | Terminated by the user. Not resumable. |
error | The 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
| Concept | Notes |
|---|---|
template_id | Slug identifying the algorithm. Format: tpl_<name>. |
params | Template-specific JSON. Opaque to the platform. |
symbols | Exchange-style uppercase tickers (e.g. BTCUSDT). One or more. |
timeframe | Candle interval the template operates on (e.g. 1m, 5m, 1h, 1d). |
capital | Quote-currency notional allocated to the strategy. Decimal string. |
leverage | Integer multiplier applied at deploy time. Default 1, max 20. |
dry_run | When 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
draftstrategy, 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: trueto verify behaviour against live market data without exchange risk, then redeploy withdry_run: falseonce confirmed.