You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/08_Moments/01_Base_Moments.jl
+19-9Lines changed: 19 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -54,7 +54,7 @@ In order to implement a new covariance estimator which will work seamlessly with
54
54
55
55
## Factory
56
56
57
-
- `factory(ce::AbstractCovarianceEstimator, w::StatsBase.AbstractWeights) -> AbstractCovarianceEstimator`: Factory method for creating instances of the estimator with new observation weights.
57
+
- `PortfolioOptimisers.factory(ce::AbstractCovarianceEstimator, w::StatsBase.AbstractWeights) -> AbstractCovarianceEstimator`: Factory method for creating instances of the estimator with new observation weights.
58
58
59
59
### Arguments
60
60
@@ -86,10 +86,9 @@ julia> function MyCovarianceEstimator(;
86
86
end
87
87
MyCovarianceEstimator
88
88
89
-
julia> function factory(::MyCovarianceEstimator, w::StatsBase.AbstractWeights)
89
+
julia> function PortfolioOptimisers.factory(::MyCovarianceEstimator, w::StatsBase.AbstractWeights)
90
90
return MyCovarianceEstimator(; w = w)
91
91
end
92
-
factory (generic function with 1 method)
93
92
94
93
julia> function Statistics.cov(est::MyCovarianceEstimator, X::PortfolioOptimisers.MatNum;
w ┴ StatsBase.Weights{Int64, Int64, Vector{Int64}}: [1, 2, 3]
135
138
```
136
139
137
140
# Related
@@ -181,7 +184,7 @@ In order to implement a new covariance estimator which will work seamlessly with
181
184
182
185
## Factory
183
186
184
-
- `factory(ve::AbstractVarianceEstimator, w::StatsBase.AbstractWeights) -> AbstractVarianceEstimator`: Factory method for creating instances of the estimator with new observation weights.
187
+
- `PortfolioOptimisers.factory(ve::AbstractVarianceEstimator, w::StatsBase.AbstractWeights) -> AbstractVarianceEstimator`: Factory method for creating instances of the estimator with new observation weights.
185
188
186
189
### Arguments
187
190
@@ -213,10 +216,9 @@ julia> function MyVarianceEstimator(;
213
216
end
214
217
MyVarianceEstimator
215
218
216
-
julia> function factory(::MyVarianceEstimator, w::StatsBase.AbstractWeights)
219
+
julia> function PortfolioOptimisers.factory(::MyVarianceEstimator, w::StatsBase.AbstractWeights)
217
220
return MyVarianceEstimator(; w = w)
218
221
end
219
-
factory (generic function with 1 method)
220
222
221
223
julia> function Statistics.var(est::MyVarianceEstimator, X::PortfolioOptimisers.MatNum;
w ┴ StatsBase.Weights{Int64, Int64, Vector{Int64}}: [1, 2, 3]
268
274
```
269
275
270
276
# Related
@@ -300,7 +306,7 @@ In order to implement a new expected returns estimator which will work seamlessl
300
306
301
307
## Factory
302
308
303
-
- `factory(me::AbstractExpectedReturnsEstimator, w::StatsBase.AbstractWeights) -> AbstractExpectedReturnsEstimator`: Factory method for creating instances of the estimator with new observation weights.
309
+
- `PortfolioOptimisers.factory(me::AbstractExpectedReturnsEstimator, w::StatsBase.AbstractWeights) -> AbstractExpectedReturnsEstimator`: Factory method for creating instances of the estimator with new observation weights.
304
310
305
311
### Arguments
306
312
@@ -331,10 +337,10 @@ julia> function MyExpectedReturnsEstimator(;
331
337
end
332
338
MyExpectedReturnsEstimator
333
339
334
-
julia> function factory(::MyExpectedReturnsEstimator, w::StatsBase.AbstractWeights)
340
+
julia> function PortfolioOptimisers.factory(::MyExpectedReturnsEstimator,
341
+
w::StatsBase.AbstractWeights)
335
342
return MyExpectedReturnsEstimator(; w = w)
336
343
end
337
-
factory (generic function with 1 method)
338
344
339
345
julia> function Statistics.mean(est::MyExpectedReturnsEstimator, X::PortfolioOptimisers.MatNum;
Copy file name to clipboardExpand all lines: src/08_Moments/05_GerberCovariance.jl
+209-4Lines changed: 209 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,10 @@ Abstract supertype for all Gerber covariance estimators in `PortfolioOptimisers.
5
5
6
6
All concrete and/or abstract types implementing Gerber covariance estimation algorithms should be subtypes of `BaseGerberCovariance`.
7
7
8
+
# Interfaces
9
+
10
+
If moving away from the already established Gerber covariance algorithms, you must follow [`AbstractCovarianceEstimator`](@ref) to implement the entire chain.
11
+
8
12
# Related
9
13
10
14
- [`GerberCovariance`](@ref)
@@ -24,6 +28,10 @@ All concrete and/or abstract types implementing specific Gerber covariance algor
24
28
25
29
These types are used to specify the algorithm when constructing a [`GerberCovariance`](@ref) estimator.
26
30
31
+
# Interfaces
32
+
33
+
If moving away from the already established Gerber covariance algorithms, you must follow [`AbstractCovarianceEstimator`](@ref) to implement the entire chain. Else you can follow the instructions and examples in [`UnstandardisedGerberCovarianceAlgorithm`](@ref) and [`StandardisedGerberCovarianceAlgorithm`](@ref).
34
+
27
35
# Related
28
36
29
37
- [`BaseGerberCovariance`](@ref)
@@ -43,6 +51,104 @@ Abstract supertype for all unstandardised Gerber covariance algorithm types.
43
51
44
52
Concrete types implementing unstandardised Gerber covariance algorithms should subtype `UnstandardisedGerberCovarianceAlgorithm`.
45
53
54
+
# Interfaces
55
+
56
+
In order to implement a new Gerber algorithm which will work seamlessly with the library, subtype `UnstandardisedGerberCovarianceAlgorithm` with all necessary parameters as part of the struct, and implement the following methods:
If the algorithm uses observation weights, the `factory` method will update the algorithm with the new weights.
75
+
76
+
- `PortfolioOptimisers.factory(alg::UnstandardisedGerberCovarianceAlgorithm, w::StatsBase.AbstractWeights) -> UnstandardisedGerberCovarianceAlgorithm`: Updates the algorithm with the new weights.
77
+
78
+
### Arguments
79
+
80
+
- $(arg_dict[:gerbalg])
81
+
- $(arg_dict[:ow])
82
+
83
+
### Returns
84
+
85
+
- $(ret_dict[:algw])
86
+
87
+
## Examples
88
+
89
+
We can create a dummy unstandardised Gerber covariance algorithm as follows:
│ │ w ┼ Weights{Int64, Int64, Vector{Int64}}: [1, 2, 3]
141
+
│ │ idx ┴ nothing
142
+
│ w ┼ Weights{Int64, Int64, Vector{Int64}}: [1, 2, 3]
143
+
│ corrected ┴ Bool: true
144
+
pdm ┼ Posdef
145
+
│ alg ┼ UnionAll: NearestCorrelationMatrix.Newton
146
+
│ kwargs ┴ @NamedTuple{}: NamedTuple()
147
+
t ┼ Float64: 0.5
148
+
alg ┼ MyUnstandardisedGerberCovarianceAlg
149
+
│ w ┴ Weights{Int64, Int64, Vector{Int64}}: [1, 2, 3]
150
+
```
151
+
46
152
# Related
47
153
48
154
- [`GerberCovarianceAlgorithm`](@ref)
@@ -63,6 +169,103 @@ Abstract supertype for all standardised Gerber covariance algorithm types. These
63
169
64
170
Concrete types implementing standardised Gerber covariance algorithms should subtype `StandardisedGerberCovarianceAlgorithm`.
65
171
172
+
# Interfaces
173
+
174
+
In order to implement a new Gerber algorithm which will work seamlessly with the library, subtype `StandardisedGerberCovarianceAlgorithm` with all necessary parameters as part of the struct, and implement the following methods:
If the algorithm uses observation weights, the `factory` method will update the algorithm with the new weights.
193
+
194
+
- `PortfolioOptimisers.factory(alg::StandardisedGerberCovarianceAlgorithm, w::StatsBase.AbstractWeights) -> StandardisedGerberCovarianceAlgorithm`: Updates the algorithm with the new weights.
195
+
196
+
### Arguments
197
+
198
+
- $(arg_dict[:gerbalg])
199
+
- $(arg_dict[:ow])
200
+
201
+
### Returns
202
+
203
+
- $(ret_dict[:algw])
204
+
205
+
## Examples
206
+
207
+
We can create a dummy standardised Gerber covariance algorithm as follows:
0 commit comments