DEVSTORY #13: Pricing CME Natural Gas American Options (ON) using options pricing functions as a service library
A CME Natural Gas American Options (ON) market maker required an American Call Option (Bjerksund Stensland 2002 approximation) model for live pricing and greeks.
The trader currently uses an Excel-based front end with a library written in C# and compiled into a .xll extension that is added to MS Excel as an extension. The function is called in a cell and inputs are entered into designated cells on a spreadsheet. The trader does not have the source code and cannot update the model.
Additional issues are that the models used by the trader to price an option differ from models used by other actors within the traders organizations. Quants, Strats and risk managers have indepedently developed their own model to factor in tail risk as an example. The mid office personnel use the stock pricing model in the ETRM system which is an older Bjerksund Stensland 1993 approximation model. There has been some enhancement to this approach in a 2002 paper. The back office personnel are reliant on an aging spreadsheet whose methodology is no longer known. A RPA tool runs macros in the spreadsheets and imports option prices into the legacy derivative accounting system.
After an acquisition by a larger bank, the organization needed a revamp of infrastructure. More stringent controls were mandated. One of the efforts were to standardize and mandate use of validated pricing and valuation models in compliance with policies across the larger bank.
To implement this standardization, the bank developed a proprietary implementation of the Bjerksund Stensland 2002 approximation. This was developed greenfield using functional programming in python. This code was packaged in a docker container and deployed to dockerhub. The container was then deployed to FAAS infrastructure running on a kubernetes clusters replicating across three regions in Asia, Europe and United States.
The American option model was deployed to a FAAS platform implementation deployed to a Kubernetes cluster on the banks hybrid cloud.
The model was developed on a quants desktop. Deployed to a local desktop Kind cluster during development and testing. The model was checked in to a git repository. A Jenkins based CI/CD process picks up the model from the repository, build and deploys a container to Sonatype repository instance at the bank ( could also use Docker Hub). The container is then deployed in to the FAAS infrastructure on clusters in the US , Europe and Asia in a matter of minutes.
The model is now accessible once the pod is running in the K8s cluster. Any pod running a prior version of the model terminates. This is normal functionality within Kubernetes.
Once the new pod is running, the model is available as an https endpoints. Traders ( using Excel VBA + HTTP ) , ETRM systems using Java clients, enterprise clients using javascript, python, Java, C# , C++ can make https requests on the function as a service endpoint.
A representative call to the the American option model is as follows
http://<server>:port/oprilia/american76?fs=3.173&x=3.15&t=48.22&r=0.0&v=0.3232&pc=c
where
fs : futures or spot price
x : option strike
t : time to expiry ( in days ) - divided by 365 in model
r : interest rate
v : volatility
pc : option type - put or call
the returned value for the above pricing request is a json response as follows
{'fs': 3.173, 'x': 3.15, 't': 48.22, 'r': 0.0, 'v': 0.3232, 'pc': 'c', 'premium': 0.159862078807113, 'delta': 0.5480222561605672, 'gamma': 1.0625264222877047, 'theta': -0.558717907757004, 'vega': 0.4567573835623682, 'rho': 0.2086026977488643}
The underlying infrastructure leverages horizontal pod autoscaling provided by Kubernetes cluster that the function as a service infrastructure and subsequently the stateless american option pricing model is deployed on. As number of requests increase beyond set threshold more pods are provisioned on demand to meet sla. Once number of requests decreases the number of pods are incrementally reduced to save costs.
The same mechanism is used to price European , Asian and Spread options at the time of writing. Additional models for exotic options, implied volatility models and greeks are in the process of being implemeted.
Oprilia is the function as a service based option model product offering being used in this case.