Hey,
I want to convert a stock chart to the underlying data.
A "tick" is an indication that a trade occured -- for example, when Alice buys
100 IBM from Bob. A "quote" is an indication that someone would like to do a
trade. For example, Alice offers to sell her shares of IBM for $106.09 each.
A "bar" is an aggregation of ticks over a period of time. For example, a
5-minute bar on IBM might record the first (open), last (close), highest and
lowest prices at which IBM was traded during the period of 11:00am to 11:05am.
For example:
symbol: IBM
period: 11:00am to 11:05am
open : 106.09
high : 106.32
low : 106.09
close : 106.25
I have a bunch of such bars, and I would like to generate reasonable
approximations of the ticks and quotes that might have produced them.
For the above example, I would like to generate a series of ticks which "could
have occured" on IBM during the period of 11:00-11:05am to produce that bar.
One way to do this is, obviously, to generate 3 ticks: the first is both the
open and the low at 11:00am, the second is the high at some intermediate time,
and the last is the close at 11:05am.
But I need a more sophisticated series. I would like to generate say, N ticks
over that period, but they need to be constrained by the high/low/open/close of
the bar, and they need to "look reasonable". They should maybe trend a little
(go up for a while, then down, rather than up-down-up-down-up-down), and I
would like quotes which support the ticks (i.e. if I generate a tick at time T
and price P, then I would like to generate some bids a little below P and
offers a little above P, all at or around T).
The ticks and quotes shouldn't be "too far" from the constraints, even if they
conform in aggregate (i.e. I don't want to see quotes $50 away from the market,
even if they never trade and hence do not effect the bar).
Could someone give me some direction or starter code?
-Dan
PS: To visualize this, think of having a bunch of 5-minute bars and converting
them to data which would look like a stock chart for that period:
http://finance.google.com/finance?q=IBM&hl=en
PPS: If it means anything, I guess you could think of ticks as 0-second bars
(if you squint a little).
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm