5
$\begingroup$

I'm looking for a library to do some time series analysis in Java but I can't find anything suitable.

I've found plenty of libraries such as Math3 of JSAT but there's much I can you for my problem.

As an example, I'd like to compute standard deviation over time, moving average etc for a specific time series.

$\endgroup$
2
  • 2
    $\begingroup$ There is something weird in your second sentence... could you please correct it? $\endgroup$
    – SRKX
    Dec 9, 2014 at 8:34
  • $\begingroup$ Don't forget that classes like this can always be "Wrapped" in a class full of functions to do those things you listed (which you will have to implement yourself). Finding a simple time-series class that supports the TYPE of operation you need should be enough: consider if you need fixed time points or variable? Do you need to insert/replace an arbitrary period of time with a new value? Can you afford to store a generic type for each time period (like a Double) or does it have to be an intrinsic like double for performance? How does it persist?... Implement the stuff you listed yourself. $\endgroup$
    – Bill K
    Jul 5, 2019 at 18:31

6 Answers 6

7
$\begingroup$

I work with time series intensively, and I am experienced in Java and scripting languages such as MATLAB and R. I strongly suggest that you should cook up your own implementations in Java, and stop hunting for and relying on any off-the-shelf implementations. They are not reliable. One should be able to write std, corr, cov, ma, etc., easily by hand. Coding them independently can really enhance your comprehension of the underlying problem.

In short, Java is not a good tool for analysis. You may want to perform prototyping and research in MATLAB, R and Python, and implement the required features in Java after the preliminary research.

$\endgroup$
6
  • $\begingroup$ I think commons math is pretty reliable. Agree most other simple things are easier to code than to figure out something like TA-Lib for instance. apache commons math link $\endgroup$
    – brian
    Sep 1, 2014 at 4:14
  • $\begingroup$ Hi Brian, agree. I personally also use commons math as a utility library. However, I often write up a wrapper around these third-party implementations, so I can have a full control over the interface. $\endgroup$
    – Simon
    Sep 1, 2014 at 13:17
  • $\begingroup$ I agree that there is no obvious leader in the market but I don't think there shouldn't be one (i.e. it wouldn't be a bad thing if we could rely on something decent, like pandas for python). I'm actually amazed that nobody has seized this market already, although there are some candidates. For easy things such as standard deviation then re-implementing is fine, but for more complicated things it might be actually very helpful to use more efficient/optimized functions. $\endgroup$
    – SRKX
    Dec 9, 2014 at 8:31
  • 3
    $\begingroup$ I like your answer except for the recommendation that these things should be built from scratch by each user. While you're right that this is a highly valuable learning experience, it also is unproductive and very error-prone. Everything else you said, especially the advice on adding another tool, is spot-on. $\endgroup$
    – user5352
    Feb 25, 2015 at 22:00
  • $\begingroup$ yes but what data structure would you use in java to hold financial time series? $\endgroup$
    – Trajan
    Jun 22, 2018 at 12:32
2
$\begingroup$

Tablesaw is similar to Python's Pandas: https://github.com/jtablesaw/tablesaw

$\endgroup$
1
$\begingroup$

Here is library for time series modelling. There are exponential smoothing models (simple, double, triple) with maximum likelihood estimation and another time series utility classes:

$\endgroup$
1
$\begingroup$

Some time ago I came up with TimEL, a Java library I've been writing to evaluate expressions for time-series data.

$\endgroup$
2
  • $\begingroup$ 404 Not Found nginx $\endgroup$
    – Ray Tayek
    Mar 26 at 21:55
  • 1
    $\begingroup$ Thank you for pointing that out @RayTayek! I've update the link with the github repo. $\endgroup$
    – cyberz
    Apr 29 at 13:47
0
$\begingroup$

You might find TA-Lib useful:

TA-Lib is widely used by trading software developers requiring to perform technical analysis of financial market data.

    Includes 200 indicators such as ADX, MACD, RSI, Stochastic, Bollinger Bands etc... (more info)
    Candlestick pattern recognition
    Open-source API for C/C++, Java, Perl, Python and 100% Managed .NET

It is pretty useful and versatile: you can grow with it beyond just standard deviation and moving averages, and also to other programming languages, as mentioned above.

Good luck!

$\endgroup$
0
$\begingroup$

JFreeeChart provides a TimeSeries data structures with some basic functionality but not a lot of analytics. I have started writing my own and I may open source it if there is sufficient interest. Moving averages, deviations, correlations, returns and most of the easy stuff are already implemented, but I think it needs a few more interesting features before I can consider it truly useful.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.