portfolio-overview 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.
- portfolio_overview-0.1.0/.github/workflows/ci.yml +32 -0
- portfolio_overview-0.1.0/.github/workflows/pypi.yml +41 -0
- portfolio_overview-0.1.0/.github/workflows/release.yml +66 -0
- portfolio_overview-0.1.0/.gitignore +8 -0
- portfolio_overview-0.1.0/CHANGELOG.md +14 -0
- portfolio_overview-0.1.0/LICENSE +21 -0
- portfolio_overview-0.1.0/Makefile +8 -0
- portfolio_overview-0.1.0/PKG-INFO +94 -0
- portfolio_overview-0.1.0/README.md +62 -0
- portfolio_overview-0.1.0/examples/demo-portfolio/bonds.yaml +17 -0
- portfolio_overview-0.1.0/examples/demo-portfolio/cash.yaml +16 -0
- portfolio_overview-0.1.0/examples/demo-portfolio/daily-performance.json +18 -0
- portfolio_overview-0.1.0/examples/demo-portfolio/financing.yaml +9 -0
- portfolio_overview-0.1.0/examples/demo-portfolio/lots.yaml +35 -0
- portfolio_overview-0.1.0/examples/demo-portfolio/market-history.csv +11 -0
- portfolio_overview-0.1.0/examples/demo-portfolio/portfolio.yaml +11 -0
- portfolio_overview-0.1.0/pyproject.toml +72 -0
- portfolio_overview-0.1.0/scripts/test.sh +8 -0
- portfolio_overview-0.1.0/src/portfolio_overview/__init__.py +38 -0
- portfolio_overview-0.1.0/src/portfolio_overview/cli.py +50 -0
- portfolio_overview-0.1.0/src/portfolio_overview/engine.py +549 -0
- portfolio_overview-0.1.0/src/portfolio_overview/loaders.py +198 -0
- portfolio_overview-0.1.0/src/portfolio_overview/py.typed +0 -0
- portfolio_overview-0.1.0/src/portfolio_overview/schema.py +172 -0
- portfolio_overview-0.1.0/src/portfolio_overview/workbook.py +260 -0
- portfolio_overview-0.1.0/tests/test_portfolio_overview.py +262 -0
- portfolio_overview-0.1.0/uv.lock +1405 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
push:
|
|
6
|
+
branches: [main]
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
workflow_call:
|
|
9
|
+
|
|
10
|
+
permissions:
|
|
11
|
+
contents: read
|
|
12
|
+
|
|
13
|
+
concurrency:
|
|
14
|
+
group: ci-${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.ref || github.run_id }}
|
|
15
|
+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
|
16
|
+
|
|
17
|
+
jobs:
|
|
18
|
+
test:
|
|
19
|
+
strategy:
|
|
20
|
+
fail-fast: false
|
|
21
|
+
matrix:
|
|
22
|
+
python: ['3.11', '3.12', '3.13']
|
|
23
|
+
runs-on: ubuntu-latest
|
|
24
|
+
timeout-minutes: 10
|
|
25
|
+
steps:
|
|
26
|
+
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
|
|
27
|
+
with:
|
|
28
|
+
persist-credentials: false
|
|
29
|
+
- uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2
|
|
30
|
+
with:
|
|
31
|
+
python-version: ${{ matrix.python }}
|
|
32
|
+
- run: make check
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
name: PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags: ['v*.*.*']
|
|
6
|
+
workflow_dispatch: {}
|
|
7
|
+
|
|
8
|
+
permissions: {}
|
|
9
|
+
|
|
10
|
+
concurrency:
|
|
11
|
+
group: pypi-${{ github.ref }}
|
|
12
|
+
cancel-in-progress: false
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
ci:
|
|
16
|
+
if: github.ref_type == 'tag' && (github.event_name == 'workflow_dispatch' || vars.PYPI_PUBLISH == 'true')
|
|
17
|
+
uses: ./.github/workflows/ci.yml
|
|
18
|
+
permissions:
|
|
19
|
+
contents: read
|
|
20
|
+
|
|
21
|
+
publish:
|
|
22
|
+
needs: ci
|
|
23
|
+
if: github.ref_type == 'tag' && (github.event_name == 'workflow_dispatch' || vars.PYPI_PUBLISH == 'true')
|
|
24
|
+
runs-on: ubuntu-latest
|
|
25
|
+
timeout-minutes: 10
|
|
26
|
+
environment: pypi
|
|
27
|
+
permissions:
|
|
28
|
+
contents: read
|
|
29
|
+
id-token: write
|
|
30
|
+
steps:
|
|
31
|
+
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
|
|
32
|
+
with:
|
|
33
|
+
persist-credentials: false
|
|
34
|
+
- uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2
|
|
35
|
+
- name: Build
|
|
36
|
+
run: |
|
|
37
|
+
version="$(python3 -c 'import tomllib; print(tomllib.load(open("pyproject.toml", "rb"))["project"]["version"])')"
|
|
38
|
+
[ "${GITHUB_REF_NAME#v}" = "$version" ] || { echo "tag $GITHUB_REF_NAME is not version $version" >&2; exit 1; }
|
|
39
|
+
uv build
|
|
40
|
+
- name: Upload
|
|
41
|
+
run: uv publish --trusted-publishing always --check-url https://pypi.org/simple/
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags: ['v*.*.*']
|
|
6
|
+
workflow_dispatch: {}
|
|
7
|
+
|
|
8
|
+
permissions: {}
|
|
9
|
+
|
|
10
|
+
concurrency:
|
|
11
|
+
group: release-${{ github.ref }}
|
|
12
|
+
cancel-in-progress: false
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
released:
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
timeout-minutes: 5
|
|
18
|
+
permissions:
|
|
19
|
+
contents: read
|
|
20
|
+
outputs:
|
|
21
|
+
done: ${{ steps.check.outputs.done }}
|
|
22
|
+
steps:
|
|
23
|
+
- id: check
|
|
24
|
+
env:
|
|
25
|
+
GH_TOKEN: ${{ github.token }}
|
|
26
|
+
TAG: ${{ github.ref_name }}
|
|
27
|
+
run: |
|
|
28
|
+
done=false
|
|
29
|
+
if [ "$GITHUB_REF_TYPE" = tag ] && gh release view "$TAG" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
|
|
30
|
+
done=true
|
|
31
|
+
echo "$TAG is already released: nothing to do"
|
|
32
|
+
fi
|
|
33
|
+
echo "done=$done" >> "$GITHUB_OUTPUT"
|
|
34
|
+
|
|
35
|
+
ci:
|
|
36
|
+
needs: released
|
|
37
|
+
if: needs.released.outputs.done != 'true'
|
|
38
|
+
uses: ./.github/workflows/ci.yml
|
|
39
|
+
permissions:
|
|
40
|
+
contents: read
|
|
41
|
+
|
|
42
|
+
github-release:
|
|
43
|
+
needs: ci
|
|
44
|
+
if: github.event_name == 'push' && github.ref_type == 'tag'
|
|
45
|
+
runs-on: ubuntu-latest
|
|
46
|
+
timeout-minutes: 10
|
|
47
|
+
permissions:
|
|
48
|
+
contents: write
|
|
49
|
+
steps:
|
|
50
|
+
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
|
|
51
|
+
with:
|
|
52
|
+
persist-credentials: false
|
|
53
|
+
- uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2
|
|
54
|
+
- name: Build
|
|
55
|
+
run: |
|
|
56
|
+
version="$(python3 -c 'import tomllib; print(tomllib.load(open("pyproject.toml", "rb"))["project"]["version"])')"
|
|
57
|
+
[ "${GITHUB_REF_NAME#v}" = "$version" ] || { echo "tag $GITHUB_REF_NAME is not version $version" >&2; exit 1; }
|
|
58
|
+
uv build
|
|
59
|
+
- env:
|
|
60
|
+
GH_TOKEN: ${{ github.token }}
|
|
61
|
+
TAG: ${{ github.ref_name }}
|
|
62
|
+
run: |
|
|
63
|
+
object=$(gh api "repos/$GITHUB_REPOSITORY/git/ref/tags/$TAG" --jq 'select(.object.type == "tag") | .object.sha')
|
|
64
|
+
test -n "$object" || { echo "::error::$TAG is not an annotated tag carrying release notes"; exit 1; }
|
|
65
|
+
gh api "repos/$GITHUB_REPOSITORY/git/tags/$object" --jq .message > "$RUNNER_TEMP/notes.md"
|
|
66
|
+
gh release create "$TAG" dist/* --repo "$GITHUB_REPOSITORY" --verify-tag --title "$TAG" --notes-file "$RUNNER_TEMP/notes.md"
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.1.0] - 2026-11-29
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- `schema`: versioned `PortfolioConfig`, `PortfolioBook` input IR (accounts, lots, cash, credit facilities, cash flows, income, optional bond terms, broker snapshots, market history), and `PortfolioReport` output IR (`schema_version = 1`).
|
|
7
|
+
- `loaders`: `load_book()` for plain YAML/CSV directories plus optional IBKR Flex XML ingestion via `ibkr-flex-accounting`.
|
|
8
|
+
- `engine`: pure, zero-network, base-currency-agnostic `evaluate(book) -> PortfolioReport` composing `eod-market-data`, `ibkr-flex-accounting`, `fhs-market-risk`, `portfolio-twr`, and optional `callable-bond-analytics`.
|
|
9
|
+
- `workbook`: modular, data-driven `render_workbook(report, path)` generating Summary, Accounts, Holdings, Allocation & FX, Performance & Risk, and conditional Bonds / Credit Facilities tabs.
|
|
10
|
+
- `cli`: `portfolio-overview validate` and `portfolio-overview build` commands plus synthetic `examples/demo-portfolio/`.
|
|
11
|
+
|
|
12
|
+
### Upgrade
|
|
13
|
+
- Action required: None.
|
|
14
|
+
- Rollback: Uninstall `portfolio-overview` or revert to a prior local script.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 benjamin-di
|
|
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,94 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: portfolio-overview
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Data-contract, base-currency-agnostic multi-custodian portfolio valuation, performance, risk, bond analytics, and Excel workbook engine
|
|
5
|
+
Project-URL: Homepage, https://github.com/benjamin-di/portfolio-overview
|
|
6
|
+
Project-URL: Issues, https://github.com/benjamin-di/portfolio-overview/issues
|
|
7
|
+
Author: benjamin-di
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: accounting,expected-shortfall,finance,ibkr,openpyxl,portfolio,twr,valuation,var
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
21
|
+
Requires-Python: >=3.11
|
|
22
|
+
Requires-Dist: eod-market-data<1,>=0.1.0
|
|
23
|
+
Requires-Dist: fhs-market-risk<1,>=0.1.0
|
|
24
|
+
Requires-Dist: ibkr-flex-accounting<1,>=0.1.0
|
|
25
|
+
Requires-Dist: openpyxl<4,>=3.1
|
|
26
|
+
Requires-Dist: pandas<3.1,>=2.2
|
|
27
|
+
Requires-Dist: portfolio-twr<1,>=0.1.0
|
|
28
|
+
Requires-Dist: pyyaml<7,>=6
|
|
29
|
+
Provides-Extra: bonds
|
|
30
|
+
Requires-Dist: callable-bond-analytics<1,>=0.1.0; extra == 'bonds'
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
# portfolio-overview
|
|
34
|
+
|
|
35
|
+
Data-contract, base-currency-agnostic multi-custodian portfolio valuation, performance, risk, bond analytics, and Excel workbook engine.
|
|
36
|
+
|
|
37
|
+
`portfolio-overview` composes five standalone financial libraries into a deterministic, zero-network functional core:
|
|
38
|
+
|
|
39
|
+
- [`eod-market-data`](https://pypi.org/project/eod-market-data/) — canonical EOD price/FX time-series store and calendar guards
|
|
40
|
+
- [`ibkr-flex-accounting`](https://pypi.org/project/ibkr-flex-accounting/) — optional Interactive Brokers Flex XML accounting snapshots
|
|
41
|
+
- [`fhs-market-risk`](https://pypi.org/project/fhs-market-risk/) — EWMA Filtered Historical Simulation VaR/ES, walk-forward backtesting, and FX sensitivity
|
|
42
|
+
- [`portfolio-twr`](https://pypi.org/project/portfolio-twr/) — linked daily TWR, geometric contribution attribution, drawdown/Sharpe/Sortino, and Modified Dietz
|
|
43
|
+
- [`callable-bond-analytics`](https://pypi.org/project/callable-bond-analytics/) (optional `[bonds]` extra) — QuantLib callable/perpetual bond YTC, YTP/YTW, Modified Duration, and DV01
|
|
44
|
+
|
|
45
|
+
## Architecture
|
|
46
|
+
|
|
47
|
+
No plugin registries or global state: every boundary is an immutable, versioned data contract.
|
|
48
|
+
|
|
49
|
+
```text
|
|
50
|
+
YAML / CSV / IBKR Flex XML (or your private bank ETL)
|
|
51
|
+
│
|
|
52
|
+
▼
|
|
53
|
+
PortfolioBook (typed input IR, schema_version = 1)
|
|
54
|
+
│
|
|
55
|
+
▼
|
|
56
|
+
evaluate(book) (pure functional core, zero network IO)
|
|
57
|
+
│
|
|
58
|
+
▼
|
|
59
|
+
PortfolioReport (typed output IR, base-currency-agnostic JSON)
|
|
60
|
+
│
|
|
61
|
+
├──▶ render_workbook(report, out.xlsx)
|
|
62
|
+
└──▶ Your downstream consumers (private bank controls, email, MCP)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Installation
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
pip install portfolio-overview
|
|
69
|
+
# With QuantLib callable/AT1 bond analytics:
|
|
70
|
+
pip install "portfolio-overview[bonds]"
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Quick Start
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
portfolio-overview validate examples/demo-portfolio
|
|
77
|
+
portfolio-overview build examples/demo-portfolio --out ./out
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Or from Python:
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
from pathlib import Path
|
|
84
|
+
from portfolio_overview import evaluate, load_book, render_workbook
|
|
85
|
+
|
|
86
|
+
book = load_book(Path("examples/demo-portfolio"))
|
|
87
|
+
report = evaluate(book)
|
|
88
|
+
print(f"NAV ({report.base_currency}): {report.nav:,.2f}")
|
|
89
|
+
render_workbook(report, Path("out/portfolio-overview.xlsx"))
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## License
|
|
93
|
+
|
|
94
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# portfolio-overview
|
|
2
|
+
|
|
3
|
+
Data-contract, base-currency-agnostic multi-custodian portfolio valuation, performance, risk, bond analytics, and Excel workbook engine.
|
|
4
|
+
|
|
5
|
+
`portfolio-overview` composes five standalone financial libraries into a deterministic, zero-network functional core:
|
|
6
|
+
|
|
7
|
+
- [`eod-market-data`](https://pypi.org/project/eod-market-data/) — canonical EOD price/FX time-series store and calendar guards
|
|
8
|
+
- [`ibkr-flex-accounting`](https://pypi.org/project/ibkr-flex-accounting/) — optional Interactive Brokers Flex XML accounting snapshots
|
|
9
|
+
- [`fhs-market-risk`](https://pypi.org/project/fhs-market-risk/) — EWMA Filtered Historical Simulation VaR/ES, walk-forward backtesting, and FX sensitivity
|
|
10
|
+
- [`portfolio-twr`](https://pypi.org/project/portfolio-twr/) — linked daily TWR, geometric contribution attribution, drawdown/Sharpe/Sortino, and Modified Dietz
|
|
11
|
+
- [`callable-bond-analytics`](https://pypi.org/project/callable-bond-analytics/) (optional `[bonds]` extra) — QuantLib callable/perpetual bond YTC, YTP/YTW, Modified Duration, and DV01
|
|
12
|
+
|
|
13
|
+
## Architecture
|
|
14
|
+
|
|
15
|
+
No plugin registries or global state: every boundary is an immutable, versioned data contract.
|
|
16
|
+
|
|
17
|
+
```text
|
|
18
|
+
YAML / CSV / IBKR Flex XML (or your private bank ETL)
|
|
19
|
+
│
|
|
20
|
+
▼
|
|
21
|
+
PortfolioBook (typed input IR, schema_version = 1)
|
|
22
|
+
│
|
|
23
|
+
▼
|
|
24
|
+
evaluate(book) (pure functional core, zero network IO)
|
|
25
|
+
│
|
|
26
|
+
▼
|
|
27
|
+
PortfolioReport (typed output IR, base-currency-agnostic JSON)
|
|
28
|
+
│
|
|
29
|
+
├──▶ render_workbook(report, out.xlsx)
|
|
30
|
+
└──▶ Your downstream consumers (private bank controls, email, MCP)
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Installation
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install portfolio-overview
|
|
37
|
+
# With QuantLib callable/AT1 bond analytics:
|
|
38
|
+
pip install "portfolio-overview[bonds]"
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Quick Start
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
portfolio-overview validate examples/demo-portfolio
|
|
45
|
+
portfolio-overview build examples/demo-portfolio --out ./out
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Or from Python:
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
from pathlib import Path
|
|
52
|
+
from portfolio_overview import evaluate, load_book, render_workbook
|
|
53
|
+
|
|
54
|
+
book = load_book(Path("examples/demo-portfolio"))
|
|
55
|
+
report = evaluate(book)
|
|
56
|
+
print(f"NAV ({report.base_currency}): {report.nav:,.2f}")
|
|
57
|
+
render_workbook(report, Path("out/portfolio-overview.xlsx"))
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## License
|
|
61
|
+
|
|
62
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
bonds:
|
|
2
|
+
- isin: SYNTH_AT1_01
|
|
3
|
+
name: Synthetic Euro Bank 6.5% AT1
|
|
4
|
+
coupon: 0.065
|
|
5
|
+
frequency: 2
|
|
6
|
+
pay_anchors:
|
|
7
|
+
- [5, 15]
|
|
8
|
+
- [11, 15]
|
|
9
|
+
day_count: ACT/ACT
|
|
10
|
+
payment_convention: Following
|
|
11
|
+
payment_calendar: TARGET
|
|
12
|
+
settlement_days: 2
|
|
13
|
+
first_call: "2030-05-15"
|
|
14
|
+
call_price: 100.0
|
|
15
|
+
reset:
|
|
16
|
+
date: "2030-05-15"
|
|
17
|
+
margin: 0.0425
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
cash:
|
|
2
|
+
- account: BrokerAlpha
|
|
3
|
+
name: Broker USD Cash
|
|
4
|
+
ccy: USD
|
|
5
|
+
balance_local: 25000.0
|
|
6
|
+
as_of: "2026-06-05"
|
|
7
|
+
- account: CustodianBeta
|
|
8
|
+
name: Custodian EUR Cash
|
|
9
|
+
ccy: EUR
|
|
10
|
+
balance_local: 15000.0
|
|
11
|
+
as_of: "2026-06-05"
|
|
12
|
+
- account: CashBankGamma
|
|
13
|
+
name: Savings GBP
|
|
14
|
+
ccy: GBP
|
|
15
|
+
balance_local: 10000.0
|
|
16
|
+
as_of: "2026-06-05"
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"date": "2026-06-04",
|
|
4
|
+
"pnl": 1200.0,
|
|
5
|
+
"basis": 250000.0,
|
|
6
|
+
"isin": {"SYNTH_EQ_US01": 800.0, "SYNTH_EQ_EU01": 400.0},
|
|
7
|
+
"groups": {"Listed equities": {"pnl": 1200.0, "basis": 250000.0}},
|
|
8
|
+
"estimated": false
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"date": "2026-06-05",
|
|
12
|
+
"pnl": 2500.0,
|
|
13
|
+
"basis": 251200.0,
|
|
14
|
+
"isin": {"SYNTH_EQ_US01": 2000.0, "SYNTH_EQ_EU01": 500.0},
|
|
15
|
+
"groups": {"Listed equities": {"pnl": 2500.0, "basis": 251200.0}},
|
|
16
|
+
"estimated": false
|
|
17
|
+
}
|
|
18
|
+
]
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
lots:
|
|
2
|
+
- account: BrokerAlpha
|
|
3
|
+
name: Synthetic Global Tech ETF
|
|
4
|
+
isin: SYNTH_EQ_US01
|
|
5
|
+
ticker: SGT.US
|
|
6
|
+
ccy: USD
|
|
7
|
+
asset_class: Equity ETF
|
|
8
|
+
qty: 500
|
|
9
|
+
avg_cost_local: 180.0
|
|
10
|
+
country: United States
|
|
11
|
+
sector: Technology
|
|
12
|
+
issuer: Synthetic ETF Issuer
|
|
13
|
+
- account: CustodianBeta
|
|
14
|
+
name: Synthetic Euro Bank Equity
|
|
15
|
+
isin: SYNTH_EQ_EU01
|
|
16
|
+
ticker: SEB.EU
|
|
17
|
+
ccy: EUR
|
|
18
|
+
asset_class: Equity
|
|
19
|
+
qty: 2000
|
|
20
|
+
avg_cost_local: 22.0
|
|
21
|
+
country: Germany
|
|
22
|
+
sector: Financials
|
|
23
|
+
issuer: Synthetic Euro Bank
|
|
24
|
+
- account: CustodianBeta
|
|
25
|
+
name: Synthetic Euro Bank 6.5% AT1
|
|
26
|
+
isin: SYNTH_AT1_01
|
|
27
|
+
ticker: SAT1.EU
|
|
28
|
+
ccy: EUR
|
|
29
|
+
asset_class: Bond
|
|
30
|
+
is_bond: true
|
|
31
|
+
qty: 100000
|
|
32
|
+
avg_cost_local: 97.5
|
|
33
|
+
country: Germany
|
|
34
|
+
sector: Financials
|
|
35
|
+
issuer: Synthetic Euro Bank
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Date,ISIN,Ticker,Bloomberg,Asset class,Currency,Close local,Source
|
|
2
|
+
2026-06-04,SYNTH_EQ_US01,SGT.US,SGT US,Equity ETF,USD,200.0,synthetic
|
|
3
|
+
2026-06-05,SYNTH_EQ_US01,SGT.US,SGT US,Equity ETF,USD,204.0,synthetic
|
|
4
|
+
2026-06-04,SYNTH_EQ_EU01,SEB.EU,SEB GY,Equity,EUR,25.0,synthetic
|
|
5
|
+
2026-06-05,SYNTH_EQ_EU01,SEB.EU,SEB GY,Equity,EUR,26.0,synthetic
|
|
6
|
+
2026-06-04,SYNTH_AT1_01,SAT1.EU,SAT1 GY,Bond,EUR,99.0,synthetic
|
|
7
|
+
2026-06-05,SYNTH_AT1_01,SAT1.EU,SAT1 GY,Bond,EUR,99.5,synthetic
|
|
8
|
+
2026-06-04,FX:EUR/USD,EURUSD=X,EURUSD,FX,USD,1.10,synthetic
|
|
9
|
+
2026-06-05,FX:EUR/USD,EURUSD=X,EURUSD,FX,USD,1.10,synthetic
|
|
10
|
+
2026-06-04,FX:GBP/USD,GBPUSD=X,GBPUSD,FX,USD,1.25,synthetic
|
|
11
|
+
2026-06-05,FX:GBP/USD,GBPUSD=X,GBPUSD,FX,USD,1.25,synthetic
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
base_currency: USD
|
|
2
|
+
valuation_date: "2026-06-05"
|
|
3
|
+
anchor_date: "2025-12-31"
|
|
4
|
+
display_timezone: UTC
|
|
5
|
+
fx_shock: 0.10
|
|
6
|
+
fx_materiality: 0.01
|
|
7
|
+
risk_free_rate: 0.03
|
|
8
|
+
themes:
|
|
9
|
+
SYNTH_EQ_US01: Global Tech
|
|
10
|
+
SYNTH_EQ_EU01: European Financials
|
|
11
|
+
SYNTH_AT1_01: Bank Capital
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "portfolio-overview"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Data-contract, base-currency-agnostic multi-custodian portfolio valuation, performance, risk, bond analytics, and Excel workbook engine"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
authors = [{ name = "benjamin-di" }]
|
|
9
|
+
requires-python = ">=3.11"
|
|
10
|
+
keywords = ["portfolio", "accounting", "valuation", "twr", "var", "expected-shortfall", "ibkr", "finance", "openpyxl"]
|
|
11
|
+
classifiers = [
|
|
12
|
+
"Development Status :: 4 - Beta",
|
|
13
|
+
"Intended Audience :: Developers",
|
|
14
|
+
"Intended Audience :: Financial and Insurance Industry",
|
|
15
|
+
"License :: OSI Approved :: MIT License",
|
|
16
|
+
"Operating System :: OS Independent",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Programming Language :: Python :: 3.11",
|
|
19
|
+
"Programming Language :: Python :: 3.12",
|
|
20
|
+
"Programming Language :: Python :: 3.13",
|
|
21
|
+
"Topic :: Office/Business :: Financial :: Investment",
|
|
22
|
+
]
|
|
23
|
+
dependencies = [
|
|
24
|
+
"eod-market-data>=0.1.0,<1",
|
|
25
|
+
"fhs-market-risk>=0.1.0,<1",
|
|
26
|
+
"ibkr-flex-accounting>=0.1.0,<1",
|
|
27
|
+
"openpyxl>=3.1,<4",
|
|
28
|
+
"pandas>=2.2,<3.1",
|
|
29
|
+
"portfolio-twr>=0.1.0,<1",
|
|
30
|
+
"PyYAML>=6,<7",
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
[project.optional-dependencies]
|
|
34
|
+
bonds = [
|
|
35
|
+
"callable-bond-analytics>=0.1.0,<1",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
[project.scripts]
|
|
39
|
+
portfolio-overview = "portfolio_overview.cli:main"
|
|
40
|
+
|
|
41
|
+
[project.urls]
|
|
42
|
+
Homepage = "https://github.com/benjamin-di/portfolio-overview"
|
|
43
|
+
Issues = "https://github.com/benjamin-di/portfolio-overview/issues"
|
|
44
|
+
|
|
45
|
+
[dependency-groups]
|
|
46
|
+
dev = [
|
|
47
|
+
"callable-bond-analytics>=0.1.0,<1",
|
|
48
|
+
"pytest>=8",
|
|
49
|
+
"ruff>=0.14",
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
[build-system]
|
|
53
|
+
requires = ["hatchling"]
|
|
54
|
+
build-backend = "hatchling.build"
|
|
55
|
+
|
|
56
|
+
[tool.hatch.build.targets.wheel]
|
|
57
|
+
packages = ["src/portfolio_overview"]
|
|
58
|
+
|
|
59
|
+
[tool.pytest.ini_options]
|
|
60
|
+
testpaths = ["tests"]
|
|
61
|
+
addopts = "-q"
|
|
62
|
+
|
|
63
|
+
[tool.ruff]
|
|
64
|
+
line-length = 120
|
|
65
|
+
target-version = "py311"
|
|
66
|
+
|
|
67
|
+
[tool.ruff.lint]
|
|
68
|
+
select = ["E", "F", "I", "B", "UP", "S", "RUF"]
|
|
69
|
+
ignore = ["S101", "RUF001", "RUF002", "RUF003"]
|
|
70
|
+
|
|
71
|
+
[tool.ruff.lint.per-file-ignores]
|
|
72
|
+
"tests/*" = ["S", "E501", "B905"]
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"""Data-contract, base-currency-agnostic multi-custodian portfolio overview engine."""
|
|
2
|
+
|
|
3
|
+
from .engine import evaluate
|
|
4
|
+
from .loaders import load_book
|
|
5
|
+
from .schema import (
|
|
6
|
+
SCHEMA_VERSION,
|
|
7
|
+
AccountSummary,
|
|
8
|
+
CashBalance,
|
|
9
|
+
CashFlow,
|
|
10
|
+
CreditFacility,
|
|
11
|
+
IncomeEvent,
|
|
12
|
+
Lot,
|
|
13
|
+
PortfolioBook,
|
|
14
|
+
PortfolioConfig,
|
|
15
|
+
PortfolioReport,
|
|
16
|
+
PositionValuation,
|
|
17
|
+
)
|
|
18
|
+
from .workbook import render_workbook
|
|
19
|
+
|
|
20
|
+
__version__ = "0.1.0"
|
|
21
|
+
|
|
22
|
+
__all__ = [
|
|
23
|
+
"SCHEMA_VERSION",
|
|
24
|
+
"AccountSummary",
|
|
25
|
+
"CashBalance",
|
|
26
|
+
"CashFlow",
|
|
27
|
+
"CreditFacility",
|
|
28
|
+
"IncomeEvent",
|
|
29
|
+
"Lot",
|
|
30
|
+
"PortfolioBook",
|
|
31
|
+
"PortfolioConfig",
|
|
32
|
+
"PortfolioReport",
|
|
33
|
+
"PositionValuation",
|
|
34
|
+
"__version__",
|
|
35
|
+
"evaluate",
|
|
36
|
+
"load_book",
|
|
37
|
+
"render_workbook",
|
|
38
|
+
]
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"""CLI for `portfolio-overview` (`validate` and `build`)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import json
|
|
7
|
+
import sys
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
from .engine import evaluate
|
|
11
|
+
from .loaders import load_book
|
|
12
|
+
from .workbook import render_workbook
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def main(argv: list[str] | None = None) -> int:
|
|
16
|
+
parser = argparse.ArgumentParser(prog="portfolio-overview", description="Multi-custodian portfolio overview CLI")
|
|
17
|
+
sub = parser.add_subparsers(dest="command", required=True)
|
|
18
|
+
|
|
19
|
+
p_val = sub.add_parser("validate", help="Load and validate a portfolio directory")
|
|
20
|
+
p_val.add_argument("directory", type=Path, help="Path to portfolio data directory")
|
|
21
|
+
|
|
22
|
+
p_build = sub.add_parser("build", help="Evaluate portfolio and write JSON report + Excel workbook")
|
|
23
|
+
p_build.add_argument("directory", type=Path, help="Path to portfolio data directory")
|
|
24
|
+
p_build.add_argument("--out", type=Path, default=Path("out"), help="Output directory (default: ./out)")
|
|
25
|
+
|
|
26
|
+
args = parser.parse_args(argv)
|
|
27
|
+
book = load_book(args.directory)
|
|
28
|
+
report = evaluate(book)
|
|
29
|
+
|
|
30
|
+
if args.command == "validate":
|
|
31
|
+
print(
|
|
32
|
+
f"OK: {report.valuation_date} | NAV {report.base_currency} {report.nav:,.2f} "
|
|
33
|
+
f"| {len(report.accounts)} accounts | {len(report.positions)} positions "
|
|
34
|
+
f"| {len(report.findings)} findings"
|
|
35
|
+
)
|
|
36
|
+
return 0
|
|
37
|
+
|
|
38
|
+
out_dir: Path = args.out
|
|
39
|
+
out_dir.mkdir(parents=True, exist_ok=True)
|
|
40
|
+
json_path = out_dir / "portfolio-report.json"
|
|
41
|
+
xlsx_path = out_dir / f"portfolio-overview-{report.valuation_date}.xlsx"
|
|
42
|
+
json_path.write_text(json.dumps(report.to_dict(), indent=2, default=str), encoding="utf-8")
|
|
43
|
+
render_workbook(report, xlsx_path)
|
|
44
|
+
print(f"Wrote {json_path}")
|
|
45
|
+
print(f"Wrote {xlsx_path}")
|
|
46
|
+
return 0
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
if __name__ == "__main__":
|
|
50
|
+
sys.exit(main())
|