hyper-agent-core 0.1.0

Core domain logic for hyper-agent: pipeline, executor, signals, positions
Documentation
use crate::error::{HyperAgentError, Result};
use hyper_strategy::strategy_config::{load_strategy_groups_from_disk_pub, StrategyGroup};
use hyper_strategy::strategy_templates::build_template;

/// Resolve a strategy by ID (saved groups) or template name.
pub fn resolve_strategy(id: &str, symbol: Option<&str>) -> Result<StrategyGroup> {
    let groups = load_strategy_groups_from_disk_pub();
    if let Some(sg) = groups.iter().find(|g| g.id == id) {
        return Ok(sg.clone());
    }
    let sym = symbol.ok_or_else(|| {
        HyperAgentError::StrategyNotFound(format!(
            "Strategy '{}' not found. Provide --symbol for template.",
            id
        ))
    })?;
    build_template(id, sym)
        .ok_or_else(|| HyperAgentError::StrategyNotFound(format!("Unknown strategy '{}'", id)))
}