fix Pnl, cob
This commit is contained in:
54
main.py
54
main.py
@ -212,8 +212,15 @@ async def start_training_loop(orchestrator, trading_executor):
|
||||
}
|
||||
|
||||
try:
|
||||
# Start real-time processing
|
||||
await orchestrator.start_realtime_processing()
|
||||
# Start real-time processing (Basic orchestrator doesn't have this method)
|
||||
try:
|
||||
if hasattr(orchestrator, 'start_realtime_processing'):
|
||||
await orchestrator.start_realtime_processing()
|
||||
logger.info("Real-time processing started")
|
||||
else:
|
||||
logger.info("Basic orchestrator - no real-time processing method available")
|
||||
except Exception as e:
|
||||
logger.warning(f"Real-time processing not available: {e}")
|
||||
|
||||
# Main training loop
|
||||
iteration = 0
|
||||
@ -223,8 +230,17 @@ async def start_training_loop(orchestrator, trading_executor):
|
||||
|
||||
logger.info(f"Training iteration {iteration}")
|
||||
|
||||
# Make coordinated decisions (this triggers CNN and RL training)
|
||||
decisions = await orchestrator.make_coordinated_decisions()
|
||||
# Make trading decisions using Basic orchestrator (single symbol method)
|
||||
decisions = {}
|
||||
symbols = ['ETH/USDT'] # Focus on ETH only for training
|
||||
|
||||
for symbol in symbols:
|
||||
try:
|
||||
decision = await orchestrator.make_trading_decision(symbol)
|
||||
decisions[symbol] = decision
|
||||
except Exception as e:
|
||||
logger.warning(f"Error making decision for {symbol}: {e}")
|
||||
decisions[symbol] = None
|
||||
|
||||
# Process decisions and collect training metrics
|
||||
iteration_decisions = 0
|
||||
@ -301,12 +317,16 @@ async def start_training_loop(orchestrator, trading_executor):
|
||||
logger.info(f"Checkpoints: {checkpoint_stats['total_checkpoints']} total, "
|
||||
f"{checkpoint_stats['total_size_mb']:.2f} MB")
|
||||
|
||||
# Log COB integration status
|
||||
for symbol in orchestrator.symbols:
|
||||
cob_features = orchestrator.latest_cob_features.get(symbol)
|
||||
cob_state = orchestrator.latest_cob_state.get(symbol)
|
||||
if cob_features is not None:
|
||||
logger.info(f"{symbol} COB: CNN features {cob_features.shape}, DQN state {cob_state.shape if cob_state is not None else 'None'}")
|
||||
# Log COB integration status (Basic orchestrator doesn't have COB features)
|
||||
symbols = getattr(orchestrator, 'symbols', ['ETH/USDT'])
|
||||
if hasattr(orchestrator, 'latest_cob_features'):
|
||||
for symbol in symbols:
|
||||
cob_features = orchestrator.latest_cob_features.get(symbol)
|
||||
cob_state = orchestrator.latest_cob_state.get(symbol)
|
||||
if cob_features is not None:
|
||||
logger.info(f"{symbol} COB: CNN features {cob_features.shape}, DQN state {cob_state.shape if cob_state is not None else 'None'}")
|
||||
else:
|
||||
logger.debug("Basic orchestrator - no COB integration features available")
|
||||
|
||||
# Sleep between iterations
|
||||
await asyncio.sleep(5) # 5 second intervals
|
||||
@ -338,8 +358,18 @@ async def start_training_loop(orchestrator, trading_executor):
|
||||
except Exception as e:
|
||||
logger.warning(f"Error saving final checkpoints: {e}")
|
||||
|
||||
await orchestrator.stop_realtime_processing()
|
||||
await orchestrator.stop_cob_integration()
|
||||
# Stop real-time processing (Basic orchestrator doesn't have these methods)
|
||||
try:
|
||||
if hasattr(orchestrator, 'stop_realtime_processing'):
|
||||
await orchestrator.stop_realtime_processing()
|
||||
except Exception as e:
|
||||
logger.warning(f"Error stopping real-time processing: {e}")
|
||||
|
||||
try:
|
||||
if hasattr(orchestrator, 'stop_cob_integration'):
|
||||
await orchestrator.stop_cob_integration()
|
||||
except Exception as e:
|
||||
logger.warning(f"Error stopping COB integration: {e}")
|
||||
logger.info("Training loop stopped with checkpoint management")
|
||||
|
||||
async def main():
|
||||
|
Reference in New Issue
Block a user