# HG changeset patch # User Dennis Concepcion Martin # Date 1637081128 -3600 # Node ID ccffaf75d240d960bb186b4373ae709e85352947 # Parent 2d78ef7a90e6dc96def495a162d87bf7d15580de refactor code diff -r 2d78ef7a90e6 -r ccffaf75d240 .idea/fucking-black-scholes.iml --- a/.idea/fucking-black-scholes.iml Tue Nov 16 17:45:04 2021 +0100 +++ b/.idea/fucking-black-scholes.iml Tue Nov 16 17:45:28 2021 +0100 @@ -2,7 +2,6 @@ - diff -r 2d78ef7a90e6 -r ccffaf75d240 .idea/vcs.xml --- a/.idea/vcs.xml Tue Nov 16 17:45:04 2021 +0100 +++ b/.idea/vcs.xml Tue Nov 16 17:45:28 2021 +0100 @@ -7,4 +7,7 @@ + + + \ No newline at end of file diff -r 2d78ef7a90e6 -r ccffaf75d240 LICENSE.md --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LICENSE.md Tue Nov 16 17:45:28 2021 +0100 @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) 2021 Dennis Concepción Martín + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff -r 2d78ef7a90e6 -r ccffaf75d240 README.md --- a/README.md Tue Nov 16 17:45:04 2021 +0100 +++ b/README.md Tue Nov 16 17:45:28 2021 +0100 @@ -1,1 +1,49 @@ -# fucking-black-scholes model \ No newline at end of file +# fucking-black-scholes model + +I'm a finance student trying to stop procrastinating and start studying my derivatives lectures. So, in order to +understand the Black-Scholes model, I built this simple command line tool. Which is far more interesting than memorizing +stupid stuff from the professor's slides. + +## Installation + +### Using PIP + +```bash +pip install fucking-black-scholes +``` + +### Manual + +```bash +git clone https://github.com/denniscm190/fucking-black-scholes.git +cd fucking-black-scholes +python setup.py install +``` + +## Usage + +```bash +fbs --help +``` + +### Examples + +Price a European call option with the following data: +- Spot price = $20 +- Exercise price = $21 +- Risk free rate = 5% +- Standard deviation = 25% +- Time to expiration = 6 months + +#### Command +```bash +fbs --spot-price=20.00 --exercise-price=21.00 --risk-free-rate=0.05 --std=0.25 --expiration=0.5 +``` + +#### Output + +```bash +--------------------------------------------- +European call option price: 1.197698084193286 +--------------------------------------------- +``` \ No newline at end of file diff -r 2d78ef7a90e6 -r ccffaf75d240 README_ES.md --- a/README_ES.md Tue Nov 16 17:45:04 2021 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -# fucking-black-scholes model \ No newline at end of file diff -r 2d78ef7a90e6 -r ccffaf75d240 fbs/main.py --- a/fbs/main.py Tue Nov 16 17:45:04 2021 +0100 +++ b/fbs/main.py Tue Nov 16 17:45:28 2021 +0100 @@ -1,6 +1,26 @@ -def main(): - pass +import click +from fbs.helpers import Option + + +@click.command() +@click.option('--spot-price', type=float, required=True, help='Spot price of the underlying asset.') +@click.option('--exercise-price', type=float, required=True, help='Exercise price of the option.') +@click.option('--risk-free-rate', type=float, required=True, help='Risk free rate.') +@click.option('--std', type=float, required=True, help='Standard deviation.') +@click.option('--expiration', type=float, required=True, help='Time to expiration.') +def cli(spot_price, exercise_price, risk_free_rate, std, expiration): + option = Option(spot_price, exercise_price, risk_free_rate, std, expiration) + + # Format output + output = 'European call option price: {}'.format(option.compute_eu_call_price()) + output_length = len(output) + line = ''.join('-' for _ in range(output_length)) + + # Output + click.echo(line) + click.echo(output) + click.echo(line) if __name__ == '__main__': - main() + cli() diff -r 2d78ef7a90e6 -r ccffaf75d240 requirements.txt --- a/requirements.txt Tue Nov 16 17:45:04 2021 +0100 +++ b/requirements.txt Tue Nov 16 17:45:28 2021 +0100 @@ -1,2 +1,3 @@ numpy~=1.21.4 -scipy~=1.7.2 \ No newline at end of file +scipy~=1.7.2 +click~=8.0.3 \ No newline at end of file diff -r 2d78ef7a90e6 -r ccffaf75d240 tests/test_helpers.py --- a/tests/test_helpers.py Tue Nov 16 17:45:04 2021 +0100 +++ b/tests/test_helpers.py Tue Nov 16 17:45:28 2021 +0100 @@ -1,5 +1,5 @@ from unittest import TestCase -from fbs.helpers import Option +from fbs import Option class TestOption(TestCase): diff -r 2d78ef7a90e6 -r ccffaf75d240 tests/test_main.py --- a/tests/test_main.py Tue Nov 16 17:45:04 2021 +0100 +++ b/tests/test_main.py Tue Nov 16 17:45:28 2021 +0100 @@ -3,4 +3,4 @@ class Test(TestCase): def test_main(self): - self.fail() + pass