MarketTechnicals.jl icon indicating copy to clipboard operation
MarketTechnicals.jl copied to clipboard

Indicator methods generalization

Open Arkoniak opened this issue 3 years ago • 2 comments

This one is related in some sense to https://github.com/JuliaQuant/MarketData.jl/issues/71 and https://github.com/JuliaQuant/MarketTechnicals.jl/issues/93. On one hand, we have few data types for time series and it's hard to say which one is better (actually it is possible that all of them are good just in different circumstances). On the other hand, we have few packages with similar functionality and developers' efforts and users' attention has diverged between them.

The idea is vague right now, but mainly, most of the indicators require rather simple input, most of the time something Vector or Matrix like, so algorithms on their own do not care about external data type and it should be utilized.

I think, that it is possible to do something like this

function indicator(input::T) where T
  v_input = unwrap(input) # convert input to Vector
  # ...
  # do calculations
  # ...
  
  wrap(v_output, T) # convert resulting vector to the type of the initial structure
end

Probably we can even put this wrap/unwrap in a macro so only actual implementation will be left. Wrapping and unwrapping can depend on type (DataFrame, TimeArray, Temporal) thus making resulting alorithm type agnostic.

We can start small, with moving averages and see how it works out.

Arkoniak avatar Apr 04 '21 18:04 Arkoniak

How about implement the unwrap/wrap by applying Tables.jl API?

We can start small, with moving averages and see how it works out.

I guess the first problem is that the we might need to rewrite lots of time-related operations (which are already done in TimeSeries.jl) for Vector/Martrix, e.g. lag, lead, moving.

but yeah, we still can try it, then check out it's worthy or not.

iblislin avatar Apr 04 '21 19:04 iblislin

How about implement the unwrap/wrap by applying Tables.jl API?

That's a good idea, I will look in Tables.jl documentation, probably it shouldn't be that hard to do.

Arkoniak avatar Apr 05 '21 11:04 Arkoniak