fix template again
This commit is contained in:
@@ -480,6 +480,51 @@ class AnnotationDashboard:
|
||||
</html>
|
||||
"""
|
||||
|
||||
@self.server.route('/api/recalculate-pivots', methods=['POST'])
|
||||
def recalculate_pivots():
|
||||
"""Recalculate pivot points for merged data"""
|
||||
try:
|
||||
data = request.get_json()
|
||||
symbol = data.get('symbol', 'ETH/USDT')
|
||||
timeframe = data.get('timeframe')
|
||||
timestamps = data.get('timestamps', [])
|
||||
ohlcv_data = data.get('ohlcv', {})
|
||||
|
||||
if not timeframe or not timestamps:
|
||||
return jsonify({
|
||||
'success': False,
|
||||
'error': {'code': 'INVALID_REQUEST', 'message': 'Missing timeframe or timestamps'}
|
||||
})
|
||||
|
||||
logger.info(f"🔄 Recalculating pivots for {symbol} {timeframe} with {len(timestamps)} candles")
|
||||
|
||||
# Convert to DataFrame
|
||||
df = pd.DataFrame({
|
||||
'open': ohlcv_data.get('open', []),
|
||||
'high': ohlcv_data.get('high', []),
|
||||
'low': ohlcv_data.get('low', []),
|
||||
'close': ohlcv_data.get('close', []),
|
||||
'volume': ohlcv_data.get('volume', [])
|
||||
})
|
||||
df.index = pd.to_datetime(timestamps)
|
||||
|
||||
# Recalculate pivot markers
|
||||
pivot_markers = self._get_pivot_markers_for_timeframe(symbol, timeframe, df)
|
||||
|
||||
logger.info(f" ✅ Recalculated {len(pivot_markers)} pivot candles")
|
||||
|
||||
return jsonify({
|
||||
'success': True,
|
||||
'pivot_markers': pivot_markers
|
||||
})
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error recalculating pivots: {e}")
|
||||
return jsonify({
|
||||
'success': False,
|
||||
'error': {'code': 'RECALC_ERROR', 'message': str(e)}
|
||||
})
|
||||
|
||||
@self.server.route('/api/chart-data', methods=['POST'])
|
||||
def get_chart_data():
|
||||
"""Get chart data for specified symbol and timeframes with infinite scroll support"""
|
||||
@@ -489,9 +534,15 @@ class AnnotationDashboard:
|
||||
timeframes = data.get('timeframes', ['1s', '1m', '1h', '1d'])
|
||||
start_time_str = data.get('start_time')
|
||||
end_time_str = data.get('end_time')
|
||||
limit = data.get('limit', 500) # Allow client to request more data
|
||||
limit = data.get('limit', 2000) # Default 2000 candles for training
|
||||
direction = data.get('direction', 'latest') # 'latest', 'before', or 'after'
|
||||
|
||||
logger.info(f"📊 Chart data request: {symbol} {timeframes} direction={direction} limit={limit}")
|
||||
if start_time_str:
|
||||
logger.info(f" start_time: {start_time_str}")
|
||||
if end_time_str:
|
||||
logger.info(f" end_time: {end_time_str}")
|
||||
|
||||
if not self.data_loader:
|
||||
return jsonify({
|
||||
'success': False,
|
||||
@@ -522,6 +573,8 @@ class AnnotationDashboard:
|
||||
)
|
||||
|
||||
if df is not None and not df.empty:
|
||||
logger.info(f" ✅ {timeframe}: {len(df)} candles ({df.index[0]} to {df.index[-1]})")
|
||||
|
||||
# Get pivot points for this timeframe
|
||||
pivot_markers = self._get_pivot_markers_for_timeframe(symbol, timeframe, df)
|
||||
|
||||
@@ -535,6 +588,8 @@ class AnnotationDashboard:
|
||||
'volume': df['volume'].tolist(),
|
||||
'pivot_markers': pivot_markers # Optional: only present if pivots exist
|
||||
}
|
||||
else:
|
||||
logger.warning(f" ❌ {timeframe}: No data returned")
|
||||
|
||||
# Get pivot bounds for the symbol
|
||||
pivot_bounds = None
|
||||
|
||||
Reference in New Issue
Block a user