dysonance / Indicators.jl

Financial market technical analysis & indicators in Julia
Other
216 stars 62 forks source link

hurst and runmad slow #34

Open Roh-codeur opened 3 years ago

Roh-codeur commented 3 years ago

hi

thanks for putting together this package. I run a series of technical analysis on stocks. If I run without hurst and runmap, it comes out to 4 seconds for 50 stocks, however, if I add these both, the time increases to 35 seconds!

I am using Julia 1.5 and the latest version of indicators

I am afraid I cant seem to print the profile trace. the issue seems to be:

function estimate_hurst(x::Array{T}; intercept::Bool=false)::T where {T<:Real} RS = genrsdata(x) rsdata = [rsdata; genrsdata(a)] rsdata = [rsdata; genrsdata(b)]

Also, I noticed that if I replace the Close with the below, it now takes close to 9 seconds!

Close = 100.0 .+ cumsum(randn(n)) Any thoughts please?

thanks Roh

dysonance commented 3 years ago

Hey @Roh-codeur, thanks for bringing this forward. I definitely want to make sure the code is efficient as possible, so I appreciate you pointing out a potential improvement that could be made.

Could you provide some more context to help me figure out how to solve what could be causing the lag?

I tried testing both hurst and runmad on a 50-asset universe with historical prices starting in 2001 and wasn't able to replicate the kind of performance drag you seem to be experiencing, so some more information like the above might help me figure it out.

Roh-codeur commented 1 year ago

@dysonance : Sorry, forgot to reply earlier. on my machine the below code takes 0.34 seconds. the issue is not with length of x, it seems to be with the value of "n"

using Indicators N = 365*8 x = cumsum(randn(N)) @time hurstInd = hurst(x; n = 200)