timeseries-julia-python
random julia and python scripts analyzing stock timeseries data
talib.jl
(507B)
1 using TimeSeries
2
3 average(A::AbstractArray) = sum(A) / length(A)
4
5 exponential_average(A::AbstractArray) =
6 let smoothing = 2 / (length(A) + 1)
7 reduce((acc, value) -> value * smoothing + acc * (1-smoothing), A)
8 end
9
10 rate_of_change(A::AbstractArray) = (A[end] - A[1]) / A[1]
11
12 sma(ta::TimeArray, n::Int) = moving(average, ta, n)
13 ema(ta::TimeArray, n::Int) = moving(exponential_average, ta, n)
14 high(ta::TimeArray, n::Int) = moving(maximum, ta, n)
15 roc(ta::TimeArray, n::Int) = moving(rate_of_change, ta, n)