Examples of BuyOrder


Examples of com.mcorrigal.matchingEngine.order.BuyOrder

  }
 
  @Test
  public void matchingEngineMatchesBuyOrderToSellOrderAtEqualPriceAndQuantity() {
      SellOrder sell = OrderFactory.newLimitSell("SELL", "30", "100");
    BuyOrder buy = OrderFactory.newLimitBuy("BUY", "30", "100");
        doReturn(sell).when(orderBook).findMatchForBuyOrder(Quantity.create("100"), Price.create("30"));
    matchingEngine.newOrderRequest(buy);
    verify(orderBook, never()).newBuyOrder(buy);
    verify(orderBook, times(1)).removeSellOrder(sell);
  }
View Full Code Here

Examples of com.mcorrigal.matchingEngine.order.BuyOrder

    verify(orderBook, times(1)).removeSellOrder(sell);
  }

    @Test
    public void matchingEngineMatchesSellOrderToSellOrderAtEqualPriceAndQuantity() {
        BuyOrder buy = OrderFactory.newLimitBuy("BUY", "30", "100");
        SellOrder sell = OrderFactory.newLimitSell("SELL", "30", "100");
        doReturn(buy).when(orderBook).findMatchForSellOrder(Quantity.create("100"), Price.create("30"));
        matchingEngine.newOrderRequest(sell);
        verify(orderBook, never()).newSellOrder(sell);
        verify(orderBook, times(1)).removeBuyOrder(buy);
View Full Code Here

Examples of com.mcorrigal.matchingEngine.order.BuyOrder

  @Given("^a matching engine with the following order book:$")
  public void aLoadedOrderBook(List<SpecifiedOrderBookLevel> orderBookLevels) throws Throwable {
    environment = new Environment();
   
    for (SpecifiedOrderBookLevel bookLevel : orderBookLevels) {
      BuyOrder buyOrder = bookLevel.getBidSideAsShortHandDescription().manufactureNewOrder();
      SellOrder sellOrder = bookLevel.getAskSideAsShortHandDescription().manufactureNewOrder();
      if (buyOrder != null) sendOrder(buyOrder);
      if (sellOrder != null) sendOrder(sellOrder);
    }
  }
View Full Code Here

Examples of com.mcorrigal.matchingEngine.order.BuyOrder

    assertTrue(asks.size() == 1);
  }
 
  @Test
  public void removeBuyOrder() {
    BuyOrder buyA = OrderFactory.newLimitBuy("A", "25", "100");
    BuyOrder buyB = OrderFactory.newLimitBuy("B", "26", "100");
    orderBook.newBuyOrder(buyA);
    orderBook.newBuyOrder(buyB);
    assertThat("buy order removed from orderBook", orderBook.removeBuyOrder(buyA), is(true));
    assertThat("number of bids in order book", bids.size(), is(1));
    assertThat("remaining order in order book", bids.get(0).equals(buyB), is(true));
View Full Code Here

Examples of com.mcorrigal.matchingEngine.order.BuyOrder

        assertThat("remaining order in order book", asks.get(0).equals(sellB), is(true));
  }
 
  @Test
  public void snapshotOrderBook() {
    BuyOrder buyA = OrderFactory.newLimitBuy("A", "25", "100");
    SellOrder sellA = OrderFactory.newLimitSell("A", "25", "100");
    orderBook.newBuyOrder(buyA);
    orderBook.newSellOrder(sellA);
    OrderBookSnapshot snapshot = orderBook.snapshot();
        assertTrue(snapshot.getBidSideSnapshot().getAll().contains(buyA));
View Full Code Here

Examples of com.mcorrigal.matchingEngine.order.BuyOrder

        assertThat(match.equals(sellOrder), is(true));
    }

    @Test
    public void testFindMatchForSellOrder() throws Exception {
        BuyOrder buyOrder = OrderFactory.newLimitBuy("BUY", "95", "100");
        orderBook.newBuyOrder(buyOrder);
        Order match = orderBook.findMatchForSellOrder(Quantity.create("100"), Price.create("95"));
        assertThat(match.equals(buyOrder), is(true));
    }
View Full Code Here

Examples of com.mcorrigal.matchingEngine.order.BuyOrder

        Price.create(price),
        Quantity.create(quantity));
  }
 
  public static BuyOrder newLimitBuy(OrderId id, Price price, Quantity quantity) {
    return new BuyOrder(
        id,
                OrderType.LIMIT,
        price,
        quantity);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.