An approach for generating the ticks given the bar could be as follows.
(The quotes leading to the ticks are left as an exercise.)
Let O,C,H,L be the open, close, high and low.
N the number of ticks required.
'O C H L'=: 106 102 109 98
HL=:H,L
N=:10
z=: 0.91207916 0.96361494 0.92080763 0.997349 0.99497231 1.0092876
0.83638168 0.84034246 1.0683546 1.0537125
NB. z is explained later but should be interpreted as the ratio
between 2 subsequent ticks
t=:(i.% <:)N
z1=: (z0=:O+(C-O)* t)*(]* [EMAIL PROTECTED]:-&%{.)*/\z
NB. O={.z1 and C={:z1
hl=: (>./,<./)z1
NB. high and low of z1
hl0=:z0{~ hl i.~z1
[z2=: z0+(z1-z0)*(z1<z0){ HL %&(-&hl0) hl
106 106.03782 104.24738 105.18131 106.6911 109 101.96309 98 100.09259 102
NB. open, close, high and low of z2 are O,C,H,L
z is generated by the Excelfunction NORM.INV(aselect();O/C;(H/L-1)/2) of
which I do not (yet) know a J-equivalent.
(see also http://home.online.no/~pjacklam/notes/invnorm/#The_algorithm )
z is normally distributed around C%O, with standard deviation -:<:H%L (which
is rather arbitrary).
Hope this helps.
R.E. Boss
> -----Oorspronkelijk bericht-----
> Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Namens Dan Bron
> Verzonden: vrijdag 22 februari 2008 20:00
> Aan: General forum
> Onderwerp: [Jgeneral] Bars to ticks
>
> 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
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm