public static synchronized StreamingQuoteApplicationService streamingQuoteApplicationService() { if (streamingQuoteApplicationService == null) { streamingQuoteApplicationService = new StreamingQuoteApplicationService( InMemoryStreamingQuoteRepository.instance()); } return streamingQuoteApplicationService; }
public void testUpdateStreamingQuoteAndQueryLatestPrice() throws Exception { QuoteBar googQuoteBar = this.googQuoteBarFixture(); this.streamingQuoteApplicationService() .updateStreamingQuoteWith(googQuoteBar); Money googPrice = this.streamingQuoteApplicationService() .latestPriceFor(new TickerSymbol("GOOG")); assertEquals(googQuoteBar.price(), googPrice); QuoteBar orclQuoteBar = this.orclQuoteBarFixture(); this.streamingQuoteApplicationService() .updateStreamingQuoteWith(orclQuoteBar); Money orclPrice = this.streamingQuoteApplicationService() .latestPriceFor(new TickerSymbol("ORCL")); assertEquals(orclQuoteBar.price(), orclPrice); QuoteBar googUpdatedQuoteBar = this.googUpdatedQuoteBarFixture(); this.streamingQuoteApplicationService() .updateStreamingQuoteWith(googUpdatedQuoteBar); googPrice = this.streamingQuoteApplicationService() .latestPriceFor(new TickerSymbol("GOOG")); assertEquals(googUpdatedQuoteBar.price(), googPrice); assertFalse(googUpdatedQuoteBar.price().equals(googQuoteBar.price())); }
@Override public void inform(QuoteBar aQuoteBar) { DomainEventPublisher.instance().reset(); ApplicationServiceRegistry .streamingQuoteApplicationService() .updateStreamingQuoteWith(aQuoteBar); DomainEventPublisher.instance().reset(); ApplicationServiceRegistry .vwapApplicationService() .fillAlgoOrdersUsing(aQuoteBar); } }
public Money latestPriceFor(TickerSymbol aTickerSymbol) { StreamingQuote streamingQuote = this.streamingQuoteRepository() .streamingQuoteOfSymbol(aTickerSymbol.symbol()); return streamingQuote == null ? null : streamingQuote.quote().price(); }
@Override public void inform(QuoteBar aQuoteBar) { DomainEventPublisher.instance().reset(); ApplicationServiceRegistry .streamingQuoteApplicationService() .updateStreamingQuoteWith(aQuoteBar); DomainEventPublisher.instance().reset(); ApplicationServiceRegistry .buyOrderApplicationService() .fillMarketOrdersUsing(aQuoteBar); } }
public void updateStreamingQuoteWith(QuoteBar aQuoteBar) { StreamingQuote streamingQuote = this.streamingQuoteRepository() .streamingQuoteOfSymbol(aQuoteBar.symbol()); if (streamingQuote == null) { streamingQuote = new StreamingQuote( new Quote( new TickerSymbol(aQuoteBar.symbol()), aQuoteBar.price())); } else { streamingQuote.updateWith(aQuoteBar.price()); } this.streamingQuoteRepository().save(streamingQuote); }
public static synchronized StreamingQuoteApplicationService streamingQuoteApplicationService() { if (streamingQuoteApplicationService == null) { streamingQuoteApplicationService = new StreamingQuoteApplicationService( InMemoryStreamingQuoteRepository.instance()); } return streamingQuoteApplicationService; } }
@Override protected void setUp() throws Exception { this.streamingQuoteApplicationService = new StreamingQuoteApplicationService( InMemoryStreamingQuoteRepository.instance()); super.setUp(); }