{
  "$schema": "https://opencode.ai/config.json",
  "default_agent": "trading-ml",
  "instructions": [
    "AGENTS.md",
    ".opencode/docs/ARCHITECTURE.md",
    ".opencode/docs/DATA.md",
    ".opencode/docs/MODELS.md"
  ],
  "agent": {
    "trading-ml": {
      "description": "Primary agent for ML trading strategy on MOEX. Coordinates data engineering, feature design, model training, backtesting, trade management, and monitoring.",
      "mode": "primary",
      "permission": { "edit": "allow", "bash": "allow", "task": "allow" }
    },
    "db-explorer": {
      "description": "Use ONLY for database exploration: inspecting schemas, running queries, checking table structures in the MySQL bitcoin_tickers database.",
      "mode": "subagent",
      "permission": { "edit": "deny", "bash": "allow" }
    },
    "data-engineer": {
      "description": "Use for data loading, cleaning, preprocessing pipelines, pandas transformations, and data validation tasks.",
      "mode": "subagent",
      "permission": { "edit": "allow", "bash": "allow" }
    },
    "feature-designer": {
      "description": "Use for technical indicator implementation, feature engineering, signal construction, and alpha research.",
      "mode": "subagent",
      "permission": { "edit": "allow", "bash": "allow" }
    },
    "model-trainer": {
      "description": "Use for ML model training (MoE, ExpertEnsemble, DQN), hyperparameter tuning, cross-validation, model evaluation, and experiment tracking.",
      "mode": "subagent",
      "permission": { "edit": "allow", "bash": "allow" }
    },
    "backtester": {
      "description": "Use for backtesting trading strategies, computing PnL, Sharpe ratio, drawdown analysis, and performance metrics.",
      "mode": "subagent",
      "permission": { "edit": "allow", "bash": "allow" }
    },
    "expert": {
      "description": "LSTM expert system — 16 parallel/cascaded expert networks (Trend, Vol, Momentum, etc.). Train and orchestrate multi-expert ensembles for MoE v12.",
      "mode": "subagent",
      "instructions": [".opencode/agent/expert/SKILL.md"],
      "permission": { "edit": "allow", "bash": "allow", "task": "allow" }
    },
    "trade-planner": {
      "description": "Расчёт параметров сделки (entry, SL, TP, лесенка) для confirmed BUY/SELL сигналов. Загружает данные, вычисляет ATR, строит план позиции.",
      "mode": "subagent",
      "instructions": [".opencode/agent/trade-planner/SKILL.md"],
      "permission": { "edit": "deny", "bash": "allow" }
    },
    "explore": {
      "description": "Fast agent specialized for exploring codebases. Use for quickly finding files by patterns, searching code for keywords, or answering questions about the codebase structure.",
      "mode": "subagent",
      "permission": { "edit": "deny", "bash": "allow" }
    },
    "general": {
      "description": "General-purpose agent for researching complex questions and executing multi-step tasks.",
      "mode": "subagent",
      "permission": { "edit": "allow", "bash": "allow", "task": "allow" }
    }
  },
  "skills": {
    "paths": [".opencode/skills"]
  },
  "command": {
    "train": {
      "description": "Train a model for a ticker. Usage: /train SBER --moe or /train SBER",
      "agent": "model-trainer",
      "template": "The user wants to train a model. Input: {{input}}. Run the appropriate training script (train_all_rr1x2.py for MoE RR 1:2, or main.py for legacy modes) with the given parameters."
    },
    "features": {
      "description": "Generate or modify technical features. Usage: /features list",
      "agent": "feature-designer",
      "template": "The user wants to work with features. Input: {{input}}. Implement or modify technical indicators and feature engineering code as requested."
    },
    "backtest": {
      "description": "Run a backtest for a trained model. Usage: /backtest SBER --load model.joblib",
      "agent": "backtester",
      "template": "The user wants to run a backtest. Input: {{input}}. Execute the backtesting workflow (MoE predict_proba_aligned, walk-forward, or TradeManager stats) and report performance metrics."
    },
    "data": {
      "description": "Explore or load data from the database. Usage: /data list-tables or /data load SBER H1",
      "agent": "db-explorer",
      "template": "The user wants to explore or load data. Input: {{input}}. Use database exploration tools to inspect schemas, run queries, or load data as requested."
    },
    "experts": {
      "description": "Train or run the LSTM expert ensemble. Usage: /experts train SBER, /experts predict SBER",
      "agent": "expert",
      "template": "The user wants to work with the expert ensemble. Input: {{input}}. Train (`--moe`, `--experts --save`), evaluate, or run fast inference with the 16-expert LSTM system."
    },
    "trade": {
      "description": "Рассчитать параметры сделки для confirmed сигнала. Usage: /trade SBER SELL 100000",
      "agent": "trade-planner",
      "template": "The user wants to plan a trade. Input: {{input}}. Extract ticker, direction (BUY/SELL), and optional capital. Call models.trade_planner.plan_trade() and display the full trade plan (entry, SL, TP, position sizing, ladder)."
    }
  }
}
