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
store Open High Low Last every x time interval
Moderator: General Moderators
Re: store Open High Low Last every x time interval
Easy wayinosent1 wrote: ...
but all i am doing is creating a zillion records each session and they are not organized into 5, 10, 30, 60 minute intervals
...
- create a simple script adding current value to DB ("table1")
- add a CRON job (run the script e.g. each minute)
- create another script to view statistics - browser use - do the math (OHLC) for selected time period on this side
You can reduce record count in "table1" storing recalculacted data in "table2" and flushing "table1"
Re: store Open High Low Last every x time interval
thanks for the input. i have it working now