-
Notifications
You must be signed in to change notification settings - Fork 24
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
assumed ordering is wrong #20
Comments
The current code is: for i in 1:length(ta) - (n-1)
vals[i] = mean(ta.values[i:i+(n-1)])
end So, using n=10, the first time it takes In your example, the first calculation would be for |
The current code calculates the average of future data, if it is applied to typical time series and the outcome series is synced with the original by the index. In my example, using n=10, the first time it takes ta.values[1:10], and the result is stored at vals[10]; the second calculation is ta.values[2:11], and the result is stored at vals[11]. This syncs with the original series. |
Okay, I see that you start your iteration at n and not 1, my mistake. |
The current code takes care of aligning the This is not an ideal solution, given that the whole If TimeSeries forces the values element to be a |
I think it is very important to sync these series by the index. This would help tremendously when say one wants to determine whether ta.values[j] is above a corresponding sma, in which case he would only compare ta.values[j] with sma.values[j]. |
TimeSeries currently takes care of this by ensuring that timestamps align. (I did find a display error though while using this example using MarketData
cl .> sma(cl, 10); |
While I work on displaying bool values in TimeSeries, here is a way to view the result above julia> cl[findwhen(cl .> sma(cl,10))]
268x1 TimeArray{Float64,1} 1980-01-16 to 1981-12-10
Close
1980-01-16 | 111.05
1980-01-17 | 110.7
1980-01-18 | 111.07
1980-01-21 | 112.1
⋮
1981-12-04 | 126.26
1981-12-07 | 125.19
1981-12-09 | 125.48
1981-12-10 | 125.71 |
How do we do element-wise operation then? |
The dot in front of the operator. |
To me that is array-wise per element operation, a preferred way of doing things in R because otherwise it would be slow. Shouldn't Julia be more flexible and provide real element-wise operations? |
Vectorizing in R ( ie passing loops to C) is necessary and there isn't any reasonably fast alternative. It turns out though that vectorizing isn't always efficient. This is a good question for Julia-users groups. |
Also, see Devectorize.jl package by @lindahua for an explanation |
stale issue. |
The indexing order seems to assume that the oldest data is at index n and the newest at index 1. But that is not how typical data are arranged. Typically, the oldest data is at index 1 and the newest at index n
In the typical ordering of the data, should the for loop be as follows?
The text was updated successfully, but these errors were encountered: