Tool & function calling
AuraScore 83/100

Quantitative Portfolio Rebalancing Function Calling Implementation

Create a TypeScript function-calling suite for executing automated equity and fixed-income rebalancing operations safely.

Deploy this template when developing programmatic trade validation and execution tools for robo-advisors or asset managers. It generates strict function declarations and order execution wrappers.

Template

Role: Senior Quantitative Platform Developer specializing in algorithmic trade execution and tool routing.

Context

  • Wealth Platform: {{wealth_platform_name}}
  • Execution Broker: {{order_execution_broker}}
  • Asset Classes: {{asset_classes_covered}}
  • Compliance Rule Engine: {{compliance_rule_engine}}
  • Execution Environment: {{runtime_environment}}
  • Max Slippage Tolerance: {{max_slippage_tolerance}}

Task

Generate a robust TypeScript automation script containing explicit tool call definitions, parameter validation guards, and an execution engine that computes portfolio delta and safely routes trades to {{order_execution_broker}} under {{wealth_platform_name}} risk rules.

Method

  1. Declare JSON schema tool definitions for portfolio drift calculation across {{asset_classes_covered}}.
  2. Implement a trade simulation tool function verifying proposed orders against {{max_slippage_tolerance}}.
  3. Define a pre-trade compliance verification tool calling {{compliance_rule_engine}} endpoints.
  4. Write the order routing tool that packages authorized order payloads for {{order_execution_broker}}.
  5. Build a state machine to track tool execution stages from quotation to order confirmation.
  6. Add transaction rollback mechanisms if any single leg in the rebalance bundle fails.
  7. Provide an automated dry-run runner tailored for {{runtime_environment}}.

Constraints

  • Output MUST be fully typed TypeScript without relying on any types.
  • MUST NOT execute unconstrained market orders; all tools MUST enforce limit bounds.
  • Financial arithmetic MUST use integer cents or big-number libraries to avoid float rounding errors.
  • Tool definitions MUST contain clear descriptions to prevent agent hallucination.

Output format

1. Agent Tool Signatures

Exported TypeScript interfaces and tool definition objects.

2. Execution Handler Script

Complete execution runtime handling validation, compliance checks, and broker invocation.

3. Simulation Fixture

Mock portfolio drift event and console execution output.

Self-review

  • Ensure {{max_slippage_tolerance}} is actively enforced within the trade simulation step.
  • Verify all methods include structured error boundaries and type-safe returns.
  • Validate that no order is routed without preceding approval from {{compliance_rule_engine}}.
AuraScore breakdown
83/100Provisional
Instruction clarity15/15 · Strong

Explicit role, a named task, and discrete steps the model can follow.

Context architecture12/12 · Strong

Background, inputs and variables the model needs before it starts.

Constraint engineering12/12 · Strong

Hard boundaries — what the model must and must not do.

Output specification6/14 · Thin

A named, field-level shape for the response.

Reasoning structure10/10 · Strong

Ordered work items that force analysis before an answer.

Model compatibility10/10 · Strong

Length and structure that travel across frontier models.

Token efficiency7/10 · Adequate

Signal density — instruction weight without padding.

Reusability7/7 · Strong

Documented variables so the scaffold adapts to new inputs.

Robustness3/5 · Adequate

Quality bar, assumptions and behaviour when inputs are thin.

Observed performance1/5 · Thin

How much real usage the template has behind it.

ai-agents
agents-tool-calling
financial-services
portfolio-management
trade-execution
typescript