TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Trading System Testability

3 点作者 jayro超过 14 年前

1 comment

rhettinger超过 14 年前
Traditional unit testing doesn't work well with the strategy component in high-frequency trading programs.<p>* The need to rapidly iterate and refine strategies is not supported by writing tests which can prematurely lock-down the logic. Likewise, freezing the business logic with tests can become an impediment to adapting to changing market conditions (some opportunities have a short life).<p>* Like chess and poker games, the opponents have a say in how the logic plays-out. You will not be able to create a mock-object that accurately simulates how the rest of the market will respond to your bids and offers.<p>* Trading can be viewed as a concurrency problem. A flood of messages (orders and cancels) from independent actors (your competitors) go into an exchange computer which matches orders and emits quotes -- this is a race condition by design. Behaviors of concurrent systems with race conditions are notoriously hard to test.<p>* The OP mentions an order simulator (fake orders used for testing) but should be aware that that system can introduce a new risk, that of failing to switch the inputs when going live with a strategy. I've seen this happen (fake orders in, live orders out, not good).<p>* For managing risks, there are reasonable alternatives to testing. For example, strategy monitoring can shut down a program with order streams that are too large, too frequent, or that accumulate large positions. These dynamic reasonable checks provide protection against irrational strategy logic. Dynamic monitoring of trading logs provide real-time logic validation (i.e. with the actual inputs received, did the strategy make correct decisions).<p>Many components of a trading system are unittestable, but the strategy engine (the business logic) is more amenable to other techniques.