PyBlackScholesAnalytics
Options and Option Strategies analytics for educational purpose using the Black-Scholes Model
Install / Use
npx skills add gabrielepompa88/pyBlackScholesAnalyticsInstalls into whichever agent you are using.
README
pyBlackScholesAnalytics
pyBlackScholesAnalytics is a Python package implementing analytics for options and option strategies under the Black-Scholes Model for educational purposes.
Summary <a name="Summary"></a>
pyBlackScholesAnalytics package is a Python package designed to use the well known Black-Scholes model to evaluate price, P&L and greeks of European options (both plain-vanilla and simple equity exotics such as cash-or-nothing Digital options), as well as simple option strategies built on them.
The package has been developed as a spin-off project of the "IT for Business and Finance" class held at the University of Siena for the Master degree in Finance in 2020.
pyBlackScholesAnalytics places itself in the middle between the coding style and level of a master student and that required for a junior quant at an investment bank. The aim is to address the gap between the two providing a playground for students to master financial concepts related to options and option strategies and implementing a dedicated comprehensive object-oriented architecture.
The package itself tries to follow the style guide for Python code PEP8. Intentional as well as unintentional departures from this style may occur in code. I'd like to thank in advance anyone who will make me aware of possible improvements in style and clarity of code.
Installation <a name="Installation"></a>
You can install pyBlackScholesAnalytics simply typing
pip install pyBlackScholesAnalytics
Latest version of the package is available on PyPI. If you encounter problems during installation please share with me.
Components <a name="Components"></a>
The current version of the package features the following components:
-
options: definitions forEuropeanOptionabstract base-class as well asPlainVanillaOptionandDigitalOptionderived classes -
portfolio: definition ofPortfolioclass implementing analytics for portfolios of options -
plotter: definitions forPlotterabstract base-class as well asOptionPlotterandPortfolioPlotterderived classes -
utils: definition of general utility functions -
numeric_routines: definition ofNumericGreeksclass implementing option greeks through finite-difference methods
Resources <a name="Resources"></a>
As far as the educational purpose is concerned, I find the pyBlackScholesAnalytics package itself helpful as much as the way in which its final version can be progressively built. In my experience, the constructive approach is ubiquitous in the real life of a Quant/Strat: a business need is first formulated by a trader or another stakeholder, then tackled by the Quant/Strat team with an ad hoc analysis, then a tactic short-term implementation of the response is produced and, finally, a strategic and robust long-term solution is designed and implemented. For this reason, the package is complemented by a series of 4 Tutorials in the form of Jupyter Notebooks and Youtube Videos. These tutorials aim to present the package step-by step in a constructive way building on the ideas of the Object-Oriented paradygm as improvements over sequential implementations of the same financial concepts.
Moreover several examples showcase the features of pyBlackScholesAnalytics package and can be used as entry-point to begin the exploration of the package.
Tutorials <a name="Tutorials"></a>
Jupyter Notebooks are available in GitHub, rendered statically thanks to Jupyter nbviewer and interactively on your web browser thanks to Binder. Each Jupyter Notebook is complemented with a dedicated Youtube video playlist.
| Jupyter Notebook | GitHub | nbviewer | Binder | Youtube Video |
|:-------------------|:--------------------------:|:--------------------------:|:--------------------------:|:------------------:|
| Derivatives Analytics - Introduction to Object Oriented Programming: in this tutorial we introduce Object-Oriented Programming in Python. We first make a non-financial example, developing the intuition behind the need of a change of programming paradigm to be able to cohordinate together different pieces of code. Once we have established the intuition, we then leverage on some basic financial knowledge to develop a Black-Scholes pricer for European call Options, first, and then a more general pricer for Plain-Vanilla put Options as well. | <img src="https://upload.wikimedia.org/wikipedia/commons/9/95/Font_Awesome_5_brands_github.svg" width="50"> | <img src="https://jupyter.org/assets/main-logo.svg" width="50"> | <img src="https://mybinder.org/static/logo.svg?v=f9f0d927b67cc9dc99d788c822ca21c0" width="50"> | <img src="https://upload.wikimedia.org/wikipedia/commons/e/ef/Youtube_logo.png" width="50"> |
| Derivatives Analytics - Inheritance and Polymorphism: in this tutorial we introduce Inheritance and Polymorphism in Python which are two milestones in Object-Oriented programming. We present these concepts introducing Digital cash-or-nothing Options and observing their similarities with Plain-Vanilla Options. Inheritance and Polymorphism allow us to leverage on the financial analogies between these two contracts and eventually represent them more efficiently as derived classes of a unique EuropeanOption abstract base class. | <img src="https://upload.wikimedia.org/wikipedia/commons/9/95/Font_Awesome_5_brands_github.svg" width="50"> | <img src="https://jupyter.org/assets/main-logo.svg" width="50"> | <img src="https://mybinder.org/static/logo.svg?v=f9f0d927b67cc9dc99d788c822ca21c0" width="50"> | <img src="https://upload.wikimedia.org/wikipedia/commons/e/ef/Youtube_logo.png" width="50"> |
| Derivatives Analytics - Objects Composition: in this tutorial we introduce Composition which is an additional way to model relationships among objects, alternatively to Inheritance. We present this relationship introducing a common MarketEnvironment under which Option contracts are emitted, a Portfolio class is designed to aggregate Options and another Plotter class is designed to provide visualization routines. Finally, we examine several Option Strategies which uses the architecture implemented so far. | <img src="https://upload.wikimedia.org/wikipedia/commons/9/95/Font_Awesome_5_brands_github.svg" width="50"> | <img src="https://jupyter.org/assets/main-logo.svg" width="50"> | <img src="https://mybinder.org/static/logo.svg?v=f9f0d927b67cc9dc99d788c822ca21c0" width="50"> | <img src="https://upload.wikimedia.org/wikipedia/commons/e/ef/Youtube_logo.png" width="50"> |
| Derivatives Analytics - Options Greeks: in this tutorial we introduce Option Greeks. That is, the derivatives of an option price with respect to its pricing paramete
Related Skills
codebase-memory-mcp
38.1kHigh-performance code intelligence MCP server. Indexes codebases into a persistent knowledge graph — average repo in milliseconds. 158 languages, sub-ms queries, 99% fewer tokens. Single static binary, zero dependencies.
codebase-memory-mcp
38.1kHigh-performance code intelligence MCP server. Indexes codebases into a persistent knowledge graph — average repo in milliseconds. 158 languages, sub-ms queries, 99% fewer tokens. Single static binary, zero dependencies.
codebase-memory-mcp
38.2kHigh-performance code intelligence MCP server. Indexes codebases into a persistent knowledge graph — average repo in milliseconds. 158 languages, sub-ms queries, 99% fewer tokens. Single static binary, zero dependencies.
tabularis
4.0kOpen-source desktop SQL workspace for PostgreSQL, MySQL/MariaDB, SQLite and 15+ more databases like DuckDB, ClickHouse, Redis and Firestore. Built-in MCP server for Claude, Cursor and Devin, SQL notebooks and visual EXPLAIN.
