Skip to content

Commit

Permalink
fix imports
Browse files Browse the repository at this point in the history
  • Loading branch information
sheriff4000 committed Jun 9, 2024
1 parent 89a3e6a commit 53c5ac2
Show file tree
Hide file tree
Showing 5 changed files with 289 additions and 302 deletions.
4 changes: 3 additions & 1 deletion src/Backtest/Forecast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ This struct represents a general forecaster that can be combined with others
Can apply forecast to data with the following signature:
forecastFunction(data::Vector{Real}, params::Real...; F::Int=1) -> Vector{Real}
"""
struct Forecaster
abstract type Forecaster end

struct BaseForecaster <: Forecaster
forecastFunction::Function
params::Vector{Any}
end
Expand Down
18 changes: 1 addition & 17 deletions src/Backtest/forecast/ARIMA.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ using Random
using Distributions
using StatsBase

using ..Combine
using ..Forecast: Forecaster

"""
This function applies differencing to a time series
Expand Down Expand Up @@ -115,22 +115,6 @@ function arima(series, p::Int, d::Int, q::Int, reparameterise_window::Int = 0; F
return restored_series[(end-F+1):end]
end

"""
This function returns a forecaster object that can be used with the Combine module
Arguments:
- p::int: The number of lags to consider
- d::int: The order of differencing
- q::int: Moving average order
Returns:
- Combined::Combine.Forecaster: The forecaster
"""

function ArimaForecaster(p::Int, d::Int, q::Int; reparameterise_window::Int = 0)
return Combine.Forecaster(arima, [p; d; q; reparameterise_window])
end

struct ArimaForecaster <: Forecaster
p::Int
d::Int
Expand Down
5 changes: 3 additions & 2 deletions src/Backtest/forecast/Combine.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
module Combine
using ..Forecast: Forecaster

"""
This struct represents a combined forecaster that is a linear combination of other forecasters
"""
struct CombinedForecaster <: Forecaster
forecasters::Vector{<:Forecaster}
weights::Vector{<:Real}
forecasters::Vector{T} where T <: Forecaster
weights::Vector{U} where U <: Real
CombinedForecaster(forecasters::Vector{Forecaster}, weights::Vector{<:Real}) = length(forecasters) == length(weights) ? new(forecasters, weights) : throw(ArgumentError("Length of forecasters and weights must be equal"))
end

Expand Down
2 changes: 1 addition & 1 deletion src/Backtest/forecast/Linear.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Linear

using DataFrames
using RollingFunctions
using ..Combine
using ..Forecast: Forecaster

"""
This function returns the parameters of a linear regression model that predicts
Expand Down
Loading

0 comments on commit 53c5ac2

Please sign in to comment.