feat: add strategy set CRUD operations (API + CLI)

This commit is contained in:
2026-04-03 08:37:04 +00:00
parent 908068d9aa
commit 1b0991c9cf
12 changed files with 510 additions and 5 deletions
+51 -1
View File
@@ -208,7 +208,40 @@ Base routes:
- `keep_ledger` (bool, default `false`)
- Response `204`: no content
### 7.3 Example Requests and Responses
### 7.3 Strategy Set Endpoints
#### List Strategy Sets
- `GET /strategy-sets`
- Auth: `read`
- Response `200`: array of `StrategySetResponse`
#### Create Strategy Set
- `POST /strategy-sets`
- Auth: `trade-write`
- Body: `CreateStrategySetRequest`
- Response `201`: `StrategySetResponse`
Note: Uses `get_or_create_strategy_set` logic, so if (name, config) pair already exists, returns existing strategy set.
#### Update Strategy Set
- `PATCH /strategy-sets/{strategy_set_id}`
- Auth: `trade-write`
- Body: `UpdateStrategySetRequest`
- Response `200`: `StrategySetResponse`
Note: Since strategy sets are identified by (name, config) uniqueness, updating may result in a new strategy set ID if name or config changes.
#### Delete Strategy Set
- `DELETE /strategy-sets/{strategy_set_id}`
- Auth: `trade-write`
- Response `204`: no content
- Response `409`: Conflict if strategy set is in use by any portfolio
### 7.4 Example Requests and Responses
- See `docs/api-examples.md` for maintained request/response examples.
@@ -266,6 +299,16 @@ Base routes:
- `infer_symbol: str | null`
`CreateStrategySetRequest`
- `name: str`
- `config: str`
`UpdateStrategySetRequest` (all fields optional)
- `name: str | null`
- `config: str | null`
### 8.2 Response Models
`PortfolioListItem`
@@ -336,6 +379,13 @@ Portfolio subcommands:
- `portfoliohub portfolio reset <portfolio_id> [--infer-symbol ...] [--force]`
- `portfoliohub portfolio delete <portfolio_id> [--keep-ledger] [--force]`
Strategy subcommands:
- `portfoliohub strategy list`
- `portfoliohub strategy create --name ... --config ...`
- `portfoliohub strategy update <strategy_set_id> [--name ...] [--config ...]`
- `portfoliohub strategy delete <strategy_set_id> [--force]`
Confirmation behavior:
- Mutating portfolio commands request confirmation by default.