Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,6 @@ venv.bak/
.Trashes
ehthumbs.db
Thumbs.db


scripts/datasets
27 changes: 18 additions & 9 deletions components/black_scholes_options_pricing.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

class BlackScholesOptionPricing(object):
def __init__(
self,
current_asset_price=None,
strike_price=None,
option_expiration=1,
risk_free_rate=0.1,
sigma=0.3,
self,
current_asset_price=None,
strike_price=None,
option_expiration=1,
risk_free_rate=0.1,
sigma=0.3,
):
self.current_asset_price = current_asset_price
self.strike_price = strike_price
Expand All @@ -21,14 +21,23 @@ def __init__(

def get_put_option_price(self):
d1 = (
np.log(self.current_asset_price / self.strike_price)
+ (self.risk_free_rate + self.sigma**2 / 2) * self.option_expiration
) / (self.sigma * np.sqrt(self.option_expiration))
np.log(self.current_asset_price / self.strike_price)
+ (self.risk_free_rate + self.sigma ** 2 / 2) * self.option_expiration
) / (self.sigma * np.sqrt(self.option_expiration))
d2 = d1 - self.sigma * np.sqrt(self.option_expiration)
return self.strike_price * np.exp(
-self.risk_free_rate * self.option_expiration
) * CDF(-d2) - self.current_asset_price * CDF(-d1)

def get_call_option_price(self):
d1 = (
np.log(self.current_asset_price / self.strike_price)
+ (self.risk_free_rate + self.sigma ** 2 / 2) * self.option_expiration
) / (self.sigma * np.sqrt(self.option_expiration))
d2 = d1 - self.sigma * np.sqrt(self.option_expiration)

return (self.current_asset_price * CDF(d1)) - (self.strike_price * np.exp((-self.risk_free_rate) * self.option_expiration) * CDF(d2))


if __name__ == "__main__":
current_asset_price = 2938.53
Expand Down
10 changes: 10 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
aiofiles==0.8.0
aiohttp==3.8.1
aiosignal==1.2.0
asgiref==3.5.2
async-timeout==4.0.2
atomicwrites==1.4.1
attrs==22.1.0
Expand All @@ -12,6 +14,8 @@ click==8.1.3
cytoolz==0.11.2
dateparser==1.0.0
distlib==0.3.6
Django==4.1.2
djangorestframework==3.14.0
dydx-v3-python==1.7.0
ecdsa==0.16.0
eth-abi==2.2.0
Expand All @@ -36,7 +40,9 @@ multiaddr==0.0.9
multidict==6.0.2
mypy-extensions==0.4.3
netaddr==0.8.0
numpy==1.24.1
packaging==21.3
pandas==1.5.2
parsimonious==0.8.1
pathspec==0.10.1
platformdirs==2.5.2
Expand All @@ -56,7 +62,11 @@ requests==2.28.1
requests-mock==1.6.0
rlp==2.0.1
six==1.16.0
sortedcontainers==2.4.0
sqlparse==0.4.3
sympy==1.6
tardis-client==1.3.3
tardis-dev==2.0.0a13
toml==0.10.2
tomli==2.0.1
toolz==0.12.0
Expand Down
Loading