set_custom_strategy
Define custom trading strategies with specific conditions to evaluate against market data for financial decision-making.
Instructions
Create a custom trading strategy with your own conditions. Then use evaluate_strategy to test it against current market conditions.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Name for your strategy | |
| conditions | Yes | Array of conditions that must ALL be met |
Implementation Reference
- src/tools/set-custom-strategy.ts:21-43 (handler)The handler function that processes the set_custom_strategy tool call.
export function setCustomStrategyTool(input: SetStrategyInput): SetStrategyResult { const validated = input.conditions .filter(c => c.field && c.operator && c.threshold !== undefined) .map(c => ({ field: c.field, operator: c.operator as ConditionOperator, threshold: c.threshold, })); setStrategy(AGENT_ID, { name: input.name, conditions: validated, created_at: new Date().toISOString(), }); return { success: true, agent_id: AGENT_ID, strategy_name: input.name, conditions_count: validated.length, agent_guidance: `Custom strategy "${input.name}" saved with ${validated.length} conditions. Call evaluate_strategy with strategy: "${input.name}" to evaluate against current market conditions.`, }; } - Input and Output type definitions for the set_custom_strategy tool.
export interface SetStrategyInput { name: string; conditions: Array<{ field: string; operator: string; threshold: string | number }>; } export interface SetStrategyResult { success: boolean; agent_id: string; strategy_name: string; conditions_count: number; agent_guidance: string; } - src/index.ts:342-361 (registration)Registration of the set_custom_strategy tool in the MCP server.
// ─── Tool: set_custom_strategy ─── server.tool( 'set_custom_strategy', 'Create a custom trading strategy with your own conditions. Then use evaluate_strategy to test it against current market conditions.', { name: z.string().describe('Name for your strategy'), conditions: z.array(z.object({ field: z.string().describe('Condition field (fear_greed, risk_score, regime, posture, etc.)'), operator: z.string().describe('Comparison operator: <, >, <=, >=, ==, !='), threshold: z.union([z.string(), z.number()]).describe('Threshold value'), })).describe('Array of conditions that must ALL be met'), }, async ({ name, conditions }) => { const gateError = gateTool('set_custom_strategy'); if (gateError) return { content: [{ type: 'text' as const, text: gateError }] }; const result = setCustomStrategyTool({ name, conditions }); return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }] }; }, );