Initial commit: MyMidas personal finance tracker
Full-stack self-hosted finance app with FastAPI backend and React frontend. Features: - Accounts, transactions, budgets, investments with GBP base currency - CSV import with auto-detection for 10 UK bank formats - ML predictions: spending forecast, net worth projection, Monte Carlo - 7 selectable themes (Obsidian, Arctic, Midnight, Vault, Terminal, Synthwave, Ledger) - Receipt/document attachments on transactions (JPEG, PNG, WebP, PDF) - AES-256-GCM field encryption, RS256 JWT, TOTP 2FA, RLS, audit log - Encrypted nightly backups + key rotation script - Mobile-responsive layout with bottom nav Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
commit
61a7884ee5
127 changed files with 13323 additions and 0 deletions
31
backend/app/workers/price_sync.py
Normal file
31
backend/app/workers/price_sync.py
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import structlog
|
||||
from sqlalchemy import select
|
||||
|
||||
logger = structlog.get_logger()
|
||||
|
||||
|
||||
async def price_sync_job() -> None:
|
||||
from app.dependencies import get_session_factory
|
||||
from app.db.models.asset import Asset
|
||||
from app.services.price_feed_service import fetch_price
|
||||
from app.services.investment_service import update_asset_price
|
||||
|
||||
session_factory = get_session_factory()
|
||||
if not session_factory:
|
||||
return
|
||||
|
||||
async with session_factory() as db:
|
||||
try:
|
||||
result = await db.execute(select(Asset).where(Asset.is_active == True)) # noqa: E712
|
||||
assets = result.scalars().all()
|
||||
updated = 0
|
||||
for asset in assets:
|
||||
data = await fetch_price(asset.symbol, asset.data_source, asset.data_source_id)
|
||||
if data and data.get("price"):
|
||||
await update_asset_price(db, asset, data["price"], data.get("change_24h"))
|
||||
updated += 1
|
||||
await db.commit()
|
||||
logger.info("price_sync_done", updated=updated, total=len(assets))
|
||||
except Exception as exc:
|
||||
await db.rollback()
|
||||
logger.error("price_sync_failed", error=str(exc))
|
||||
Loading…
Add table
Add a link
Reference in a new issue