OptionStratLib v0.1.0: Financial Options Library
Table of Contents
- Introduction
- Features
- Project Structure
- Setup Instructions
- Library Usage
- Usage Examples
- Testing
- Contribution and Contact
Introduction
OptionStratLib is a comprehensive Rust library for options trading and strategy development across multiple asset classes. This versatile toolkit enables traders, quants, and developers to:
Features
- Valuation Models: Implements Black-Scholes and binomial models for option pricing.
- Greeks Calculation: Calculates delta, gamma, theta, vega, and rho for sensitivity analysis.
- Option Types: Supports European and American options, both calls and puts.
- Risk Analysis: Includes VaR (Value at Risk) calculations and other risk metrics. TODO!
- Simulations: Allows Monte Carlo simulations for scenario analysis.
- Exotic Options: Supports some types of exotic options such as Asian and lookback options. TODO!
- Strategy Development: Provides tools for creating and backtesting option trading strategies.
- Performance Visualization: Generates payoff diagrams and risk profiles for visual analysis.
- Multi-Asset Support: TODO!
- Risk Management: TODO!
- Backtesting: TODO!
- Performance Metrics: Generates performance metrics for strategy evaluation and Positions.
Project Structure
The project is structured as follows:
-
Options Module (
option.rs): This module contains the core implementation of option-related structures and methods. It includes theOptionsstruct that represents an option contract, along with methods for pricing, calculating Greeks, and managing the profit and loss (P&L) of the option. -
Pricing Models (
pricing/):binomial_model.rs: Implements the binomial model for pricing options.black_scholes_model.rs: Implements the Black-Scholes model for pricing options.monte_carlo.rs: Provides tools for running Monte Carlo simulations to price options.payoff.rs: Defines the payoff functions for different option types.telegraph.rs: Implements the Telegraphic method for pricing options.utils.rs: Utility functions related to option pricing.
-
Greeks Calculation (
greeks/):equations.rs: Contains the mathematical equations for calculating various Greeks (delta, gamma, theta, vega, rho).utils.rs: Utility functions for working with Greeks.
-
Profit and Loss (P&L) (
pnl/):utils.rs: Implements functions for calculating the P&L of option positions.
-
Risk Management (
risk/):- This module will contain implementations of risk metrics and management strategies, such as Value-at-Risk (VaR), Expected Shortfall, and risk-based portfolio optimization.
-
Strategies (
strategies/):base.rs: Defines the base traits and structures for option trading strategies.bear_put_spread.rs,bull_call_spread.rs,butterfly_spread.rs,collar.rs,covered_call.rs,iron_condor.rs,protective_put.rs,straddle.rs,strangle.rs: Implementations of various option trading strategies.utils.rs: Utility functions for working with option trading strategies.
-
Curves and Surfaces (
curves/,surfaces/):- These modules will contain functionality for constructing, analyzing, and visualizing yield curves, volatility surfaces, and other financial curves and surfaces.
-
Visualization (
visualization/):binomial_tree.rs: Visualization of binomial option pricing trees.strategy.rs: Visualization of option trading strategies.utils.rs: Utility functions for creating visualizations.
-
Volatility (
volatility/):utils.rs: Utility functions for working with volatility.
-
Backtesting (
backtesting/):- This module will contain the necessary functionality for performing backtesting of trading strategies.
-
Utility Modules:
constants.rs: Defines common constants used throughout the project.model/: Contains structs and types used to represent various financial concepts, such as options, positions, and formats.
Setup Instructions
- Clone the repository:
git clone https://github.com/joaquinbejar/OptionStratLib.git
cd OptionStratLib
- Build the project:
make build
- Run tests:
make test
- Format the code:
make fmt
- Run linting:
make lint
- Clean the project:
make clean
- Run the project:
make run
- Fix issues:
make fix
- Run pre-push checks:
make pre-push
- Generate documentation:
make doc
- Publish the package:
make publish
- Generate coverage report:
make coverage
Library Usage
To use the library in your project, add the following to your Cargo.toml:
[]
= { = "https://github.com/joaquinbejar/OptionStratLib.git" }
Usage Examples
Here are some examples of how to use the library for option pricing and analysis:
use Options;
use ;
use Graph;
use Error;
use Greeks;
use ExpirationDate;
use Strategies;
use BullCallSpread;
use Graph;
use Error;
Testing
To run unit tests:
make test
To run tests with coverage:
make coverage
Contribution and Contact
We welcome contributions to this project! If you would like to contribute, please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Make your changes and ensure that the project still builds and all tests pass.
- Commit your changes and push your branch to your forked repository.
- Submit a pull request to the main repository.
If you have any questions, issues, or would like to provide feedback, please feel free to contact the project maintainer:
Joaquín Béjar García
- Email: jb@taunais.com
- GitHub: joaquinbejar
We appreciate your interest and look forward to your contributions!