05/31 Fix fetch price issues

This commit is contained in:
2026-05-31 22:06:10 -04:00
parent 9bc8bb3238
commit 67ed91d94c
3 changed files with 62 additions and 13 deletions
+16 -3
View File
@@ -257,6 +257,19 @@ def refresh_prices():
@investments_bp.route('/api/price/<ticker>')
@login_required
def api_price(ticker):
"""Live price lookup for a ticker — used in the add transaction form."""
price = fetch_price(ticker)
return jsonify({'ticker': ticker.upper(), 'price': price})
"""Live price lookup for a ticker — used in the add/edit investment form."""
ticker = ticker.upper().strip()
error = None
price = None
try:
price = fetch_price(ticker)
if price is None:
error = f'No data returned for {ticker}. Check the ticker format.'
except Exception as e:
error = str(e)
return jsonify({
'ticker': ticker,
'price': price,
'error': error,
})