feat(portfolio): add asset name field across API, DB, and CLI

This commit is contained in:
2026-04-03 14:51:36 +00:00
parent aeb4f10fd0
commit 0654b24d66
13 changed files with 115 additions and 19 deletions
+4
View File
@@ -50,6 +50,7 @@ Response 200:
"portfolio_id": "krw-btc",
"broker": "upbit",
"status": "enabled",
"name": "Bitcoin",
"symbol": "KRW-BTC",
"cash_balance": 1000000.0,
"asset_quantity": 0.1,
@@ -82,6 +83,7 @@ Response 200:
"portfolio_id": "krw-btc",
"broker": "upbit",
"status": "enabled",
"name": "Bitcoin",
"symbol": "KRW-BTC",
"cash_balance": 1000000.0,
"asset_quantity": 0.1,
@@ -133,6 +135,7 @@ curl -X POST "http://localhost:8000/portfolios" \
"portfolio_id": "krw-btc",
"broker": "upbit",
"status": "enabled",
"name": "Bitcoin",
"symbol": "KRW-BTC",
"strategy_name": "target_value",
"strategy_params": {},
@@ -159,6 +162,7 @@ curl -X PATCH "http://localhost:8000/portfolios/krw-btc" \
-H "Content-Type: application/json" \
-d '{
"broker": "upbit",
"name": "Bitcoin",
"symbol": "KRW-BTC"
}'
```
+5 -2
View File
@@ -5,7 +5,7 @@
This document defines the database schema in an AI-agent-friendly format.
- Source of truth: Alembic revisions in `migrations/versions`
- Current baseline revision: `20260403_0007`
- Current baseline revision: `20260403_0008`
- Baseline files:
- `migrations/versions/20260403_0001_initial_portfolio_schema.py`
- `migrations/versions/20260403_0002_strategy_set_columns.py`
@@ -14,6 +14,7 @@ This document defines the database schema in an AI-agent-friendly format.
- `migrations/versions/20260403_0005_auth_user_fields_and_tokens.py`
- `migrations/versions/20260403_0006_bot_principals_and_bot_tokens.py`
- `migrations/versions/20260403_0007_bot_principal_permission_only.py`
- `migrations/versions/20260403_0008_portfolio_name_column.py`
## 2. Scope
@@ -145,7 +146,7 @@ Purpose:
Current baseline note:
- The columns below describe the currently migrated schema through revision `20260403_0005`.
- The columns below describe the currently migrated schema through revision `20260403_0008`.
Columns:
@@ -154,6 +155,7 @@ Columns:
| portfolio_id | Text | NO | - | Primary Key |
| broker | Text | NO | "kis" | Broker code |
| status | Text | NO | "enabled" | Portfolio status |
| name | Text | NO | - | Asset name |
| symbol | Text | NO | - | Trading symbol |
| cash_balance | Float | NO | - | Current cash balance |
| asset_quantity | Float | NO | - | Current asset quantity |
@@ -294,3 +296,4 @@ When schema changes:
| 20260403_0005 | migrations/versions/20260403_0005_auth_user_fields_and_tokens.py | Add password/permission/login fields to `users` and create `auth_tokens` table |
| 20260403_0006 | migrations/versions/20260403_0006_bot_principals_and_bot_tokens.py | Add `bot_principals` table and `auth_tokens.bot_principal_id` for bot API key management |
| 20260403_0007 | migrations/versions/20260403_0007_bot_principal_permission_only.py | Remove `bot_principals.owner_user_id` and enforce bot-local `permission` model |
| 20260403_0008 | migrations/versions/20260403_0008_portfolio_name_column.py | Add non-null `portfolios.name` (asset display name), backfilled from `symbol` |
+4 -1
View File
@@ -387,6 +387,7 @@ Bootstrap rule:
- `portfolio_id: str`
- `broker: str = "kis"`
- `status: str = "enabled"`
- `name: str | null` (when null, defaults to `symbol`)
- `symbol: str`
- `strategy_name: str = "target_value"`
- `strategy_params: object = {}`
@@ -401,6 +402,7 @@ Bootstrap rule:
- `broker: str | null`
- `status: str | null`
- `name: str | null`
- `symbol: str | null`
- `strategy_name: str | null`
- `strategy_params: object | null`
@@ -492,6 +494,7 @@ Bootstrap rule:
- `portfolio_id: str`
- `broker: str`
- `status: str`
- `name: str`
- `symbol: str`
- `cash_balance: float`
- `asset_quantity: float`
@@ -553,7 +556,7 @@ Portfolio subcommands:
- `portfoliohub portfolio list [--broker ...] [--status ...]`
- `portfoliohub portfolio status <portfolio_id> [--recent 5]`
- `portfoliohub portfolio create <portfolio_id> --symbol ... [options] [--force]`
- `portfoliohub portfolio create <portfolio_id> --symbol ... [--name ...] [options] [--force]`
- `portfoliohub portfolio update <portfolio_id> [options] [--force]`
- `portfoliohub portfolio buy <portfolio_id> --quantity ... --price ... [options] [--force]`
- `portfoliohub portfolio sell <portfolio_id> --quantity ... --price ... [options] [--force]`