kiro steering, live training wip
This commit is contained in:
@@ -2104,7 +2104,7 @@ class RealTrainingAdapter:
|
||||
|
||||
# Real-time inference support
|
||||
|
||||
def start_realtime_inference(self, model_name: str, symbol: str, data_provider) -> str:
|
||||
def start_realtime_inference(self, model_name: str, symbol: str, data_provider, enable_live_training: bool = True) -> str:
|
||||
"""
|
||||
Start real-time inference using orchestrator's REAL prediction methods
|
||||
|
||||
@@ -2112,6 +2112,7 @@ class RealTrainingAdapter:
|
||||
model_name: Name of model to use for inference
|
||||
symbol: Trading symbol
|
||||
data_provider: Data provider for market data
|
||||
enable_live_training: If True, automatically train on L2 pivots
|
||||
|
||||
Returns:
|
||||
inference_id: Unique ID for this inference session
|
||||
@@ -2132,11 +2133,32 @@ class RealTrainingAdapter:
|
||||
'status': 'running',
|
||||
'start_time': time.time(),
|
||||
'signals': [],
|
||||
'stop_flag': False
|
||||
'stop_flag': False,
|
||||
'live_training_enabled': enable_live_training
|
||||
}
|
||||
|
||||
logger.info(f"Starting REAL-TIME inference: {inference_id} with {model_name} on {symbol}")
|
||||
|
||||
# Start live pivot training if enabled
|
||||
if enable_live_training:
|
||||
try:
|
||||
from ANNOTATE.core.live_pivot_trainer import get_live_pivot_trainer
|
||||
|
||||
pivot_trainer = get_live_pivot_trainer(
|
||||
orchestrator=self.orchestrator,
|
||||
data_provider=data_provider,
|
||||
training_adapter=self
|
||||
)
|
||||
|
||||
if pivot_trainer:
|
||||
pivot_trainer.start(symbol=symbol)
|
||||
logger.info(f"✅ Live pivot training ENABLED - will train on L2 peaks automatically")
|
||||
else:
|
||||
logger.warning("Could not initialize live pivot trainer")
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to start live pivot training: {e}")
|
||||
|
||||
# Start inference loop in background thread
|
||||
thread = threading.Thread(
|
||||
target=self._realtime_inference_loop,
|
||||
@@ -2153,8 +2175,21 @@ class RealTrainingAdapter:
|
||||
return
|
||||
|
||||
if inference_id in self.inference_sessions:
|
||||
self.inference_sessions[inference_id]['stop_flag'] = True
|
||||
self.inference_sessions[inference_id]['status'] = 'stopped'
|
||||
session = self.inference_sessions[inference_id]
|
||||
session['stop_flag'] = True
|
||||
session['status'] = 'stopped'
|
||||
|
||||
# Stop live pivot training if it was enabled
|
||||
if session.get('live_training_enabled', False):
|
||||
try:
|
||||
from ANNOTATE.core.live_pivot_trainer import get_live_pivot_trainer
|
||||
pivot_trainer = get_live_pivot_trainer()
|
||||
if pivot_trainer:
|
||||
pivot_trainer.stop()
|
||||
logger.info("Live pivot training stopped")
|
||||
except Exception as e:
|
||||
logger.error(f"Error stopping live pivot training: {e}")
|
||||
|
||||
logger.info(f"Stopped real-time inference: {inference_id}")
|
||||
|
||||
def get_latest_signals(self, limit: int = 50) -> List[Dict]:
|
||||
|
||||
Reference in New Issue
Block a user