ZhuLinsen/daily_stock_analysis · error · Error
当前平台不支持自动安装更新。
Error message
当前平台不支持自动安装更新。
What it means
Raised when recording a sell whose quantity exceeds the position available as of the trade date. _validate_sell_quantity (portfolio_service.py:691) normalizes the (symbol, market, currency) key, replays events up to trade_date via _calculate_available_quantity, and throws PortfolioOversellError (code=portfolio_oversell) when available + EPS < requested. The exception carries symbol, trade_date, requested_quantity and available_quantity attributes.
Source
Thrown at apps/dsa-desktop/main.js:1777
setDesktopUpdateState({
status: UPDATE_STATUS.ERROR,
updateMode: UPDATE_MODE.AUTO,
currentVersion: resolveDesktopVersion(),
latestVersion: desktopUpdateState?.latestVersion || '',
releaseUrl: desktopUpdateState?.releaseUrl || RELEASES_PAGE_URL,
checkedAt: new Date().toISOString(),
message: `自动更新失败:${message}`,
});
});
electronAutoUpdaterConfigured = true;
return updater;
}
async function performElectronUpdaterCheck({ manual = false } = {}) {
const updater = configureElectronAutoUpdater();
if (!updater) {
throw new Error('当前平台不支持自动安装更新。');
}
if (electronUpdateCheckInFlight) {
return desktopUpdateState;
}
electronUpdateCheckInFlight = true;
setDesktopUpdateState({
status: UPDATE_STATUS.CHECKING,
updateMode: UPDATE_MODE.AUTO,
currentVersion: resolveDesktopVersion(),
message: manual ? '正在检查桌面端更新...' : '正在后台检查桌面端更新...',
});
try {
await updater.checkForUpdates();
return desktopUpdateState;
} catch (error) {
const message = error instanceof Error ? error.message : String(error);View on GitHub (pinned to 5159bd72e8)
Solutions
- Import trades in chronological order and insert missing buy or split_adjustment events first
- Inspect the exception fields (available_quantity, trade_date) to see what the replay thinks you hold
- Verify market/currency of the sell match the recorded buys so the (symbol, market, currency) key aligns
- If you genuinely short-sell, this service rejects it by design: record only covered sells
Example fix
# before svc.add_trade(account_id=1, symbol="AAPL", side="sell", quantity=200, trade_date=date(2025,1,10), ...) # after # record the missing split first, then the sell svc.add_corporate_action(account_id=1, symbol="AAPL", action_type="split_adjustment", split_ratio=2.0, effective_date=date(2025,1,5)) svc.add_trade(account_id=1, symbol="AAPL", side="sell", quantity=200, trade_date=date(2025,1,10), ...)
Defensive patterns
Strategy: try-catch
Validate before calling
def available_before_sell(svc, account_id, symbol, market, currency, trade_date):
# replay the same computation the service does
return svc._calculate_available_quantity(
account_id=account_id,
key=(svc._normalize_symbol_for_position(symbol), svc._normalize_market(market), svc._normalize_currency(currency)),
as_of_date=trade_date,
) Type guard
from src.services.portfolio_service import PortfolioOversellError
def is_oversell(exc: Exception) -> bool:
return isinstance(exc, PortfolioOversellError) Try / catch
from src.services.portfolio_service import PortfolioOversellError
try:
svc.add_trade(account_id=a, side="sell", quantity=q, ...)
except PortfolioOversellError as exc:
# exc.available_quantity, exc.trade_date, exc.symbol carry the diagnosis
raise UserInputError(f"only {exc.available_quantity} shares available on {exc.trade_date}") from exc Prevention
- Import buys and splits before the sells they cover, in date order
- Record split_adjustment events before later sells
- Match market and currency of sells to the recorded buys
- Read the exception's available_quantity instead of recomputing the position yourself
When it happens
Trigger: add_trade(side='sell', quantity=200) when replay of buys/splits up to that date yields only 100 shares; selling before the covering buy (trade_date earlier than the buy's date); selling in the wrong market/currency key so the matching position is not found; a prior split_adjustment event missing so available quantity is understated.
Common situations: Importing broker history out of order (sells before their buys); forgetting to record a stock split before later sells; selling HK shares recorded under a different currency key; rounding: fractional-share lots where cumulative float error exceeds EPS; margin/short selling, which this service does not model.
Related errors
AI-assisted analysis of ZhuLinsen/daily_stock_analysis@5159bd72e8 (2026-08-15).
Data as JSON: /api/errors/10cfb65f000ccad2.
Report an issue: GitHub.