MongoDB: Schema design for stock tick database -


I need to store daily stock closing prices as well as tick data in MongoDB. How do you prepare such a schema? For daily prices, I have to keep a document for each share symbol, such as

  {symbol: "AAPL", quotation: {{Date: '2014-01-01', Value: { Open: 1, high: 1, low: 1, close: 1, quantity: 100}}, {date: '2014-01-02', value: {open: 1, high: 1, lower: 1, close : 1, quantity: 100}}, ...}}   

For tick statistics I can do something like the above, in which there was an array of sub-documents per hour tix is.

However, considering the maximum document size is only 16 MB, I believe limited reach is very fast, especially for tick data.

I know about this approach, will it be a good attitude? To wit. A copy per copy per day?

So, how will you prepare the schema for daily values ​​and keep the data ticking respectively?

I think you are on the right path I

  • each Placing a document for the stock symbol will give you a good overview of all the symbols in the collection. And each document will have a fairly satisfactory shape.
  • In my opinion, if you are close to 16 MB on a document, the schema-design is good enough, it is not easily readable or maintained. Every time you want anything from the document, you have to get lots of data.
  • You mention "a document per symbol per day" for me that this is a sensible way of making data structured. Although I am not familiar with the details in the stock data from the stock, I think this will give you a good foundation for schema design. You split it every day, and you can easily get all the ticks for a given day / hour.
  • Remember, there is no complete solution for schema-design, as long as you think well through it ( is definitely a right / wrong way though ) ;)

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -