changeset 4:ccffaf75d240

refactor code
author Dennis Concepcion Martin <dennisconcepcionmartin@gmail.com>
date Tue, 16 Nov 2021 17:45:28 +0100
parents 2d78ef7a90e6
children 94bf1c757908
files .idea/fucking-black-scholes.iml .idea/vcs.xml LICENSE.md README.md README_ES.md fbs/main.py requirements.txt tests/test_helpers.py tests/test_main.py
diffstat 9 files changed, 88 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- 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 @@
 <module type="PYTHON_MODULE" version="4">
   <component name="NewModuleRootManager">
     <content url="file://$MODULE_DIR$">
-      <sourceFolder url="file://$MODULE_DIR$/fbs" isTestSource="false" />
       <excludeFolder url="file://$MODULE_DIR$/venv" />
     </content>
     <orderEntry type="inheritedJdk" />
--- 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 @@
       </list>
     </option>
   </component>
+  <component name="VcsDirectoryMappings">
+    <mapping directory="$PROJECT_DIR$" vcs="Git" />
+  </component>
 </project>
\ No newline at end of file
--- /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
--- 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
--- 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
--- 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()
--- 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
--- 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):
--- 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