Skip to content

Commit

Permalink
an order might not be immediately executed
Browse files Browse the repository at this point in the history
  • Loading branch information
vogelito committed Jan 30, 2018
1 parent 0e714ac commit 6a389f4
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/main/java/com/bitso/Bitso.java
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,19 @@ public BigDecimal placeSellMarketOrder(BigDecimal majorToSpend, BitsoBook book)
return null;
}

public void waitUntilProcessed(String id) {
while(true) {
BitsoLookupOrders blo = lookupOrder(id);
BookOrder bo = blo.list.get(0);
if (bo.status == BookOrder.STATUS.COMPLETE) return;
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}

public String getDepositAddress() {
return quoteEliminator(sendBitsoPost(baseUrl + "bitcoin_deposit_address"));
}
Expand Down Expand Up @@ -585,6 +598,7 @@ public BookOrder findMatchingOrders(JSONObject o, BitsoBook book) {
}

String id = o.getString("id");
waitUntilProcessed(id);
int counter = 0;
if (++counter < 5) {
BookOrder bo = findMatchingOrders(id, book);
Expand Down

0 comments on commit 6a389f4

Please sign in to comment.