Author |
Topic: data structures for stock history (Read 3744 times) |
|
inexorable
Full Member
Posts: 211
|
|
data structures for stock history
« on: Aug 3rd, 2011, 11:58am » |
Quote Modify
|
Suppose that you have access to a file which contains the closing price for 10,000 stock tickers on each day over a period of 10 years. Suppose also that you must create a component of a computer program which will be called thousands to hundreds of thousands of times per day on many different days to: (A) Retrieve the closing price associated with a given stock ticker for a given date. (B) Iterate through all stock tickers that have price information available on a given date. (C) Find the last date before a given date for which a given stock ticker had closing price information available. What data structures would you use to organize this stock information to best satisfy (A), (B) and (C)?
|
|
IP Logged |
|
|
|
towr
wu::riddles Moderator Uberpuzzler
Some people are average, some are just mean.
Gender:
Posts: 13730
|
|
Re: data structures for stock history
« Reply #1 on: Aug 3rd, 2011, 1:14pm » |
Quote Modify
|
You could use b-trees to build indexes on those properties. Or just throw it in a relational database.
|
|
IP Logged |
Wikipedia, Google, Mathworld, Integer sequence DB
|
|
|
inexorable
Full Member
Posts: 211
|
|
Re: data structures for stock history
« Reply #2 on: Aug 4th, 2011, 11:59am » |
Quote Modify
|
I think solution expected was using inmemory data structures(like bigtable, memcached etc), assuming you have clusters of machines available at your disposal.
|
|
IP Logged |
|
|
|
agent_purge
Newbie
Posts: 4
|
|
Re: data structures for stock history
« Reply #3 on: Aug 6th, 2011, 10:27am » |
Quote Modify
|
For A and B, keep an index on dates. At each leaf, keep another index (B tree) on stocks for that date. For C, another data structure is needed. You can keep information about gaps in dates for each stock indexed by stock. This data structure should not take much space as date entries are compressed into intervals.
|
|
IP Logged |
|
|
|
Neetasha
Newbie
Posts: 2
|
|
data structures for stock history
« Reply #4 on: Sep 15th, 2011, 9:21pm » |
Quote Modify
|
Data structures are generally based on the ability of a computer to fetch and store data at any place in its memory, specified by an address,a bit string that can be itself stored in memory and manipulated by the program.You could use b-trees to build indexes on those properties.
|
|
IP Logged |
|
|
|
|