Improve training agent progress reporting
This commit is contained in:
@@ -118,6 +118,10 @@ def main() -> None:
|
||||
target_horizons = _horizons(args.horizons, decision_horizon)
|
||||
feature_names = _feature_names_arg(args.features)
|
||||
round_trip_cost = max(0.0, 2.0 * (float(settings.taker_fee_rate) + float(settings.slippage_rate)))
|
||||
_progress(
|
||||
f"training started: symbols={len(symbols)} interval={interval} "
|
||||
f"limit={args.limit} epochs={args.epochs}"
|
||||
)
|
||||
|
||||
artifact: dict[str, Any] = {
|
||||
"version": 4,
|
||||
@@ -141,7 +145,9 @@ def main() -> None:
|
||||
"symbols": {},
|
||||
}
|
||||
|
||||
for symbol in symbols:
|
||||
total_symbols = len(symbols)
|
||||
for index, symbol in enumerate(symbols, start=1):
|
||||
_progress(f"{symbol}: training started ({index}/{total_symbols})")
|
||||
result = _train_symbol(
|
||||
client=client,
|
||||
symbol=symbol,
|
||||
@@ -170,10 +176,10 @@ def main() -> None:
|
||||
seed=args.seed,
|
||||
)
|
||||
if result is None:
|
||||
print(f"{symbol}: skipped, not enough candles or train/validation samples")
|
||||
_progress(f"{symbol}: skipped, not enough candles or train/validation samples")
|
||||
continue
|
||||
artifact["symbols"][symbol] = result
|
||||
print(
|
||||
_progress(
|
||||
f"{symbol}: model={result['model']} lookback={result['lookback']} "
|
||||
f"features={result['input_size']} hidden={result['hidden_size']} "
|
||||
f"layers={result['num_layers']} horizons={','.join(map(str, result['target_horizons']))} "
|
||||
@@ -187,7 +193,11 @@ def main() -> None:
|
||||
tmp_output = output.with_name(f"{output.name}.tmp")
|
||||
tmp_output.write_text(json.dumps(artifact, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
|
||||
tmp_output.replace(output)
|
||||
print(f"saved {output}")
|
||||
_progress(f"saved {output}")
|
||||
|
||||
|
||||
def _progress(message: str) -> None:
|
||||
print(message, flush=True)
|
||||
|
||||
|
||||
def _parse_args() -> argparse.Namespace:
|
||||
@@ -274,12 +284,13 @@ def _train_symbol(
|
||||
add_indicators(rows)
|
||||
market_candles[context_symbol] = rows
|
||||
except Exception as exc:
|
||||
print(f"{symbol}: context {context_symbol} skipped: {exc}")
|
||||
_progress(f"{symbol}: context {context_symbol} skipped: {exc}")
|
||||
trend_candles = _historical_klines(client, symbol, "D", min(max(260, limit // 24 + 260), 1000))
|
||||
add_indicators(trend_candles)
|
||||
|
||||
best: dict[str, Any] | None = None
|
||||
for lookback in lookbacks:
|
||||
_progress(f"{symbol}: preparing lookback={lookback}")
|
||||
prepared = _prepare_data(
|
||||
candles=candles,
|
||||
feature_names=feature_names,
|
||||
@@ -307,6 +318,11 @@ def _train_symbol(
|
||||
for dropout in dropouts:
|
||||
if num_layers <= 1 and dropout != 0.0:
|
||||
continue
|
||||
_progress(
|
||||
f"{symbol}: fitting {architecture} "
|
||||
f"lookback={lookback} hidden={hidden_size} "
|
||||
f"layers={num_layers} dropout={dropout}"
|
||||
)
|
||||
candidate = _fit_candidate(
|
||||
prepared=prepared,
|
||||
architecture=architecture,
|
||||
|
||||
Reference in New Issue
Block a user