21

I am looking for an all-java implementation of black scholes, preferably open source. I found jquantlib and quantlib (C++). Any other recommendations?

The jquantlib site seems to be down.

I'd prefer to stay away from a C++ implementation that runs on a jvm like quantlib seems to be. My team would like to look at the code if open source and none of us are C++ capable.

Tal Fishman
  • 13,449
  • 7
  • 63
  • 110
colin
  • 249
  • 3
  • 4

3 Answers3

13

Black Scholes in java?

This guy, Christian Fries http://www.christian-fries.de/, has some impressive codes and a book on these topics.

You can find http://www.christian-fries.de/finmath/book/index.html the contents as well as the library itself http://www.finmath.net/finmath-lib/.

As well as your request, you'll see LIBOR model, HJM model, binomial model, etc. Of course there are numerical algorithms to solve these problems like Box Muller transform, etc.. He also has a straight forward approach to theoretical stuff on the topics(probably much straight forward than others)

Hope it helps!

Christian Fries
  • 1,806
  • 16
  • 17
Andr
  • 763
  • 1
  • 8
  • 9
  • Ok - finmath appears useful. Thx. Tho the test applets appear to require java 1.5 only. But I'll keep looking. – colin Sep 14 '11 at 18:52
  • The code uses enums and generics, so it'll require at least Java 5 (which, to be fair, had been out for almost seven years when @colin's comment was posted!) – Martin McNulty Jan 29 '13 at 16:44
  • It is now at Java 6 and we are developing a branch which will use Java 8. Intention is to support Java 6 and Java 8 by two different releases. – Christian Fries Aug 31 '13 at 19:15
6

QuantLib itself also provides Swig interfaces which can be used to create bindings for dozens of languages, Java included. Quoting:

SWIG is a software development tool that connects programs written in C and C++ with a variety of high-level programming languages. SWIG is used with different types of target languages including common scripting languages such as Perl, PHP, Python, Tcl and Ruby. The list of supported languages also includes non-scripting languages such as C#, Common Lisp (CLISP, Allegro CL, CFFI, UFFI), D, Go language, Java, Lua, Modula-3, OCAML, Octave and R.

See the QuantLib site for more on support for other languages and extensions.

On the other hand, JQuantLib is an independent project that was last reported to have a good sized portion of a prior release ported to Java.

Dirk Eddelbuettel
  • 4,864
  • 3
  • 27
  • 34
4

Yep, there is one and it's leagues better than jquantlib.

https://code.google.com/p/maygard/

  • 1
    Why is it better? Your answer would be significantly improved if you add a few points along these lines. – Louis Marascio Apr 29 '13 at 13:44
  • 1
    I wonder too why it's 'leagues better', from quickly looking at the source I'd say it's 'leagues' worse. The payoff for futures contracts is simply wrong, and (unless the java compiler does miracles) the numerical routines look rather slow. – hroptatyr Apr 30 '13 at 10:54
  • It's leagues better because unlike jquantlib it's actually an object-oriented "Java API" and not a C++ procedural convert. I've used the API for fast, accurate and precise pricing of bonds and exotic options. The numerical routines are only as slow as your computer; if you want real-time performance you need to get a 'Real-Time JVM' such as Oracle's JRockIt. – El Prezidenté May 01 '13 at 13:01
  • Can you update your answer to state this? Also, JRockit isn't a real-time java. Did you mean a JIT? – chrisaycock May 10 '13 at 01:51
  • Oracle JRockit Real Time offers response time capabilities in microseconds! It guarantees a maximum response time of single digit milliseconds with Deterministic-GC and contains Latency Analysis Tools for monitoring and tuning the application. http://www.oracle.com/technetwork/middleware/jrockit/overview/index-086343.html – El Prezidenté May 10 '13 at 21:57
  • JRoCkIt offers excellent real-time for most needs. If you need hardcore real-time guarantee of 20 microseconds (+/- 5 microseconds), you need to fire off your Java application in an RTSJ thread, which isnt' available on standard JVMs.

    RTSJ http://www.rtsj.org/

    There are many RTSJ compliant VMs on the market. Do a bit of googling and it should yield some options for an RTSJ-JVM. There is a nice topic on this site about RTSJ JVMs: http://stackoverflow.com/questions/4051966/which-real-time-rtsj-jvm-is-most-preferred

    – El Prezidenté May 11 '13 at 00:45
  • For those new to Java RTS, it's very easy, here's a primer that should get you going in minutes! http://www.informit.com/articles/article.aspx?p=1353608 – El Prezidenté May 11 '13 at 00:51