quantflow-finance 0.1.0__py3-none-any.whl

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.
quantflow/__init__.py ADDED
@@ -0,0 +1,16 @@
1
+ """
2
+ QuantFlow: Essential quantitative finance tools for modern portfolio management.
3
+
4
+ A comprehensive Python package for options pricing, risk analytics, and market data processing.
5
+ """
6
+
7
+ __version__ = "0.1.0"
8
+ __author__ = "JEEVAN B A"
9
+ __email__ = "jeevanba273@gmail.com"
10
+
11
+ # Import main classes for easy access
12
+ from .options.black_scholes import BlackScholes
13
+ from .risk.metrics import RiskMetrics
14
+ from .data.fetcher import MarketData
15
+
16
+ __all__ = ['BlackScholes', 'RiskMetrics', 'MarketData']
@@ -0,0 +1,10 @@
1
+ """
2
+ Options pricing and Greeks calculation module.
3
+
4
+ This module provides implementations of various option pricing models including
5
+ the Black-Scholes-Merton model for European options.
6
+ """
7
+
8
+ from .black_scholes import BlackScholes
9
+
10
+ __all__ = ['BlackScholes']
@@ -0,0 +1,89 @@
1
+ """
2
+ Black-Scholes option pricing model implementation.
3
+ """
4
+
5
+ import numpy as np
6
+ from scipy.stats import norm
7
+
8
+
9
+ class BlackScholes:
10
+ """
11
+ Black-Scholes option pricing model.
12
+
13
+ Parameters:
14
+ S: Current stock price
15
+ K: Strike price
16
+ T: Time to expiration in years
17
+ r: Risk-free interest rate
18
+ sigma: Volatility
19
+ option_type: 'call' or 'put'
20
+ """
21
+
22
+ def __init__(self, S, K, T, r, sigma, option_type='call'):
23
+ self.S = float(S)
24
+ self.K = float(K)
25
+ self.T = float(T)
26
+ self.r = float(r)
27
+ self.sigma = float(sigma)
28
+ self.option_type = option_type.lower()
29
+
30
+ def price(self):
31
+ """Calculate option price using Black-Scholes formula."""
32
+ # Calculate d1 and d2 parameters
33
+ d1 = (np.log(self.S / self.K) + (self.r + 0.5 * self.sigma**2) * self.T) / (self.sigma * np.sqrt(self.T))
34
+ d2 = d1 - self.sigma * np.sqrt(self.T)
35
+
36
+ if self.option_type == 'call':
37
+ # Call option formula: S*N(d1) - K*e^(-rT)*N(d2)
38
+ return self.S * norm.cdf(d1) - self.K * np.exp(-self.r * self.T) * norm.cdf(d2)
39
+ else:
40
+ # Put option formula: K*e^(-rT)*N(-d2) - S*N(-d1)
41
+ return self.K * np.exp(-self.r * self.T) * norm.cdf(-d2) - self.S * norm.cdf(-d1)
42
+
43
+ def delta(self):
44
+ """Calculate option delta (price sensitivity to stock price)."""
45
+ d1 = (np.log(self.S / self.K) + (self.r + 0.5 * self.sigma**2) * self.T) / (self.sigma * np.sqrt(self.T))
46
+
47
+ if self.option_type == 'call':
48
+ return norm.cdf(d1)
49
+ else:
50
+ return norm.cdf(d1) - 1
51
+
52
+ def gamma(self):
53
+ """Calculate option gamma (rate of change of delta)."""
54
+ d1 = (np.log(self.S / self.K) + (self.r + 0.5 * self.sigma**2) * self.T) / (self.sigma * np.sqrt(self.T))
55
+
56
+ # Gamma is the same for both calls and puts
57
+ return norm.pdf(d1) / (self.S * self.sigma * np.sqrt(self.T))
58
+
59
+ def theta(self):
60
+ """Calculate option theta (time decay per year)."""
61
+ d1 = (np.log(self.S / self.K) + (self.r + 0.5 * self.sigma**2) * self.T) / (self.sigma * np.sqrt(self.T))
62
+ d2 = d1 - self.sigma * np.sqrt(self.T)
63
+
64
+ first_term = -(self.S * norm.pdf(d1) * self.sigma) / (2 * np.sqrt(self.T))
65
+
66
+ if self.option_type == 'call':
67
+ second_term = -self.r * self.K * np.exp(-self.r * self.T) * norm.cdf(d2)
68
+ else:
69
+ second_term = self.r * self.K * np.exp(-self.r * self.T) * norm.cdf(-d2)
70
+
71
+ return first_term + second_term
72
+
73
+ def vega(self):
74
+ """Calculate option vega (sensitivity to volatility change)."""
75
+ d1 = (np.log(self.S / self.K) + (self.r + 0.5 * self.sigma**2) * self.T) / (self.sigma * np.sqrt(self.T))
76
+
77
+ # Vega is the same for both calls and puts
78
+ # Divide by 100 to get sensitivity per 1% volatility change
79
+ return (self.S * norm.pdf(d1) * np.sqrt(self.T)) / 100
80
+
81
+ def greeks(self):
82
+ """Calculate all Greeks at once."""
83
+ return {
84
+ 'price': self.price(),
85
+ 'delta': self.delta(),
86
+ 'gamma': self.gamma(),
87
+ 'theta': self.theta(),
88
+ 'vega': self.vega()
89
+ }
@@ -0,0 +1,36 @@
1
+ Metadata-Version: 2.4
2
+ Name: quantflow-finance
3
+ Version: 0.1.0
4
+ Summary: Essential quantitative finance tools for modern portfolio management
5
+ Home-page: https://github.com/jeevanba273/quantflow
6
+ Author: JEEVAN B A
7
+ Author-email: jeevanba273@gmail.com
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Intended Audience :: Financial and Insurance Industry
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Requires-Python: >=3.8
15
+ Description-Content-Type: text/markdown
16
+ Requires-Dist: numpy>=1.20.0
17
+ Requires-Dist: scipy>=1.7.0
18
+ Requires-Dist: pandas>=1.3.0
19
+ Requires-Dist: matplotlib>=3.3.0
20
+ Requires-Dist: yfinance>=0.1.70
21
+ Provides-Extra: dev
22
+ Requires-Dist: pytest>=6.0; extra == "dev"
23
+ Requires-Dist: black; extra == "dev"
24
+ Requires-Dist: flake8; extra == "dev"
25
+ Dynamic: author
26
+ Dynamic: author-email
27
+ Dynamic: classifier
28
+ Dynamic: description
29
+ Dynamic: description-content-type
30
+ Dynamic: home-page
31
+ Dynamic: provides-extra
32
+ Dynamic: requires-dist
33
+ Dynamic: requires-python
34
+ Dynamic: summary
35
+
36
+ A comprehensive Python package for options pricing, risk analytics, and market data processing.
@@ -0,0 +1,7 @@
1
+ quantflow/__init__.py,sha256=A1rqAAQZKe8ucPRxQMbbfmCTrqzfatolYMtwJaZsqF4,489
2
+ quantflow/options/__init__.py,sha256=APJLkYOzHFi3YdTuBGqzVnoPhFfux-D5FTsyKcvBzDA,257
3
+ quantflow/options/black_scholes.py,sha256=0hUGvh1pE64xeXELsnOO1rkmfM8iSg7HFva50WcdqKM,3272
4
+ quantflow_finance-0.1.0.dist-info/METADATA,sha256=pd2z-Qui2RJrAResK18z3DA6qG0nMwdShvozzfIKTxM,1263
5
+ quantflow_finance-0.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
6
+ quantflow_finance-0.1.0.dist-info/top_level.txt,sha256=sB0SEFBNnqB89JBoJuaBB-CMHUCAFVrFkJ-W55BBiJ4,10
7
+ quantflow_finance-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ quantflow