callbacks.training_telemetry
Enhanced telemetry callback for detailed training insights. Tracks portfolio metrics, action distributions, and trading patterns.
Classes
Custom callback for tracking detailed trading metrics during training. |
Module Contents
- class callbacks.training_telemetry.TradingTelemetryCallback(verbose=0, log_freq=256, action_threshold=0.1)
Bases:
stable_baselines3.common.callbacks.BaseCallbackCustom callback for tracking detailed trading metrics during training.
Logs: - Portfolio value and equity changes - Action statistics (buy/sell/hold distribution) - Episode-level metrics (win rate, drawdown) - Per-ticker performance insights
- Parameters:
verbose (int)
log_freq (int)
action_threshold (float)
- log_freq = 256
- action_threshold = 0.1
- episode_rewards: list[float] = []
- episode_lengths: list[int] = []
- episode_equity_start: list[float] = []
- episode_equity_end: list[float] = []
- action_history: list[numpy.ndarray] = []
- buy_count = 0
- sell_count = 0
- hold_count = 0
- max_portfolio_value = 0
- min_portfolio_value
- cumulative_trades = 0
- current_episode_start_value = None
- _on_training_start()
Called before the first rollout starts.
- Return type:
None
- _on_rollout_start()
Called at the beginning of a new rollout (before collecting data).
- Return type:
None
- _on_step()
Called after each step in the environment.
- Returns:
If False, training will be stopped.
- Return type:
bool
- _on_rollout_end()
Called at the end of a rollout (after collecting n_steps). This is when PPO does its policy update.
- Return type:
None
- _log_detailed_metrics()
Log detailed metrics about training progress.
- Return type:
None
- _on_training_end()
Called at the end of training.
- Return type:
None