Files
Multi_Swarm_Coevolutive/scripts/smoke_run.py
Adriano Dal Pastro b6539802e0 refactor(layout): rename multi_swarm → multi_swarm_core con doppia nidificazione uv workspace
- mv src/multi_swarm → src/multi_swarm_core/multi_swarm_core (member layout)
- sed-replace globale degli import: from/import multi_swarm.* → multi_swarm_core.*
- 115 occorrenze aggiornate in src/ scripts/ tests/
- multi_swarm_coevolutive (nome repo) preservato dal word boundary

Pre-condizione per il setup uv workspace della Fase 3.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-15 17:43:48 +00:00

77 lines
2.2 KiB
Python

from __future__ import annotations
import json
from pathlib import Path
import numpy as np
import pandas as pd # type: ignore[import-untyped]
from multi_swarm_core.genome.hypothesis import HypothesisAgentGenome, ModelTier
from multi_swarm_core.llm.client import CompletionResult
from multi_swarm_core.orchestrator.run import RunConfig, run_phase1
_MOCK_STRATEGY = json.dumps(
{
"rules": [
{
"condition": {
"op": "gt",
"args": [
{"kind": "indicator", "name": "rsi", "params": [14]},
{"kind": "literal", "value": 70.0},
],
},
"action": "entry-short",
},
{
"condition": {
"op": "lt",
"args": [
{"kind": "indicator", "name": "rsi", "params": [14]},
{"kind": "literal", "value": 30.0},
],
},
"action": "entry-long",
},
]
}
)
class MockLLMClient:
def complete(
self, genome: HypothesisAgentGenome, system: str, user: str,
max_tokens: int = 2000,
) -> CompletionResult:
text = "```json\n" + _MOCK_STRATEGY + "\n```"
return CompletionResult(
text=text, input_tokens=120, output_tokens=60,
tier=genome.model_tier, model="mock",
)
def main() -> None:
idx = pd.date_range("2024-01-01", periods=1000, freq="1h", tz="UTC")
close = 100 + np.cumsum(np.random.RandomState(0).normal(0.01, 1.0, 1000))
ohlcv = pd.DataFrame(
{"open": close, "high": close + 0.5, "low": close - 0.5, "close": close, "volume": 1.0},
index=idx,
)
cfg = RunConfig(
run_name="smoke",
population_size=3,
n_generations=1,
elite_k=1,
tournament_k=2,
p_crossover=0.5,
seed=0,
model_tier=ModelTier.C,
db_path=Path("./runs.db"),
)
run_id = run_phase1(cfg, ohlcv=ohlcv, llm=MockLLMClient()) # type: ignore[arg-type]
print(f"Smoke run completed: {run_id}")
if __name__ == "__main__":
main()