-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
individual files to run js from mongo
- Loading branch information
Ubuntu
committed
Aug 21, 2015
1 parent
a8f8b38
commit fb6a195
Showing
1 changed file
with
15 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" } | ||
]) |