一句话:报告渣打银行以 Haskell 构建类型驱动的大规模定价工作流,证明函数式编程可支撑工业级核心业务。
这是一篇来自渣打银行的经验报告,讲述函数式编程在超大规模真实场景中的应用。Haskell 被用于支撑整个 Markets 业务线(2023 年运营收入 30 亿美元)的核心软件库,覆盖从交易估值与风险分析的基础 API 与 CLI,到长时批处理与亚秒级 RESTful 服务,再到终端用户 GUI 的完整技术栈;数千名用户使用这些软件,百余人直接编写函数式代码。作者重点介绍如何借助类型驱动的方式编排大规模定价工作流:同一套 API 既可在本地为单笔交易定价,也可在数千个云节点上为百万笔交易定价;计算的各个部分可独立运行与检查,重算某一部分只会触发依赖部分的重算。实现建立在 monad、lens、数据类型泛型(datatype generics)与闭包序列化等社区数十年研究成果之上。作者认为函数式编程是本项目成功的主要驱动因素之一,且未发现明显弊端。
We present a case-study of using functional programming in the real world at a very large scale. At Standard Chartered Bank, Haskell is used in a core software library supporting the entire Markets division – a business line with 3 billion USD operating income in 2023. Typed functional programming is used across the entire tech stack, including foundational APIs and CLIs for deal valuation and risk analysis, server-side components for long-running batches or sub-second RESTful services, and end-user GUIs. Thousands of users across Markets interact with software built using functional programming, and over one hundred write functional code. In this experience report we focus on how we leverage functional programming to orchestrate type-driven large-scale pricing workflows. The same API can be used to price one trade locally, or millions of trades across thousands of cloud nodes. Different parts of the computation can be run and inspected individually, and recomputing one part triggers recalculation of the dependent parts only. We build upon decades of research and experience in the functional programming community, relying on concepts such as monads, lenses, datatype generics, and closure serialisation. We conclude that the use of functional programming is one of the main drivers of the success of our project, and we see no significant downsides from it.
@article{DijkstraMN24,
title = {Functional Programming in Financial Markets (Experience Report)},
author = {Atze Dijkstra and José Pedro Magalhães and Pierre Néron},
journal = {Proceedings of the ACM on Programming Languages},
volume = {8},
number = {ICFP},
year = {2024},
doi = {10.1145/3674633}
}