@Then("^the book is empty$") public void the_book_is_empty() throws Throwable { final List<OrderBookRow> actualBuy = FluentIterable.from(matchingUnit.getOrders(OrderSide.Buy)) .transform(OrderBookRow.FROM_Order(matchingUnit)) .toImmutableList(); final List<OrderBookRow> actualSell = FluentIterable.from(matchingUnit.getOrders(OrderSide.Sell)) .transform(OrderBookRow.FROM_Order(matchingUnit)) .toImmutableList(); assertEquals(new ArrayList<OrderBookRow>(), actualBuy); assertEquals(new ArrayList<OrderBookRow>(), actualSell); }
@Given("^the following orders are submitted in this order:$") public void the_following_orders_are_submitted_in_this_order(DataTable orderTable) throws Throwable { final List<OrderEntryRow> orderRows = orderTable.asList(OrderEntryRow.class); for (OrderEntryRow orderRow : orderRows) { matchingUnit.addOrder( new OrderEntry( orderRow.side, orderRow.broker, orderRow.quantity, orderRow.getOrderType())); } }
@Then("^the book looks like:$") public void the_book_looks_like(DataTable expectedBooks) throws Throwable { final List<String> headerColumns = new ArrayList<String>(expectedBooks.raw().get(0)); final int columns = headerColumns.size(); final int sideSize = columns / 2; for (int i = 0; i < columns; i++) { headerColumns.set(i, (i < sideSize ? "Buy " : "Sell ") + headerColumns.get(i)); } final List<List<String>> raw = new ArrayList<List<String>>(); raw.add(headerColumns); final List<List<String>> body = expectedBooks.raw().subList(1, expectedBooks.raw().size()); raw.addAll(body); final DataTable montageTable = expectedBooks.toTable(raw); final List<MontageRow> rows = montageTable.asList(MontageRow.class); final List<OrderBookRow> expectedBids = FluentIterable.from(rows) .filter(MontageRow.NON_EMPTY_BID) .transform(MontageRow.TO_TEST_BID) .toImmutableList(); final List<OrderBookRow> expectedAsks = FluentIterable.from(rows) .filter(MontageRow.NON_EMPTY_ASK) .transform(MontageRow.TO_TEST_ASK) .toImmutableList(); final List<OrderBookRow> actualBuy = FluentIterable.from(matchingUnit.getOrders(OrderSide.Buy)) .transform(OrderBookRow.FROM_Order(matchingUnit)) .toImmutableList(); final List<OrderBookRow> actualSell = FluentIterable.from(matchingUnit.getOrders(OrderSide.Sell)) .transform(OrderBookRow.FROM_Order(matchingUnit)) .toImmutableList(); assertEquals(expectedBids, actualBuy); assertEquals(expectedAsks, actualSell); }
@Then("^the calculated IMP is:$") public void the_calculated_IMP_is(List<Double> imp) { assertThat(matchingUnit.getIndicativeMatchingPrice(), is(imp.get(0))); }
@When("^class auction completes$") public void class_auction_completes() throws Throwable { matchingUnit.auction(); }
@Given("^that reference price is ([0-9]*\\.?[0-9]+)$") public void that_reference_price_is_(double price) throws Throwable { matchingUnit.setReferencePrice(price); }
@Given("^that trading mode for security is \"([^\"]*)\" and phase is \"([^\"]*)\"$") public void that_trading_mode_for_security_is_and_phase_is( TradingMode tradingMode, TradingPhase phase) throws Throwable { matchingUnit.setTradingMode(tradingMode); matchingUnit.setTradingPhase(phase); }