DBase

Discussions about custom-built testing platforms written in C, C++, or Java.
Post Reply
shakyamuni
Roundtable Knight
Roundtable Knight
Posts: 113
Joined: Wed Jun 04, 2003 9:44 am
Location: Somewhere, Hyperspace

DBase

Post by shakyamuni » Sat Feb 28, 2004 8:53 pm

Anyone have DBase experience? I need to build one to house my historical data and snatch it out to run sims.
Last edited by shakyamuni on Tue Dec 28, 2004 10:31 pm, edited 1 time in total.

Bernd
Roundtable Knight
Roundtable Knight
Posts: 126
Joined: Wed Apr 30, 2003 6:39 am

Post by Bernd » Sun Feb 29, 2004 8:41 am

:wink:
Last edited by Bernd on Fri Apr 18, 2008 3:05 am, edited 1 time in total.

Forum Mgmnt
Roundtable Knight
Roundtable Knight
Posts: 1842
Joined: Tue Apr 15, 2003 11:02 am
Contact:

Post by Forum Mgmnt » Sun Feb 29, 2004 10:38 am

shakyamuni,

As Hiramhon mentioned, we use memory to store historical data during testing. This is part of the reason VeriTrader can run a simulation in a few seconds.

In VeriTrader 2.0 we will be using a small SQL embedded database to store test results. This will allow us to offer a research management system so you can start with ideas and keep track of the tests associated with those ideas. The reasons a database will be used here is only partially because the data won't fit in memory.

The main reason is because SQL offers an ad-hoc query ability which will allow us to provide features enabling our users to search historical tests in ways we can't even anticipate. This will allow VeriTrader to stay on the leading edge.

Please read the other thread that Bernd mentioned, and perhaps you will come to the same conclusions we did.

- Forum Mgmnt

shakyamuni
Roundtable Knight
Roundtable Knight
Posts: 113
Joined: Wed Jun 04, 2003 9:44 am
Location: Somewhere, Hyperspace

Post by shakyamuni » Mon Mar 01, 2004 1:09 am

Awesome, thanks for the great help guys! I read the other threads and got some good info.
Last edited by shakyamuni on Tue Dec 28, 2004 10:33 pm, edited 1 time in total.

verec
Roundtable Knight
Roundtable Knight
Posts: 162
Joined: Mon Jun 09, 2003 7:04 pm
Location: London, UK
Contact:

Post by verec » Sat Mar 06, 2004 5:13 pm

What does the code that actually does the testing look like? Presumably, something of the sort:

Code: Select all

for(int i = 0, length = quotes.length ; i < length ; ++i) {
    Quote q = quotes[i] ;
    float close = q.close ;
    float high = q.high ;
    float low = q.low ;

    // here starts the interesting bits
    ...
}
Assuming that is the case, what you are interested in is in saving/restoring the quotes array, and this for each instrument.

There are a number of ways you can do this, but the most simple way is to let Java builtin serialization do it for you:

Code: Select all

package com.yourcompany.yourstuff.storage ;

import com.yourcompany.yourstuff.Quote ;

import java.io.FileOutputStream ;
import java.io.ObjectOutputStream ;
import java.io.FileInputStream ;
import java.io.ObjectInputStream ;

import java.io.IOException ;
import java.io.FileNotFoundException ;

public class QuoteStore {

    private static final String dataStore   =   "datastore.bin" ;
    
    private static Quote[]
    get(ObjectInputStream s) {
        Quote[] quotes = null ;
        try {
            quotes = (Quote[]) s.readObject() ;
        } catch(IOException e) {
        } catch(Throwable t) {
        } finally {
            return quotes ;
        }
    }
    
    public static Quote[]
    get() {
        Quote[] quotes = null ;
        try {
            FileInputStream in = new FileInputStream(dataStore);
            ObjectInputStream s = new ObjectInputStream(in);
            quotes = get(s) ;
            s.close() ;
        } catch (FileNotFoundException e) {
        } catch (IOException e) {
        } finally {
            return quotes ;
        }
    }
    
    private static void
    put(Quote[] quotes, ObjectOutputStream s) {
        try {
            s.writeObject(quotes) ;
        } catch(IOException e) {
        }
    }
    
    public static void
    put(Quote[] quotes) {
        try {
            FileOutputStream out = new FileOutputStream(dataStore) ;
            ObjectOutputStream s = new ObjectOutputStream(out) ;
            put(quotes, s) ;
            s.close() ;
        } catch (FileNotFoundException e) {
        } catch (IOException e) {
        }
    }
}
How to handle more than one such instrument is left as an exerxcise ;-)

Given this skeleton, then the first example can be rewritten as:

Code: Select all

Quote[] quotes = QuoteStore.get() ;
for(int i = 0, length = quotes.length ; i < length ; ++i) {
    Quote q = quotes[i] ;
    // as before ...
BTW: this code doesn't assume anything more complex than this is needed to group your daily OHLC together:

Code: Select all

class Quote {
    public float open ;
    public float high ;
    public float low ;
    public float close ;
}
HTH.

Post Reply