Skip to content

Commit 6ee4bee

Browse files
authored
Fix API bug in prices_to_returns when using a benchmark. Add more docs. (#48)
* Update pre-commit. * Fix bug in prices_to_returns when using a benchmark. * Docs up to `03_Preprocessing`.
1 parent 21a9639 commit 6ee4bee

23 files changed

+962
-867
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ repos:
2626
- id: check-merge-conflict
2727
args: [--assume-in-merge]
2828
- repo: https://github.com/igorshubovych/markdownlint-cli
29-
rev: v0.45.0
29+
rev: v0.46.0
3030
hooks:
3131
- id: markdownlint-fix
3232
- repo: https://github.com/citation-file-format/cffconvert
@@ -42,7 +42,7 @@ repos:
4242
hooks:
4343
- id: yamllint
4444
- repo: https://github.com/ericphanson/ExplicitImports.jl
45-
rev: v1.13.2
45+
rev: v1.14.0
4646
hooks:
4747
- id: explicit-imports
4848
name: ExplicitImports checks

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "PortfolioOptimisers"
22
uuid = "e0036ec9-05e5-505d-a6a9-07af41c94861"
3-
version = "0.11.0"
3+
version = "0.11.1"
44
authors = ["Daniel Celis Garza <daniel.celis.garza@gmail.com>"]
55

66
[deps]

docs/make.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ using PortfolioOptimisers
22
using Documenter, DocumenterTools, DocumenterCitations, Literate, StatsPlots, GraphRecipes,
33
Handcalcs, StatsBase, DocumenterVitepress
44

5-
exported = names(PortfolioOptimisers)
5+
exported_symbols = names(PortfolioOptimisers)
66
all_symbols = names(PortfolioOptimisers; all = true)
77
filter!(x -> !contains(string(x), r"#|^eval$|^include$"), all_symbols)
8-
for sym in setdiff!(all_symbols, exported)
8+
private_symbols = setdiff(all_symbols, exported_symbols)
9+
for sym in private_symbols
910
eval(quote
1011
import PortfolioOptimisers: $(sym)
1112
end)

docs/src/References.bib

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
@article{brinson_attribution,
2+
title = {Measuring non-US. equity portfolio performance},
3+
author = {Brinson, Gary P and Fachler, Nimrod},
4+
journal = {The Journal of Portfolio Management},
5+
volume = {11},
6+
number = {3},
7+
pages = {73--76},
8+
year = {1985},
9+
publisher = {Portfolio Management Research}
10+
}
11+
112
@article{DBHTs,
213
title = {Hierarchical information clustering by means of topologically embedded graphs},
314
author = {Song, Won-Min and Di Matteo, Tiziana and Aste, Tomaso},

docs/src/api/01_Base.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ IsEmptyError
3434
IsNonFiniteError
3535
```
3636

37+
## Utility types
38+
39+
Custom types are the bread and butter of `PorfolioOptimisers.jl`, the following types non-specific and used throughout the library.
40+
41+
```@docs
42+
VecScalar
43+
```
44+
3745
## Base type aliases
3846

3947
`PortfolioOptimisers.jl` heavily relies on `Julia`'s dispatch and type system to ensure data validity. Many custom types and functions/methods can accept different data types. These can be represented as type unions, many of which are used throughout the library. The following type aliases centralise these union definitions, as well as improving correctness and maintainability.
@@ -66,4 +74,6 @@ VecDate
6674
Dict_Vec
6775
Sym_Str
6876
Str_Vec
77+
Num_VecNum_VecScalar
78+
Num_ArrNum_VecScalar
6979
```

docs/src/api/02_Tools.md

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,49 @@
11
# Tools
22

3-
## Public
3+
`PorfolioOptimisers.jl` is a complex codebase which uses a variety of general purpose tools including functions, constants and types.
4+
5+
## Utility functions
6+
7+
We strive to be as type-stable, inferrable, and immutable as possible in order to improve robustness, performance, and correctness. These functions help us achieve these goals.
48

59
```@docs
6-
VecScalar
7-
brinson_attribution
810
traverse_concrete_subtypes
911
concrete_typed_array
1012
factory(::Nothing, args...; kwargs...)
1113
```
1214

13-
## Private
15+
## Assertions
16+
17+
In order to increase correctness, robustness, and safety, we make extensive use of [defensive programming](https://en.wikipedia.org/wiki/Defensive_programming). The following functions perform some of these validations and are usually called at variable instantiation.
1418

1519
```@docs
16-
AbstractReturnsResult
17-
Num_VecNum_VecScalar
18-
Num_ArrNum_VecScalar
1920
assert_nonempty_nonneg_finite_val
21+
assert_nonempty_gt0_finite_val
2022
assert_nonempty_finite_val
21-
assert_nonempty_geq0_finite_val
2223
assert_matrix_issquare
24+
```
25+
26+
## Mathematical functions
27+
28+
`PortfolioOptimisers.jl` makes use of various mathematical operators, some of which are generic to support the variety of inputs supported by the library.
29+
30+
```@docs
2331
:⊗
2432
:⊙
2533
:⊘
2634
:⊕
2735
:⊖
2836
dot_scalar
37+
```
38+
39+
## View functions
40+
41+
[`NestedClustered`](@ref) optimisations need to index the asset universe in order to produce the inner optimisations. These indexing operations are implemented as views, indexing, and custom index generators.
42+
43+
```@docs
2944
nothing_scalar_array_view
3045
nothing_scalar_array_view_odd_order
3146
nothing_scalar_array_getindex
3247
nothing_scalar_array_getindex_odd_order
33-
nothing_asset_sets_view
3448
fourth_moment_index_generator
3549
```

docs/src/api/03_Preprocessing.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
# Preprocessing
22

3-
## Public
3+
## Prices to returns
4+
5+
Other than [`FiniteAllocationOptimisationEstimator`](@ref), all optimisations work based off returns data rather than price data. These functions and types are involved in computing returns.
46

57
```@docs
8+
AbstractReturnsResult
69
ReturnsResult
7-
drop_incomplete
10+
_check_names_and_returns_matrix
811
prices_to_returns
9-
select_k_extremes
1012
```
1113

12-
## Private
14+
## Pre-filtering
15+
16+
Price data is often incomplete or noisy, so it can be worthwhile having some pre-filtering steps to remove data that does not contribute meaningful information and may pollute calculations.
1317

1418
```@docs
15-
_check_names_and_returns_matrix
19+
find_complete_indices
20+
select_k_extremes
1621
```

docs/src/api/08_Moments/12_PortfolioOptimisersCovariance.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
PortfolioOptimisersCovariance
55
cov(ce::PortfolioOptimisersCovariance, X::MatNum; dims = 1, kwargs...)
66
cor(ce::PortfolioOptimisersCovariance, X::MatNum; dims = 1, kwargs...)
7-
drop_correlated
7+
find_correlated_indices
88
```

docs/src/api/13_ConstraintGeneration/2_LinearConstraintGeneration.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ _collect_terms!
2525
_collect_terms
2626
_eval_numeric_functions
2727
asset_sets_matrix_view
28+
nothing_asset_sets_view
2829
```
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Base finite allocation
2+
3+
```@docs
4+
FiniteAllocationOptimisationEstimator
5+
```

0 commit comments

Comments
 (0)