-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathOrderBook.java
More file actions
25 lines (17 loc) · 835 Bytes
/
Copy pathOrderBook.java
File metadata and controls
25 lines (17 loc) · 835 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package bittrex;
import java.math.BigDecimal;
import java.util.TreeMap;
import java.util.stream.Collectors;
public class OrderBook {
public final TreeMap<BigDecimal, BigDecimal> asks = new TreeMap<>();
public final TreeMap<BigDecimal, BigDecimal> bids = new TreeMap<>((k1, k2) -> -k1.compareTo(k2));
public OrderBook(TreeMap<BigDecimal, BigDecimal> asks, TreeMap<BigDecimal, BigDecimal> bids) {
this.asks.putAll(asks);
this.bids.putAll(bids);
}
@Override
public String toString() {
return "Order book:\n\tasks: " + asks.entrySet().stream().map(e -> e.getKey() + " -> " + e.getValue()).collect(Collectors.joining(","))
+ "\n\tbids: " + bids.entrySet().stream().map(e -> e.getKey() + " -> " + e.getValue()).collect(Collectors.joining(","));
}
}