Files
Personal-Finance-Management/scripts/fetch_prices.py
T
2026-05-31 16:40:59 -04:00

26 lines
754 B
Python

#!/usr/bin/env python3
"""
Cron script: update investment prices via yfinance.
Run by systemd timer pfm-prices.timer at 4PM weekdays.
"""
import sys
import os
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from app import create_app
from app.services.investment_service import update_prices
app = create_app()
if __name__ == '__main__':
with app.app_context():
print('[fetch_prices] Starting price update...')
updated = update_prices()
if updated:
for ticker, price in updated.items():
print(f' {ticker}: {price:.4f}')
print(f'[fetch_prices] Updated {len(updated)} ticker(s).')
else:
print('[fetch_prices] No tickers updated.')