使用mongodb存储日内净值数据 [英] Using mongodb for store intraday equity data

查看:90
本文介绍了使用mongodb存储日内净值数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想存储日间即日交易股票数据.这些数据是合成的(即Price-Volume),需要按顺序维护.如何组织mongodb数据以便非常频繁地更新数据并按所有者名称,日期读取索引? 预先感谢

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 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:

库存

{
    _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 } )

_id关键字段默认情况下已建立索引,因此这样的更新将非常快:

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 } } )

这篇关于使用mongodb存储日内净值数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆