|
Building an Automated Foreign Exchange Trading System
Introduction
"We are not trying to predict where the market is heading, we are simply trying to gain a small edge over random entry into the market and use our finely tuned money management system to ultimately generate a consistent profit over time".
This blog will document my efforts to build an automated foreign exhange trading system using C#.
I have worked as a programmer within financial trading for almost 10 years and now I feel it is time to put my programming and trading knowledge to use and try to build an automated trading system (see this Wiki article for more info on automated trading).
The system will use SQL Server as the backend database and C# with WPF for the front end GUI. I will also need several third party controls such as a grid and a charting control.
System Overview
The aim of this project is therefore to produce a system which will enable trading strategies to be defined, backtested, forwardtested and ultimately traded:
- Strategy Definition: The system will enable a trading strategy to be defined as a set of unambiguous rules.
- Backtesting: The system will enable a trading strategy to be tested against a set of historical market data.
- Forwardtesting: The system will enable a trading strategy to be tested in real time in the relevant market.
- Trading: The system will enable a trading strategy to be traded in real time, with real money!
In addition, the system requires a way to manage the capital we have invested in the strategy. It
must manage the risk inherent in any trading system, with the ultimate aim being to preserve the capital invested in the strategy
whilst producing a reasonable rate of return, i.e. it must manage the risk/reward ratio and provide a mechanism for money management.
It must enable the testing of various trade sizes, stop loss strategies and profit taking strategies.
The system also requires a market prices database and extensive charting functionality.
Initially, the system will operate within the foreign exchange market as this is a highly liquid
market, it is open 24hrs a day and is a market I am familiar with. There are many brokers operating in the fx market, spreads
are low and leverage can be easily obtained.
Strategy Definition
A strategy is basically a set of rules that define a trading idea. There are four types of rules (actions) that define a strategy:
- Entry Rule: Defines where and why we will enter the market, i.e. the initial long or short trade.
- Exit Rule: Defines where and why we will exit the trade. This could be due to a profit target being reached, or perhaps the conditions that triggered entry are no longer valid.
- Stop/Loss Rule: Defines where and why we will place the stop/loss for the trade, and is used in conjunction with the Entry Rule. This is closely linked to our risk management strategy.
- Take Profit Rule: Defines where and why we will take profit (or lock-in profit) from the trade. Again, this is closely linked to our risk management strategy.
To be continued...
© Andrew Sinclair 2009 [andy@andrewsinclair.co.uk]
|