mirror of
https://github.com/chrisnov-it/quantumbotx.git
synced 2026-07-27 18:57:47 +00:00
0346b0d632
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.
22 lines
609 B
Python
22 lines
609 B
Python
# core/routes/api_chart.py
|
|
|
|
from flask import Blueprint, jsonify, request
|
|
from core.utils.mt5 import get_rates_mt5
|
|
import MetaTrader5 as mt5
|
|
|
|
api_chart = Blueprint('api_chart', __name__)
|
|
|
|
@api_chart.route('/api/chart/data')
|
|
def api_chart_data():
|
|
symbol = request.args.get('symbol', 'EURUSD')
|
|
df = get_rates_mt5(symbol, mt5.TIMEFRAME_H1, 100)
|
|
|
|
if df is None or df.empty:
|
|
return jsonify({"error": "Gagal mengambil data grafik"}), 500
|
|
|
|
chart_data = {
|
|
"labels": df.index.strftime('%H:%M').tolist(),
|
|
"data": df['close'].tolist()
|
|
}
|
|
return jsonify(chart_data)
|