Files
2026-06-05 15:51:57 -04:00

30 lines
964 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, check_and_save_price_alerts
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.')
print('[fetch_prices] Checking price alerts (threshold=5%)...')
n = check_and_save_price_alerts(threshold=5.0)
print(f'[fetch_prices] {n} alert(s) saved.')