tags:

views:

361

answers:

1

Hello!
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

+3  A: 

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

sgargan