Skip to content

Commit

Permalink
individual files to run js from mongo
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed Aug 21, 2015
1 parent a8f8b38 commit fb6a195
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions mongo-queries/group_ltc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// group ltc trades by second, with volume-weigted price
db.ltc_trades.aggregate([
{ $match: { timestamp: { $gt: 1440117467} } },
{ $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} },
{ $out: "grouped_ltc_trades" }
])

0 comments on commit fb6a195

Please sign in to comment.