Discussions about the testing and simulation of mechanical trading systems using historical data and other methods. Trading Blox Customers should post Trading Blox specific questions in the Customer Support forum.
yoyo2000
Roundtable Fellow
Posts: 58
Joined: Fri Jan 30, 2004 10:37 pm

In which there is a model generating synthetic market data,its name is (Simple) price vector model.
I am very interested in it,but I couldn't get the exactly steps to perform it,for there is only simple description about them in the book,no related fomulars and step-by-step examples.
Could anyone give me some further information about it in details?
much appreciation!

Roscoe
Roundtable Knight
Posts: 250
Joined: Sat Jan 24, 2004 2:06 am
Location: Houston TX
Attached is a random data generator in an Excel file - just copy the formulae down as many rows as you want then copy to a regular ASCII file to work with. I presume this is what you are asking?
Attachments
Random Data Generator 95.xls
Simple random data generator in Excel 95 format.

yoyo2000
Roundtable Fellow
Posts: 58
Joined: Fri Jan 30, 2004 10:37 pm
Thank you for your kindness,Roscoe,actually,I'v got another random data generator,but the pure random data can't show the characteristic of market,so I wanted to generate synthetic data from real data in some way,and that's the purpose of the price vector model.maybe it's my fault not to describ the way they are done.
Since the book doesn't say the exactly steps,I can only describe it in a brief.
the following is how the price vector model works:
1.get a series of real data,identify and catalog the price vector as bull(up) and bear(down),finding how many there are of each (up and down separately) and graphing them separately by numbers of segments or price changes fro each vector or move.
2.find out how many vectors are there,and how many cells there should be for each piece or segment in these vector
3.then start randomly with an upvector or downvector,determine vector segment length from the vector segment distribution graph,and create prices for each segment of the vector.

but I feel puzzle that how to identify and catalog vectors?that's,how to determine the length ?

verec
Roundtable Knight
Posts: 162
Joined: Mon Jun 09, 2003 7:04 pm
Location: London, UK
Contact:
There is an answer which is so obvious that I surely didn't understand the question

Let's take a simple sequence of numbers:

Code: Select all

``20, 23, 28, 25, 26, 29, 27, 23, 21, 20``
Then draw a mark each time there is a "trend" change:

Code: Select all

``````20, 23, 28, 25, 26, 29, 27, 23, 21, 20
------------^---^-------^-------------``````
In this example you end-up with four "segments":
1. starts at 20 and ends at 28, length: 3, nature: up
2. starts at 28 and ends at 25, length: 2, nature: down
3. starts at 25 and ends at 29, length: 3, nature: up
4. starts at 29 and ends at 20, length: 5, nature: down
Are you after some code which, given a sequence of prices as above would tell you the segments, length and direction, or is the basic problem more subtle?
FWIW: here's some code that just implements the above:

Code: Select all

``````import java.util.ArrayList;
import java.util.List;

public class Sequence {

int     segStart ;
int     segEnd ;

class Segment {
float[] values ;
int     start ;
boolean up ;

Segment(float[] series) {
values = new float[1 + segEnd - segStart] ;
System.arraycopy(series, segStart, values, 0, values.length) ;
start = segStart ;
up = values[values.length -1] >= values[0] ;
}

public String
toString() {
return  " starting at " + start
+ " of length " + values.length
+ " is " + (up ? "up" : "down")
;
}
}

Segment[]
calcSegments(
float[] series) {

List segments = new ArrayList() ;

segEnd = segStart = 0 ;

float   prev = series[segStart] ;
float   curr = 0 ;

for (int i = 1, length = series.length ; i < length ; ++i) {
curr = series[i] ;

if (    (curr >= prev) && (series[segEnd] >= series[segStart])
||  (curr <= prev) && (series[segEnd] <= series[segStart])) {
segEnd = i ;
} else {
segments.add(new Segment(series)) ;  // start new segment
segStart = segEnd = i ;              // segments share
--segStart ;                         // last value
}

prev = curr ;
}

return (Segment[]) segments.toArray(new Segment[0]) ;
}

void run(float[] series) {
Segment[] segments = calcSegments(series) ;

for (int i = 0, length = segments.length ; i < length ; ++i ) {
Segment segment = segments[i] ;
System.out.println("segment #" + i + segment) ;
}
}

public static void main(String[] args) {
float[] sample = { 20, 23, 28, 25, 26, 29, 27, 23, 21, 20 } ;

new Sequence().run(sample) ;
}

/*
* segment #0 starting at 0 of length 3 is up
* segment #1 starting at 2 of length 2 is down
* segment #2 starting at 3 of length 3 is up
* segment #3 starting at 5 of length 5 is down
*/
}
``````
I'm sure you can translate this any way you fancy

later edit
If you have Java installed, which you can get otherwise from here you can compile and run the code as:

Code: Select all

``````javac Sequence.java
java -cp . Sequence``````
Last edited by verec on Sun Sep 12, 2004 7:37 pm, edited 1 time in total.

yoyo2000
Roundtable Fellow
Posts: 58
Joined: Fri Jan 30, 2004 10:37 pm
Thank you,Verec,I will study your code.