-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMain.java
More file actions
49 lines (40 loc) · 1.67 KB
/
Main.java
File metadata and controls
49 lines (40 loc) · 1.67 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.stream.Collectors;
import bittrex.BittrexWS;
import bittrex.CurrencyPair;
import bittrex.Trade;
public class Main {
public static void main(String[] args) throws IOException {
BittrexWS ws = new BittrexWS();
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
do {
String readLine = br.readLine();
if (readLine != null && readLine.length() > 0) {
try {
switch (readLine.charAt(0)) {
case 'o':
System.out.println(ws.getOrderBook(new CurrencyPair(readLine.substring(2))));
break;
case 't':
System.out.println("Trades: \n\t" + ws.getTrades(new CurrencyPair(readLine.substring(2))).stream().map(Trade::toString).collect(Collectors.joining("\n\t")));
break;
default:
help();
break;
}
} catch (Throwable t) {
System.out.println("failed " + t.getMessage());
}
} else {
help();
}
} while(true);
}
private static void help() {
System.out.println("type 'o XXX/YYY' to fetch order book.");
System.out.println("type 't XXX/YYY' to fetch last trades.");
System.out.println("where XXX: base currency, YYY: counter currency, i.e. BTC/USDT -> bittrex market USDT-BTC");
}
}