Option Calculator

Option Calculator · GPT-Aktionen

A1chemy Option Calculator API

API for options data and portfolio statistics and Greeks for options positions.

  • POST /data/optionsget options data by given underlying and options details.
  • POST /portfolio/statsCalculate portfolio statistics and Greeks.
  • POST /portfolio/performanceCalculates portfolio performance across different implied volatilities and underlying price scenarios.
  • POST /pricing/option_pricingCalculates the pricing and greeks for the provided options information. Either option price or implied volatility can be used as inputs, but not both. Only one parameter should be set for each option.
  • POST /strategy/projectionCalculate option strategy projections.
Ursprüngliches API-Schema
{
  "openapi": "3.0.0",
  "info": {
    "title": "A1chemy Option Calculator API",
    "description": "API for options data and portfolio statistics and Greeks for options positions.",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://option-calculator.a1chemy.com",
      "description": "Main API server"
    }
  ],
  "paths": {
    "/data/options": {
      "post": {
        "operationId": "queryOptions",
        "summary": "get options data by given underlying and options details.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "underlying": {
                    "type": "string",
                    "example": "TQQQ"
                  },
                  "options": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "option_type": {
                          "type": "string",
                          "enum": [
                            "c",
                            "p"
                          ],
                          "description": "c for call, p for put"
                        },
                        "strike": {
                          "type": "number",
                          "format": "float"
                        },
                        "expiration": {
                          "type": "string",
                          "format": "date-time",
                          "description": "Expiration date of the option, format: 2024-04-26T00:00:00.000000"
                        }
                      }
                    }
                  }
                }
              },
              "examples": {
                "example1": {
                  "value": {
                    "underlying": "TQQQ",
                    "options": [
                      {
                        "option_type": "c",
                        "strike": 61,
                        "expiration": "2024-04-26T00:00:00.000000"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successfully calculated options",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "options": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "ask": {
                            "type": "number"
                          },
                          "bid": {
                            "type": "number"
                          },
                          "change": {
                            "type": "number"
                          },
                          "change_percent": {
                            "type": "number"
                          },
                          "expiration": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "greeks": {
                            "type": "object",
                            "properties": {
                              "delta": {
                                "type": "number"
                              },
                              "gamma": {
                                "type": "number"
                              },
                              "greeks_type": {
                                "type": "string"
                              },
                              "rho": {
                                "type": "number"
                              },
                              "theta": {
                                "type": "number"
                              },
                              "vega": {
                                "type": "number"
                              }
                            }
                          },
                          "implied_volatility": {
                            "type": "number"
                          },
                          "last_price": {
                            "type": "number"
                          },
                          "option_type": {
                            "type": "string"
                          },
                          "strike": {
                            "type": "number"
                          },
                          "ticker_type": {
                            "type": "string"
                          },
                          "time": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "underlying": {
                            "type": "string"
                          },
                          "volume": {
                            "type": "integer"
                          }
                        }
                      }
                    },
                    "underlying": {
                      "type": "object",
                      "properties": {
                        "ask": {
                          "type": "number"
                        },
                        "bid": {
                          "type": "number"
                        },
                        "last_price": {
                          "type": "number"
                        },
                        "ticker_type": {
                          "type": "string"
                        },
                        "time": {
                          "type": "string",
                          "format": "date-time"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/portfolio/stats": {
      "post": {
        "operationId": "calculatePortfolioStats",
        "summary": "Calculate portfolio statistics and Greeks.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "underlying": {
                    "type": "string",
                    "example": "TQQQ"
                  },
                  "positions": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "option_type": {
                          "type": "string",
                          "enum": [
                            "c",
                            "p"
                          ],
                          "description": "c for call, p for put"
                        },
                        "strike": {
                          "type": "number",
                          "format": "float"
                        },
                        "expiration": {
                          "type": "string",
                          "format": "date-time",
                          "description": "format: 2024-04-26T00:00:00.000000"
                        },
                        "count": {
                          "type": "integer"
                        },
                        "contract_size": {
                          "type": "integer"
                        }
                      }
                    }
                  }
                }
              },
              "examples": {
                "example1": {
                  "value": {
                    "underlying": "TQQQ",
                    "positions": [
                      {
                        "option_type": "c",
                        "strike": 62,
                        "expiration": "2024-04-26T00:00:00.000000",
                        "count": 1,
                        "contract_size": 100
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successfully calculated portfolio statistics and Greeks",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "pnl": {
                      "type": "number",
                      "description": "Total profit and loss for the portfolio"
                    },
                    "positions_stats": {
                      "type": "array",
                      "description": "Statistics for each position in the portfolio",
                      "items": {
                        "type": "object",
                        "properties": {
                          "greeks": {
                            "description": "Greeks for this option",
                            "type": "object",
                            "properties": {
                              "delta": {
                                "type": "number"
                              },
                              "gamma": {
                                "type": "number"
                              },
                              "greeks_type": {
                                "type": "string"
                              },
                              "rho": {
                                "type": "number"
                              },
                              "theta": {
                                "type": "number"
                              },
                              "vega": {
                                "type": "number"
                              }
                            }
                          },
                          "pnl": {
                            "type": "number"
                          },
                          "position": {
                            "type": "object",
                            "properties": {
                              "contract_size": {
                                "type": "integer"
                              },
                              "count": {
                                "type": "integer"
                              },
                              "option": {
                                "type": "object",
                                "properties": {
                                  "ask": {
                                    "type": "number"
                                  },
                                  "bid": {
                                    "type": "number"
                                  },
                                  "change": {
                                    "type": "number"
                                  },
                                  "change_percent": {
                                    "type": "number"
                                  },
                                  "expiration": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "implied_volatility": {
                                    "type": "number"
                                  },
                                  "last_price": {
                                    "type": "number"
                                  },
                                  "option_type": {
                                    "type": "string"
                                  },
                                  "strike": {
                                    "type": "number"
                                  },
                                  "ticker_type": {
                                    "type": "string"
                                  },
                                  "time": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "underlying": {
                                    "type": "string"
                                  },
                                  "volume": {
                                    "type": "integer"
                                  }
                                }
                              },
                              "price": {
                                "type": "number"
                              }
                            }
                          },
                          "position_greeks": {
                            "type": "object",
                            "description": "Greeks for this position, calculated as greeks * count",
                            "properties": {
                              "delta": {
                                "type": "number"
                              },
                              "gamma": {
                                "type": "number"
                              },
                              "greeks_type": {
                                "type": "string"
                              },
                              "rho": {
                                "type": "number"
                              },
                              "theta": {
                                "type": "number"
                              },
                              "vega": {
                                "type": "number"
                              }
                            }
                          }
                        }
                      }
                    },
                    "total_greeks": {
                      "type": "object",
                      "description": "Total Greeks for the portfolio",
                      "properties": {
                        "delta": {
                          "type": "number"
                        },
                        "gamma": {
                          "type": "number"
                        },
                        "greeks_type": {
                          "type": "string"
                        },
                        "rho": {
                          "type": "number"
                        },
                        "theta": {
                          "type": "number"
                        },
                        "vega": {
                          "type": "number"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/portfolio/performance": {
      "post": {
        "operationId": "calculatePortfolioPerformance",
        "summary": "Calculates portfolio performance across different implied volatilities and underlying price scenarios.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "underlying": {
                    "type": "string",
                    "example": "510050"
                  },
                  "implied_votility_range": {
                    "type": "object",
                    "properties": {
                      "step": {
                        "type": "number",
                        "format": "float"
                      },
                      "per_direction_count": {
                        "type": "integer"
                      }
                    }
                  },
                  "underlying_range": {
                    "type": "object",
                    "properties": {
                      "step": {
                        "type": "number",
                        "format": "float"
                      },
                      "per_direction_count": {
                        "type": "integer"
                      }
                    }
                  },
                  "positions": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "option_type": {
                          "type": "string",
                          "enum": [
                            "c",
                            "p"
                          ],
                          "description": "c for call, p for put"
                        },
                        "strike": {
                          "type": "number",
                          "format": "float"
                        },
                        "expiration": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "count": {
                          "type": "integer"
                        },
                        "contract_size": {
                          "type": "integer"
                        }
                      }
                    }
                  }
                }
              },
              "examples": {
                "example1": {
                  "value": {
                    "underlying": "TQQQ",
                    "implied_votility_range": {
                      "step": 0.05,
                      "per_direction_count": 3
                    },
                    "underlying_range": {
                      "step": 0.02,
                      "per_direction_count": 10
                    },
                    "positions": [
                      {
                        "option_type": "c",
                        "strike": 62,
                        "expiration": "2024-04-26T00:00:00.000000",
                        "count": -2,
                        "contract_size": 100
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successfully calculated portfolio performance",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "implied_volatility_percent": {
                        "type": "number",
                        "format": "float"
                      },
                      "stats": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "implied_volatility_percent": {
                              "type": "number",
                              "format": "float"
                            },
                            "stats": {
                              "type": "object",
                              "properties": {
                                "pnl": {
                                  "type": "number"
                                },
                                "positions_stats": {
                                  "type": null
                                },
                                "total_greeks": {
                                  "type": "object",
                                  "properties": {
                                    "delta": {
                                      "type": "number"
                                    },
                                    "gamma": {
                                      "type": "number"
                                    },
                                    "greeks_type": {
                                      "type": "string"
                                    },
                                    "rho": {
                                      "type": "number"
                                    },
                                    "theta": {
                                      "type": "number"
                                    },
                                    "vega": {
                                      "type": "number"
                                    }
                                  }
                                }
                              }
                            },
                            "underlying_price": {
                              "type": "number",
                              "format": "float"
                            },
                            "underlying_price_percent": {
                              "type": "number",
                              "format": "float"
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/pricing/option_pricing": {
      "post": {
        "operationId": "calculateOptionPricing",
        "summary": "Calculates the pricing and greeks for the provided options information. Either option price or implied volatility can be used as inputs, but not both. Only one parameter should be set for each option.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "pricing_type": {
                    "type": "string",
                    "enum": [
                      "european",
                      "american"
                    ]
                  },
                  "underlying_price": {
                    "type": "number",
                    "format": "float"
                  },
                  "start_time": {
                    "type": "string",
                    "format": "date-time",
                    "description": "Start time of the option, format: 2024-03-01T00:00:00.000000",
                    "nullable": true
                  },
                  "r": {
                    "type": "number",
                    "format": "float",
                    "description": "Risk-free interest rate"
                  },
                  "q": {
                    "type": "number",
                    "format": "float",
                    "description": "Dividend yield"
                  },
                  "options": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "expiration": {
                          "type": "string",
                          "format": "date",
                          "description": "Expiration date of the option, format: 2024-04-26T00:00:00.000000"
                        },
                        "strike": {
                          "type": "number",
                          "format": "float"
                        },
                        "option_type": {
                          "type": "string",
                          "enum": [
                            "c",
                            "p"
                          ]
                        },
                        "option_price": {
                          "type": "number",
                          "format": "float",
                          "nullable": true
                        },
                        "implied_volatility": {
                          "type": "number",
                          "format": "float",
                          "nullable": true
                        }
                      }
                    }
                  }
                },
                "required": [
                  "pricing_type",
                  "underlying_price",
                  "r",
                  "q",
                  "options"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Option pricing and greeks response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "ask": {
                        "type": "number",
                        "format": "float"
                      },
                      "bid": {
                        "type": "number",
                        "format": "float"
                      },
                      "change": {
                        "type": "number",
                        "format": "float",
                        "nullable": true
                      },
                      "change_percent": {
                        "type": "number",
                        "format": "float",
                        "nullable": true
                      },
                      "expiration": {
                        "type": "string",
                        "format": "date-time"
                      },
                      "greeks": {
                        "type": "object",
                        "properties": {
                          "delta": {
                            "type": "number",
                            "format": "float"
                          },
                          "gamma": {
                            "type": "number",
                            "format": "float"
                          },
                          "greeks_type": {
                            "type": "string"
                          },
                          "rho": {
                            "type": "number",
                            "format": "float"
                          },
                          "theta": {
                            "type": "number",
                            "format": "float"
                          },
                          "vega": {
                            "type": "number",
                            "format": "float"
                          }
                        }
                      },
                      "implied_volatility": {
                        "type": "number",
                        "format": "float"
                      },
                      "last_price": {
                        "type": "number",
                        "format": "float"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/strategy/projection": {
      "post": {
        "operationId": "calculateOptionStrategyProjection",
        "summary": "Calculate option strategy projections.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "underlying": {
                    "type": "string",
                    "example": "TQQQ"
                  },
                  "projection_type": {
                    "type": "string",
                    "enum": [
                      "up",
                      "down",
                      "stay_within"
                    ],
                    "example": "up"
                  },
                  "expect_time": {
                    "type": "string",
                    "format": "date",
                    "example": "2024-04-01"
                  },
                  "price_up_percent": {
                    "type": "number",
                    "format": "float",
                    "description": "The percentage of the price going up, 0.05 for 5%",
                    "example": 0.05,
                    "nullable": true
                  },
                  "price_up_value": {
                    "type": "number",
                    "format": "float",
                    "description": "The value of the price going up, may be used instead of price_up_percent",
                    "example": 5,
                    "nullable": true
                  },
                  "price_down_percent": {
                    "type": "number",
                    "format": "float",
                    "description": "The percentage of the price going down, 0.05 for 5%",
                    "example": 0.05,
                    "nullable": true
                  },
                  "price_down_value": {
                    "type": "number",
                    "format": "float",
                    "description": "The value of the price going down, may be used instead of price_down_percent",
                    "example": 5,
                    "nullable": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "An array of option strategy projections",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "description": {
                        "type": "string"
                      },
                      "name": {
                        "type": "string"
                      },
                      "stats": {
                        "type": "object",
                        "properties": {
                          "margin": {
                            "type": "number",
                            "format": "float"
                          },
                          "positions_stats": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "greeks": {
                                  "type": "object",
                                  "properties": {
                                    "delta": {
                                      "type": "number"
                                    },
                                    "gamma": {
                                      "type": "number"
                                    },
                                    "greeks_type": {
                                      "type": "string"
                                    },
                                    "rho": {
                                      "type": "number"
                                    },
                                    "theta": {
                                      "type": "number"
                                    },
                                    "vega": {
                                      "type": "number"
                                    }
                                  }
                                },
                                "position": {
                                  "type": "object",
                                  "properties": {
                                    "contract_size": {
                                      "type": "integer"
                                    },
                                    "count": {
                                      "type": "integer"
                                    },
                                    "option": {
                                      "type": "object",
                                      "properties": {
                                        "ask": {
                                          "type": "number"
                                        },
                                        "bid": {
                                          "type": "number"
                                        },
                                        "change": {
                                          "type": "number"
                                        },
                                        "change_percent": {
                                          "type": "number"
                                        },
                                        "expiration": {
                                          "type": "string",
                                          "format": "date-time"
                                        },
                                        "implied_volatility": {
                                          "type": "number"
                                        },
                                        "last_price": {
                                          "type": "number"
                                        },
                                        "option_type": {
                                          "type": "string"
                                        },
                                        "strike": {
                                          "type": "number"
                                        },
                                        "underlying": {
                                          "type": "string"
                                        }
                                      }
                                    }
                                  }
                                }
                              }
                            }
                          },
                          "total_greeks": {
                            "type": "object",
                            "properties": {
                              "delta": {
                                "type": "number"
                              },
                              "gamma": {
                                "type": "number"
                              },
                              "greeks_type": {
                                "type": "string"
                              },
                              "rho": {
                                "type": "number"
                              },
                              "theta": {
                                "type": "number"
                              },
                              "vega": {
                                "type": "number"
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}