{
  "$schema": "https://opencode.ai/config.json",
  "instructions": [
    "AGENTS.md"
  ],
  "watcher": {
    "ignore": [
      ".ipynb_checkpoints/**",
      "__pycache__/**",
      "*.pyc",
      ".env",
      "*.log"
    ]
  },
  "agent": {
    "build": {
      "mode": "primary",
      "permission": {
        "edit": "allow",
        "bash": "allow"
      }
    },
    "plan": {
      "mode": "primary",
      "permission": {
        "edit": "deny",
        "bash": "deny"
      }
    },
    "tech-analyst": {
      "description": "Speculative technical analysis MOEX (H1/D1): entry/exit, swing trading, impulses, patterns, Wyckoff, order book",
      "mode": "subagent",
      "permission": {
        "edit": "deny",
        "bash": {
          "python *": "allow",
          "pip *": "allow"
        },
        "grep": "allow",
        "skill": {
          "db-schema-reference": "allow",
          "tbank-api-reference": "allow",
          "moex-tickers": "allow",
          "indicators-library": "allow",
          "spec-tech-analysis": "allow",
          "state-management": "allow"
        }
      }
    },
    "fund-analyst": {
      "description": "Speculative fundamental analysis MOEX: catalysts, news, macro events, earnings, dividend cutoffs",
      "mode": "subagent",
      "permission": {
        "edit": "deny",
        "bash": {
          "*": "deny",
          "python *": "allow",
          "pip *": "allow"
        },
        "grep": "allow",
        "webfetch": "allow",
        "skill": {
          "db-schema-reference": "allow",
          "moex-tickers": "allow",
          "tbank-api-reference": "allow",
          "spec-fund-analysis": "allow",
          "news-context": "allow",
          "state-management": "allow"
        }
      }
    },
    "invest-tech-analyst": {
      "description": "Investment technical analysis MOEX (D1/W1/MN): long-term trends, accumulation phases, strategic levels, dividend gaps",
      "mode": "subagent",
      "permission": {
        "edit": "deny",
        "bash": {
          "python *": "allow",
          "pip *": "allow"
        },
        "grep": "allow",
        "skill": {
          "db-schema-reference": "allow",
          "tbank-api-reference": "allow",
          "moex-tickers": "allow",
          "indicators-library": "allow",
          "invest-tech-analysis": "allow",
          "state-management": "allow"
        }
      }
    },
    "invest-fund-analyst": {
      "description": "Investment fundamental analysis MOEX: DCF, business value, sector analysis, dividends, macro trends",
      "mode": "subagent",
      "permission": {
        "edit": "deny",
        "bash": {
          "*": "deny",
          "python *": "allow",
          "pip *": "allow"
        },
        "grep": "allow",
        "webfetch": "allow",
        "skill": {
          "db-schema-reference": "allow",
          "moex-tickers": "allow",
          "tbank-api-reference": "allow",
          "invest-fund-analysis": "allow",
          "news-context": "allow",
          "state-management": "allow"
        }
      }
    },
    "python-modules-dev": {
      "description": "Development of supporting Python modules: indicators, oscillators, calculation functions, utilities",
      "mode": "subagent",
      "permission": {
        "edit": "allow",
        "bash": {
          "*": "deny",
          "python *": "allow",
          "pip *": "allow",
          "grep *": "allow",
          "pytest *": "allow",
          "ruff *": "allow",
          "mypy *": "allow"
        },
        "skill": {
          "*": "allow"
        }
      }
    },
    "db-review": {
      "description": "Review and verification of SQL queries, DB table schemas, optimization",
      "mode": "subagent",
      "permission": {
        "edit": "deny",
        "bash": "deny",
        "grep": "allow",
        "skill": {
          "db-schema-reference": "allow"
        }
      }
    },
    "trade-executor": {
      "description": "Opening trades via T-Bank API: limit orders, stop-loss, take-profit, position sizing",
      "mode": "subagent",
      "permission": {
        "edit": "deny",
        "bash": {
          "*": "allow"
        },
        "grep": "allow",
        "skill": {
          "tbank-api-reference": "allow",
          "moex-tickers": "allow",
          "spec-tech-analysis": "allow",
          "state-management": "allow"
        }
      }
    },
    "nn-tech-analyst": {
      "description": "Neural network technical analysis MOEX: NN inference, signal generation, integration with traditional TA, ensemble predictions",
      "mode": "subagent",
      "permission": {
        "edit": "deny",
        "bash": {
          "python *": "allow",
          "pip *": "allow"
        },
        "grep": "allow",
        "skill": {
          "db-schema-reference": "allow",
          "tbank-api-reference": "allow",
          "moex-tickers": "allow",
          "indicators-library": "allow",
          "nn-architecture": "allow",
          "nn-data-preparation": "allow",
          "nn-training-methodology": "allow",
          "spec-tech-analysis": "allow",
          "state-management": "allow"
        }
      }
    },
    "nn-data-engineer": {
      "description": "Data preparation for neural networks: feature engineering, dataset creation, data quality, normalization, train/val/test splits",
      "mode": "subagent",
      "permission": {
        "edit": "allow",
        "bash": {
          "*": "deny",
          "python *": "allow",
          "pip *": "allow",
          "grep *": "allow",
          "pytest *": "allow",
          "ruff *": "allow",
          "mypy *": "allow"
        },
        "skill": {
          "*": "allow"
        }
      }
    },
    "nn-trainer": {
      "description": "Training and validation of neural networks for technical analysis: model creation, training loops, hyperparameter tuning, backtesting, model registry",
      "mode": "subagent",
      "permission": {
        "edit": "allow",
        "bash": {
          "*": "deny",
          "python *": "allow",
          "pip *": "allow",
          "grep *": "allow",
          "pytest *": "allow",
          "ruff *": "allow",
          "mypy *": "allow"
        },
        "skill": {
          "*": "allow"
        }
      }
    },
    "wyckoff-analyst": {
      "description": "Wyckoff phase analysis for MOEX tickers \u2014 rule-based algorithmic labeling (H1/D1/W1)",
      "mode": "subagent",
      "permission": {
        "edit": "deny",
        "bash": {
          "python *": "allow",
          "pip *": "allow"
        },
        "grep": "allow",
        "skill": {
          "db-schema-reference": "allow",
          "moex-tickers": "allow",
          "state-management": "allow"
        }
      }
    }
  },
  "mcp": {
    "sftp": {
      "type": "local",
      "command": [
        "/home/ai/.local/bin/sftp-mcp-wrapper.sh",
        "--host=192.168.1.135",
        "--port=22",
        "--user=ai",
        "--password=g49020007"
      ],
      "enabled": true
    },
    "duckduckgo": {
      "type": "local",
      "command": [
        "npx",
        "duckduckgo-websearch"
      ]
    }
  },
  "command": {
    "fetch": {
      "description": "Fetch quotes from DB by ticker and timeframe",
      "template": "python -c \"import mysql.connector; conn = mysql.connector.connect(host='nlbotinterface.ru', port=3306, user='bitcoin', password='g49020007', database='bitcoin_tickers'); cursor = conn.cursor(); cursor.execute('SELECT * FROM {TICKER}_{TF} ORDER BY timestamp DESC LIMIT 10'); [print(row) for row in cursor.fetchall()]; conn.close()\""
    },
    "analyze": {
      "description": "Run technical analysis for a ticker",
      "agent": "tech-analyst",
      "template": "Perform technical analysis for ticker {TICKER} on timeframes H1, D1, W1. Read reports/00-STATE.md and reports/tickers/{TICKER}.md before starting. After analysis, update both files."
    },
    "fundamental": {
      "description": "Run fundamental analysis for a ticker",
      "agent": "fund-analyst",
      "template": "Perform fundamental analysis for ticker {TICKER}. Read reports/00-STATE.md and reports/tickers/{TICKER}.md before starting. After analysis, update both files."
    },
    "full-report": {
      "description": "Combined report: technical + fundamental analysis (sequential)",
      "template": "Perform full analysis of ticker {TICKER} SEQUENTIALLY:\n1. FIRST call @tech-analyst for technical analysis of {TICKER}. WAIT for completion.\n2. THEN call @fund-analyst for fundamental analysis of {TICKER}. WAIT for completion.\n3. Combine results and update reports/tickers/{TICKER}.md and reports/00-STATE.md.\nDO NOT run agents in parallel \u2014 strictly one at a time."
    },
    "state": {
      "description": "View project state and analyses",
      "template": "Read reports/00-STATE.md and reports/tickers/{TICKER}.md (if specified). Show the current state."
    },
    "batch-analyze": {
      "description": "Batch analysis of tickers (sequential)",
      "template": "Perform full analysis of tickers: {TICKERS} SEQUENTIALLY (not in parallel).\nFor EACH ticker in the list:\n1. Read reports/00-STATE.md and reports/tickers/{TICKER}.md\n2. FIRST call @tech-analyst for technical analysis. WAIT for completion.\n3. THEN call @fund-analyst for fundamental analysis. WAIT for completion.\n4. Update reports/tickers/{TICKER}.md and reports/00-STATE.md\n\nMove to the next ticker ONLY after fully completing the previous one.\nDO NOT run analysis of multiple tickers in parallel."
    },
    "invest-analyze": {
      "description": "Run investment technical analysis for a ticker",
      "agent": "invest-tech-analyst",
      "template": "Perform investment technical analysis for ticker {TICKER} on timeframes D1, W1, MN. Find a long-term entry point. Read reports/00-STATE.md and reports/tickers/{TICKER}.md before starting."
    },
    "invest-fundamental": {
      "description": "Run investment fundamental analysis for a ticker",
      "agent": "invest-fund-analyst",
      "template": "Perform investment fundamental analysis for ticker {TICKER}. Assess fair value (DCF + multiples + DDM). Read reports/00-STATE.md and reports/tickers/{TICKER}.md before starting."
    },
    "invest-report": {
      "description": "Full investment report: tech + fund analysis for long-term portfolio (sequential)",
      "template": "Generate an investment report for ticker {TICKER} SEQUENTIALLY:\n1. FIRST call @invest-tech-analyst for investment technical analysis of {TICKER}. WAIT for completion.\n2. THEN call @invest-fund-analyst for investment fundamental analysis of {TICKER}. WAIT for completion.\n3. Combine results: entry zone + fair value + final recommendation.\n4. Update reports/tickers/{TICKER}.md.\nDO NOT run agents in parallel \u2014 strictly one at a time."
    },
    "trade": {
      "description": "Open a trade via T-Bank API based on signal from report",
      "agent": "trade-executor",
      "template": "Read the signal for ticker {TICKER} from reports/tickers/{TICKER}.md. Check parameters, calculate position size (risk 1% of {CAPITAL} RUB). Place a limit order via T-Bank API. Request confirmation before sending."
    },
    "trade-manual": {
      "description": "Open a trade with manual parameters via T-Bank API",
      "agent": "trade-executor",
      "template": "Place a trade via T-Bank API: ticker={TICKER}, direction={DIRECTION}, entry={ENTRY} RUB, SL={SL} RUB, TP={TP} RUB, capital={CAPITAL} RUB. Check parameters, calculate lots, round prices, request confirmation."
    },
    "trade-report": {
      "description": "Show report on all open and closed trades",
      "template": "Generate a trade report: read reports/trades.json, show open positions, statistics (P&L, win rate, commissions), last closed trades."
    },
    "close-trade": {
      "description": "Close an open trade",
      "agent": "trade-executor",
      "template": "Close trade {TRADE_ID} for ticker {TICKER} at the current market price. Fetch price via T-Bank API, calculate exit commission, update trade journal reports/trades.json."
    },
    "nn-analyze": {
      "description": "Run neural network analysis for a ticker (NN + traditional TA integration)",
      "agent": "nn-tech-analyst",
      "template": "Perform neural network analysis for ticker {TICKER}. Check if trained NN model exists in registry. Load best model, run inference on D1 timeframe, integrate with traditional TA. Read reports/00-STATE.md and reports/tickers/{TICKER}.md before starting. After analysis, update both files."
    },
    "nn-train-ticker": {
      "description": "Train a neural network model for a specific ticker",
      "agent": "nn-trainer",
      "template": "Train a neural network model for ticker {TICKER} on timeframe {TF}. 1. Prepare data (use @nn-data-engineer's pipeline). 2. Select architecture: {ARCH} (lstm/gru/cnn/transformer). 3. Run hyperparameter optimization (50 trials). 4. Train best model. 5. Run walk-forward backtest. 6. Register in ModelRegistry and export for inference. Update src/ml/ code as needed."
    },
    "nn-prepare-data": {
      "description": "Prepare ML dataset for a ticker (feature engineering + normalization + sequences)",
      "agent": "nn-data-engineer",
      "template": "Prepare ML dataset for ticker {TICKER} on timeframe {TF}. Run the full data pipeline: load OHLCV \u2192 add price features \u2192 add indicator features \u2192 add calendar features \u2192 encode targets \u2192 normalize \u2192 create sequences \u2192 save dataset. Update src/ml/features/ and src/ml/data/ modules as needed. Update reports/00-STATE.md."
    },
    "nn-registry": {
      "description": "Show trained NN models in registry",
      "template": "Read the model registry at src/ml/models/saved/registry.json. Show all registered models grouped by ticker with their metrics (accuracy, Sharpe ratio, training date). Highlight the best model per ticker."
    },
    "nn-backtest": {
      "description": "Backtest a trained NN model using walk-forward validation",
      "agent": "nn-trainer",
      "template": "Run walk-forward backtest for model {MODEL} (or for ticker {TICKER}). Load model from ModelRegistry, run walk-forward validation, calculate trading metrics (Sharpe, return, drawdown, win rate). Output detailed backtest report."
    },
    "wyckoff": {
      "description": "Run Wyckoff phase analysis for one or more tickers (rule-based, no NN)",
      "agent": "wyckoff-analyst",
      "template": "Perform Wyckoff phase analysis for ticker {TICKER}. Load D1 data from DB, calculate features, run WyckoffLabeler. Report current phase, market structure, detected events. Read reports/00-STATE.md before starting. After analysis, save report to reports/tickers/{TICKER}_wyckoff.md and update reports/00-STATE.md."
    },
    "wyckoff-batch": {
      "description": "Batch Wyckoff analysis of multiple tickers (sequential)",
      "agent": "wyckoff-analyst",
      "template": "Perform Wyckoff phase analysis for tickers: {TICKERS} SEQUENTIALLY. For each ticker: load D1 data \u2192 calculate features \u2192 run WyckoffLabeler \u2192 report phase/events/structure \u2192 save to reports/tickers/{TICKER}_wyckoff.md. After ALL tickers, update reports/00-STATE.md with aggregated Wyckoff phase summary."
    }
  }
}