store Open High Low Last every x time interval
Posted: Sun Nov 20, 2011 7:34 pm
Hi
I am using code that captures in real time stock index prices changing, tick by tick, while the session is open.
That data comes in as a variable. i'll call it $price
the code then inputs the new price into a MySQL table called price.
but all i am doing is creating a zillion records each session and they are not organized into 5, 10, 30, 60 minute intervals
what i am trying to figure out is how to store the prices temporarily and then at a certain time interval, then input to the DB
example, the session begins at 10 AM:
$price @ 10:00:00 am = 11000
store: $open = 11000 $high = 11000 low = 11000 last = 11000
$price @ 10:00:30 am = 11010
store: $open = 11000 $high = 11010 low = 11000 last = 11010
$price @ 10:01:00 am = 10990
store: $open = 11000 $high = 11010 low = 10990 last = 10990
etc
so i need to find a way to compare $price to the first $price at the start of the time interval, and then at, for example, in a 60 minute interval, at 10:59:59 AM upload the OHLC for that hour to the DB
to make it easier the start time can be whenever the page is opened
I am using code that captures in real time stock index prices changing, tick by tick, while the session is open.
That data comes in as a variable. i'll call it $price
the code then inputs the new price into a MySQL table called price.
but all i am doing is creating a zillion records each session and they are not organized into 5, 10, 30, 60 minute intervals
what i am trying to figure out is how to store the prices temporarily and then at a certain time interval, then input to the DB
example, the session begins at 10 AM:
$price @ 10:00:00 am = 11000
store: $open = 11000 $high = 11000 low = 11000 last = 11000
$price @ 10:00:30 am = 11010
store: $open = 11000 $high = 11010 low = 11000 last = 11010
$price @ 10:01:00 am = 10990
store: $open = 11000 $high = 11010 low = 10990 last = 10990
etc
so i need to find a way to compare $price to the first $price at the start of the time interval, and then at, for example, in a 60 minute interval, at 10:59:59 AM upload the OHLC for that hour to the DB
to make it easier the start time can be whenever the page is opened