Quant Math in Rust


#1

Hi, I am new to this forum and to Rust, so please be kind to me. I was in charge of writing the pricing library that Morgan Stanley use for pricing all equity-related products, all in C++.

It strikes me that Rust is the perfect language for this sort of application – fast, functional, rigorous, no garbage collection. So I have created a framework for pricing and risk calculation of financial derivatives in Rust.

There’s a lot to do, and I’d really appreciate collaboration and help. I’d love some real Rust experts to read my code and comment or better still fix it. I’d love volunteers at any level to write the many bits and pieces that are needed in a pricing library.


#2

Have you gotten much uptake out of this library? I’m really interested in how well Rust holds up in production.


#3

Not yet. I’ve spoken to various quants and quant devs about the library in different investment banks. They are interested in Rust as an idea, but are frightened by the lack of trained developers, and are worried by what they see as a work in progress. Banks are very conservative and do not want to take on risks that they do not have control over.

In my opinion, Rust offers far more than in-house functional languages like Slang, or less performant languages like Scala or F#. But there is resistance to what is seen as a language under development.


#4

Yeah, I can understand that. I suspect it’s hard enough to find good quant dev folks for C++, let alone Rust. Plus, QuantLib and some of the other quant packages have been very well developed over the years, and it’s difficult to compete with that stable an ecosystem.

I would like to contribute to this (particularly the FX side), but sadly my plate is too full. Is this mostly a toy project or is it something you’re actively trying to push? I may try to fit in some time over the summer.


#5

Hi Cameron,

Any contributions would be extremely welcome, especially in FX. I have experience with other asset classes, but I’ve never worked with short-dated FX, which has some pretty weird conventions of its own.

I don’t think of this as a toy project, though it has been stalled for a while. My next task is to develop interfaces for it, which I’d like to drive using Rust macros, so the same code will simultaneously generate all the interfaces I need, such as Excel, Python, C, … I therefore ended up getting a bit sidetracked into making Excel interfaces work in Rust.

As with any project like this, the main issue is to build up enough momentum. If universities start to get interested in it, then that will generate candidates who can use it in banks. Similarly, if banks start to get interested in it, that will cause universities to take notice. It is a virtuous cycle, but one that needs kickstarting.

I think if you (or anyone else) were to work on it, that could help your career, even if it did not lead to a job writing Rust. C++ is slowly playing catch-up with Rust, and canny heads of development will take on Rust developers for C++ programming roles. Moreover, work on a quant library that is pretty similar to the sort of library you would experience in a top-tier investment bank is not going to do you any harm, even if the language is different.


#6

Very cool to see this, especially from someone in industry.

I work in spot fx market making and spend most of my time with kdb, so haven’t touched something like quantlib since university. But will keep this in mind for future projects and contribute if possible.


#7

Awesome. I can see that KDB is a great language for analysis for delta one quants, but Rust just feels like the right language for the high performance, high accuracy, analytics you need for risk neutral pricing and risk.


#8

Well, my university is not exactly the most quant-heavy of schools out there, but I’m actively trying to get the faculty to let us (I’m a finance PhD student) teach more computational stuff, and this looks like a good example of something that could be built out.

Hell, working on this might give me some good research topics.


#9

If you are up for it, let’s chat about some more concrete ideas. We certainly need a lot of basic FX items in the library, like vol surfaces that work in moneyness rather than strike, defining options in delta rather than strike, even just how to define FX instruments. Then on top of that, we need ways of calculating the values of common FX instruments like barrier options.

Vol risks in FX are generally expressed as sensitivities to instruments, like risk reversals and butterflies. Getting that to work in QuantMath would be a good project.

I know the FX world is moving away from American options, but they still exist in FX. An American pricer for FX options would be a nice self-contained project. A lot different from an equities pricer, which has to worry about dividends.