Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No method matching lagfill #133

Open
millerjoey opened this issue Nov 2, 2021 · 1 comment
Open

No method matching lagfill #133

millerjoey opened this issue Nov 2, 2021 · 1 comment

Comments

@millerjoey
Copy link

Hey, seems there's a bug in a call to lagfill:

ERROR: MethodError: no method matching lagfill(::TimeArray{Float64, 2, DateTime, Matrix{Float64}}, ::Int64, ::Matrix{Float64})
Closest candidates are:
  lagfill(::TimeArray, ::Integer, ::AbstractFloat) at /home/joe/.julia/packages/MarketTechnicals/5qm8H/src/utilities.jl:90
Stacktrace:
 [1] dpo(ta::TimeArray{Float64, 2, DateTime, Matrix{Float64}}, n::Int64)
   @ MarketTechnicals ~/.julia/packages/MarketTechnicals/5qm8H/src/momentum.jl:350

It happens when it's used on a TimeArray with second dim > 1 as far as I can tell.

Something like this

function lagfill(ta::TimeArray, r1::Integer, fill::AbstractMatrix{T}) where T<:AbstractFloat
  @assert size(fill, 2) == size(ta, 2)
  _lta = lag(ta, r1, padding = true)
  _lta_values = values(_lta)

  for i in 1:r1
    _lta_values[i, :] = fill
  end

  TimeArray(timestamp(ta), _lta_values, colnames(ta))
end

Should fix it.

@iblislin
Copy link
Member

iblislin commented Nov 5, 2021

ah, could you send a PR for it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants