469,086 Members | 1,133 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,086 developers. It's quick & easy.

general advice on data storage

Hi,

I'm new to vb.net and would be grateful if anyone could offer some
advice on the best way to approach this problem:

I wish to dynamically capture pricing information e.g. 10 stock prices
and use this data to generate a number of graphs over time (in real
time) of each share price. This means for each share I need to store a
price and a timestamp.

I would need to collect around 600 pairs of data per stock (once per
second for 10 mins), so around 6000 in total, then roll the data
forward so that I only ever keep 600 records i.e. always have the last
10 minutes worth of data for each stock.

I would therefore like to know the best method to store this data on
the fly. I can only think of an array or dataset as a way to do this
but maybe there are better solutions I am unaware of?

Thanks for any help,

Mike

Nov 21 '05 #1
5 1027
Mike,

It is a very rough answer for a newsgroup, however I think that I would
first try for an SQLExpress or the old MSDE database. With a table per
share.

Than add it everytime rows using the insert to the share tables with a new
datatime field as key.

Creating those tables is easy to do in VBNet in a for each loop.

To get than a datatable for the last 10 minutes is just getting that with a
fill with a "where" clause the < datatime. It is not slow however I don't
know if it is quick enough.

It needs of course consequent deleting with another seperate running program
from the old rows.

Using the dataset/datatable itself inside a dataset will almost for sure
break you up in VS2003. Deleting of that will probably be to slow (this
should be improved in VS2005, however I did not try it yet)

Just as first idea when I saw your question.

Cor
Nov 21 '05 #2
Thanks Cor - much appreciated. I'll try out your suggestions.

Nov 21 '05 #3
How often will the graph be redrawn?

In addition to Cor's reply, here's another option:
Use a linked list. Something like the following [psuedocode]:

public struct StockHistoryItem
Dim price as double
Dim timestamp as DateTime
end struct

class StockHistory
Private data() as StockHistoryItem
Private startData as Long = 0
Private endData as Long = 0
Private maxSize as Long = 0

public Sub New(byref size as Long)
if Size>0 then
maxSize = size
Redim data(maxSize) As StockHistoryItem
else
throw new Exception - invalid
end if
end sub

public sub AddItem(ByVal newItem as StockHistoryItem)
if endData = maxSize then
endData = 0
else
endData += 1
end if
data(endData) = newItem
if endData = maxSize Then
startData = 0
else
startData += 1
end if
end sub
end class

Bear in mind I don't think the upper bound stuff is correct - you might need
(endData + 1) in the "If" statements involving it. You obviously need
functions to retrieve data - you could implement IEnumerable or have
something like:
public sub GetItem(byref index as Long)
if index >=0 AND index <= maxsize - 1 then
' You also need to check in case you haven't yet filled the
structure with values.
GetItem = data(Dim item As Long = (index + startData) Mod
maxSize)
end if
end sub
If you took Cor's route, you don't necessarily need an entirely separate
program, you could clean up old rows each time you draw the graph.

Jevon
"Mike" <my***@pearcey2001.freeserve.co.uk> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Hi,

I'm new to vb.net and would be grateful if anyone could offer some
advice on the best way to approach this problem:

I wish to dynamically capture pricing information e.g. 10 stock prices
and use this data to generate a number of graphs over time (in real
time) of each share price. This means for each share I need to store a
price and a timestamp.

I would need to collect around 600 pairs of data per stock (once per
second for 10 mins), so around 6000 in total, then roll the data
forward so that I only ever keep 600 records i.e. always have the last
10 minutes worth of data for each stock.

I would therefore like to know the best method to store this data on
the fly. I can only think of an array or dataset as a way to do this
but maybe there are better solutions I am unaware of?

Thanks for any help,

Mike

Nov 21 '05 #4
Sorry, I should add to this that it obviously isn't necessarily the best
option if memory is an issue, but for the amount of data you mention it
shouldn't be too much of a problem.

Jevon

"Jevon" <pl****@ask.com> wrote in message
news:ek**************@tk2msftngp13.phx.gbl...
How often will the graph be redrawn?

In addition to Cor's reply, here's another option:
Use a linked list. Something like the following [psuedocode]:

public struct StockHistoryItem
Dim price as double
Dim timestamp as DateTime
end struct

class StockHistory
Private data() as StockHistoryItem
Private startData as Long = 0
Private endData as Long = 0
Private maxSize as Long = 0

public Sub New(byref size as Long)
if Size>0 then
maxSize = size
Redim data(maxSize) As StockHistoryItem
else
throw new Exception - invalid
end if
end sub

public sub AddItem(ByVal newItem as StockHistoryItem)
if endData = maxSize then
endData = 0
else
endData += 1
end if
data(endData) = newItem
if endData = maxSize Then
startData = 0
else
startData += 1
end if
end sub
end class

Bear in mind I don't think the upper bound stuff is correct - you might
need (endData + 1) in the "If" statements involving it. You obviously need
functions to retrieve data - you could implement IEnumerable or have
something like:
public sub GetItem(byref index as Long)
if index >=0 AND index <= maxsize - 1 then
' You also need to check in case you haven't yet filled the
structure with values.
GetItem = data(Dim item As Long = (index + startData) Mod
maxSize)
end if
end sub
If you took Cor's route, you don't necessarily need an entirely separate
program, you could clean up old rows each time you draw the graph.

Jevon
"Mike" <my***@pearcey2001.freeserve.co.uk> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Hi,

I'm new to vb.net and would be grateful if anyone could offer some
advice on the best way to approach this problem:

I wish to dynamically capture pricing information e.g. 10 stock prices
and use this data to generate a number of graphs over time (in real
time) of each share price. This means for each share I need to store a
price and a timestamp.

I would need to collect around 600 pairs of data per stock (once per
second for 10 mins), so around 6000 in total, then roll the data
forward so that I only ever keep 600 records i.e. always have the last
10 minutes worth of data for each stock.

I would therefore like to know the best method to store this data on
the fly. I can only think of an array or dataset as a way to do this
but maybe there are better solutions I am unaware of?

Thanks for any help,

Mike


Nov 21 '05 #5
Thanks for the alternative. I would ideally like to redraw the graph
each time a new data point is stored, so I'm hoping once a second.

I'm not sure whether the performance of graphing add-ins would be able
to handle this or not, but maybe I could resort to drawing it if they
can't. My ultimate aim would be to have each of these graphs running
within a datagrid cell (which would most likely require me to draw
manually) but that is way beyond my current level so I'll save that
part of it as a project for the future :-)

Thanks again,

Mike

Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by SophistiCat | last post: by
9 posts views Thread by pankaj_wolfhunter | last post: by
3 posts views Thread by James Armstrong | last post: by
7 posts views Thread by Joe Ross | last post: by
3 posts views Thread by Agnes | last post: by
37 posts views Thread by dmoran21 | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by kglaser89 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.