开发者

Using mongodb for store intraday equity data

开发者 https://www.devze.com 2023-03-06 19:06 出处:网络
I want to store day bay day trading stock data. These data are composite ( ie Price-Volume ) and needs to be mantained in order. How to organize开发者_Go百科 the mongodb data in order to update the da

I want to store day bay day trading stock data. These data are composite ( ie Price-Volume ) and needs to be mantained in order. How to organize开发者_Go百科 the mongodb data in order to update the data very frequently and reading indexing by equity name,date ? Thanks in advance


You could use a schema something like this:

stocks

{
    _id: "MSFT",
    price: 24.69,
    volume: 53931025,
    date: 20110519
}

Then add indexes over the fields you'll be sorting and filtering by, e.g.

db.stocks.ensureIndex( { date: 1 } )

The _id key field is indexed by default, so updates like this will be very fast:

db.stocks.update( { _id: "MSFT" }, { $set : { price: 25.04 } } )
0

精彩评论

暂无评论...
验证码 换一张
取 消