management¶
Post-construction portfolio management: rebalancing trade lists, drift/limit monitoring, and before/after or portfolio-vs-portfolio comparisons. Portfolio itself assumes frictionless, always-rebalanced-to-target trading - this is where the turn-that-assumption-off tools live.
rebalancing ¶
Post-construction portfolio management: rebalancing trade lists, drift/limit monitoring, and before/after or portfolio-vs-portfolio comparisons.
PortPy's Portfolio itself assumes frictionless, always-rebalanced-to-target trading (see Portfolio.returns' docstring) - this module is where the turn-that-assumption-off tools live, for anyone who wants to model the actual trade list, drift, and cost of getting from one set of weights to another.
rebalance ¶
rebalance(
target_weights: Series | ModelResult,
current_weights: Series,
method: str = "threshold",
threshold: float = 0.05,
cost_bps: float = 0.0,
) -> ModelResult
Build a trade list from current_weights to target_weights.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target_weights
|
Series | ModelResult
|
Desired allocation - a plain weight |
required |
current_weights
|
Series
|
The book's actual current weights. |
required |
method
|
str
|
"full"/"calendar" trade all the way to |
'threshold'
|
threshold
|
float
|
Drift threshold for |
0.05
|
cost_bps
|
float
|
Flat round-trip cost per unit of turnover, in basis points -
see |
0.0
|
Returns:
| Type | Description |
|---|---|
ModelResult
|
A |
ModelResult
|
(post-trade) allocation, renormalized to sum to 1. |
ModelResult
|
|
ModelResult
|
(one-way, matching |
ModelResult
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/portpy/models/management/rebalancing.py
monitor ¶
Check current weights against a set of drift/exposure/concentration limits.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
current_weights
|
Series
|
The book's current weights. |
required |
limits
|
dict[str, Any]
|
Any of:
- |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
|
dict[str, Any]
|
each breach is |
dict[str, Any]
|
being |
Source code in src/portpy/models/management/rebalancing.py
compare ¶
Compare two portfolios, model results, or raw weight vectors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
Any
|
A |
required |
b
|
Any
|
Same options - the "after"/candidate side. |
required |
Returns:
| Type | Description |
|---|---|
ModelResult
|
A |
ModelResult
|
|
ModelResult
|
|
ModelResult
|
|
ModelResult
|
concentration), and |
ModelResult
|
mode, also |
ModelResult
|
|
ModelResult
|
metric both sides have). |