ppar 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.
ppar-0.1.0/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2025, John D. Reynolds
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
ppar-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,153 @@
1
+ Metadata-Version: 2.2
2
+ Name: ppar
3
+ Version: 0.1.0
4
+ Summary: A python-based application that produces multi-period attribution, contribution, and benchmark-relative ex-post risk statistics.
5
+ Author-email: John Reynolds <jjjkreynolds@gmail.com>
6
+ License: Copyright (c) 2025, John D. Reynolds
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ of this software and associated documentation files (the "Software"), to deal
10
+ in the Software without restriction, including without limitation the rights
11
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ copies of the Software, and to permit persons to whom the Software is
13
+ furnished to do so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in all
16
+ copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ SOFTWARE.
25
+ Project-URL: Repository, https://github.com/JohnDReynolds/portfolio-performance-analytics
26
+ Keywords: portfolio,performance,analytics,attribution,brinson,fachler,risk,statistics
27
+ Requires-Python: >=3.12.1
28
+ Description-Content-Type: text/markdown
29
+ License-File: LICENSE
30
+ Requires-Dist: great_tables>=0.14.0
31
+ Requires-Dist: lxml>=5.1.0
32
+ Requires-Dist: matplotlib>=3.8.2
33
+ Requires-Dist: numpy>=1.26.4
34
+ Requires-Dist: pandas>=2.2.2
35
+ Requires-Dist: polars>=1.16.0
36
+ Requires-Dist: pyarrow>=15.0.1
37
+ Requires-Dist: scipy>=1.12.0
38
+ Requires-Dist: seaborn>=0.13.2
39
+
40
+ # portfolio-performance-analytics
41
+ portfolio-performance-analytics (ppar) is a python-based application that produces holdings-based multi-period attribution, contribution, and benchmark-relative ex-post risk statistics.
42
+
43
+ [License](LICENSE)
44
+
45
+ ## Table of Contents
46
+
47
+ - [Description](#description)
48
+ - [Features](#features)
49
+ - [Usage](#usage)
50
+ - [Implementation](#implementation)
51
+ - [Enhancements](#enhancements)
52
+ - [Technical](#technical)
53
+
54
+ ---
55
+
56
+ ## Description
57
+
58
+ portfolio-performance-analytics (ppar) is a python package that produces holdings-based multi-period attribution, contribution, and benchmark-relative ex-post risk statistics. It uses the Brinson-Fachler methodology for calculating attribution effects, and uses the Carino method for logarithmically-smoothing cumulative effects over multi-period time frames.
59
+
60
+ The inputs required to produce the analytics fall into three categories:
61
+ 1. Periodic "classification-level" weights and returns for a portfolio and its benchmark. A "classification" can be any category such as region, country, economic sector, industry, security, etc. The weights and returns must satisfy the formula: *SumOf(weights * returns) = Total Return*. They will typically be beginning-of-period weights and period returns. (Required)
62
+ 2. Classification items and descriptions. (Optional)
63
+ 3. Mappings from the classification scheme of the weights and returns to a reporting classification. (Optional)
64
+
65
+ The input data may be provided directly as either:
66
+ 1. Pandas DataFrames.
67
+ 2. Polars DataFrames.
68
+ 3. Python dictionaries (for Classifications and Mappings).
69
+ 4. csv files.
70
+
71
+ For sample input data sources, please refer to the python script demo.py and the ppar/demo_data directory. Once the input data has been provided, then the analytics may be requested using different calculation parameters, time-periods, and frequencies:
72
+ 1. Daily (or for whatever data frequency is provided).
73
+ 2. Monthly
74
+ 3. Quarterly
75
+ 4. Yearly
76
+
77
+ The outputs are represented by different views and charts. See [Features](#features) below. They may be delivered in different formats:
78
+ 1. csv files
79
+ 2. html strings
80
+ 3. json strings
81
+ 4. Pandas DataFrames
82
+ 5. png files
83
+ 6. Polars DataFrames
84
+ 7. Python "great tables"
85
+ 8. xml strings
86
+
87
+ ---
88
+
89
+ ## Features
90
+
91
+ The below sample outputs portray a large-cap alpha strategy that has achieved a high active return of 1737 bps over the benchmark. In the total lines of the Economic Sector Attribution reports, you can see that this active return can be broken down into 359 bps in sector allocation and 1378 bps in selecting securities. From the Risk Statistics report, you can see that this has been accomplished with a lower downside probabilty than the benchmark (29% vs 36%), and a higher annualized sharpe ratio than the benchmark (2.02 vs 1.27). The largest contributor to active performance was in the Information Technology Sector. Although the portfolio was slightly under-allocated in the Information Technology sector (by -0.05%), it did an excellent job of selecting securities for a total active contribution of 431 bps in the sector.
92
+
93
+ - **Attribution & Contribution**:
94
+ <img src="images/CumulativeAttributionByEconomicSector.jpg" alt="Cumulative Attribution by Economic Sector Table" width="100%" />
95
+ <br><br><br>
96
+ <img src="images/OverallAttributionByEconomicSector.jpg" alt="Overall Attribution by Economic Sector Table" width="100%" />
97
+ <br><br><br>
98
+ <img src="images/OverallAttributionBySecurity.jpg" alt="Overall Attribution by Security Table" width="100%" />
99
+ <br><br><br>
100
+ <img src="images/OverallAttributionByEconomicSector.png" alt="Overall Attribution by Economic Sector Chart" width="100%" />
101
+ <br><br><br>
102
+ <img src="images/OverallContributionByEconomicSector.png" alt="Overall Contribution by Economic Sector Chart" width="100%" />
103
+ <br><br><br>
104
+ <img src="images/SubPeriodAttributionEffectsByEconomicSector.png" alt="Sub-Period Attribution Effects by Economic Sector Chart" width="100%" />
105
+ <br><br><br>
106
+ <img src="images/SubPeriodReturns.png" alt="Sub-Period Returns Chart" width="100%" />
107
+ <br><br><br>
108
+ <img src="images/ActiveContributionsByEconomicSector.png" alt="Active Contributions by Economic Sector Chart" width="100%" />
109
+ <br><br><br>
110
+ <img src="images/TotalAttributionEffectsByEconomicSector.png" alt="Total Attribution Effects by Economic Sector Chart" width="100%" />
111
+ <br><br><br>
112
+ <img src="images/CumulativeAttributionEffectsByEconomicSector.png" alt="Cumulative Attribution Effect by Economic Sector Chart" width="100%" />
113
+ <br><br><br>
114
+ <img src="images/CumulativeReturns.png" alt="Cumulative Returns" width="100%" />
115
+ <br><br><br>
116
+
117
+ - **Ex-Post Risk Statistics**:
118
+ <img src="images/RiskStatistics.jpg" alt="Risk Statistics" width="100%" />
119
+ <br>
120
+
121
+ ---
122
+
123
+ ## Installation
124
+ pip install ppar
125
+
126
+ ---
127
+
128
+ ## Usage
129
+ python demo.py
130
+
131
+ ---
132
+
133
+ ## Implementation
134
+ Typically, a user will develop their own "data source" functions that provide the data in one of the above formats. The python script "demo.py" has sample data source functions.
135
+
136
+ Users can also develop their own "presentation layer" using the various output formats as the inputs to their presentation layer.
137
+
138
+ This application can also be made available as a PyPi python package.
139
+
140
+ ---
141
+
142
+ ## Enhancements
143
+ Future enhancements may include:
144
+ 1. Break out the interaction (cross-product) effect. It is currently included in the selection effect.
145
+ 2. Break out the currency effect.
146
+ 3. Additional multi-period smoothing algorithms (e.g. Menchero).
147
+ 4. The independent treatment of the long and short sides of each sector.
148
+ 5. Support time-series of risk-free rates (as opposed to a single annual rate).
149
+
150
+ ---
151
+
152
+ ## Technical
153
+ Being built on top of Polars dataframes, ppar is able to efficiently process large datasets through parallel processing, vectorization, lazy evaluation, and using Apache Arrow as its underlying data format.
ppar-0.1.0/README.md ADDED
@@ -0,0 +1,114 @@
1
+ # portfolio-performance-analytics
2
+ portfolio-performance-analytics (ppar) is a python-based application that produces holdings-based multi-period attribution, contribution, and benchmark-relative ex-post risk statistics.
3
+
4
+ [License](LICENSE)
5
+
6
+ ## Table of Contents
7
+
8
+ - [Description](#description)
9
+ - [Features](#features)
10
+ - [Usage](#usage)
11
+ - [Implementation](#implementation)
12
+ - [Enhancements](#enhancements)
13
+ - [Technical](#technical)
14
+
15
+ ---
16
+
17
+ ## Description
18
+
19
+ portfolio-performance-analytics (ppar) is a python package that produces holdings-based multi-period attribution, contribution, and benchmark-relative ex-post risk statistics. It uses the Brinson-Fachler methodology for calculating attribution effects, and uses the Carino method for logarithmically-smoothing cumulative effects over multi-period time frames.
20
+
21
+ The inputs required to produce the analytics fall into three categories:
22
+ 1. Periodic "classification-level" weights and returns for a portfolio and its benchmark. A "classification" can be any category such as region, country, economic sector, industry, security, etc. The weights and returns must satisfy the formula: *SumOf(weights * returns) = Total Return*. They will typically be beginning-of-period weights and period returns. (Required)
23
+ 2. Classification items and descriptions. (Optional)
24
+ 3. Mappings from the classification scheme of the weights and returns to a reporting classification. (Optional)
25
+
26
+ The input data may be provided directly as either:
27
+ 1. Pandas DataFrames.
28
+ 2. Polars DataFrames.
29
+ 3. Python dictionaries (for Classifications and Mappings).
30
+ 4. csv files.
31
+
32
+ For sample input data sources, please refer to the python script demo.py and the ppar/demo_data directory. Once the input data has been provided, then the analytics may be requested using different calculation parameters, time-periods, and frequencies:
33
+ 1. Daily (or for whatever data frequency is provided).
34
+ 2. Monthly
35
+ 3. Quarterly
36
+ 4. Yearly
37
+
38
+ The outputs are represented by different views and charts. See [Features](#features) below. They may be delivered in different formats:
39
+ 1. csv files
40
+ 2. html strings
41
+ 3. json strings
42
+ 4. Pandas DataFrames
43
+ 5. png files
44
+ 6. Polars DataFrames
45
+ 7. Python "great tables"
46
+ 8. xml strings
47
+
48
+ ---
49
+
50
+ ## Features
51
+
52
+ The below sample outputs portray a large-cap alpha strategy that has achieved a high active return of 1737 bps over the benchmark. In the total lines of the Economic Sector Attribution reports, you can see that this active return can be broken down into 359 bps in sector allocation and 1378 bps in selecting securities. From the Risk Statistics report, you can see that this has been accomplished with a lower downside probabilty than the benchmark (29% vs 36%), and a higher annualized sharpe ratio than the benchmark (2.02 vs 1.27). The largest contributor to active performance was in the Information Technology Sector. Although the portfolio was slightly under-allocated in the Information Technology sector (by -0.05%), it did an excellent job of selecting securities for a total active contribution of 431 bps in the sector.
53
+
54
+ - **Attribution & Contribution**:
55
+ <img src="images/CumulativeAttributionByEconomicSector.jpg" alt="Cumulative Attribution by Economic Sector Table" width="100%" />
56
+ <br><br><br>
57
+ <img src="images/OverallAttributionByEconomicSector.jpg" alt="Overall Attribution by Economic Sector Table" width="100%" />
58
+ <br><br><br>
59
+ <img src="images/OverallAttributionBySecurity.jpg" alt="Overall Attribution by Security Table" width="100%" />
60
+ <br><br><br>
61
+ <img src="images/OverallAttributionByEconomicSector.png" alt="Overall Attribution by Economic Sector Chart" width="100%" />
62
+ <br><br><br>
63
+ <img src="images/OverallContributionByEconomicSector.png" alt="Overall Contribution by Economic Sector Chart" width="100%" />
64
+ <br><br><br>
65
+ <img src="images/SubPeriodAttributionEffectsByEconomicSector.png" alt="Sub-Period Attribution Effects by Economic Sector Chart" width="100%" />
66
+ <br><br><br>
67
+ <img src="images/SubPeriodReturns.png" alt="Sub-Period Returns Chart" width="100%" />
68
+ <br><br><br>
69
+ <img src="images/ActiveContributionsByEconomicSector.png" alt="Active Contributions by Economic Sector Chart" width="100%" />
70
+ <br><br><br>
71
+ <img src="images/TotalAttributionEffectsByEconomicSector.png" alt="Total Attribution Effects by Economic Sector Chart" width="100%" />
72
+ <br><br><br>
73
+ <img src="images/CumulativeAttributionEffectsByEconomicSector.png" alt="Cumulative Attribution Effect by Economic Sector Chart" width="100%" />
74
+ <br><br><br>
75
+ <img src="images/CumulativeReturns.png" alt="Cumulative Returns" width="100%" />
76
+ <br><br><br>
77
+
78
+ - **Ex-Post Risk Statistics**:
79
+ <img src="images/RiskStatistics.jpg" alt="Risk Statistics" width="100%" />
80
+ <br>
81
+
82
+ ---
83
+
84
+ ## Installation
85
+ pip install ppar
86
+
87
+ ---
88
+
89
+ ## Usage
90
+ python demo.py
91
+
92
+ ---
93
+
94
+ ## Implementation
95
+ Typically, a user will develop their own "data source" functions that provide the data in one of the above formats. The python script "demo.py" has sample data source functions.
96
+
97
+ Users can also develop their own "presentation layer" using the various output formats as the inputs to their presentation layer.
98
+
99
+ This application can also be made available as a PyPi python package.
100
+
101
+ ---
102
+
103
+ ## Enhancements
104
+ Future enhancements may include:
105
+ 1. Break out the interaction (cross-product) effect. It is currently included in the selection effect.
106
+ 2. Break out the currency effect.
107
+ 3. Additional multi-period smoothing algorithms (e.g. Menchero).
108
+ 4. The independent treatment of the long and short sides of each sector.
109
+ 5. Support time-series of risk-free rates (as opposed to a single annual rate).
110
+
111
+ ---
112
+
113
+ ## Technical
114
+ Being built on top of Polars dataframes, ppar is able to efficiently process large datasets through parallel processing, vectorization, lazy evaluation, and using Apache Arrow as its underlying data format.
@@ -0,0 +1,19 @@
1
+ """
2
+ Imports and publc exposure for the package.
3
+ """
4
+
5
+ # Explicitly import the specific members or modules.
6
+ # If they are defined below in __all__, then they must be imported here.
7
+ from ppar.analytics import Analytics
8
+ from ppar.attribution import Attribution, View
9
+ from ppar.frequency import Frequency
10
+ from ppar.riskstatistics import RiskStatistics
11
+
12
+ # Define the public API using __all__
13
+ __all__ = [
14
+ "Analytics",
15
+ "Attribution",
16
+ "Frequency",
17
+ "RiskStatistics",
18
+ "View",
19
+ ]