-
Type: Bug
-
Resolution: Cannot Reproduce
-
Priority: Major - P3
-
None
-
Affects Version/s: 6.0.5
-
Component/s: None
-
ALL
Example:
I have the following documents
// 759 { "symbol": "MA309", "volume": NumberInt("14"), "timestamp": ISODate("2023-04-28T09:57:59.000Z") }// 760 { "symbol": "rb2310", "volume": NumberInt("1"), "timestamp": ISODate("2023-04-28T09:57:59.000Z") }// 761 { "symbol": "MA309", "volume": NumberInt("6"), "timestamp": ISODate("2023-04-28T09:57:59.001Z") }// 762 { "symbol": "rb2310", "volume": NumberInt("52"), "timestamp": ISODate("2023-04-28T09:57:59.5Z") }// 763 { "symbol": "MA309", "volume": NumberInt("7"), "timestamp": ISODate("2023-04-28T09:58:00.000Z") }// 764 { "symbol": "MA309", "volume": NumberInt("226"), "timestamp": ISODate("2023-04-28T09:58:00.001Z") }// 765 { "symbol": "rb2310", "volume": NumberInt("17"), "timestamp": ISODate("2023-04-28T09:58:00.5Z") }// 766 { "symbol": "MA309", "volume": NumberInt("108"), "timestamp": ISODate("2023-04-28T09:58:01.000Z") }// 767 { "symbol": "rb2310", "volume": NumberInt("4"), "timestamp": ISODate("2023-04-28T09:58:01.000Z") }// 768 { "symbol": "rb2310", "volume": NumberInt("19"), "timestamp": ISODate("2023-04-28T09:58:01.5Z") }// 769 { "symbol": "MA309", "volume": NumberInt("2"), "timestamp": ISODate("2023-04-28T09:58:02.000Z") }// 770 { "symbol": "rb2310", "volume": NumberInt("1"), "timestamp": ISODate("2023-04-28T09:58:02.000Z") }
Aggregate using the following
db.getCollection("ticks").aggregate([{ $group: { _id: { symbol: "$symbol", minute: { $dateToString: { format: "%Y-%m-%d %H:%M", date: "$timestamp", } }, }, volume: { $sum: "$volume" } } }])
If $sum turns out to be 10, then there is a 1% chance that the incidental calculation will be 20.