3

I am looking for resources (if they exist) that explain the differences between quant finance software in academia and the real world, or explain how quant software is implemented in practice.

For example, in uni we learn the Black-Scholes formula and how to write it out in code, which is fairly simple. e.g.

import numpy as np
from scipy.stats import norm

def Black_Scholes(S: float, K: float, T: float, r: float, sigma: float) -> dict: d1 = (np.log(S/K) + (r + sigma*2 / 2) T) / (sigma * np.sqrt(T)) d2 = d1 - sigma * np.sqrt(T)

return { 
  "call": S * norm.cdf( d1) - K * np.exp(-r*T) * norm.cdf( d2), 
  "put": -S * norm.cdf(-d1) + K * np.exp(-r*T) * norm.cdf(-d2)
}

print(Black_Scholes(10, 10, 1, 0.05, 0.1)["call"]) print(Black_Scholes(10, 10, 1, 0.05, 0.1)["put"])

But as soon as I look at any serious open-source quantitative finance software (and presumably proprietary software too), the first thing I notice is there are many additional factors that need to be considered that receive little to no mention in any classroom I've been in.

For example, in QuantLib Python, to price a European option you do something like:

today = ql.Date().todaysDate()
riskFreeTS = ql.YieldTermStructureHandle(ql.FlatForward(today, 0.05, ql.Actual365Fixed()))
dividendTS = ql.YieldTermStructureHandle(ql.FlatForward(today, 0.01, ql.Actual365Fixed()))
volatility = ql.BlackVolTermStructureHandle(ql.BlackConstantVol(today, ql.NullCalendar(), 0.1, ql.Actual365Fixed()))
initialValue = ql.QuoteHandle(ql.SimpleQuote(100))
process = ql.BlackScholesMertonProcess(initialValue, dividendTS, riskFreeTS, volatility)

engine = ql.AnalyticEuropeanEngine(process)

So to price a European option we need to implement (or use someone's implementation of) things like Dates and Term Structures, and even a Quote object. Using dates of course means day counting is required, which requires day counting conventions, and so on.

Then you might want to calibrate your model which is conceptually easy to do, but now that you have Dates and Quotes and TermStructures, how do you handle these ?

I've used option pricing as an example, but this applies to many more areas of QF.

So I'm wondering if there are any good references for all these considerations? I can read the QuantLib source (and I have read quite a bit of it), or other open-source projects, but this does not actually explain the leaps from academia to practice.

Thank you in advance for any help!

Note: I do have a copy of 'Implementing QuantLib'.

FISR
  • 117
  • 5
  • 6
    If you are considering to leap from academia to practice don't worry. The typical task for a programmer and quant in any financial institution is to navigate through code written by others. There is no reference that could prepare you for all the details to come. On the other hand I found more helpful teamwork there than in any other institution I have been at. – Kurt G. Aug 29 '23 at 19:18
  • Thanks for your comment. Do you know of any good open source projects that are worth looking at that deal with these sort of issues ? – FISR Aug 29 '23 at 20:22
  • 2
    For the fixed income world I'm personally working a project available at github.com/attack68/rateslib. Unfortunately I haven't finished or released the accompanying book yet, but yes you're right, a big part of that library (50%) was putting in the building blocks: auto diff, day count, calendars, interpolation, and scheduling. Without any of that it was impossible to generalise to cover the full scope of securities and derivatives. – Attack68 Aug 29 '23 at 20:33
  • @Attack68 I've actually already stumbled across RatesLib, very nice project. Didn't know a book was coming alongside it, so that's cool to hear. What do you use the AD for? Is it forward mode (I see you use dual) ? – FISR Aug 29 '23 at 20:46
  • 2
    Adding to Kurt G'd excellent comment, no single implementation is "complete". Quantlib is great but doesn't handle details like expiry vs delivery date. For equity, many options are American and dividends are discrete and unknown. There is no single model that is being used. Its kind of hard to write a book about this because the money is not in details that a handful of people really need or desire. If you offer Python for beginners on Udemy, you get hundreds of thousands of students. Python for experts gets you a few hundred sign-ups. – AKdemy Aug 29 '23 at 22:32
  • 2
    @FISR Remaining time in academia is probably better spent in deeply learning the theoretical stuff, surely accompanied by crunching numbers using your favourite programming language. I find python terrific. If you really want to get a taste of a practical financial institutions task you may want to see how the following tools work: Git, Tortoise, Bitbucket, Visual Studio, ... Participating in open source projects is a good idea but I don't know how much reputation you have to get so that your pull requests get accepted. If an institution pays you for programming this is quite different: – Kurt G. Aug 30 '23 at 06:35
  • 1
    The demand for code is on their side. :) – Kurt G. Aug 30 '23 at 06:35
  • 2
    Also: quite a lot of time at work you will spend by communicating with people about their questions and helping them with their programming tasks. QSE is the prime platform to practice those things. Try to answer a few questions here. – Kurt G. Aug 30 '23 at 06:42
  • 2
    @FISR, AD is forward mode, and the libary couldnt exist without it (Python would be too slow and too unwieldy). It handles curve solving via optimization, risk sensitivity calculation and FX currency conversion, and some ad hoc calculations when derivatives are involved. – Attack68 Aug 30 '23 at 07:01
  • 1
    @Attack68 what does AD do for FX conversions ? I need to have a closer look at your library. – FISR Aug 30 '23 at 08:04
  • 2
    When you have a physical amount of cash, say 100 EUR, a naive FX conversion would suggest that is 110 USD (with eurusd 1.10). But that is just the equivalent value of 100 EUR expressed in USD, it doesnt actually represent 110 USD physical. A forward mode AD representation of this is <Dual: 110, "fx_eurusd", 100>. By having a datatype that preserves exposure to the FX rate via first derivatives allows that cash quantity to be properly represented and that cascades down to other functions/methods without a constant need to perform checks in code. All the information necessary is in the Dual. – Attack68 Aug 30 '23 at 08:29
  • 2
    bit more here: https://rateslib.readthedocs.io/en/latest/f_fxr.html#sensitivity-management – Attack68 Aug 30 '23 at 08:33
  • @FISR Regarding your requests to reopen: This forum can be pretty subjective when closing questions that ask for references. Sometimes, questions are lauded; other times, they get closed. Recently, it has been the latter. It's unfortunate. At least there are good comments here that you could/should consider an answer, IMO. – amdopt Sep 03 '23 at 12:03

0 Answers0