← Cookbook

✅ runnablePython ✓TypeScript ✓

Recipe 04 — Set up a DCA strategy programmatically

Status: ✅ runnable SDK surface: client.strategies.create(kind="DCA", params=...) Server endpoint: POST /v1/strategies TZ reference: TZ-3 §4.8 (strategy kinds), TZ-3 §17 (validation phases)

Creates a Dollar-Cost-Averaging strategy that buys $500 worth of ETH every day from a $5 000 USDC deposit. The strategy starts in draft status; promote through the M3-S1 7-phase validation pipeline (or call client.strategies.validate(...)) to reach ready then running.

PYTHONPATH=packages/sdk-py/src python cookbook/recipes/04-dca-strategy/python_example.py
npx tsx cookbook/recipes/04-dca-strategy/typescript_example.ts

Expected: prints the new instance_id + status="draft". Use recipe 05 to pause/resume.

Source: cookbook/recipes/04-dca-strategy/README.md