strategy_performance_analysis
Calculate historical trade-level strategy performance metrics from supplied records, including P&L, win/loss statistics and supported drawdown metrics; this is historical analysis, not a forecast.
When to use
Use when an agent needs deterministic historical performance analysis for a supplied trading strategy or trade set.
Selection guidance
Role: specialized. Use when an agent needs deterministic historical performance analysis for a supplied trading strategy or trade set.
Use cases
- strategy performance
- backtest results
- trade statistics
- drawdown analysis
- profit factor
- expectancy
Access
- REST:
POST https://api.rafidsystem.com/api/v1/trading/strategy-performance-analysis - x402:
POST https://api.rafidsystem.com/api/v1/x402/trading/strategy-performance-analysis - MCP tool:
strategy_performance_analysis
Price: $0.35 USD per call. Payment options are deployment-configured; inspect /api/v1/payment-methods. Prices and payment semantics are unchanged from the canonical registry.
Related tools
Example input
{
"trades": [
{
"tradeId": "t1",
"symbol": "BTCUSD",
"direction": "long",
"entryPrice": 100,
"exitPrice": 110,
"quantity": 1,
"fees": 1,
"status": "closed"
},
{
"tradeId": "t2",
"symbol": "BTCUSD",
"direction": "short",
"entryPrice": 100,
"exitPrice": 105,
"quantity": 1,
"fees": 1,
"status": "closed"
}
],
"initialEquity": 1000
}Example output
{
"metrics": {
"totalTrades": 2,
"winningTrades": 1,
"losingTrades": 1,
"breakevenTrades": 0,
"winRate": 0.5,
"lossRate": 0.5,
"grossProfit": 10,
"grossLoss": 5,
"netPnl": 3,
"averageWinningTrade": 9,
"averageLosingTrade": -6,
"largestWinner": 9,
"largestLoser": -6,
"profitFactor": 2,
"expectancyPerTrade": 1.5,
"averageRMultiple": null,
"cumulativeReturn": 0.003,
"maximumDrawdown": 6,
"currentDrawdown": 6,
"recoveryFactor": 0.5,
"sharpeRatio": null,
"sortinoRatio": null,
"volatility": null,
"averageHoldingPeriodSeconds": null,
"bestTradingDay": null,
"worstTradingDay": null,
"maxConsecutiveWins": 1,
"maxConsecutiveLosses": 1
},
"performanceSummary": "Historical example.",
"strengths": [],
"weaknesses": [],
"riskFlags": [],
"dataQuality": {
"completeTradeCount": 2,
"incompleteTradeCount": 0,
"warnings": []
},
"calculationAssumptions": []
}Input schema
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"trades": {
"maxItems": 100000,
"type": "array",
"items": {
"type": "object",
"properties": {
"tradeId": {
"type": "string",
"minLength": 1,
"maxLength": 200
},
"symbol": {
"type": "string",
"minLength": 1,
"maxLength": 100
},
"strategy": {
"type": "string",
"minLength": 1,
"maxLength": 100
},
"assetClass": {
"type": "string",
"minLength": 1,
"maxLength": 100
},
"direction": {
"type": "string",
"enum": [
"long",
"short"
]
},
"timeframe": {
"type": "string",
"minLength": 1,
"maxLength": 30
},
"source": {
"type": "string",
"minLength": 1,
"maxLength": 80
},
"marketRegime": {
"type": "string",
"minLength": 1,
"maxLength": 40
},
"confidence": {
"type": "number",
"minimum": 0,
"maximum": 100
},
"entryTime": {
"anyOf": [
{
"type": "string",
"format": "date-time",
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
},
{
"type": "number"
}
]
},
"exitTime": {
"anyOf": [
{
"type": "string",
"format": "date-time",
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
},
{
"type": "number"
}
]
},
"entryPrice": {
"type": "number",
"exclusiveMinimum": 0
},
"exitPrice": {
"type": "number",
"exclusiveMinimum": 0
},
"quantity": {
"type": "number",
"exclusiveMinimum": 0
},
"fees": {
"type": "number",
"minimum": 0
},
"realizedPnl": {
"type": "number"
},
"stopLoss": {
"type": "number",
"exclusiveMinimum": 0
},
"takeProfit": {
"type": "number",
"exclusiveMinimum": 0
},
"takeProfits": {
"maxItems": 20,
"type": "array",
"items": {
"type": "number",
"exclusiveMinimum": 0
}
},
"status": {
"type": "string",
"enum": [
"open",
"closed",
"cancelled",
"rejected"
]
},
"session": {
"type": "string",
"minLength": 1,
"maxLength": 40
},
"executionStatus": {
"type": "string",
"minLength": 1,
"maxLength": 40
},
"exitReason": {
"type": "string",
"minLength": 1,
"maxLength": 80
},
"leverage": {
"type": "number",
"exclusiveMinimum": 0
},
"margin": {
"type": "number",
"minimum": 0
},
"rMultiple": {
"type": "number"
},
"maxFavorableExcursion": {
"type": "number"
},
"maxAdverseExcursion": {
"type": "number"
}
},
"required": [
"symbol"
],
"additionalProperties": false
}
},
"initialEquity": {
"type": "number",
"minimum": 0
},
"accountEquity": {
"type": "number",
"minimum": 0
},
"riskPerTrade": {
"type": "number",
"exclusiveMinimum": 0
},
"period": {
"type": "object",
"properties": {
"from": {
"anyOf": [
{
"type": "string",
"format": "date-time",
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
},
{
"type": "number"
}
]
},
"to": {
"anyOf": [
{
"type": "string",
"format": "date-time",
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
},
{
"type": "number"
}
]
}
},
"additionalProperties": false
}
},
"required": [
"trades"
],
"additionalProperties": false
}Output schema
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"metrics": {
"type": "object",
"properties": {
"totalTrades": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"winningTrades": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"losingTrades": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"breakevenTrades": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"winRate": {
"type": [
"number",
"null"
]
},
"lossRate": {
"type": [
"number",
"null"
]
},
"grossProfit": {
"type": [
"number",
"null"
]
},
"grossLoss": {
"type": [
"number",
"null"
]
},
"netPnl": {
"type": [
"number",
"null"
]
},
"averageWinningTrade": {
"type": [
"number",
"null"
]
},
"averageLosingTrade": {
"type": [
"number",
"null"
]
},
"largestWinner": {
"type": [
"number",
"null"
]
},
"largestLoser": {
"type": [
"number",
"null"
]
},
"profitFactor": {
"type": [
"number",
"null"
]
},
"expectancyPerTrade": {
"type": [
"number",
"null"
]
},
"averageRMultiple": {
"type": [
"number",
"null"
]
},
"totalR": {
"type": [
"number",
"null"
]
},
"maximumDrawdownR": {
"type": [
"number",
"null"
]
},
"cumulativeReturn": {
"type": [
"number",
"null"
]
},
"maximumDrawdown": {
"type": [
"number",
"null"
]
},
"currentDrawdown": {
"type": [
"number",
"null"
]
},
"recoveryFactor": {
"type": [
"number",
"null"
]
},
"sharpeRatio": {
"type": [
"number",
"null"
]
},
"sortinoRatio": {
"type": [
"number",
"null"
]
},
"volatility": {
"type": [
"number",
"null"
]
},
"averageHoldingPeriodSeconds": {
"type": [
"number",
"null"
]
},
"bestTradingDay": {
"type": [
"string",
"null"
]
},
"worstTradingDay": {
"type": [
"string",
"null"
]
},
"maxConsecutiveWins": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"maxConsecutiveLosses": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"totalTrades",
"winningTrades",
"losingTrades",
"breakevenTrades",
"winRate",
"lossRate",
"grossProfit",
"grossLoss",
"netPnl",
"averageWinningTrade",
"averageLosingTrade",
"largestWinner",
"largestLoser",
"profitFactor",
"expectancyPerTrade",
"averageRMultiple",
"cumulativeReturn",
"maximumDrawdown",
"currentDrawdown",
"recoveryFactor",
"sharpeRatio",
"sortinoRatio",
"volatility",
"averageHoldingPeriodSeconds",
"bestTradingDay",
"worstTradingDay",
"maxConsecutiveWins",
"maxConsecutiveLosses"
],
"additionalProperties": false
},
"performanceSummary": {
"type": "string"
},
"strengths": {
"type": "array",
"items": {
"type": "string"
}
},
"weaknesses": {
"type": "array",
"items": {
"type": "string"
}
},
"riskFlags": {
"type": "array",
"items": {
"type": "string"
}
},
"dataQuality": {
"type": "object",
"properties": {
"completeTradeCount": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"incompleteTradeCount": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"warnings": {
"type": "array",
"items": {
"type": "string"
}
}
},
"required": [
"completeTradeCount",
"incompleteTradeCount",
"warnings"
],
"additionalProperties": false
},
"calculationAssumptions": {
"type": "array",
"items": {
"type": "string"
}
},
"methodology": {
"type": "array",
"items": {
"type": "string"
}
},
"sourceTraceability": {
"type": "object",
"properties": {
"strategyPerformance": {
"type": "string",
"enum": [
"GROK",
"SIGNALFLOW",
"MERGED",
"NEW"
]
},
"tradeRisk": {
"type": "string",
"enum": [
"GROK",
"SIGNALFLOW",
"MERGED",
"NEW"
]
},
"portfolioExposure": {
"type": "string",
"enum": [
"GROK",
"SIGNALFLOW",
"MERGED",
"NEW"
]
},
"tradeLog": {
"type": "string",
"enum": [
"GROK",
"SIGNALFLOW",
"MERGED",
"NEW"
]
},
"notes": {
"type": "array",
"items": {
"type": "string"
}
}
},
"required": [
"strategyPerformance",
"tradeRisk",
"portfolioExposure",
"tradeLog",
"notes"
],
"additionalProperties": false
}
},
"required": [
"metrics",
"performanceSummary",
"strengths",
"weaknesses",
"riskFlags",
"dataQuality",
"calculationAssumptions"
],
"additionalProperties": false
}Category: Trading Intelligence · hierarchy: specialized · idempotent: yes · side effects: no