option-prices 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Your Name
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,77 @@
1
+ Metadata-Version: 2.4
2
+ Name: option-prices
3
+ Version: 0.1.1
4
+ Summary: Option pricing using the Black Scholes Model
5
+ Author-email: Shreenivas Dani <shreenivasdani@gmail.com>
6
+ License: MIT
7
+ Requires-Python: >=3.8
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: numpy
11
+ Requires-Dist: scipy
12
+ Dynamic: license-file
13
+
14
+ # Option-prices
15
+
16
+ This package is to be used for option price calculation using the Black Scholes Model and binomial model
17
+
18
+ ## Description
19
+
20
+ This package provides a simple and easy-to-use implementation of the Black Scholes Model and binomial model for calculating European call and put option prices. It is designed for students, traders, and developers who want a lightweight and reliable tool for option pricing without the complexity of larger libraries.
21
+
22
+ ## Getting Started
23
+
24
+ ### Dependencies
25
+
26
+ Numpy,Scipy
27
+
28
+ ### Installing
29
+
30
+ pip install option-prices
31
+
32
+ ### Executing program
33
+
34
+ import option_pricings
35
+ from option_pricings import bsm
36
+ from option_pricings import binomial
37
+
38
+ ## example when time scale is in year
39
+ price=bsm(S=50,K=50,T=1,r=6,sigma=25,option_type = "call",time_scale="Year")
40
+ print(price)
41
+
42
+ price = binomial(S=30,K=40,r=6,T=2,time_step = 1,u=1.2,d=0.8)
43
+ print(price)
44
+
45
+ # using sigma parameter instead of u and d
46
+ price = binomial(S=30,K=40,r=6,T=2,time_step = 1,sigma = 25)
47
+ print(price)
48
+
49
+ # put option
50
+ price = binomial(S=30,K=40,r=6,T=2,time_step = 1,u=1.2,d=0.8,option_type="put")
51
+ print(price)
52
+
53
+ # changing time scale to month
54
+ price = binomial(S=30,K=40,r=6,T=24,time_step = 12,u=1.2,d=0.8,time_scale = "month")
55
+ print(price)
56
+
57
+ ## example when time scale is in month
58
+ price = bsm(S=50,K=50,T=6,r=6,sigma=25,option_type = "call",time_scale="Month")
59
+ print(price)
60
+
61
+ Note:
62
+ When time_scale="Year", enter T in years.
63
+ When time_scale="Month", enter T in months.
64
+ same thing applies for binomial
65
+ ## Authors
66
+
67
+ Shreenivas Dani
68
+
69
+ shreenivasdani@gmail.com
70
+ ## Version History
71
+
72
+ * 0.1
73
+ * Initial Release
74
+
75
+ ## License
76
+
77
+ This project is licensed under the MIT License - see the LICENSE.md file for details
@@ -0,0 +1,64 @@
1
+ # Option-prices
2
+
3
+ This package is to be used for option price calculation using the Black Scholes Model and binomial model
4
+
5
+ ## Description
6
+
7
+ This package provides a simple and easy-to-use implementation of the Black Scholes Model and binomial model for calculating European call and put option prices. It is designed for students, traders, and developers who want a lightweight and reliable tool for option pricing without the complexity of larger libraries.
8
+
9
+ ## Getting Started
10
+
11
+ ### Dependencies
12
+
13
+ Numpy,Scipy
14
+
15
+ ### Installing
16
+
17
+ pip install option-prices
18
+
19
+ ### Executing program
20
+
21
+ import option_pricings
22
+ from option_pricings import bsm
23
+ from option_pricings import binomial
24
+
25
+ ## example when time scale is in year
26
+ price=bsm(S=50,K=50,T=1,r=6,sigma=25,option_type = "call",time_scale="Year")
27
+ print(price)
28
+
29
+ price = binomial(S=30,K=40,r=6,T=2,time_step = 1,u=1.2,d=0.8)
30
+ print(price)
31
+
32
+ # using sigma parameter instead of u and d
33
+ price = binomial(S=30,K=40,r=6,T=2,time_step = 1,sigma = 25)
34
+ print(price)
35
+
36
+ # put option
37
+ price = binomial(S=30,K=40,r=6,T=2,time_step = 1,u=1.2,d=0.8,option_type="put")
38
+ print(price)
39
+
40
+ # changing time scale to month
41
+ price = binomial(S=30,K=40,r=6,T=24,time_step = 12,u=1.2,d=0.8,time_scale = "month")
42
+ print(price)
43
+
44
+ ## example when time scale is in month
45
+ price = bsm(S=50,K=50,T=6,r=6,sigma=25,option_type = "call",time_scale="Month")
46
+ print(price)
47
+
48
+ Note:
49
+ When time_scale="Year", enter T in years.
50
+ When time_scale="Month", enter T in months.
51
+ same thing applies for binomial
52
+ ## Authors
53
+
54
+ Shreenivas Dani
55
+
56
+ shreenivasdani@gmail.com
57
+ ## Version History
58
+
59
+ * 0.1
60
+ * Initial Release
61
+
62
+ ## License
63
+
64
+ This project is licensed under the MIT License - see the LICENSE.md file for details
@@ -0,0 +1,2 @@
1
+ from .bsm import bsm
2
+ from .binomial import binomial
@@ -0,0 +1,64 @@
1
+ import numpy as np
2
+ import scipy as sc
3
+
4
+
5
+ def __moves__(sigma,time_step):
6
+ u=np.exp(sigma*np.sqrt(time_step))
7
+ d=np.exp(np.negative(sigma)*np.sqrt(time_step))
8
+ return [u,d]
9
+
10
+
11
+
12
+
13
+ def binomial(S:int,K:int,r:int,T:int,time_step:int,u:int=None,d:int=None,sigma:int=None,time_scale:str="year",option_type:str="call"):
14
+ r = r/100
15
+ if time_scale=="month":
16
+ T_years=T/12
17
+ time_step=time_step/12
18
+ elif time_scale == "day":
19
+ T_years = T / 365
20
+ time_step = time_step / 365
21
+ if u!=None and d!=None:
22
+ pass
23
+ elif sigma!=None:
24
+ move=__moves__(sigma,time_step)
25
+ u=move[0]
26
+ d=move[1]
27
+ n_steps = int(T/time_step)
28
+
29
+
30
+ #price tree
31
+ prob = (np.exp(r*time_step)-d)/(u-d)
32
+ nodes = np.zeros([n_steps+1,n_steps+1])
33
+ nodes[0][0]=S
34
+ for i in range(1,n_steps+1):
35
+ nodes[i][0]=nodes[i-1][0]*u
36
+ nodes[i, 1:i+1] = nodes[i-1, 0:i] * d
37
+
38
+
39
+
40
+ #terminal node calculation
41
+ for i in range(n_steps+1):
42
+ if option_type=="call":
43
+ nodes[-1,i]=max(nodes[-1,i]-K,0)
44
+ elif option_type=="put":
45
+ nodes[-1,i]=max(K-nodes[-1,i],0)
46
+
47
+
48
+
49
+ #reverse calculation
50
+ copy=np.copy(nodes)
51
+ for i in reversed(range(1,n_steps+1)):
52
+ for j in range(i):
53
+ nodes[i-1][j]=np.exp(-r * time_step) * (prob * nodes[i, j] + (1 - prob) * nodes[i, j+1])
54
+
55
+
56
+ return round(nodes[0,0],2)
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+
@@ -0,0 +1,32 @@
1
+ import numpy as np
2
+ from scipy.stats import norm
3
+ N= norm.cdf
4
+ #call = C = S₀N(d₁) - Ke⁻ʳᵗN(d₂)
5
+ #put=ke^(-rT)*N(-d2)-S*N(-d1)
6
+ #d₁ = [ln(S₀/K) + (r + σ²/2)t] / (σ√t)
7
+ #d₂ = d₁ - σ√t
8
+
9
+ def bsm(S,K,T,r,sigma,option_type="call",time_scale="year"):
10
+ if time_scale == "month":
11
+ T = T/12
12
+ elif time_scale != "month" or time_scale != "year":
13
+ "plz enter month or year as you time scale"
14
+ r = r/100
15
+ sigma = sigma/100
16
+ denominator = (sigma*np.sqrt(T))
17
+ numerator = np.log(S/K)+(r+(sigma**2*0.5))*T
18
+ d1 = numerator/denominator
19
+ d2 = d1-denominator
20
+ if option_type == "call":
21
+ price = (S*N(d1))-((K*np.exp(-1*r*T))*(N(d2)))
22
+ elif option_type == "put":
23
+ price = ((K*np.exp(-1*r*T))*(N(-1*d2)))-(S*N(-d1))
24
+ else:
25
+ "Plz put the correct option type"
26
+ return round(price,2)
27
+
28
+
29
+
30
+ if __name__ =="__main__":
31
+ a=bsm(50,50,1,6,25,option_type = "call")
32
+
@@ -0,0 +1,77 @@
1
+ Metadata-Version: 2.4
2
+ Name: option-prices
3
+ Version: 0.1.1
4
+ Summary: Option pricing using the Black Scholes Model
5
+ Author-email: Shreenivas Dani <shreenivasdani@gmail.com>
6
+ License: MIT
7
+ Requires-Python: >=3.8
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: numpy
11
+ Requires-Dist: scipy
12
+ Dynamic: license-file
13
+
14
+ # Option-prices
15
+
16
+ This package is to be used for option price calculation using the Black Scholes Model and binomial model
17
+
18
+ ## Description
19
+
20
+ This package provides a simple and easy-to-use implementation of the Black Scholes Model and binomial model for calculating European call and put option prices. It is designed for students, traders, and developers who want a lightweight and reliable tool for option pricing without the complexity of larger libraries.
21
+
22
+ ## Getting Started
23
+
24
+ ### Dependencies
25
+
26
+ Numpy,Scipy
27
+
28
+ ### Installing
29
+
30
+ pip install option-prices
31
+
32
+ ### Executing program
33
+
34
+ import option_pricings
35
+ from option_pricings import bsm
36
+ from option_pricings import binomial
37
+
38
+ ## example when time scale is in year
39
+ price=bsm(S=50,K=50,T=1,r=6,sigma=25,option_type = "call",time_scale="Year")
40
+ print(price)
41
+
42
+ price = binomial(S=30,K=40,r=6,T=2,time_step = 1,u=1.2,d=0.8)
43
+ print(price)
44
+
45
+ # using sigma parameter instead of u and d
46
+ price = binomial(S=30,K=40,r=6,T=2,time_step = 1,sigma = 25)
47
+ print(price)
48
+
49
+ # put option
50
+ price = binomial(S=30,K=40,r=6,T=2,time_step = 1,u=1.2,d=0.8,option_type="put")
51
+ print(price)
52
+
53
+ # changing time scale to month
54
+ price = binomial(S=30,K=40,r=6,T=24,time_step = 12,u=1.2,d=0.8,time_scale = "month")
55
+ print(price)
56
+
57
+ ## example when time scale is in month
58
+ price = bsm(S=50,K=50,T=6,r=6,sigma=25,option_type = "call",time_scale="Month")
59
+ print(price)
60
+
61
+ Note:
62
+ When time_scale="Year", enter T in years.
63
+ When time_scale="Month", enter T in months.
64
+ same thing applies for binomial
65
+ ## Authors
66
+
67
+ Shreenivas Dani
68
+
69
+ shreenivasdani@gmail.com
70
+ ## Version History
71
+
72
+ * 0.1
73
+ * Initial Release
74
+
75
+ ## License
76
+
77
+ This project is licensed under the MIT License - see the LICENSE.md file for details
@@ -0,0 +1,11 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ option_prices/__init__.py
5
+ option_prices/binomial.py
6
+ option_prices/bsm.py
7
+ option_prices.egg-info/PKG-INFO
8
+ option_prices.egg-info/SOURCES.txt
9
+ option_prices.egg-info/dependency_links.txt
10
+ option_prices.egg-info/requires.txt
11
+ option_prices.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ numpy
2
+ scipy
@@ -0,0 +1,2 @@
1
+ dist
2
+ option_prices
@@ -0,0 +1,21 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "option-prices"
7
+ version = "0.1.1"
8
+ description = "Option pricing using the Black Scholes Model"
9
+ readme = "README.md"
10
+ license = { text = "MIT" }
11
+ authors = [
12
+ { name = "Shreenivas Dani", email = "shreenivasdani@gmail.com" }
13
+ ]
14
+ requires-python = ">=3.8"
15
+ dependencies = [
16
+ "numpy",
17
+ "scipy"
18
+ ]
19
+
20
+ [tool.setuptools.packages.find]
21
+ where = ["."]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+