feat: update strategy set schema fields

This commit is contained in:
2026-04-03 08:03:27 +00:00
parent 3eae90a9ab
commit ebd4559939
13 changed files with 131 additions and 37 deletions
+3 -2
View File
@@ -114,8 +114,9 @@ Response 200:
],
"strategy_set": {
"id": "stv-001",
"strategy_name": "target_value",
"strategy_config": "{}",
"name": "target_value",
"config": "{}",
"nick": "target_value:99914b932bd3",
"created_at": "2026-04-03T00:00:00Z"
},
"live_quantity": null
+10 -5
View File
@@ -5,8 +5,10 @@
This document defines the database schema in an AI-agent-friendly format.
- Source of truth: Alembic revisions in `migrations/versions`
- Current baseline revision: `20260403_0001`
- Baseline file: `migrations/versions/20260403_0001_initial_portfolio_schema.py`
- Current baseline revision: `20260403_0002`
- Baseline files:
- `migrations/versions/20260403_0001_initial_portfolio_schema.py`
- `migrations/versions/20260403_0002_strategy_set_columns.py`
## 2. Scope
@@ -38,14 +40,16 @@ Columns:
| Column | Type | Null | Default | Constraints / Notes |
|---|---|---|---|---|
| id | Text | NO | - | Primary Key |
| strategy_name | Text | NO | - | Part of unique pair |
| strategy_config | Text | NO | "" | Part of unique pair |
| name | Text | NO | - | Strategy name, part of unique pair |
| config | Text | NO | "" | Strategy config payload, part of unique pair |
| nick | Text | NO | - | Unique strategy set nickname |
| created_at | DateTime(timezone=True) | NO | NOW() | Creation timestamp |
Constraints:
- Primary key: `id`
- Unique: `uq_strategy_sets_name_config` on (`strategy_name`, `strategy_config`)
- Unique: `uq_strategy_sets_name_config` on (`name`, `config`)
- Unique: `uq_strategy_sets_nick` on (`nick`)
### 4.2 portfolios
@@ -155,3 +159,4 @@ When schema changes:
| Revision ID | File | Summary |
|---|---|---|
| 20260403_0001 | migrations/versions/20260403_0001_initial_portfolio_schema.py | Initial schema for strategy sets, portfolios, ledger, indexes, optional hypertable |
| 20260403_0002 | migrations/versions/20260403_0002_strategy_set_columns.py | Rename `strategy_name`->`name`, `strategy_config`->`config`, add unique `nick` |
+8
View File
@@ -275,6 +275,14 @@ Base routes:
- `strategy_set: StrategySetResponse | null`
- `live_quantity: float | null`
`StrategySetResponse`
- `id: str`
- `name: str`
- `config: str`
- `nick: str`
- `created_at: datetime | null`
`LedgerEntryResponse`
- Snapshot-oriented ledger response including balances after each action