This package provides a flexible & efficient time series class, TS
, for the Julia programming language. While still early in development, the overarching goal is for the class to be able to slice & dice data with the rapid prototyping speed of R's xts
and Python's pandas
packages, while retaining the performance one expects from Julia.
See the documentation for a more in-depth look at the package and some of the pain points it may solve when doing technical research with time series data.
Below is a brief teaser with a minimal use case illustrating a small subset of features. This example also makes use of the Indicators.jl package, which provides a series of financial market technical analysis indicators with wrappers for the Temporal.TS
type. Visualization is offered through the Plots.jl package, which Temporal leverages through RecipesBase.jl.
using Temporal, Plots, Indicators
crude = quandl("CHRIS/CME_CL1")
gasoline = quandl("CHRIS/CME_RB1")
prices = [crude["2012/2019", :Settle] gasoline["2012/2019", :Settle]]
prices.fields = [:Crude, :Gasoline]
prices = dropnan(prices)
daily_returns = diff(log(prices))
cumulative_returns = cumprod(1 + daily_returns)
spread = cumulative_returns[:,1] - cumulative_returns[:,2]
spread = [spread sma(spread, n=200)]
spread.fields = Symbol.(["Spread", "SMA (200)"])
gr()
ℓ = @layout[ a{0.7h}; b{0.3h} ]
plot(cumulative_returns, c=[:black :purple], layout=ℓ, subplot=1)
plot!(spread, c=[:blue :orange], layout=ℓ, subplot=2)