ZhuLinsen/daily_stock_analysis · error · PortfolioConflictError
conflict
conflict
Error message
Duplicate trade_uid for account_id={account_id}: {trade_uid} What it means
Error "Duplicate trade_uid for account_id={account_id}: {trade_uid}" thrown in ZhuLinsen/daily_stock_analysis.
Source
Thrown at src/services/portfolio_service.py:254
row = self.repo.add_trade_in_session(
session=session,
account_id=account_id,
trade_uid=trade_uid_norm,
symbol=symbol_norm,
market=market_norm,
currency=currency_norm,
trade_date=trade_date,
side=side_norm,
quantity=float(quantity),
price=float(price),
fee=float(fee),
tax=float(tax),
note=(note or "").strip() or None,
dedup_hash=dedup_hash_norm,
)
return {"id": int(row.id)}
except (DuplicateTradeUidError, DuplicateTradeDedupHashError) as exc:
raise PortfolioConflictError(str(exc)) from exc
def record_cash_ledger(
self,
*,
account_id: int,
event_date: date,
direction: str,
amount: float,
currency: Optional[str] = None,
note: Optional[str] = None,
) -> Dict[str, Any]:
direction_norm = (direction or "").strip().lower()
if direction_norm not in VALID_CASH_DIRECTIONS:
raise ValueError("direction must be in or out")
if amount <= 0:
raise ValueError("amount must be > 0")
with self.repo.portfolio_write_session() as session:
account = self._require_active_account_in_session(session=session, account_id=account_id)View on GitHub (pinned to 5159bd72e8)
Solutions
- Ensure each trade_uid is unique per account; regenerate or deduplicate IDs in the import source.
- If re-importing, delete or skip previously imported trades with the same trade_uid.
- Fix the upstream export that produced duplicate trade_uids.
When it happens
Trigger: Thrown at src/services/portfolio_service.py:254 when the library encounters an invalid state.
Common situations: Raised when a trade with the same trade_uid already exists for the account; occurs on duplicate imports or retried trade submissions.
AI-assisted analysis of ZhuLinsen/daily_stock_analysis@5159bd72e8 (2026-08-15).
Data as JSON: /api/errors/6d83328907b0e11a.
Report an issue: GitHub.