Skip to content

Commit

Permalink
aggregate trades by timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed Aug 21, 2015
1 parent d82b25e commit a8f8b38
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions collect-data/queries.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
db.ltc_trades.aggregate([
{ $group: {
_id: '$timestamp',
total_price: { $sum: { $multiply: [ "$price", "$amount" ] } },
total_quantity: { $sum: "$amount" }
} },
{ $project: {
price: { $divide: [ "$total_price", "$total_quantity" ] },
amount: "$total_quantity"
} },
{ $sort: {_id: 1} }
])

0 comments on commit a8f8b38

Please sign in to comment.