INNER CODE UNIT · Java
handleMarketMakerOrders
qtds35k/HighFrequencyTradingBot · src/trading/Main.java:158
private static boolean handleMarketMakerOrders(Map<String, OrderCycle> marketMakerOrderMap, HttpHelper hh, Manager bigBoss) throws IOException, InterruptedException {
boolean adjustCounter = false;
for (Map.Entry<String, OrderCycle> entry : marketMakerOrderMap.entrySet()) {
OrderCycle order = entry.getValue();
order.updateOrderStatus(); // SELLs may happen here
String symbol = order.getSymbol();
Integer qty = order.getQty();
Double priceToBuy = order.getPriceToBuy();
Double currenBid = bigBoss.getBidBySymbol(symbol);
if (order.getState() == 1) {
if (!priceToBuy.equals(currenBid)) {
if (hh.cancelOrder(order.getOrderIdCancel(), order.getOrderIdBuy())) {
// 1. the order is still unbought
// 2. priceToBuy does not match current bid price
// 3. it's indeed cancelled after the cancel command
// if all the above are satisfied, terminate the order cycle