Files
Reynov Christian 0346b0d632 Refactor and update forex and stock modal handling in JavaScript
Refactor the JavaScript code to use a single modal for both forex and stock profiles. Update error handling to display server error messages. Remove unused app.py and fetch.py files. Adjust various routes and strategies for consistency.
2025-08-08 10:39:03 +08:00

24 lines
783 B
Python

# core/routes/api_forex.py
from flask import Blueprint, jsonify
from core.utils.symbols import get_forex_symbols
from core.utils.external import get_mt5_symbol_profile
api_forex = Blueprint('api_forex', __name__)
@api_forex.route('/api/forex-data')
def get_forex_data():
"""
Mengembalikan daftar simbol forex, diurutkan berdasarkan popularitas (volume harian).
Formatnya adalah array JSON, bukan dictionary, agar urutan tetap terjaga.
"""
forex_symbols = get_forex_symbols()
return jsonify(forex_symbols)
@api_forex.route('/api/forex/<symbol>/profile')
def get_forex_profile(symbol):
profile = get_mt5_symbol_profile(symbol)
if profile:
return jsonify(profile)
return jsonify({"error": "Could not fetch symbol profile from MT5"}), 404