Skip to main content
Glama
nbiish
by nbiish

option_greeks

Calculate option Greeks (Delta, Gamma, Theta, Vega, Rho) using the Black-Scholes model to analyze risk and sensitivity in options trading.

Instructions

Calculate the Greeks for a Black-Scholes option

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
SYesCurrent price of the asset
KYesStrike price of the option
TYesTime to expiration in years
rYesRisk-free interest rate
sigmaYesVolatility of the asset
optionTypeNoOption type: "call" or "put"call

Implementation Reference

  • Core implementation of the option_greeks tool logic, calculating Delta, Gamma, Vega, Theta, and Rho using Black-Scholes formulas for call and put options.
    const optionGreeks = (S, K, T, r, sigma, optionType = 'call') => {
      try {
        const d1 = (Math.log(S / K) + (r + 0.5 * sigma * sigma) * T) / (sigma * Math.sqrt(T));
        const d2 = d1 - sigma * Math.sqrt(T);
    
        let delta, gamma, vega, theta, rho;
    
        if (optionType === 'call') {
          delta = normalCDF(d1);
          gamma = normalPDF(d1) / (S * sigma * Math.sqrt(T));
          vega = S * normalPDF(d1) * Math.sqrt(T);
          theta = -(S * normalPDF(d1) * sigma) / (2 * Math.sqrt(T)) - 
                 r * K * Math.exp(-r * T) * normalCDF(d2);
          rho = K * T * Math.exp(-r * T) * normalCDF(d2);
        } else if (optionType === 'put') {
          delta = normalCDF(d1) - 1;
          gamma = normalPDF(d1) / (S * sigma * Math.sqrt(T));
          vega = S * normalPDF(d1) * Math.sqrt(T);
          theta = -(S * normalPDF(d1) * sigma) / (2 * Math.sqrt(T)) + 
                 r * K * Math.exp(-r * T) * normalCDF(-d2);
          rho = -K * T * Math.exp(-r * T) * normalCDF(-d2);
        } else {
          throw new Error('Invalid option type. Must be "call" or "put".');
        }
    
        return { delta, gamma, vega, theta, rho };
      } catch (e) {
        return `Error: ${e.message}`;
      }
    };
  • Input and output schema definitions for the option_greeks tool using Zod validation.
      inputSchema: z.object({
        S: z.number().describe('Current price of the asset'),
        K: z.number().describe('Strike price of the option'),
        T: z.number().describe('Time to expiration in years'),
        r: z.number().describe('Risk-free interest rate'),
        sigma: z.number().describe('Volatility of the asset'),
        optionType: z.enum(['call', 'put']).default('call')
          .describe('Option type: "call" or "put"')
      }),
      outputSchema: z.union([
        z.object({
          delta: z.number(),
          gamma: z.number(),
          vega: z.number(),
          theta: z.number(),
          rho: z.number()
        }),
        z.string()
      ]),
    },
  • index.js:571-598 (registration)
    Registration of the 'option_greeks' tool with Genkit's ai.defineTool, linking schema and handler function.
    ai.defineTool(
      {
        name: 'option_greeks',
        description: 'Calculate the Greeks for a Black-Scholes option',
        inputSchema: z.object({
          S: z.number().describe('Current price of the asset'),
          K: z.number().describe('Strike price of the option'),
          T: z.number().describe('Time to expiration in years'),
          r: z.number().describe('Risk-free interest rate'),
          sigma: z.number().describe('Volatility of the asset'),
          optionType: z.enum(['call', 'put']).default('call')
            .describe('Option type: "call" or "put"')
        }),
        outputSchema: z.union([
          z.object({
            delta: z.number(),
            gamma: z.number(),
            vega: z.number(),
            theta: z.number(),
            rho: z.number()
          }),
          z.string()
        ]),
      },
      async ({ S, K, T, r, sigma, optionType }) => {
        return optionGreeks(S, K, T, r, sigma, optionType);
      }
    );
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the calculation action but lacks details on behavioral traits: it doesn't specify if this is a read-only operation, whether it requires authentication, what the output format looks like (e.g., numeric values, JSON structure), or any rate limits. For a calculation tool with no annotation coverage, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence: 'Calculate the Greeks for a Black-Scholes option.' It is front-loaded with the core action and resource, with zero wasted words. Every part of the sentence earns its place by specifying what is calculated and the model involved, making it highly concise and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (financial calculation with 6 parameters), no annotations, and no output schema, the description is minimally adequate. It identifies the tool's purpose but lacks completeness: it doesn't explain the output (what Greeks are returned, e.g., delta, gamma), behavioral context, or usage scenarios. For a tool with rich parameters but no structured output or annotations, more detail would be helpful for the agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with clear documentation for all parameters (e.g., S as 'Current price of the asset'). The description adds no additional parameter semantics beyond what's in the schema, such as explaining the Black-Scholes model context or typical value ranges. Since the schema does the heavy lifting, the baseline score of 3 is appropriate, but the description doesn't compensate with extra insights.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Calculate the Greeks for a Black-Scholes option.' It specifies the verb ('calculate') and the resource ('Greeks'), and mentions the underlying model ('Black-Scholes option'), which distinguishes it from generic calculation tools. However, it doesn't explicitly differentiate from sibling tools like 'black_scholes' (which might calculate option prices rather than Greeks), leaving room for improvement.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools (e.g., 'black_scholes' for option pricing or 'npv' for financial calculations) or specify contexts like financial modeling, risk assessment, or educational purposes. Without such cues, the agent must infer usage from the tool name and parameters alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/nbiish/mcp-calc-tools'

If you have feedback or need assistance with the MCP directory API, please join our Discord server