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

Streaming feature #1

Open
femtotrader opened this issue Dec 26, 2016 · 4 comments
Open

Streaming feature #1

femtotrader opened this issue Dec 26, 2016 · 4 comments

Comments

@femtotrader
Copy link
Contributor

femtotrader commented Dec 26, 2016

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

@dysonance
Copy link
Owner

@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.

@femtotrader
Copy link
Contributor Author

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

@femtotrader
Copy link
Contributor Author

Some inspiration from Python ecosystem with streamz
JuliaQuant/MarketTechnicals.jl#93 (comment)

@femtotrader
Copy link
Contributor Author

femtotrader commented Dec 1, 2017

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)

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

No branches or pull requests

2 participants