Files
mt5-quant/src/tools/definitions/analytics.rs
T
Devid HW bc5d0d7022 Reorganize tool definitions into granular domain modules
**New structure:**
src/tools/definitions/
├── mod.rs         # Aggregates all 43 tools
├── system.rs      # 3 tools: healthcheck, verify_setup, list_symbols
├── experts.rs     # 4 tools: compile_ea, list_experts, list_indicators, list_scripts
├── backtest.rs    # 4 tools: run_backtest, get_backtest_status, cache_status, clean_cache
├── optimization.rs # 4 tools: run_optimization, get_optimization_status, get_optimization_results, list_jobs
├── analytics.rs   # 9 tools: analyze_report + 8 granular analytics
├── reports.rs     # 11 tools: list_reports, search_reports, get_latest_report, etc.
├── setfiles.rs    # 8 tools: read/write/patch/clone/diff set files
└── baseline.rs    # 1 tool: compare_baseline

**Benefits:**
- Domain-based organization (21KB monolith -> 9 focused files)
- Each domain can evolve independently
- Easier to find and modify tool definitions
- Clear separation between system, experts, backtest, optimization, analytics, reports, setfiles
2026-04-19 02:25:25 +07:00

129 lines
4.0 KiB
Rust

use serde_json::{json, Value};
pub fn tool_analyze_report() -> Value {
json!({
"name": "analyze_report",
"description": "Run comprehensive analytics on a backtest report. By default runs all analytics. Use 'analytics' array to run specific ones: monthly_pnl, drawdown_events, top_losses, loss_sequences, position_pairs, direction_bias, streak_analysis, concurrent_peak",
"inputSchema": {
"type": "object",
"properties": {
"report_dir": { "type": "string", "description": "Path to report directory containing deals.csv" },
"analytics": {
"type": "array",
"description": "Optional: specific analytics to run. If omitted, runs all.",
"items": {
"type": "string",
"enum": ["monthly_pnl", "drawdown_events", "top_losses", "loss_sequences", "position_pairs", "direction_bias", "streak_analysis", "concurrent_peak"]
}
},
"top_losses_limit": { "type": "integer", "description": "Number of top losses to return (default: 10)" }
}
}
})
}
pub fn tool_analyze_monthly_pnl() -> Value {
json!({
"name": "analyze_monthly_pnl",
"description": "Analyze monthly profit/loss breakdown from a backtest report",
"inputSchema": {
"type": "object",
"properties": {
"report_dir": { "type": "string", "description": "Path to report directory containing deals.csv" }
}
}
})
}
pub fn tool_analyze_drawdown_events() -> Value {
json!({
"name": "analyze_drawdown_events",
"description": "Analyze drawdown events reconstructed from balance curve",
"inputSchema": {
"type": "object",
"properties": {
"report_dir": { "type": "string" }
}
}
})
}
pub fn tool_analyze_top_losses() -> Value {
json!({
"name": "analyze_top_losses",
"description": "Get top N worst losses with grid depth analysis",
"inputSchema": {
"type": "object",
"properties": {
"report_dir": { "type": "string" },
"limit": { "type": "integer", "description": "Number of losses to return (default: 10)", "default": 10 }
}
}
})
}
pub fn tool_analyze_loss_sequences() -> Value {
json!({
"name": "analyze_loss_sequences",
"description": "Analyze consecutive loss streaks and their impact",
"inputSchema": {
"type": "object",
"properties": {
"report_dir": { "type": "string" }
}
}
})
}
pub fn tool_analyze_position_pairs() -> Value {
json!({
"name": "analyze_position_pairs",
"description": "Analyze entry/exit position pairs and their performance",
"inputSchema": {
"type": "object",
"properties": {
"report_dir": { "type": "string" }
}
}
})
}
pub fn tool_analyze_direction_bias() -> Value {
json!({
"name": "analyze_direction_bias",
"description": "Analyze long vs short performance bias",
"inputSchema": {
"type": "object",
"properties": {
"report_dir": { "type": "string" }
}
}
})
}
pub fn tool_analyze_streaks() -> Value {
json!({
"name": "analyze_streaks",
"description": "Analyze win/loss streaks with dates and current streak",
"inputSchema": {
"type": "object",
"properties": {
"report_dir": { "type": "string" }
}
}
})
}
pub fn tool_analyze_concurrent_peak() -> Value {
json!({
"name": "analyze_concurrent_peak",
"description": "Find peak number of concurrent open positions",
"inputSchema": {
"type": "object",
"properties": {
"report_dir": { "type": "string" }
}
}
})
}