refactor: remove mock trading functionality from backend and frontend

Removes all mock price simulation features:
- Delete MockPriceManager from backend/data/
- Remove mock_mode, enable_mock, is_mock_mode flags from services
- Remove mock CLI options and config
- Remove mock mode UI components and state from frontend
- Update tests to remove mock references

Now system supports only live and backtest modes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-26 13:38:51 +08:00
parent fecf8a9466
commit 9bcc4221a4
21 changed files with 56 additions and 709 deletions

View File

@@ -1019,11 +1019,6 @@ def backtest(
@app.command()
def live(
mock: bool = typer.Option(
False,
"--mock",
help="Use mock mode with simulated prices (for testing)",
),
config_name: str = typer.Option(
"live",
"--config-name",
@@ -1078,7 +1073,6 @@ def live(
Example:
evotraders live # Run immediately (default)
evotraders live --mock # Mock mode
evotraders live -t 22:30 # Run at 22:30 local time daily
evotraders live --schedule-mode intraday --interval-minutes 60
evotraders live --trigger-time now # Run immediately
@@ -1086,33 +1080,31 @@ def live(
"""
schedule_mode = str(_normalize_typer_value(schedule_mode, "daily"))
interval_minutes = int(_normalize_typer_value(interval_minutes, 60))
mode_name = "MOCK" if mock else "LIVE"
console.print(
Panel.fit(
f"[bold cyan]EvoTraders {mode_name} Mode[/bold cyan]",
"[bold cyan]EvoTraders LIVE Mode[/bold cyan]",
border_style="cyan",
),
)
# Check for required API key in live mode
if not mock:
env_file = get_project_root() / ".env"
if not env_file.exists():
console.print("\n[yellow]Warning: .env file not found[/yellow]")
console.print("Creating from template...\n")
template = get_project_root() / "env.template"
if template.exists():
shutil.copy(template, env_file)
console.print("[green].env file created[/green]")
console.print(
"\n[red]Error: Please edit .env and set FINNHUB_API_KEY[/red]",
)
console.print(
"Get your free API key at: https://finnhub.io/register\n",
)
else:
console.print("[red]Error: env.template not found[/red]")
raise typer.Exit(1)
env_file = get_project_root() / ".env"
if not env_file.exists():
console.print("\n[yellow]Warning: .env file not found[/yellow]")
console.print("Creating from template...\n")
template = get_project_root() / "env.template"
if template.exists():
shutil.copy(template, env_file)
console.print("[green].env file created[/green]")
console.print(
"\n[red]Error: Please edit .env and set FINNHUB_API_KEY[/red]",
)
console.print(
"Get your free API key at: https://finnhub.io/register\n",
)
else:
console.print("[red]Error: env.template not found[/red]")
raise typer.Exit(1)
# Handle historical data cleanup
handle_history_cleanup(config_name, auto_clean=clean)
@@ -1168,12 +1160,9 @@ def live(
# Display configuration
console.print("\n[bold]Configuration:[/bold]")
if mock:
console.print(" Mode: [yellow]MOCK[/yellow] (Simulated prices)")
else:
console.print(
" Mode: [green]LIVE[/green] (Real-time prices via Finnhub)",
)
console.print(
" Mode: [green]LIVE[/green] (Real-time prices via Finnhub)",
)
console.print(f" Config: {config_name}")
console.print(f" Server: {host}:{port}")
console.print(f" Poll Interval: {poll_interval}s")
@@ -1188,22 +1177,17 @@ def live(
project_root = get_project_root()
os.chdir(project_root)
# Data update (if not mock mode)
if not mock:
run_data_updater(project_root)
auto_update_market_store(
config_name,
end_date=nyse_now.date().isoformat(),
)
auto_enrich_market_store(
config_name,
end_date=nyse_now.date().isoformat(),
force=False,
)
else:
console.print(
"\n[dim]Mock mode enabled - skipping data update[/dim]\n",
)
# Data update
run_data_updater(project_root)
auto_update_market_store(
config_name,
end_date=nyse_now.date().isoformat(),
)
auto_enrich_market_store(
config_name,
end_date=nyse_now.date().isoformat(),
force=False,
)
# Build command using backend.main
cmd = [
@@ -1229,8 +1213,6 @@ def live(
str(interval_minutes),
]
if mock:
cmd.append("--mock")
if enable_memory:
cmd.append("--enable-memory")