06/01 Optimize porfolio page
This commit is contained in:
@@ -6,7 +6,8 @@ from wtforms.validators import DataRequired, Optional, NumberRange, Length
|
||||
from app.extensions import db
|
||||
from app.models.investment import Investment, InvestmentTransaction
|
||||
from app.services.investment_service import (
|
||||
get_portfolio_summary, update_prices, fetch_price, fetch_price_history,
|
||||
get_portfolio_summary, update_prices, fetch_price,
|
||||
fetch_price_history, fetch_day_change,
|
||||
ASSET_COLORS, ASSET_TYPE_LABELS
|
||||
)
|
||||
from datetime import date
|
||||
@@ -275,6 +276,19 @@ def api_price(ticker):
|
||||
})
|
||||
|
||||
|
||||
@investments_bp.route('/api/daychange/<ticker>')
|
||||
@login_required
|
||||
def api_day_change(ticker):
|
||||
"""
|
||||
Lightweight endpoint: return today's open-to-current day change only.
|
||||
Used by the portfolio page to load change badges quickly.
|
||||
"""
|
||||
data = fetch_day_change(ticker.upper().strip())
|
||||
if data is None:
|
||||
return jsonify({'error': f'No data for {ticker}'}), 404
|
||||
return jsonify(data)
|
||||
|
||||
|
||||
@investments_bp.route('/api/history/<ticker>')
|
||||
@login_required
|
||||
def api_price_history(ticker):
|
||||
|
||||
Reference in New Issue
Block a user