Skip to main content

A comprehensive options pricing and analysis library

Project description

OptiVerse

License: MIT Python

A high-performance Python library for options pricing, Greeks calculation, and derivatives strategies analysis. Built with C++ for speed and wrapped with Python for ease of use.

Features

  • Black-Scholes-Merton Model for European options pricing
  • Greeks calculation (Delta, Gamma, Theta, Vega, Rho)
  • Options strategies (Calls, Puts, Straddles, Strangles)
  • High performance C++ implementation with Python bindings

Installation

Prerequisites

  • Python 3.7 or higher
  • C++ compiler (automatically handled by pip)

Install from PyPI

pip install optiverse

Verify Installation

import optiverse
print("OptiVerse installed successfully!")

Quick Start

Basic Options Pricing

import optiverse

# Create a Black-Scholes model
model = optiverse.models.BlackScholesModel(
    strike_price=100.0,      # Strike price
    volatility=0.25,         # 25% volatility
    risk_free_rate=0.05,     # 5% risk-free rate
    time_to_maturity=0.25,   # 3 months to expiration
    underlying_price=105.0   # Current stock price
)

# Calculate option prices
call_price = model.call_price()
put_price = model.put_price()

print(f"Call Price: ${call_price:.4f}")
print(f"Put Price: ${put_price:.4f}")

Greeks Analysis

# Create Greeks calculator
greeks = optiverse.models.GreeksCalculator(model)

# Calculate Greeks
delta_call = greeks.call_delta()
gamma = greeks.gamma()
vega = greeks.vega()
theta_call = greeks.call_theta()

print(f"Call Delta: {delta_call:.4f}")
print(f"Gamma: {gamma:.4f}")
print(f"Vega: {vega:.4f}")
print(f"Theta: {theta_call:.4f}")

Options Strategies

# Long Straddle Strategy
straddle = optiverse.strategies.LongStraddle(
    underlying_price=100.0,
    volatility=0.25,
    risk_free_rate=0.05,
    time_to_maturity=0.25,
    strike=100.0,
    quantity=1.0
)

# Analyze strategy
current_value = straddle.total_value()
total_delta = straddle.total_delta()

print(f"Strategy Value: ${current_value:.4f}")
print(f"Portfolio Delta: {total_delta:.4f}")

API Reference

BlackScholesModel

BlackScholesModel(strike_price, volatility, risk_free_rate, time_to_maturity, underlying_price)

Methods:

  • call_price() → Calculate call option price
  • put_price() → Calculate put option price
  • d1() → Calculate d1 parameter
  • d2() → Calculate d2 parameter

GreeksCalculator

GreeksCalculator(model: BlackScholesModel)

Methods:

  • call_delta() / put_delta() → Price sensitivity to underlying
  • gamma() → Delta sensitivity to underlying
  • vega() → Price sensitivity to volatility
  • call_theta() / put_theta() → Price sensitivity to time
  • call_rho() / put_rho() → Price sensitivity to interest rate

Strategy Classes

Available strategies:

  • LongCall / ShortCall
  • LongPut / ShortPut
  • LongStraddle / ShortStraddle
  • LongStrangle / ShortStrangle

Common Methods:

  • total_value() → Current strategy value
  • total_delta() → Portfolio delta
  • payoff_at_expiration(price) → Payoff at expiration

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

optipricer-0.1.0.tar.gz (8.2 kB view details)

Uploaded Source

File details

Details for the file optipricer-0.1.0.tar.gz.

File metadata

  • Download URL: optipricer-0.1.0.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for optipricer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c40fc274c53b18b8a371067fe4b65d48db41ce138428d1ed96f3de635d245729
MD5 d5864d31b0656848d40a729369a2a8ca
BLAKE2b-256 da71a14f8ef5fa85f960a1d167c2d70df8052569ded8dd2e6835047061856331

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page