public void fillMarketOrdersUsing(QuoteBar aQuoteBar) { TickerSymbol tickerSymbol = new TickerSymbol(aQuoteBar.symbol()); int totalQuantityAvailable = aQuoteBar .totalQuantity() .toBigInteger() .intValue(); Collection<BuyOrder> openOrders = this.buyOrderRepository().openOrdersOf(tickerSymbol); this.marketFillService().fillMarketBuyOrders(openOrders, totalQuantityAvailable); }
public void testOpenOrdersOf() throws Exception { this.repository.save(this.buyOrderFixture1()); this.repository.save(this.buyOrderFixture2()); this.repository.save(this.buyOrderFixture3()); Collection<BuyOrder> foundOrders = this.repository.openOrdersOf(this.googTickerFixture()); assertNotNull(foundOrders); assertFalse(foundOrders.isEmpty()); assertEquals(2, foundOrders.size()); }
this.buyOrderRepository.openOrdersOf(tickerSymbol);
public void testUnmatchedFillMarketOrders() throws Exception { BuyOrder[] buyOrders = this.buyOrderFixture(); for (BuyOrder buyOrder : buyOrders) { this.buyOrderRepository.save(buyOrder); } QuoteBar quoteBar = this.quoteBarUnmatchedFixture(); TickerSymbol tickerSymbol = new TickerSymbol(quoteBar.symbol()); int totalQuantityAvailable = quoteBar .totalQuantity() .toBigInteger() .intValue(); Collection<BuyOrder> openOrders = this.buyOrderRepository.openOrdersOf(tickerSymbol); MarketFillService marketFillService = new MarketFillService(this.buyOrderRepository); marketFillService.fillMarketBuyOrders(openOrders, totalQuantityAvailable); int stillOpenCount = 0; for (BuyOrder previouslyOpenOrder : buyOrders) { assertFalse(previouslyOpenOrder.isFilled()); assertTrue(previouslyOpenOrder.isOpen()); ++stillOpenCount; } assertEquals(buyOrders.length, stillOpenCount); }