feat: add portfolio daemon assignment and improve list rendering
- Add --daemon-id option to portfolio update command for daemon assignment - Update managed_by_daemon_id field in portfolio updates - Refactor print_portfolio_table() to print_portfolio_list() for better readability - Display daemon_id in portfolio list output when assigned - Show portfolio tags and managed daemon information in CLI list view - Add daemon_id support to portfolio repository and service layers - Update schemas to include managed_by_daemon_id field in responses
This commit is contained in:
@@ -112,6 +112,8 @@ class PortfolioRepository(Protocol):
|
||||
|
||||
def get(self, portfolio_id: str) -> Portfolio: ...
|
||||
|
||||
def get_portfolio_by_name_and_user(self, owner_user_id: str, name: str) -> Portfolio | None: ...
|
||||
|
||||
def get_or_create(
|
||||
self,
|
||||
portfolio_id: str,
|
||||
|
||||
@@ -743,6 +743,20 @@ class PostgresPortfolioRepository:
|
||||
self._attach_tags(cur, [portfolio])
|
||||
return portfolio
|
||||
|
||||
def get_portfolio_by_name_and_user(self, owner_user_id: str, name: str) -> Portfolio | None:
|
||||
self.ensure_schema()
|
||||
with self._connect().cursor() as cur:
|
||||
cur.execute(
|
||||
_SELECT_PORTFOLIO + "WHERE owner_user_id = %s AND name = %s",
|
||||
(owner_user_id, name),
|
||||
)
|
||||
row = cur.fetchone()
|
||||
if row is None:
|
||||
return None
|
||||
portfolio = self._row_to_portfolio(row)
|
||||
self._attach_tags(cur, [portfolio])
|
||||
return portfolio
|
||||
|
||||
def get_or_create(
|
||||
self,
|
||||
portfolio_id: str,
|
||||
@@ -850,6 +864,7 @@ class PostgresPortfolioRepository:
|
||||
"asset_price": "asset_price",
|
||||
"active_strategy_id": "active_strategy_id",
|
||||
"avabile_strategies": "avabile_strategies",
|
||||
"managed_by_daemon_id": "managed_by_daemon_id",
|
||||
}
|
||||
assignments: list[str] = []
|
||||
params: list[object] = []
|
||||
|
||||
Reference in New Issue
Block a user