Exploring 24/7 Market Data with Julia: Volatility and Simple Visualizations

Recently, I’ve been experimenting with Julia for analyzing 24/7 market data. I normally work with more general data tools, so this was partly an excuse to see how comfortable Julia feels for a small time-series project.

The dataset is pretty simple: timestamp, price, and trading volume. But continuously traded markets are interesting because there is no traditional market close. Instead of looking at “trading days,” I wanted to calculate returns over fixed intervals and see how volatility changes over time.

A simplified version looks like this:


using CSV
using DataFrames
using Statistics

df = CSV.read("market_data.csv", DataFrame)

df.return = [missing; diff(log.(df.price))]

returns = collect(skipmissing(df.return))

println("Mean return: ", mean(returns))
println("Std deviation: ", std(returns))

From there, I started experimenting with rolling volatility. For example, using a 24-observation window:


window = 24

rolling_vol = [
    i < window ? missing :
    std(df.return[i-window+1:i])
    for i in 1:nrow(df)
]

The visualization part is where it becomes much easier to spot what the summary statistics hide.

For market data, I’ve been looking at public datasets as well as exchange/API documentation, mainly to understand how price and timestamp data are structured before turning them into something usable for analysis.

One thing I’m still thinking about is the best Julia-native approach for larger datasets. With a few thousand rows, almost anything works. Once the dataset becomes millions of observations, though, repeatedly calculating rolling statistics this way obviously isn’t ideal.

I’m also curious about visualization. I’ve started with basic plotting, but Makie looks interesting for exploring larger time-series datasets.

For people who regularly use Julia for this kind of work, what would you recommend for rolling-window calculations and time-series visualization?

Would you keep everything in DataFrames, or use a more specialized package once the dataset gets larger?

Have a look at OnlineStats.jl for streaming updates of statistics. The JuliaIO org should also have something to work with streamed inputs so you don’t have to load everything into memory.

You may also be interested in my own package PortfolioOptimisers.jl, I’m working on online portfolio selection right now. It may be of interest to you.

Welcome! I guess if you keep the window size fairly short this won’t be a problem for quite some time. So do you want to keep track of everything at once? Maybe you could consider focusing on the last n days or so?