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

Streaming feature

Open femtotrader opened this issue 7 years ago • 4 comments

Hello,

I wonder if Temporal.jl have streaming feature ie a kind of circular buffer datastructure which is able to receive for example tick events and store them or to resample to candlestick (OHLCV).

Kind regards

PS: see StreamTimeArray https://github.com/femtotrader/TimeSeriesIO.jl/blob/master/src/stream_timearray.jl StreamTimeArrayOHLCV https://github.com/femtotrader/TimeSeriesIO.jl/blob/master/src/stream_timearray_ohlcv.jl

femtotrader avatar Dec 26 '16 22:12 femtotrader

@femtotrader This is something that I would definitely like to add on later. Something I am always considering is the amount of dependencies required to use my packages. As the package becomes more fully developed and feature-rich, additional dependencies will surely follow, but for now I'm trying to keep the pre-requisites in moderation. For now my primary goal is to be able to analyze and manipulate time series data as efficiently as possible, so that my planned efforts to develop a systematic trading & backtesting platform will go smoothly. Getting live streaming quotes strikes me as something that would come after much of the historical analytical side of things has been fully implemented.

dysonance avatar Mar 01 '17 11:03 dysonance

You might be interested by https://github.com/femtotrader/TALib.jl see https://github.com/femtotrader/TALib.jl/issues/19

femtotrader avatar Mar 04 '17 18:03 femtotrader

Some inspiration from Python ecosystem with streamz https://github.com/JuliaQuant/MarketTechnicals.jl/issues/93#issuecomment-341361834

femtotrader avatar Nov 04 '17 09:11 femtotrader

A streaming example (probably not very efficient)

using Temporal
import Base: circshift!, push!


function circshift!(ts::TS, n)
    ts.values = circshift(ts.values, n)
    ts.index = circshift(ts.index, n)
    ts
end

function push!(ts::TS, values::Array, idx::Vector)
    n = length(idx)
    circshift!(ts, -n)
    ts.values[end-n+1:end,:] = values
    ts.index[end-n+1:end] = idx
    ts
end

srand(1234)
idx=DateTime(2010,1,1):Dates.Hour(1):DateTime(2017,1,1)-Dates.Hour(1)
n=length(idx)
price=100+cumsum(2*(rand(n)-0.5))
volume=rand(n)*1000
ts = TS([price volume], collect(idx), [:price, :volume])
println(ts)

#ts = circshift(ts, -1)
#println(ts)

new_values = [204.0 100.0]
new_idx = [DateTime(2017,1,1,0,0,0)]

push!(ts, new_values, new_idx)

new_values = [205.0 100.1 ; 206.0 100.2]
new_idx = [DateTime(2017,1,1,1,0,0),DateTime(2017,1,1,2,0,0)]
push!(ts, new_values, new_idx)

println(ts)

femtotrader avatar Dec 01 '17 14:12 femtotrader