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

Dispatch on now #56

Open
milktrader opened this issue Oct 27, 2016 · 3 comments
Open

Dispatch on now #56

milktrader opened this issue Oct 27, 2016 · 3 comments
Assignees

Comments

@milktrader
Copy link
Member

milktrader commented Oct 27, 2016

Add a TimeType argument to all the indicators that produces a scalar (or boolean) result.

For example, the sma method would look like this:

function sma{T,N}(ta::TimeArray{T,N}, n::Int, now::TimeType)
    t = find(ta.timestamp .== now)[1]
    mean(ta.values[t-n:t])
end

And it would function like this:

julia> dt = Date(2001,12,31)
2001-12-31

julia> sma(cl, 10, dt)
21.323636363636368
@milktrader milktrader self-assigned this Oct 27, 2016
@iblislin
Copy link
Member

I guess we can use macro to implement this feature?

@alexandrebrilhante
Copy link
Contributor

Something like a @now macro could work. Are you working on this @milktrader?

@iblislin
Copy link
Member

iblislin commented Jul 29, 2018

Now, I have a more clear idea about implementing this and #52:
Put an option struct at the head of all the function body.
e.g.

struct Option
 ...
end

function ta_args(opt)  # return the args need to be passed to TimeArray functions, e.g. `padding`
...
end

function myma(...; ..., kw...)
  opt = Option(kw...)
  lag(...; ta_args(opt)...)
  ...
end

and the functionta_args can be implemented as a macro.

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

No branches or pull requests

3 participants