开发 Java 交易应用程序:是否存在用于定义交易规则的模式/框架?

发布于 2024-08-07 02:35:35 字数 1185 浏览 6 评论 0原文

我正在设计一个交易应用程序,该应用程序将使用市场的 API 在市场上下订单。这不是投资银行中那种复杂的高性能算法交易应用程序。这只是一个小型个人应用程序,根据市场状况/趋势,每天可能会交易两到三次
该应用程序将(大致)包含以下模块/包:
策略
- 实际交易算法
分析
- 用于分析实时价格和价格的课程市场上的订单产生买入/卖出信号
服务
- 用于维持与市场的连接、检索市场信息和下达买/卖订单的类。
到目前为止,该应用程序所需的一切似乎都可以在互联网上获得:
* Apache CXF 用于生成用于访问市场 Web 服务的 Java 类。
* Apache Maths 用于执行定价分析
* Wikipedia 用于各种设计模式,即工厂、主题/观察者、状态、 ETC..

然而,我真正陷入困境的是算法。我决定使用 状态模式 将各个部分划分为逻辑分组当满足某些市场条件时应执行的逻辑。问题是我开始发现每个状态类很可能会包含大量 if else 语句:

if(this_condition) {
    // do something
} else if (another_condition) {
    // do something else
} else {
    // etc..., etc...
}


我忍不住觉得我在这里遗漏了一些东西,并且必须存在一些我不知道的框架或设计模式,它使开发人员能够将给定业务上下文的所有输入和输出封装到有限数量的可以在其上构建业务规则[算法]的业务操作[输入/输出]。即,我希望能够将应用程序变成某种规则处理器,而不是对算法进行硬编码。不幸的是我不知道从哪里开始。我希望我已经足够清楚地解释了我的困境,如果您希望我澄清任何事情,请告诉我。 谢谢

I am in the process of designing a trading application which will use a Market's API to place orders on the Market. This isn't a complex high performance algorithmic trading application of the kind found in investment banks. This is just a small personal application which will trade maybe two or three times a day depending on market conditions/trends
The application will consist (roughly) of the following modules/packages:
Strategies
- The actual trading algorithms
Analytics
- The classes for analysing the live prices & orders on the market to produce buy/sell signals
Services
- The classes used to maintain a connection to the market, retrieve market information and place buy/sell orders.

So far, everything required for the application seems to be available on the internet:
* Apache CXF for generating the Java classes used for accessing the market's web services.
* Apache Maths for the performing the pricing analytics
* Wikipedia for the various design patterns i.e. Factory, Subject/Observer, State, etc..

Where I'm really stuck however is with the algorithms. I've decided to use the State pattern to partition, into logical groupings, the various pieces of logic which should be performed when certain market conditions are met. The problem is that I'm beginning to see that it is very likely that each state class will contain an explosion of if else statements:

if(this_condition) {
    // do something
} else if (another_condition) {
    // do something else
} else {
    // etc..., etc...
}

I can't help but feel I'm missing something here and that there must exist some framework or design pattern I don't know about which enables the developer to encapsulate all the inputs and outputs of a given business context into a finite number of business actions [input/output] on which business rules[algorithms] can be built. I.e. Rather than having to hardcode the algorithms I'm hoping that it should be possible to make the application into a rules processor of some sort. Unfortunately I don't know where to start on this. I hope I've explained my dilema clearly enough, if you would like me to clarify anything please let me know.
Thank you

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

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

发布评论

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

评论(1

2024-08-14 02:35:35

我会看一些规则引擎,

Drools - drools.org

Imperius - http://incubator.apache .org/imperius/

您可能会对实时市场数据做出反应。复杂事件处理 (CEP) 工具非常适合解决这一问题。检查

http://esper.codehaus.org

hth

ste

I would take a look at some rules engines,

Drools - drools.org

or

Imperius - http://incubator.apache.org/imperius/

It's likely you're going to be reacting to realtime market data. This is something that Complex Event Processing (CEP) tools are perfect for. Check

http://esper.codehaus.org.

hth

ste

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