{
  "$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"
  ],
  "provider": {
    "studio": {
      "name": "LM Studio",
      "npm": "@ai-sdk/openai-compatible",
      "options": {
        "baseURL": "http://192.168.1.54:1234/v1"
      },
      "models": {
        "glm-5.2": {
          "name": "GLM 5.2",
          "contextLimit": 1048576
        },
        "google/gemma-4-26b-a4b-qat": {
          "name": "Gemma 4 26b (A4B QAT)",
          "contextLimit": 262144
        },
        "nvidia/nemotron-3-nano-omni": {
          "name": "Nemotron 3 Nano Omni 30b",
          "contextLimit": 262144
        },
        "mistralai/devstral-small-2-2512": {
          "name": "DevStral Small 2 24b",
          "contextLimit": 393216
        },
        "qwen/qwen3-coder-30b": {
          "name": "Qwen3 Coder 30b",
          "contextLimit": 262144
        },
        "zai-org/glm-4.7-flash": {
          "name": "GLM 4.7 Flash 30b",
          "contextLimit": 202752
        },
        "qwen/qwen3.6-27b": {
          "name": "Qwen 3.6 27b",
          "contextLimit": 262144
        },
        "omnicoder-9b": {
          "name": "OmniCoder (Qwen3.5) 9b",
          "contextLimit": 262144
        },
        "qwen/qwen3.5-9b": {
          "name": "Qwen 3.5 9b",
          "contextLimit": 262144
        },
        "qwen/qwen3.6-35b-a3b": {
          "name": "Qwen 3.6 35b",
          "contextLimit": 262144
        }
      }
    }
  },
  "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" }
    }
  },
  "mcp": {
    "ssh": {
      "type": "local",
      "command": ["/home/ai/node_modules/.bin/ssh-mcp", "--host=chicker.ru", "--port=22", "--user=pi", "--password=g49020007", "--timeout=30000", "--maxChars=none"],
      "enabled": true
    }
  },
  "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)."
    }
  }
}
