Add REST API with dashboard and configurable port (server.host/port, TM_PORT, --port)
This commit is contained in:
@@ -170,6 +170,25 @@ def train(cfg_path, generations, population, data, exchange) -> None:
|
||||
click.echo(f"Gewichte gespeichert in: {cfg.training.state_file}")
|
||||
|
||||
|
||||
@cli.command("serve")
|
||||
@click.option("--config", "cfg_path", default="config.yaml", show_default=True)
|
||||
@click.option("--host", default=None, help="Bind-Adresse (Default: server.host aus config.yaml)")
|
||||
@click.option("--port", type=int, default=None, help="Port (Default: server.port aus config.yaml)")
|
||||
@click.option("--data", type=click.Choice(["auto", "live", "mock"]), default="auto",
|
||||
show_default=True, help="Kursdatenquelle für die API")
|
||||
@click.option("--exchange", default=None, help="Exchange für Kursdaten (zB. binance, kraken)")
|
||||
def serve(cfg_path, host, port, data, exchange) -> None:
|
||||
"""Startet die REST-API + HTML-Dashboard (Paper-Befehle, keine Live-Orders)."""
|
||||
import os
|
||||
|
||||
cfg = load_config(cfg_path)
|
||||
host = host or os.getenv("TM_HOST") or cfg.server.host
|
||||
port = int(port or os.getenv("TM_PORT") or cfg.server.port)
|
||||
from .server import run_server
|
||||
|
||||
run_server(cfg_path, host=host, port=port, data=data, exchange=exchange)
|
||||
|
||||
|
||||
@cli.command("show")
|
||||
@click.argument("path", default="config.yaml")
|
||||
def show(path) -> None:
|
||||
@@ -179,6 +198,7 @@ def show(path) -> None:
|
||||
"trading": cfg.trading.__dict__,
|
||||
"strategy": cfg.strategy.__dict__,
|
||||
"training": cfg.training.__dict__,
|
||||
"server": cfg.server.__dict__,
|
||||
"exchanges": {
|
||||
n: {
|
||||
"api_key": "***" if e.api_key else "",
|
||||
|
||||
Reference in New Issue
Block a user