Two Java trading system technical questions

Quote from vicirek:

It must be j2ee because only him would create 5 arrays instead of one multidimensional array since he is indexing bars.
.

Hi vicirek,

Be very careful about the assumptions on the structure of the data in a data engine.

When I built my trading platform I spent a lot of time exploring different data structures and architectures. My primary concern was speed and flexibility, processing tick data for a large number of symbols in real-time, not back-testing or processing bar-data (I build bars in real-time from tick data). I am closer to the "multiple arrays" camp, and it is much better for what I value most. That said, the data structure I use is an implementation of an interface with methods like:
public void add(double dValue)
public double getPreviousValue(int nPrev)
Since it is an interface I can implement it any way I like.

On the other hand the OP did mention Open, High, Low, Close, so they are probably building something different than I built, so you may be right, just put it in a "Bar" data structure.

Take care,
-David

PS I do store historical tick and bar data in CSV files. One file for each symbol/timeframe.
 
Quote from vincegata:

[BIf you're looking for speed then you can declare your member variables as public and set and get them directly without using get and set functions. This is C++ syntax but you get the idea. [/B]

I believe the get() and set() will be optimized out by the JIT. There is no speed penalty.

That said, when I am using a class that is equivalent to a C struct, and only use it locally, I just make the variables public. It is really much cleaner IMHO. Though I use only Java now, I was a C++ programmer for many years.

-David
 
Quote from dholliday:

Hi vicirek,

Be very careful about the assumptions on the structure of the data in a data engine.

When I built my trading platform I spent a lot of time exploring different data structures and architectures. My primary concern was speed and flexibility, processing tick data for a large number of symbols in real-time, not back-testing or processing bar-data (I build bars in real-time from tick data). I am closer to the "multiple arrays" camp, and it is much better for what I value most. That said, the data structure I use is an implementation of an interface with methods like:
public void add(double dValue)
public double getPreviousValue(int nPrev)
Since it is an interface I can implement it any way I like.

On the other hand the OP did mention Open, High, Low, Close, so they are probably building something different than I built, so you may be right, just put it in a "Bar" data structure.

Take care,
-David

PS I do store historical tick and bar data in CSV files. One file for each symbol/timeframe.

If you construct bars from ticks with unknown number of ticks per period then best is to use container like queue (vector) per each symbol (kept in array or another vector). At the end of bar period just get first last min max (ohlc), empty vector and start acquiring ticks for next bar. No need to store ticks for entire day, no need for extra counter for arrays or worry about going past the end of array. Only problem to solve is how to account for empty bars (no trades, no quote updates, or feed issues)

For in memory storage I prefer to use containers as well holding bar structs (if using bars).

For disk data storage binary file is probably faster and more compact.
 
Quote from GloriaBrown:

I have two Java trading system technical questions and hope people with experience can give me suggestion:

Background information: I would develop my system with Java and run in either Windows 7 64 bits/ Ubuntu 64 bits. I will eventually connect the live trading version to Interactive Broker Java socket API.

First question:
For a interdays trading backtest system, should I put day open, close, high, low, vloume separately into array?

I think there are two possible ways: 1. day open, close, high, low, volume separately into array, then I have 5 arrays to work with my calculation 2. Put all of these into one array or linklist to do the calculation.

I think the 1. would be more easy to handle all backtest calculations, do you agree?

you are tangling stuff all together.

1) price attributes (open/close/high/low), create a value object and put all of them inside ( google: java encapsulation example). It's one of the fundamental concept.

2) backtest looping: get a real database - mysql to store the data, then loop through them via resultset, use a util method to populate the above value object while looping. Unless you have a very specialized performance need for in-memory data structure always use a database, laziness is not an excuse.

3) if you require a large number of those value objects for calculation, see if the calculation can be done via sql instead.

Second question:
Which function of Java GUI should I use to build a report page like this one?
Here is the testing result page that I want to display with Java:
http://i.imm.io/1e6vc.jpeg
Which function of Java GUI should I use to build a report page like this one?

thx!:D [/B]

google web toolkit (gwt) + smartgwt (widget templates).
 
Quote from GloriaBrown:


First question:
For a interdays trading backtest system, should I put day open, close, high, low, vloume separately into array?

I think there are two possible ways: 1. day open, close, high, low, volume separately into array, then I have 5 arrays to work with my calculation 2. Put all of these into one array or linklist to do the calculation.

I think the 1. would be more easy to handle all backtest calculations, do you agree?

Yes, use separate arrays.
Don't use a data base to store your data-sets.
Take care.
 
Quote from vincegata:

@dholliday - could you tell if you are consistently profitable? - thx.
No, I lose a little bit on each trade... but I make it up on volume.
 
Quote from dholliday:

No, I lose a little bit on each trade... but I make it up on volume.

"...but I make it up on volume." -- you mean you are paid for the limit orders?
 
Quote from vincegata:

"...but I make it up on volume." -- you mean you are paid for the limit orders?

Thanks for the investing humor. I laughed.
Seriously, my trading has never set the world on fire and probably would not impress you or anyone else.
Take care,
-D
 
Quote from dholliday:

Thanks for the investing humor. I laughed.
Seriously, my trading has never set the world on fire and probably would not impress you or anyone else.
Take care,
-D

Thanks for sharing in any case.
 
Back
Top