FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
bitso-java/src/main/java/com/bitso/BitsoOrderBook.java at master · bitsoex/bitso-java · GitHub
bitsoex
/
bitso-java
Public
Notifications
You must be signed in to change notification settings
Fork
33
Star
40
Code
Issues
6
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
bitso-java
/
src
/
main
/
java
/
com
/
bitso
/
BitsoOrderBook.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
148 lines (118 loc) · 3.68 KB
Breadcrumbs
bitso-java
/
src
/
main
/
java
/
com
/
bitso
/
BitsoOrderBook.java
Copy path
File metadata and controls
148 lines (118 loc) · 3.68 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
package
com
.
bitso
;
import
java
.
math
.
BigDecimal
;
import
java
.
util
.
Comparator
;
import
java
.
util
.
Date
;
import
org
.
json
.
JSONArray
;
import
org
.
json
.
JSONObject
;
import
com
.
bitso
.
helpers
.
Helpers
;
public
class
BitsoOrderBook
{
private
Date
mOrderDate
;
private
int
mSequence
;
private
PublicOrder
[]
mAsks
;
private
PublicOrder
[]
mBids
;
public
BitsoOrderBook
(
JSONObject
o
) {
this
.
mOrderDate
=
Helpers
.
getZonedDatetime
(
o
,
"updated_at"
);
this
.
mSequence
=
Helpers
.
getInt
(
o
,
"sequence"
);
processOrders
(
o
);
}
private
void
processOrders
(
JSONObject
o
) {
// Getting asks
if
(
o
.
has
(
"asks"
)) {
JSONArray
asksArray
=
o
.
getJSONArray
(
"asks"
);
int
totalAsks
=
asksArray
.
length
();
mAsks
=
new
PublicOrder
[
totalAsks
];
for
(
int
i
=
0
;
i
<
totalAsks
;
i
++) {
mAsks
[
i
] =
new
PublicOrder
(
asksArray
.
getJSONObject
(
i
));
}
}
// Getting bids
if
(
o
.
has
(
"bids"
)) {
JSONArray
bidsArray
=
o
.
getJSONArray
(
"bids"
);
int
totalBids
=
bidsArray
.
length
();
mBids
=
new
PublicOrder
[
totalBids
];
for
(
int
i
=
0
;
i
<
totalBids
;
i
++) {
mBids
[
i
] =
new
PublicOrder
(
bidsArray
.
getJSONObject
(
i
));
}
}
}
public
Date
getOrderDate
() {
return
mOrderDate
;
}
public
void
setOrderDate
(
Date
mOrderDate
) {
this
.
mOrderDate
=
mOrderDate
;
}
public
int
getSequence
() {
return
mSequence
;
}
public
void
setSequence
(
int
mSequence
) {
this
.
mSequence
=
mSequence
;
}
public
PublicOrder
[]
getAsks
() {
return
mAsks
;
}
public
void
setAsks
(
PublicOrder
[]
mAsks
) {
this
.
mAsks
=
mAsks
;
}
public
PublicOrder
[]
getBids
() {
return
mBids
;
}
public
void
setBids
(
PublicOrder
[]
mBids
) {
this
.
mBids
=
mBids
;
}
public
String
toString
() {
return
Helpers
.
fieldPrinter
(
this
,
BitsoOrderBook
.
class
);
}
public
class
PublicOrder
implements
Comparable
<
PublicOrder
> {
private
String
mBook
;
private
BigDecimal
mPrice
;
private
BigDecimal
mAmount
;
private
String
mOrderId
;
public
PublicOrder
(
JSONObject
o
) {
mBook
=
Helpers
.
getString
(
o
,
"book"
);
mPrice
=
Helpers
.
getBD
(
o
,
"price"
);
mAmount
=
Helpers
.
getBD
(
o
,
"amount"
);
if
(
o
.
has
(
"oid"
)) {
mOrderId
=
Helpers
.
getString
(
o
,
"oid"
);
}
else
{
mOrderId
=
""
;
}
}
public
String
getBook
() {
return
mBook
;
}
public
void
setBook
(
String
mBook
) {
this
.
mBook
=
mBook
;
}
public
BigDecimal
getPrice
() {
return
mPrice
;
}
public
void
setPrice
(
BigDecimal
mPrice
) {
this
.
mPrice
=
mPrice
;
}
public
BigDecimal
getAmount
() {
return
mAmount
;
}
public
void
setAmount
(
BigDecimal
mAmount
) {
this
.
mAmount
=
mAmount
;
}
public
String
getOrderId
() {
return
mOrderId
;
}
public
void
setOrderId
(
String
mOrderId
) {
this
.
mOrderId
=
mOrderId
;
}
public
String
toString
() {
return
Helpers
.
fieldPrinter
(
this
,
PublicOrder
.
class
);
}
public
int
compareTo
(
PublicOrder
o
) {
return
mPrice
.
compareTo
(
o
.
mPrice
);
}
public
class
Comparators
{
public
Comparator
<
PublicOrder
>
PRICE
=
new
Comparator
<
PublicOrder
>() {
public
int
compare
(
PublicOrder
o1
,
PublicOrder
o2
) {
return
o1
.
mPrice
.
compareTo
(
o2
.
mPrice
);
}
};
}
}
}
Back
|
FazBrowse Home
|
New Git URL