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? 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!
In Perl, I'd just use a hash of a hash, with the date as the primary key. Makes it real easy to keep track of the prices and get the exact data you need w/o s foreach my date (sort keys %prices) { my $open = $prices{$date}{open}; my $high = $prices{$date}{high}; my $low = $prices{$date}{low}; my $close = $prices{$date}{close}; my $volume = $prices{$date}{volume}; my $oi = $prices{$date}{oi}; # do interesting things below } Here's a Stack Overflow question that offers a Java version of Perl hashes....
Simple float[] arrays and int[] array for volume is the most efficient. I mean, using an ArrayList or Vector will about double your memory usage by creating Float objects, and a Hashtable would just be a lot slower for accessing the data linearly.
j2ee, you should use classes like that: Code: class BarClass { private: double open; double high; double low; double close; int volume; string date; string symbol; public: BarClass() : open(0), high(0), low(0), close(0), volume(0), date(""), symbol("") {} BarClass(double o, double h, double l, double c, int v, string str, string sym) : open(o), high(h), low(l), close(c), volume(v), date(str), symbol(sym) {} double get_open() { return open;} double set_open(double o) {open=o;} // other set & get }; vector<BarClass> bar_vec; // use vector deque<BarClass> bar_deq; // or use deque for more flexibility if you need to remove old bars. You must use double for prices or you will loose a lot of precision when calculating averages and whatnot. If 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.
And who says there are no patterns. It must be j2ee because only him would create 5 arrays instead of one multidimensional array since he is indexing bars. I think that talking about structs, classes and associative containers is too much at this point.