forked from bitsoex/bitso-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBitsoTransactions.java
More file actions
55 lines (44 loc) · 1.42 KB
/
Copy pathBitsoTransactions.java
File metadata and controls
55 lines (44 loc) · 1.42 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
50
51
52
53
54
55
package com.bitso;
import java.math.BigDecimal;
import java.util.ArrayList;
import org.json.JSONArray;
import org.json.JSONObject;
import com.bitso.BitsoTransactions.Transaction.SIDE;
import com.bitso.helpers.Helpers;
public class BitsoTransactions {
public ArrayList<Transaction> list;
public BitsoTransactions(JSONArray a) {
list = new ArrayList<Transaction>(a.length());
for (int i = 0; i < a.length(); i++) {
JSONObject o = a.getJSONObject(i);
Transaction t = new Transaction();
t.date = Long.parseLong(o.getString("date"));
t.tid = o.getLong("tid");
t.price = new BigDecimal(o.getString("price"));
t.amount = new BigDecimal(o.getString("amount"));
t.side = SIDE.valueOf(o.getString("side").toUpperCase());
list.add(t);
}
}
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("Bitso Recent Transactions\n");
for (Transaction t : list) {
sb.append(t);
}
return sb.toString();
}
public static class Transaction {
public enum SIDE {
SELL, BUY
};
public long date;
public long tid;
public BigDecimal price;
public BigDecimal amount;
public SIDE side;
public String toString() {
return Helpers.fieldPrinter(this);
}
}
}