This project's goal is to investigate the performance of various option strategies. It is divided into three main parts:
- Option Calculator: Calculate the basic return profile for individual options (e.g., calls or puts) given specific parameters.
- Strategy Analyzer: Analyze the return profiles of simple strategies like covered calls, cash-secured puts, bull call spreads, and seagulls.
- Backtest Analyzer: Evaluate the performance of strategies over longer time periods using historical data.
Contains the web application built with Flask. This folder includes templates, static assets, and the main application logic.
-
/web/templates: HTML templates for the web interface.index.html: The homepage with navigation to different tools.option_calculator.html: Interface for calculating individual option prices and payoffs.strategy_analyzer.html: Interface for analyzing option strategies.backtest_analyzer.html: Interface for backtesting strategies over historical data.
-
/web/static: Static assets such as CSS and JavaScript files.css/style.css: Styles for the web application.
-
/web/app.py: The main Flask application file. Defines routes for the web interface and API endpoints for calculations and backtesting.
Core logic and utilities for option pricing, strategy creation, and calculations.
-
/core/strategies: Contains strategy definitions and a factory for creating strategies.strategy_base.py: Base classes for option and stock positions, and the trading strategy framework.strategy_factory.py: Factory for creating predefined strategies like covered calls and cash-secured puts.
-
/core/pricing: Implements pricing models for options.black_scholes.py: Black-Scholes model for option pricing and greeks calculation.
-
/core/utils: Utility functions for date calculations and other helpers.date_utils.py: Functions for calculating time-to-maturity and other date-related utilities.
Modules for analyzing and backtesting strategies.
/analytics/backtest_engine.py: Engine for running backtests on strategies, including buy-and-hold and cash-secured put comparisons./analytics/returns.py: Functions for calculating returns and performance metrics.
Contains unit tests for the application. (Currently not included but recommended for future development.)
(Optional) Placeholder for storing any data files, such as historical price data or backtest results.
(Optional) Placeholder for configuration files, such as environment variables or settings.
This file. Provides an overview of the project and its structure.
Defines the project metadata and dependencies for Python.
(Optional) Placeholder for listing Python dependencies if not using pyproject.toml.
(Optional) Placeholder for additional static assets if needed.
I use uv to manage the package dependency.
uv run -m web.app
- Open the application in your browser at
http://localhost:8080.