TimeSeries.moving
— Functionmoving(f, ta::TimeArray{T,1}, w::Integer; padding = false)
Apply user-defined function f
to a 1D TimeArray
with window size w
.
Example
To calculate the simple moving average of a time series:
moving(mean, ta, 10)
moving(f, ta::TimeArray{T,2}, w::Integer; padding = false, dims = 1, colnames = [...])
Example
In case of dims = 2
, the user-defined function f
will get a 2D Array
as input.
moving(ohlc, 10, dims = 2, colnames = [:A, ...]) do
+│ 2001-12-31 │ 21.417 │
As mentioned previously, we lose the first nine observations to the consuming nature of this operation. They are not missing per se, they simply do not exist.
TimeSeries.moving
— Functionmoving(f, ta::TimeArray{T,1}, w::Integer; padding = false)
Apply user-defined function f
to a 1D TimeArray
with window size w
.
Example
To calculate the simple moving average of a time series:
moving(mean, ta, 10)
moving(f, ta::TimeArray{T,2}, w::Integer; padding = false, dims = 1, colnames = [...])
Example
In case of dims = 2
, the user-defined function f
will get a 2D Array
as input.
moving(ohlc, 10, dims = 2, colnames = [:A, ...]) do
# given that `ohlc` is a 500x4 `TimeArray`,
# size(A) is (10, 4)
...
-end
upto
Another operation common in time series analysis is an aggregation function. TimeSeries
supports this with the upto
method. Suppose you want to keep track of the sum of all the values from the beginning to the present timestamp. You would use the upto
method like this:
julia> using TimeSeries
+end