如何设计适合金融工具的编程语言?

发布于 2024-08-14 04:48:34 字数 581 浏览 6 评论 0原文

我在一家专门从事金融的精品店工作。

我们考虑设计一种语言来描述与金融市场相关的金融实体。

这主要用作某种脚本语言来替换电子表格和 VBA 宏中运行的许多流程。

它必须简单,而且实际上必须在幕后调用各种 C++ 和 C# 库。它必须让用户抽象地处理可以代表时间序列(日内和每日)的对象。

它必须是完全可调试的,当用户遇到问题时,我们必须能够进入 C++/C# 代码并重现错误。理想情况下,它必须能够通过 Excel 中的某种机制启动并在 Excel 中返​​回结果。 (不幸的是,几乎每个从事财务工作的人都在使用 Excel)

如果你必须完成这项任务,你会怎么做?

你会选择函数式语法吗?

您会开发某种可以解释的脚本语言,还是用另一种语言编译它(例如将脚本转换为 C++ 或 C#)?

我没有找到任何用于这种开发的开源项目,但是有没有使用这种语法的商业产品?

编辑:我阅读了您所有的答案,但我会等待更多时间才能选择答案。不过,它们都是非常有用的意见!

EDIT2:我将高性能标记标记为解决方案。你们所有的回复都非常有用,我已经全部修改了。他是第一个回答的人,他的回答对我们来说非常有见地。

I work for a boutique specialized in finance.

We thought about designing a language to describe financial entities related to financial markets.

This would be mainly used as some kind of scripting language to replace many process run in spreadsheets and VBA macros.

It has to be simple and it has, in fact, to call various C++ and C# libraries behind the scenes. It has to let users handle abstractly objects which could represent time series (intraday and daily).

It has to be fully debuggable, when an user will have an issue, we must be able to step in the C++/C# code and reproduce the bugs. Ideally it has to be able to be launched via some mechanism within Excel and return the results within Excel. (unfortunately almost every person working in Finance is using Excel)

If you had to do this task, how would you go about it ?

Would you go for a functional syntax ?

Would you develop some scripting language which would be interpreted or would you compile it in another language (like converting the scripts in C++ or C#) ?

I did not find any open-source project for this kind of development, but is there any commercial product using this kind of syntax ?

EDIT: I read all your answers but I will wait more time before to pick an answer. They are all very useful opinions though !

EDIT2: I marked High-Performance Mark's as solution. All your replies are very useful and I have modded all of them up. He was one of the first answers and his reply is quite insightful for us.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

陌若浮生 2024-08-21 04:48:34

我建议您集中精力用您喜欢的 OO 语言(C# 或 C++,尽管我怀疑您可能会发现将前者与 Excel 集成更容易)开发一组丰富的类。这将为您提供描述与金融市场相关的金融实体的语言。完成此操作后,您应该考虑是否继续用某种领域特定语言包装这些类,或者只是将它们公开给您的用户社区。

我怀疑您的领域具有一些不可简化的复杂性,并且中间 DSL 必须(几乎)与您的类集一样复杂,因此,您通过创建它几乎没有什么收获。

另一种方法是将 Excel 与 Mathematica 集成,Wolfram 为其制作了某种工具箱。我没有这方面的经验,但 Mathematica 肯定适合您必须执行的任何计算。

问候

I suggest that you concentrate on developing a rich set of classes in your preferred OO language (either C# or C++, though I suspect you might find it easier to integrate the former with Excel). That would give you your language to describe financial entities related to financial markets. When you've done that you should consider whether to continue to wrap these classes in some Domain Specific Language, or simply to expose them to your user community.

I suspect that your domain has some irreducable complexity and that an intermediate DSL will have to be (nearly) as complex as your set of classes and that, therefore, you have little to gain by creating it.

Another approach would be to integrate Excel with Mathematica for which Wolfram produce a toolbox of some sort. I have no experience of this, but Mathematica is certainly suitable for any of the computations you'll have to do.

Regards

留蓝 2024-08-21 04:48:34

我会用 Python 封装 C++ 库。

我将定义一个流畅的类包,它实际上是我的特定领域语言。

基于这两个基础我会直接使用Python语言。我不会发明自己的新语法。世界不需要另一种语法;我们有足够的语法和语法来解析,足够持续到时间的尽头。

你会选择函数式语法吗?Python 具有函数式功能。如果您小心地设计 Python 类,您就可以实现干净的函数式风格。

理想情况下,它必须能够通过 Excel 中的某种机制启动并在 Excel 中返​​回结果。

由于 Python 解释器可以嵌入到 C++(或 C#)应用程序中,因此您可以轻松创建 Excel API 。从 Excel 到新语言,尽可能少地使用 C++ API 来启动 Python 功能。

顺便说一句,您的竞争对手是 Resolver One。这就是他们所做的。

I would wrap the C++ libraries in Python.

I would define a package of fluent classes that -- in effect -- was my domain-specific language.

I would use the Python language directly based on those two foundations. I would not invent my own new syntax. The world doesn't need Another Syntax; we have syntax and grammars enough to parse, enough to last till the end of time.

Would you go for a functional syntax ? Python has functional capabilities. If you're careful with your Python class design, you can achieve a clean functional style.

Ideally it has to be able to be launched via some mechanism within Excel and return the results within Excel.

Since the Python interpreter can be embedded in a C++ (or C#) application, you can easily create Excel API's. From Excel to your new language, do as little as possible in the C++ API to initiate the Python functionality.

BTW, your competition is Resolver One. This is what they do.

一袭白衣梦中忆 2024-08-21 04:48:34

利用 c# 的另一个观点。

由于您已经拥有用户熟悉并以 Excel 形式购买的功能强大的通用函数式编程工具,因此我希望围绕该工具构建一个解决方案。您仍然可以选择使用其他第 3 方插件和集成选项(例如 R 和 Mathematica),

我会研究用户定义函数的托管自动化插件。这些本质上是使用 System.Runtime.InteropServices 的 C# 库项目,如本文所述 链接文本。对于用户来说,这些函数是使用函数向导以正常方式在单元级别添加的,并且或多或少可以是您想要的。这就是您的 DSL。用户可以选择轻松地将功能集成到他们现有的模型中。也可以快速制作一些原型来测试其可行性。这些是完全可调试的。

此外,使用 Visual Studio Tools for Office,您可以访问完整的 Excel 对象层次结构,甚至添加操作窗格,可以通过拖放控件来布局这些操作窗格,以满足更复杂的数据输入要求。我相信,如果您需要添加专门的可视化效果,甚至可以通过这种方式将 WPF 与 Excel 结合使用。如果您需要将数据保留回 Sql Server,您可以使用此方法构建一个周转验证表单。

我听起来像个百万美元的骗子! (澄清一下,我不为他们工作)。

您需要评估其性能,但我不确定它将如何扩展。

Another viewpoint which leverages c#.

As you already have a powerful general purpose functional programming tool your users are familiar with and have bought into in the shape of Excel I would look to build a solution around that. You still get the option that way of being able to use other 3rd party add-ons and integrated options (e.g. R and Mathematica)

I would look into Managed Automation Add-ins for User Defined Functions. These are essentially c# library projects that use the System.Runtime.InteropServices as described in this article link text. To the users these functions are added at a cell level in the normal way using the function wizard and can be more or less what you want them to be. This then is your DSL. Users can choose to integrate the functionality in their existing models easily. It would also be fast to prototype something to test the feasibility of this. These are fully debuggable.

Additionally using Visual Studio Tools for Office you can access the full excel object hierarchy and even add action panes which can be laid out by dragging and dropping controls for more complex data entry requirements. I believe it is even possible to use WPF with Excel in this way if you needed to add specialised visualisations. If you needed to persist data back to say Sql Server you could build a turn around validation form using this approach.

I sound like a M$ shill! (Just to set the record straight I do not work for them).

You would need to evaluate the performance of this and I am not sure how it would scale.

陪我终i 2024-08-21 04:48:34

Haskell 知名人士 Simon Peyton-Jones 撰写了一篇论文 “编写合约:金融工程的一次冒险”讨论了函数式语言如何有助于编写金融衍生品合约的可执行描述。 F# 应该可以实现这样的方法。

我相信 LexiFi 的产品旨在将部分研究商业化。

Simon Peyton-Jones of Haskell fame contributed to a paper 'Composing contracts: an adventure in financial engineering' which discussed how functional languages lent themselves to composing executable descriptions of financial derivative contracts. Such a method should be possible with F#.

I believe the offerings of LexiFi aimed to commercialise some of this research.

人生百味 2024-08-21 04:48:34

Jane Street Capital 使用 OCaml,并在此处写下了他们的经验。如果广泛阅读的话,这是一本非常有趣的书。

对于您的环境,如果您遵循他们的模型,则可以使用 F#< /a>,它最初是作为 OCaml 方言出现的,但当然也运行在 .NET 世界中。

Jane Street Capital uses OCaml, and wrote up their experiences here. It's a pretty interesting if broad read.

For your environment, if you followed their model, you could use F#, which started out life as an OCaml dialect, but which of course runs in the .NET world.

疑心病 2024-08-21 04:48:34

如果您的底层库使用 Java,您应该考虑在 Groovy 中创建 DSL。有很多关于此的播客和文章,尝试谷歌搜索“DSL Groovy”。

If your underlying library uses Java you should take a look at doing a DSL in Groovy. There are a number of podcasts and article about this, try Googling "DSL Groovy".

篱下浅笙歌 2024-08-21 04:48:34

大多数数字处理金融机构(或其中的部门)已经获得了 Matlab 许可证。我建议您查看 Matlab 提供的面向对象工具(事实上,也可以查看他们的Financial工具箱)。

首先,我认为您可以获得三件事:

1)访问高级环境,在该环境中用户可以专注于问题而不是实施
2) 高质量图形的可用性
3) 与 Excel 和其他生产力包无缝集成

我知道您的意思是开发一种语言(而不是应用程序),但请考虑将您的语义搭载到一种众所周知的语言 - 这样您就可以避免用户的学习曲线。

Most number-crunching financial institutions (or divisions therein) have already acquired Matlab licenses. I recommend that you take a look at the Object Oriented facilities offered by Matlab (and, indeed, at their Financial Toolbox).

Up front I think you gain three things:

1) Access to a high-level environment where users can concentrate on the problem and not on the implementation
2) Availability of high-quality graphics
3) Seamless integration with Excel and other productivity packages

I know you mean to develop a Language (as opposed to an application) but consider piggy-backing your semantics to a well know language - this way you avoid the learning curve for your users.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文