numfolio 0.0.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,33 @@
1
+ ## Development 👩‍💻
2
+
3
+ ### GitFlow
4
+
5
+ The development cycle follows a *[GitFlow](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow)*
6
+ paradigm. The releases are contained in the `master` branch, which
7
+ must contain stable code. The main development branch
8
+ is `develop`. Pull requests are used to align feature branches to `develop` and
9
+ `develop` to `master`. Automatic tests are run to assess the
10
+ code quality, see [`tests`](tests) folder.
11
+
12
+ ### Code style
13
+
14
+ The style and the quality of the code is managed
15
+ by [`ruff`](https://docs.astral.sh/ruff/). See [`pyproject.toml`](pyproject.toml) for configuration.
16
+ A plugin for a documentation is also used, the `md` paradigm for [`mkdocs`](https://www.mkdocs.org/)
17
+ has been chosen. See [`docs`](docs) folder for documentation-related issues.
18
+ The import rules are managed through [`isort`](https://pycqa.github.io/isort/), see [`pyproject.toml`](pyproject.toml) file, section
19
+ `[tool.isort]`.
20
+
21
+ The style syntax rules are imposed with the help of [`pre-commit`](https://pre-commit.com/) tool.
22
+ Those are specified in the [`.pre-commit-config.yaml`](.pre-commit-config.yaml) file.
23
+ To initialize the tool run
24
+ ```bash
25
+ pre-commit install
26
+ ```
27
+ A common error on `macOS` is related to `UTC-8` format. See [this](https://stackoverflow.com/questions/60557160/python3-8-fails-with-fatal-python-error-config-get-locale-encoding) issue
28
+ on StackOverflow. To update the tool use `pre-commit autoupdate`.
29
+
30
+
31
+ ### Contributors
32
+
33
+ Authors and contributors have been collected in [`AUTHORS.md`](docs/docs/authors.md) file.
numfolio-0.0.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Andrea
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,4 @@
1
+ # Include the README
2
+ include *.md
3
+ include pyproject.toml
4
+ include *.rst
@@ -0,0 +1,111 @@
1
+ Metadata-Version: 2.4
2
+ Name: numfolio
3
+ Version: 0.0.1
4
+ Author-email: agdiiura <andreadiiura@gmail.com>
5
+ Description-Content-Type: text/markdown
6
+ License-File: LICENSE
7
+ Requires-Dist: joblib>=1.3.2
8
+ Requires-Dist: pandas>=2.2.1
9
+ Requires-Dist: numpy>=1.22
10
+ Requires-Dist: scikit-learn>=1.5.0
11
+ Requires-Dist: scipy>=1.12.0
12
+ Requires-Dist: arch>=6.3.0
13
+ Requires-Dist: numba>0.59.0
14
+ Provides-Extra: build
15
+ Requires-Dist: ruff>=0.11.0; extra == "build"
16
+ Requires-Dist: colorama>=0.4.6; extra == "build"
17
+ Requires-Dist: coverage>=7.0; extra == "build"
18
+ Requires-Dist: isort>=6.0.0; extra == "build"
19
+ Requires-Dist: pre-commit>=4.0.0; extra == "build"
20
+ Requires-Dist: setuptools-git-versioning>=1.13.4; extra == "build"
21
+ Requires-Dist: unittest-xml-reporting>=3.2.0; extra == "build"
22
+ Provides-Extra: docs
23
+ Requires-Dist: mkdocs>=1.6.0; extra == "docs"
24
+ Requires-Dist: mkdocstrings[python]==0.26.2; extra == "docs"
25
+ Dynamic: license-file
26
+
27
+ # numfolio ⚡
28
+ Portfolio performance accelerated by Numba
29
+
30
+ A lightweight, flexible Python package for analyzing portfolio returns,
31
+ risk metrics, and correlations using modern statistical and machine learning methods.
32
+
33
+ ---
34
+
35
+ ## 🚀 Features
36
+
37
+ ✅ Bootstrapped metric estimation (e.g., Sharpe Ratio, Sortino Ratio)
38
+
39
+ ✅ Automatic Scorecard Generation with time-based aggregation (Yearly, Quarterly, Monthly)
40
+
41
+ ✅ Covariance and Correlation estimation with robust shrinkage methods
42
+
43
+ ✅ Parallel computation for scalability
44
+
45
+ ✅ Clean, consistent API inspired by scikit-learn & pandas
46
+
47
+
48
+ ---
49
+
50
+ ## 🔧 Installation
51
+
52
+ To install the package the simplest procedure is:
53
+ ```bash
54
+ pip install numfolio
55
+ ```
56
+ Now you can test the installation... In a python shell:
57
+
58
+ ```python
59
+ import numfolio as nf
60
+
61
+ nf.__version__
62
+ ```
63
+
64
+ Optional dependencies are `docs` for documentation and
65
+ `build` for development. To install optional
66
+ dependencies `pip install numfolio[docs,build]`.
67
+
68
+ ## 📚 Example Usage
69
+
70
+ ### 1. Compute Scorecard from PnL or Returns:
71
+
72
+ ```python
73
+ import pandas as pd
74
+ from numfolio import get_scorecard
75
+
76
+ # Sample PnL data
77
+ dates = pd.date_range("2025-01-01", periods=60, freq="D")
78
+ pnl = pd.Series(range(100, 160), index=dates)
79
+
80
+ df = pd.DataFrame({"pnl": pnl})
81
+
82
+ scorecard = get_scorecard(df, freq="M")
83
+ print(scorecard)
84
+ ```
85
+
86
+ ### 2. Estimate Bootstrapped Sharpe Ratio:
87
+
88
+ ```python
89
+ import numpy as np
90
+ from numfolio import bootstrap_metric
91
+
92
+ # Generate fake returns
93
+ returns = np.random.default_rng().normal(0, 1, 100)
94
+
95
+ bootstrapped = bootstrap_metric(returns, metric="sharpe_ratio", n_bootstraps=500)
96
+ print("Bootstrapped Sharpe Ratios:", bootstrapped[:5])
97
+ ```
98
+
99
+ ### 3. Estimate Correlation Matrix:
100
+
101
+ ```python
102
+ import pandas as pd
103
+ import numpy as np
104
+ from numfolio import estimate_correlation
105
+
106
+ dates = pd.date_range("2025-01-01", periods=100, freq="D")
107
+ returns = pd.DataFrame(np.random.default_rng().normal(0, 1, (100, 3)), columns=["A", "B", "C"], index=dates)
108
+
109
+ correlation = estimate_correlation(returns, method="ledoit_wolf", n_bootstraps=200)
110
+ print(correlation)
111
+ ```
@@ -0,0 +1,85 @@
1
+ # numfolio ⚡
2
+ Portfolio performance accelerated by Numba
3
+
4
+ A lightweight, flexible Python package for analyzing portfolio returns,
5
+ risk metrics, and correlations using modern statistical and machine learning methods.
6
+
7
+ ---
8
+
9
+ ## 🚀 Features
10
+
11
+ ✅ Bootstrapped metric estimation (e.g., Sharpe Ratio, Sortino Ratio)
12
+
13
+ ✅ Automatic Scorecard Generation with time-based aggregation (Yearly, Quarterly, Monthly)
14
+
15
+ ✅ Covariance and Correlation estimation with robust shrinkage methods
16
+
17
+ ✅ Parallel computation for scalability
18
+
19
+ ✅ Clean, consistent API inspired by scikit-learn & pandas
20
+
21
+
22
+ ---
23
+
24
+ ## 🔧 Installation
25
+
26
+ To install the package the simplest procedure is:
27
+ ```bash
28
+ pip install numfolio
29
+ ```
30
+ Now you can test the installation... In a python shell:
31
+
32
+ ```python
33
+ import numfolio as nf
34
+
35
+ nf.__version__
36
+ ```
37
+
38
+ Optional dependencies are `docs` for documentation and
39
+ `build` for development. To install optional
40
+ dependencies `pip install numfolio[docs,build]`.
41
+
42
+ ## 📚 Example Usage
43
+
44
+ ### 1. Compute Scorecard from PnL or Returns:
45
+
46
+ ```python
47
+ import pandas as pd
48
+ from numfolio import get_scorecard
49
+
50
+ # Sample PnL data
51
+ dates = pd.date_range("2025-01-01", periods=60, freq="D")
52
+ pnl = pd.Series(range(100, 160), index=dates)
53
+
54
+ df = pd.DataFrame({"pnl": pnl})
55
+
56
+ scorecard = get_scorecard(df, freq="M")
57
+ print(scorecard)
58
+ ```
59
+
60
+ ### 2. Estimate Bootstrapped Sharpe Ratio:
61
+
62
+ ```python
63
+ import numpy as np
64
+ from numfolio import bootstrap_metric
65
+
66
+ # Generate fake returns
67
+ returns = np.random.default_rng().normal(0, 1, 100)
68
+
69
+ bootstrapped = bootstrap_metric(returns, metric="sharpe_ratio", n_bootstraps=500)
70
+ print("Bootstrapped Sharpe Ratios:", bootstrapped[:5])
71
+ ```
72
+
73
+ ### 3. Estimate Correlation Matrix:
74
+
75
+ ```python
76
+ import pandas as pd
77
+ import numpy as np
78
+ from numfolio import estimate_correlation
79
+
80
+ dates = pd.date_range("2025-01-01", periods=100, freq="D")
81
+ returns = pd.DataFrame(np.random.default_rng().normal(0, 1, (100, 3)), columns=["A", "B", "C"], index=dates)
82
+
83
+ correlation = estimate_correlation(returns, method="ledoit_wolf", n_bootstraps=200)
84
+ print(correlation)
85
+ ```
@@ -0,0 +1,111 @@
1
+ Metadata-Version: 2.4
2
+ Name: numfolio
3
+ Version: 0.0.1
4
+ Author-email: agdiiura <andreadiiura@gmail.com>
5
+ Description-Content-Type: text/markdown
6
+ License-File: LICENSE
7
+ Requires-Dist: joblib>=1.3.2
8
+ Requires-Dist: pandas>=2.2.1
9
+ Requires-Dist: numpy>=1.22
10
+ Requires-Dist: scikit-learn>=1.5.0
11
+ Requires-Dist: scipy>=1.12.0
12
+ Requires-Dist: arch>=6.3.0
13
+ Requires-Dist: numba>0.59.0
14
+ Provides-Extra: build
15
+ Requires-Dist: ruff>=0.11.0; extra == "build"
16
+ Requires-Dist: colorama>=0.4.6; extra == "build"
17
+ Requires-Dist: coverage>=7.0; extra == "build"
18
+ Requires-Dist: isort>=6.0.0; extra == "build"
19
+ Requires-Dist: pre-commit>=4.0.0; extra == "build"
20
+ Requires-Dist: setuptools-git-versioning>=1.13.4; extra == "build"
21
+ Requires-Dist: unittest-xml-reporting>=3.2.0; extra == "build"
22
+ Provides-Extra: docs
23
+ Requires-Dist: mkdocs>=1.6.0; extra == "docs"
24
+ Requires-Dist: mkdocstrings[python]==0.26.2; extra == "docs"
25
+ Dynamic: license-file
26
+
27
+ # numfolio ⚡
28
+ Portfolio performance accelerated by Numba
29
+
30
+ A lightweight, flexible Python package for analyzing portfolio returns,
31
+ risk metrics, and correlations using modern statistical and machine learning methods.
32
+
33
+ ---
34
+
35
+ ## 🚀 Features
36
+
37
+ ✅ Bootstrapped metric estimation (e.g., Sharpe Ratio, Sortino Ratio)
38
+
39
+ ✅ Automatic Scorecard Generation with time-based aggregation (Yearly, Quarterly, Monthly)
40
+
41
+ ✅ Covariance and Correlation estimation with robust shrinkage methods
42
+
43
+ ✅ Parallel computation for scalability
44
+
45
+ ✅ Clean, consistent API inspired by scikit-learn & pandas
46
+
47
+
48
+ ---
49
+
50
+ ## 🔧 Installation
51
+
52
+ To install the package the simplest procedure is:
53
+ ```bash
54
+ pip install numfolio
55
+ ```
56
+ Now you can test the installation... In a python shell:
57
+
58
+ ```python
59
+ import numfolio as nf
60
+
61
+ nf.__version__
62
+ ```
63
+
64
+ Optional dependencies are `docs` for documentation and
65
+ `build` for development. To install optional
66
+ dependencies `pip install numfolio[docs,build]`.
67
+
68
+ ## 📚 Example Usage
69
+
70
+ ### 1. Compute Scorecard from PnL or Returns:
71
+
72
+ ```python
73
+ import pandas as pd
74
+ from numfolio import get_scorecard
75
+
76
+ # Sample PnL data
77
+ dates = pd.date_range("2025-01-01", periods=60, freq="D")
78
+ pnl = pd.Series(range(100, 160), index=dates)
79
+
80
+ df = pd.DataFrame({"pnl": pnl})
81
+
82
+ scorecard = get_scorecard(df, freq="M")
83
+ print(scorecard)
84
+ ```
85
+
86
+ ### 2. Estimate Bootstrapped Sharpe Ratio:
87
+
88
+ ```python
89
+ import numpy as np
90
+ from numfolio import bootstrap_metric
91
+
92
+ # Generate fake returns
93
+ returns = np.random.default_rng().normal(0, 1, 100)
94
+
95
+ bootstrapped = bootstrap_metric(returns, metric="sharpe_ratio", n_bootstraps=500)
96
+ print("Bootstrapped Sharpe Ratios:", bootstrapped[:5])
97
+ ```
98
+
99
+ ### 3. Estimate Correlation Matrix:
100
+
101
+ ```python
102
+ import pandas as pd
103
+ import numpy as np
104
+ from numfolio import estimate_correlation
105
+
106
+ dates = pd.date_range("2025-01-01", periods=100, freq="D")
107
+ returns = pd.DataFrame(np.random.default_rng().normal(0, 1, (100, 3)), columns=["A", "B", "C"], index=dates)
108
+
109
+ correlation = estimate_correlation(returns, method="ledoit_wolf", n_bootstraps=200)
110
+ print(correlation)
111
+ ```
@@ -0,0 +1,10 @@
1
+ CONTRIBUTING.md
2
+ LICENSE
3
+ MANIFEST.in
4
+ README.md
5
+ pyproject.toml
6
+ numfolio.egg-info/PKG-INFO
7
+ numfolio.egg-info/SOURCES.txt
8
+ numfolio.egg-info/dependency_links.txt
9
+ numfolio.egg-info/requires.txt
10
+ numfolio.egg-info/top_level.txt
@@ -0,0 +1,20 @@
1
+ joblib>=1.3.2
2
+ pandas>=2.2.1
3
+ numpy>=1.22
4
+ scikit-learn>=1.5.0
5
+ scipy>=1.12.0
6
+ arch>=6.3.0
7
+ numba>0.59.0
8
+
9
+ [build]
10
+ ruff>=0.11.0
11
+ colorama>=0.4.6
12
+ coverage>=7.0
13
+ isort>=6.0.0
14
+ pre-commit>=4.0.0
15
+ setuptools-git-versioning>=1.13.4
16
+ unittest-xml-reporting>=3.2.0
17
+
18
+ [docs]
19
+ mkdocs>=1.6.0
20
+ mkdocstrings[python]==0.26.2
@@ -0,0 +1 @@
1
+ numfolio
@@ -0,0 +1,99 @@
1
+ # The addition of the pyproject.toml activates the so-called "build-isolation" mode of pip,
2
+ # where each build environment is created ad-hoc, and it's isolated from the active virtual
3
+ # environment where the package is being installed. This may create unwanted behaviours,
4
+ # as the rebuilding of the build dependencies even when they have been already installed previously.
5
+ # To prevent this behavior, either remove the pyproject.toml or launch pip the option --no-build-isolation.
6
+
7
+ [build-system]
8
+ requires = ["setuptools", "setuptools-git-versioning", "wheel"]
9
+ build-backend = "setuptools.build_meta"
10
+
11
+ [project]
12
+ name = "numfolio"
13
+ version = "0.0.1"
14
+ readme = "README.md"
15
+ authors = [
16
+ {name = "agdiiura", email="andreadiiura@gmail.com"}
17
+ ]
18
+
19
+ dependencies = [
20
+ "joblib>=1.3.2",
21
+ "pandas>=2.2.1",
22
+ "numpy>=1.22",
23
+ "scikit-learn>=1.5.0",
24
+ "scipy>=1.12.0",
25
+ "arch>=6.3.0",
26
+ "numba>0.59.0",
27
+ ]
28
+
29
+ [project.optional-dependencies]
30
+ build = [
31
+ "ruff>=0.11.0",
32
+ "colorama>=0.4.6",
33
+ "coverage>=7.0",
34
+ "isort>=6.0.0",
35
+ "pre-commit>=4.0.0",
36
+ "setuptools-git-versioning>=1.13.4",
37
+ "unittest-xml-reporting>=3.2.0"
38
+ ]
39
+ docs = [
40
+ "mkdocs>=1.6.0",
41
+ "mkdocstrings[python]==0.26.2"
42
+ ]
43
+
44
+ [tool.setuptools]
45
+ py-modules = ["numfolio"]
46
+
47
+ [tool.ruff]
48
+ src = ["numfolio"]
49
+ line-length = 90
50
+ extend-exclude = ["*.ipynb"]
51
+
52
+ [tool.ruff.lint]
53
+ select = ['E', 'W', 'D']
54
+ ignore = [
55
+ #"W503",
56
+ #"W504",
57
+ "E402",
58
+ "E731",
59
+ #"S001",
60
+ "D400",
61
+ "D202",
62
+ "D203",
63
+ "D212",
64
+ "D415",
65
+ "D205",
66
+ "D407", # Missing dashed underline after section
67
+ "D406", # Section name should end with a newline
68
+ "D412", # No blank lines allowed between a section header and its content
69
+ ]
70
+ exclude = [
71
+ "docs/sphinxext/*.py",
72
+ "docs/build/*.py",
73
+ "docs/temp/*.py",
74
+ "docs/source/conf.py",
75
+ ".eggs/*.py",
76
+ "env",
77
+ "*.ipynb"
78
+ ]
79
+
80
+ [tool.ruff.lint.per-file-ignores]
81
+ "*__init__.py" = ["F401", "F403"]
82
+ "setup.py" = ["F401", "D100"]
83
+ #"tests/*.py" = ["I900"]
84
+ #"examples/*.py" = ["I900"]
85
+
86
+ [tool.ruff.lint.pycodestyle]
87
+ max-line-length = 119
88
+
89
+ [tool.isort]
90
+ combine_as_imports = true
91
+ multi_line_output = 0
92
+ length_sort = true
93
+ lines_between_types = 1
94
+ sections = ["FUTURE","STDLIB","THIRDPARTY","FIRSTPARTY","LOCALFOLDER"]
95
+
96
+ [tool.codespell]
97
+ quiet-level = 0
98
+ ignore-words-list = "sur,manuel,assertIn"
99
+ skip = "*.ipynb,*.html,pyproject.toml"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+