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
+110 -4
View File
@@ -255,9 +255,115 @@ Response 204:
- No content.
## 5. Common Error Examples
## 5. Strategy Sets
### 5.1 Missing token
### 5.1 GET /strategy-sets
Request:
```bash
curl -X GET "http://localhost:8000/strategy-sets" \
-H "Authorization: Bearer <READ_TOKEN>"
```
Response 200:
```json
[
{
"id": "set-1",
"name": "target_value",
"config": "{\"target\": 1000}",
"nick": "target_value:abc123def456",
"created_at": "2026-04-03T08:13:08.318Z"
},
{
"id": "set-2",
"name": "momentum",
"config": "{\"window\": 20}",
"nick": "momentum:xyz789uvw012",
"created_at": "2026-04-03T08:14:15.450Z"
}
]
```
### 5.2 POST /strategy-sets
Request:
```bash
curl -X POST "http://localhost:8000/strategy-sets" \
-H "Authorization: Bearer <TRADE_WRITE_TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"name": "target_value",
"config": "{\"target\": 1000}"
}'
```
Response 201:
```json
{
"id": "set-1",
"name": "target_value",
"config": "{\"target\": 1000}",
"nick": "target_value:abc123def456",
"created_at": "2026-04-03T08:13:08.318Z"
}
```
### 5.3 PATCH /strategy-sets/{strategy_set_id}
Request:
```bash
curl -X PATCH "http://localhost:8000/strategy-sets/set-1" \
-H "Authorization: Bearer <TRADE_WRITE_TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"config": "{\"target\": 2000}"
}'
```
Response 200:
```json
{
"id": "set-1-updated",
"name": "target_value",
"config": "{\"target\": 2000}",
"nick": "target_value:def789ghi012",
"created_at": "2026-04-03T08:13:08.318Z"
}
```
Note: Since strategy sets are identified by (name, config) uniqueness, updating may result in a new strategy set ID.
### 5.4 DELETE /strategy-sets/{strategy_set_id}
Request:
```bash
curl -X DELETE "http://localhost:8000/strategy-sets/set-1" \
-H "Authorization: Bearer <TRADE_WRITE_TOKEN>"
```
Response 204:
- No content on success.
Response 409 Conflict (if strategy set is in use):
```json
{
"detail": "Strategy set is in use by 1 portfolio(s) and cannot be deleted"
}
```
## 6. Common Error Examples
### 6.1 Missing token
Response 401:
@@ -267,7 +373,7 @@ Response 401:
}
```
### 5.2 Invalid token
### 6.2 Invalid token
Response 401:
@@ -277,7 +383,7 @@ Response 401:
}
```
### 5.3 Insufficient permission
### 6.3 Insufficient permission
Response 403: