Created
November 8, 2015 06:13
-
-
Save agran/7a054bce084ef0e90ec3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@SuppressWarnings({ "unchecked", "rawtypes" }) | |
public SortableList<BigInteger, Order> getOrdersSortableList(long have, long want, boolean filter) | |
{ | |
//FILTER ALL KEYS | |
Collection<BigInteger> keys = ((BTreeMap<Tuple4, BigInteger>) this.haveWantKeyMap).subMap( | |
Fun.t4(have, want, null, null), | |
Fun.t4(have, want, Fun.HI(), Fun.HI())).values(); | |
//Filters orders with unacceptably small amount. These orders have not worked | |
if(filter){ | |
Iterator<BigInteger> iter = keys.iterator(); | |
while (iter.hasNext()) { | |
Order order = this.get(iter.next()); | |
BigDecimal increment = order.calculateBuyIncrement(order, DBSet.getInstance()); | |
BigDecimal amount = order.getAmountLeft(); | |
amount = amount.subtract(amount.remainder(increment)); | |
if (amount.compareTo(BigDecimal.ZERO) <= 0) | |
iter.remove(); | |
} | |
} | |
//RETURN | |
return new SortableList<BigInteger, Order>(this, keys); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment