squarequant 0.1.0__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.
- squarequant-0.1.0/LICENSE +21 -0
- squarequant-0.1.0/PKG-INFO +217 -0
- squarequant-0.1.0/README.md +167 -0
- squarequant-0.1.0/setup.cfg +4 -0
- squarequant-0.1.0/setup.py +52 -0
- squarequant-0.1.0/squarequant/__init__.py +41 -0
- squarequant-0.1.0/squarequant/api.py +548 -0
- squarequant-0.1.0/squarequant/constants.py +35 -0
- squarequant-0.1.0/squarequant/core/__init__.py +6 -0
- squarequant-0.1.0/squarequant/core/base.py +166 -0
- squarequant-0.1.0/squarequant/core/data.py +106 -0
- squarequant-0.1.0/squarequant/core/metrics.py +1633 -0
- squarequant-0.1.0/squarequant/plot/__init__.py +7 -0
- squarequant-0.1.0/squarequant/plot/plot.py +972 -0
- squarequant-0.1.0/squarequant/utils/__init__.py +6 -0
- squarequant-0.1.0/squarequant/utils/helpers.py +85 -0
- squarequant-0.1.0/squarequant.egg-info/PKG-INFO +217 -0
- squarequant-0.1.0/squarequant.egg-info/SOURCES.txt +19 -0
- squarequant-0.1.0/squarequant.egg-info/dependency_links.txt +1 -0
- squarequant-0.1.0/squarequant.egg-info/requires.txt +15 -0
- squarequant-0.1.0/squarequant.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Gabriel Bosch
|
|
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,217 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: squarequant
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A Python package for quantitative finance
|
|
5
|
+
Home-page: https://github.com/SquareQuant/squarequant-package
|
|
6
|
+
Author: Gabriel Bosch
|
|
7
|
+
Author-email: contact@suqarequant.org
|
|
8
|
+
Project-URL: Documentation, https://squarequant.readthedocs.io
|
|
9
|
+
Project-URL: Bug Tracker, https://github.com/SquareQuant/squarequant-package/issues
|
|
10
|
+
Keywords: finance,risk,portfolio,investment,stocks,analysis,visualization
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
19
|
+
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
20
|
+
Classifier: Intended Audience :: Science/Research
|
|
21
|
+
Classifier: Development Status :: 4 - Beta
|
|
22
|
+
Requires-Python: >=3.7
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: pandas>=1.0.0
|
|
26
|
+
Requires-Dist: numpy>=1.18.0
|
|
27
|
+
Requires-Dist: yfinance>=0.1.63
|
|
28
|
+
Requires-Dist: scipy>=1.5.0
|
|
29
|
+
Requires-Dist: matplotlib>=3.3.0
|
|
30
|
+
Provides-Extra: optimization
|
|
31
|
+
Requires-Dist: cvxpy>=1.0.0; extra == "optimization"
|
|
32
|
+
Provides-Extra: dev
|
|
33
|
+
Requires-Dist: pytest>=6.0.0; extra == "dev"
|
|
34
|
+
Requires-Dist: black>=21.5b2; extra == "dev"
|
|
35
|
+
Requires-Dist: flake8>=3.9.0; extra == "dev"
|
|
36
|
+
Requires-Dist: sphinx>=4.0.0; extra == "dev"
|
|
37
|
+
Requires-Dist: sphinx-rtd-theme>=0.5.0; extra == "dev"
|
|
38
|
+
Dynamic: author
|
|
39
|
+
Dynamic: author-email
|
|
40
|
+
Dynamic: classifier
|
|
41
|
+
Dynamic: description
|
|
42
|
+
Dynamic: description-content-type
|
|
43
|
+
Dynamic: home-page
|
|
44
|
+
Dynamic: keywords
|
|
45
|
+
Dynamic: project-url
|
|
46
|
+
Dynamic: provides-extra
|
|
47
|
+
Dynamic: requires-dist
|
|
48
|
+
Dynamic: requires-python
|
|
49
|
+
Dynamic: summary
|
|
50
|
+
|
|
51
|
+
# SquareQuant
|
|
52
|
+
|
|
53
|
+
A professional-grade Python package for financial risk analysis, advanced portfolio metrics, and investment visualization with a focus on performance and usability.
|
|
54
|
+
|
|
55
|
+
## Features
|
|
56
|
+
|
|
57
|
+
### Data Management
|
|
58
|
+
- Seamless download and integration with Yahoo Finance data
|
|
59
|
+
- Flexible data filtering and preprocessing utilities
|
|
60
|
+
- Configurable date ranges and interval selection
|
|
61
|
+
|
|
62
|
+
### Risk Metrics
|
|
63
|
+
- **Standard Metrics**:
|
|
64
|
+
- Sharpe & Sortino Ratios
|
|
65
|
+
- Volatility & Semi-Deviation
|
|
66
|
+
- Maximum Drawdown (MDD) & Average Drawdown
|
|
67
|
+
- Value at Risk (VaR) & Conditional Value at Risk (CVaR)
|
|
68
|
+
- **Advanced Metrics**:
|
|
69
|
+
- Mean Absolute Deviation (MAD)
|
|
70
|
+
- Ulcer Index
|
|
71
|
+
- Entropic Risk Measure (ERM)
|
|
72
|
+
- Entropic Value at Risk (EVaR)
|
|
73
|
+
- Conditional Drawdown at Risk (CDaR)
|
|
74
|
+
- Entropic Drawdown at Risk (EDaR)
|
|
75
|
+
|
|
76
|
+
### Visualization
|
|
77
|
+
- Interactive risk metrics dashboards
|
|
78
|
+
- Correlation matrix heatmaps
|
|
79
|
+
- Drawdown analysis charts
|
|
80
|
+
- Return distribution visualization
|
|
81
|
+
- Risk contribution analysis
|
|
82
|
+
- Portfolio weight allocation diagrams
|
|
83
|
+
|
|
84
|
+
### Implementation Advantages
|
|
85
|
+
- Memory-efficient vectorized calculations
|
|
86
|
+
- Dual API approaches: functional & object-oriented
|
|
87
|
+
- Configurable window sizes for all metrics
|
|
88
|
+
- Minimal external dependencies
|
|
89
|
+
|
|
90
|
+
## Installation
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
pip install squarequant
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Quick Start Guide
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
import squarequant as sq
|
|
100
|
+
import matplotlib.pyplot as plt
|
|
101
|
+
|
|
102
|
+
# Download stock data
|
|
103
|
+
tickers = ["AAPL", "MSFT", "GOOGL"]
|
|
104
|
+
config = sq.DownloadConfig(
|
|
105
|
+
start_date="2020-01-01",
|
|
106
|
+
end_date="2023-01-01",
|
|
107
|
+
interval="1d"
|
|
108
|
+
)
|
|
109
|
+
data = sq.download_tickers(tickers, config)
|
|
110
|
+
|
|
111
|
+
# Calculate risk metrics
|
|
112
|
+
assets = ["AAPL_Close", "MSFT_Close", "GOOGL_Close"]
|
|
113
|
+
|
|
114
|
+
# Sharpe ratio with a 1-year rolling window
|
|
115
|
+
sharpe_ratios = sq.sharpe(data, assets, window=252)
|
|
116
|
+
|
|
117
|
+
# Plot the results
|
|
118
|
+
plt.figure(figsize=(12, 8))
|
|
119
|
+
sharpe_ratios.plot()
|
|
120
|
+
plt.title("Rolling Sharpe Ratios")
|
|
121
|
+
plt.show()
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Advanced Usage Examples
|
|
125
|
+
|
|
126
|
+
### Multiple Risk Metrics Visualization
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
# Create a visualization of multiple risk metrics
|
|
130
|
+
sq.plot_rolling_metrics(
|
|
131
|
+
data=data,
|
|
132
|
+
assets=assets,
|
|
133
|
+
metrics=['sharpe', 'vol', 'mdd', 'var'],
|
|
134
|
+
windows={'vol': 20, 'mdd': 252}
|
|
135
|
+
)
|
|
136
|
+
plt.show()
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Risk Comparison Dashboard
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
# Create a risk comparison dashboard
|
|
143
|
+
sq.plot_risk_comparison(
|
|
144
|
+
data=data,
|
|
145
|
+
assets=assets,
|
|
146
|
+
risk_metrics=['vol', 'mdd', 'var', 'cvar', 'semidev', 'ulcer'],
|
|
147
|
+
)
|
|
148
|
+
plt.show()
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Performance Metrics Table
|
|
152
|
+
|
|
153
|
+
```python
|
|
154
|
+
# Generate a performance metrics table
|
|
155
|
+
sq.plot_performance_metrics(
|
|
156
|
+
data=data,
|
|
157
|
+
assets=assets,
|
|
158
|
+
risk_free=0.02, # 2% risk-free rate
|
|
159
|
+
)
|
|
160
|
+
plt.show()
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Object-Oriented Interface
|
|
164
|
+
|
|
165
|
+
SquareQuant provides an object-oriented interface for more advanced use cases:
|
|
166
|
+
|
|
167
|
+
```python
|
|
168
|
+
from squarequant.core.metrics import EntropicValueAtRisk
|
|
169
|
+
|
|
170
|
+
# Create an EVaR calculator
|
|
171
|
+
calculator = EntropicValueAtRisk(
|
|
172
|
+
data=data,
|
|
173
|
+
assets=assets,
|
|
174
|
+
alpha=0.95, # 95% confidence level
|
|
175
|
+
window=252,
|
|
176
|
+
start="2021-01-01",
|
|
177
|
+
end="2022-01-01"
|
|
178
|
+
)
|
|
179
|
+
|
|
180
|
+
# Calculate EVaR
|
|
181
|
+
evar_values = calculator.calculate()
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Configuration Options
|
|
185
|
+
|
|
186
|
+
### Custom Risk-Free Rate
|
|
187
|
+
|
|
188
|
+
```python
|
|
189
|
+
# Using a constant value
|
|
190
|
+
sharpe_ratios = sq.sharpe(data, assets, freerate_value=0.02)
|
|
191
|
+
|
|
192
|
+
# Using a column in your data
|
|
193
|
+
sharpe_ratios = sq.sharpe(data, assets, freerate="TREASURY_YIELD")
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Custom Confidence Levels
|
|
197
|
+
|
|
198
|
+
```python
|
|
199
|
+
# Calculate VaR with 99% confidence
|
|
200
|
+
var_values = sq.var(data, assets, confidence=0.99)
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## Documentation
|
|
204
|
+
|
|
205
|
+
For full documentation, visit [https://squarequant.readthedocs.io](https://squarequant.readthedocs.io)
|
|
206
|
+
|
|
207
|
+
## Contributing
|
|
208
|
+
|
|
209
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
210
|
+
|
|
211
|
+
## License
|
|
212
|
+
|
|
213
|
+
MIT
|
|
214
|
+
|
|
215
|
+
## Author
|
|
216
|
+
|
|
217
|
+
Gabriel Bosch
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# SquareQuant
|
|
2
|
+
|
|
3
|
+
A professional-grade Python package for financial risk analysis, advanced portfolio metrics, and investment visualization with a focus on performance and usability.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
### Data Management
|
|
8
|
+
- Seamless download and integration with Yahoo Finance data
|
|
9
|
+
- Flexible data filtering and preprocessing utilities
|
|
10
|
+
- Configurable date ranges and interval selection
|
|
11
|
+
|
|
12
|
+
### Risk Metrics
|
|
13
|
+
- **Standard Metrics**:
|
|
14
|
+
- Sharpe & Sortino Ratios
|
|
15
|
+
- Volatility & Semi-Deviation
|
|
16
|
+
- Maximum Drawdown (MDD) & Average Drawdown
|
|
17
|
+
- Value at Risk (VaR) & Conditional Value at Risk (CVaR)
|
|
18
|
+
- **Advanced Metrics**:
|
|
19
|
+
- Mean Absolute Deviation (MAD)
|
|
20
|
+
- Ulcer Index
|
|
21
|
+
- Entropic Risk Measure (ERM)
|
|
22
|
+
- Entropic Value at Risk (EVaR)
|
|
23
|
+
- Conditional Drawdown at Risk (CDaR)
|
|
24
|
+
- Entropic Drawdown at Risk (EDaR)
|
|
25
|
+
|
|
26
|
+
### Visualization
|
|
27
|
+
- Interactive risk metrics dashboards
|
|
28
|
+
- Correlation matrix heatmaps
|
|
29
|
+
- Drawdown analysis charts
|
|
30
|
+
- Return distribution visualization
|
|
31
|
+
- Risk contribution analysis
|
|
32
|
+
- Portfolio weight allocation diagrams
|
|
33
|
+
|
|
34
|
+
### Implementation Advantages
|
|
35
|
+
- Memory-efficient vectorized calculations
|
|
36
|
+
- Dual API approaches: functional & object-oriented
|
|
37
|
+
- Configurable window sizes for all metrics
|
|
38
|
+
- Minimal external dependencies
|
|
39
|
+
|
|
40
|
+
## Installation
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install squarequant
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Quick Start Guide
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
import squarequant as sq
|
|
50
|
+
import matplotlib.pyplot as plt
|
|
51
|
+
|
|
52
|
+
# Download stock data
|
|
53
|
+
tickers = ["AAPL", "MSFT", "GOOGL"]
|
|
54
|
+
config = sq.DownloadConfig(
|
|
55
|
+
start_date="2020-01-01",
|
|
56
|
+
end_date="2023-01-01",
|
|
57
|
+
interval="1d"
|
|
58
|
+
)
|
|
59
|
+
data = sq.download_tickers(tickers, config)
|
|
60
|
+
|
|
61
|
+
# Calculate risk metrics
|
|
62
|
+
assets = ["AAPL_Close", "MSFT_Close", "GOOGL_Close"]
|
|
63
|
+
|
|
64
|
+
# Sharpe ratio with a 1-year rolling window
|
|
65
|
+
sharpe_ratios = sq.sharpe(data, assets, window=252)
|
|
66
|
+
|
|
67
|
+
# Plot the results
|
|
68
|
+
plt.figure(figsize=(12, 8))
|
|
69
|
+
sharpe_ratios.plot()
|
|
70
|
+
plt.title("Rolling Sharpe Ratios")
|
|
71
|
+
plt.show()
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Advanced Usage Examples
|
|
75
|
+
|
|
76
|
+
### Multiple Risk Metrics Visualization
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
# Create a visualization of multiple risk metrics
|
|
80
|
+
sq.plot_rolling_metrics(
|
|
81
|
+
data=data,
|
|
82
|
+
assets=assets,
|
|
83
|
+
metrics=['sharpe', 'vol', 'mdd', 'var'],
|
|
84
|
+
windows={'vol': 20, 'mdd': 252}
|
|
85
|
+
)
|
|
86
|
+
plt.show()
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Risk Comparison Dashboard
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
# Create a risk comparison dashboard
|
|
93
|
+
sq.plot_risk_comparison(
|
|
94
|
+
data=data,
|
|
95
|
+
assets=assets,
|
|
96
|
+
risk_metrics=['vol', 'mdd', 'var', 'cvar', 'semidev', 'ulcer'],
|
|
97
|
+
)
|
|
98
|
+
plt.show()
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Performance Metrics Table
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
# Generate a performance metrics table
|
|
105
|
+
sq.plot_performance_metrics(
|
|
106
|
+
data=data,
|
|
107
|
+
assets=assets,
|
|
108
|
+
risk_free=0.02, # 2% risk-free rate
|
|
109
|
+
)
|
|
110
|
+
plt.show()
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Object-Oriented Interface
|
|
114
|
+
|
|
115
|
+
SquareQuant provides an object-oriented interface for more advanced use cases:
|
|
116
|
+
|
|
117
|
+
```python
|
|
118
|
+
from squarequant.core.metrics import EntropicValueAtRisk
|
|
119
|
+
|
|
120
|
+
# Create an EVaR calculator
|
|
121
|
+
calculator = EntropicValueAtRisk(
|
|
122
|
+
data=data,
|
|
123
|
+
assets=assets,
|
|
124
|
+
alpha=0.95, # 95% confidence level
|
|
125
|
+
window=252,
|
|
126
|
+
start="2021-01-01",
|
|
127
|
+
end="2022-01-01"
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
# Calculate EVaR
|
|
131
|
+
evar_values = calculator.calculate()
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Configuration Options
|
|
135
|
+
|
|
136
|
+
### Custom Risk-Free Rate
|
|
137
|
+
|
|
138
|
+
```python
|
|
139
|
+
# Using a constant value
|
|
140
|
+
sharpe_ratios = sq.sharpe(data, assets, freerate_value=0.02)
|
|
141
|
+
|
|
142
|
+
# Using a column in your data
|
|
143
|
+
sharpe_ratios = sq.sharpe(data, assets, freerate="TREASURY_YIELD")
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Custom Confidence Levels
|
|
147
|
+
|
|
148
|
+
```python
|
|
149
|
+
# Calculate VaR with 99% confidence
|
|
150
|
+
var_values = sq.var(data, assets, confidence=0.99)
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Documentation
|
|
154
|
+
|
|
155
|
+
For full documentation, visit [https://squarequant.readthedocs.io](https://squarequant.readthedocs.io)
|
|
156
|
+
|
|
157
|
+
## Contributing
|
|
158
|
+
|
|
159
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
160
|
+
|
|
161
|
+
## License
|
|
162
|
+
|
|
163
|
+
MIT
|
|
164
|
+
|
|
165
|
+
## Author
|
|
166
|
+
|
|
167
|
+
Gabriel Bosch
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
with open("README.md", "r", encoding="utf-8") as fh:
|
|
4
|
+
long_description = fh.read()
|
|
5
|
+
|
|
6
|
+
setup(
|
|
7
|
+
name="squarequant",
|
|
8
|
+
version="0.1.0",
|
|
9
|
+
author="Gabriel Bosch",
|
|
10
|
+
author_email="contact@suqarequant.org",
|
|
11
|
+
description="A Python package for quantitative finance",
|
|
12
|
+
long_description=long_description,
|
|
13
|
+
long_description_content_type="text/markdown",
|
|
14
|
+
url="https://github.com/SquareQuant/squarequant-package",
|
|
15
|
+
project_urls={
|
|
16
|
+
"Documentation": "https://squarequant.readthedocs.io",
|
|
17
|
+
"Bug Tracker": "https://github.com/SquareQuant/squarequant-package/issues",
|
|
18
|
+
},
|
|
19
|
+
packages=find_packages(),
|
|
20
|
+
classifiers=[
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"Programming Language :: Python :: 3.7",
|
|
23
|
+
"Programming Language :: Python :: 3.8",
|
|
24
|
+
"Programming Language :: Python :: 3.9",
|
|
25
|
+
"License :: OSI Approved :: MIT License",
|
|
26
|
+
"Operating System :: OS Independent",
|
|
27
|
+
"Topic :: Office/Business :: Financial :: Investment",
|
|
28
|
+
"Topic :: Scientific/Engineering :: Information Analysis",
|
|
29
|
+
"Intended Audience :: Financial and Insurance Industry",
|
|
30
|
+
"Intended Audience :: Science/Research",
|
|
31
|
+
"Development Status :: 4 - Beta",
|
|
32
|
+
],
|
|
33
|
+
python_requires=">=3.7",
|
|
34
|
+
install_requires=[
|
|
35
|
+
"pandas>=1.0.0",
|
|
36
|
+
"numpy>=1.18.0",
|
|
37
|
+
"yfinance>=0.1.63",
|
|
38
|
+
"scipy>=1.5.0",
|
|
39
|
+
"matplotlib>=3.3.0",
|
|
40
|
+
],
|
|
41
|
+
extras_require={
|
|
42
|
+
"optimization": ["cvxpy>=1.0.0"],
|
|
43
|
+
"dev": [
|
|
44
|
+
"pytest>=6.0.0",
|
|
45
|
+
"black>=21.5b2",
|
|
46
|
+
"flake8>=3.9.0",
|
|
47
|
+
"sphinx>=4.0.0",
|
|
48
|
+
"sphinx-rtd-theme>=0.5.0",
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
keywords="finance, risk, portfolio, investment, stocks, analysis, visualization",
|
|
52
|
+
)
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# squarequant/__init__.py
|
|
2
|
+
"""
|
|
3
|
+
SquareQuant: A Python package for financial risk metrics and stock data analysis
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
__version__ = '0.1.0'
|
|
7
|
+
|
|
8
|
+
# Import main functions for easy access
|
|
9
|
+
from squarequant.core.data import download_tickers, DownloadConfig
|
|
10
|
+
from squarequant.core.metrics import (
|
|
11
|
+
SharpeRatio,
|
|
12
|
+
SortinoRatio,
|
|
13
|
+
Volatility,
|
|
14
|
+
MaximumDrawdown,
|
|
15
|
+
ValueAtRisk,
|
|
16
|
+
CalmarRatio,
|
|
17
|
+
ConditionalValueAtRisk,
|
|
18
|
+
SemiDeviation,
|
|
19
|
+
AverageDrawdown,
|
|
20
|
+
UlcerIndex,
|
|
21
|
+
MeanAbsoluteDeviation,
|
|
22
|
+
EntropicRiskMeasure,
|
|
23
|
+
EntropicValueAtRisk,
|
|
24
|
+
ConditionalDrawdownAtRisk,
|
|
25
|
+
EntropicDrawdownAtRisk
|
|
26
|
+
)
|
|
27
|
+
from squarequant.api import sharpe, sortino, vol, mdd, var, calmar, cvar, semidev, avgdd, ulcer, mad, erm, evar, cdar, edar
|
|
28
|
+
|
|
29
|
+
# Import plotting functions
|
|
30
|
+
from squarequant.plot.plot import (
|
|
31
|
+
plot_rolling_metrics,
|
|
32
|
+
plot_correlation_matrix,
|
|
33
|
+
plot_drawdown,
|
|
34
|
+
plot_risk_comparison,
|
|
35
|
+
plot_performance_metrics,
|
|
36
|
+
plot_risk_contribution,
|
|
37
|
+
plot_returns_distribution,
|
|
38
|
+
plot_multiple_drawdowns,
|
|
39
|
+
plot_volatility_comparison,
|
|
40
|
+
plot_weight_allocation
|
|
41
|
+
)
|