@Test public void pipetteValueIsOnePipetteDividedByExchangeRateWhenBaseCurrencyEqualsAccountCurreny() { assertThat(cut.calculatePipetteValue(currency("EUR"), new ForexSymbol("EURUSD"), new Price(1.6))) .isEqualTo(new AccuratePrice(0.00000625), ALLOWED_OFFSET); assertThat(cut.calculatePipetteValue(currency("CHF"), new ForexSymbol("CHFJPY"), new Price(160.0))) .isEqualTo(new AccuratePrice(0.000000062500), ALLOWED_OFFSET); }
public AccuratePrice calculatePipetteValue(final Currency accountCurrency, final ForexSymbol tradedSymbol, final Price tradeSymbolPrice) { if (accountCurrency.equals(tradedSymbol.getBaseCurrency())) { return new AccuratePrice(0.00001 / tradeSymbolPrice.asDouble()); } else if (accountCurrency.equals(tradedSymbol.getQuoteCurrency())) { return PIPETTE; } final Optional<AccuratePrice> exchangeRate = exchangeRateStore.getExchangeRate(tradedSymbol.getQuoteCurrency(), accountCurrency); return exchangeRate.map(rate -> new AccuratePrice(0.00001 * exchangeRate.get().asRawValue())) .orElseThrow(() -> createIlegalArgumentsException(accountCurrency, tradedSymbol)); }
PipetteValueCalculator { public AccuratePrice calculatePipetteValue(final Currency accountCurrency, final ForexSymbol tradedSymbol, final Price tradeSymbolPrice) { if (accountCurrency.equals(tradedSymbol.getBaseCurrency())) { return new AccuratePrice(0.00001 / tradeSymbolPrice.asDouble()); } else if (accountCurrency.equals(tradedSymbol.getQuoteCurrency())) { return PIPETTE; } final Optional<AccuratePrice> exchangeRate = exchangeRateStore.getExchangeRate(tradedSymbol.getQuoteCurrency(), accountCurrency); return exchangeRate.map(rate -> new AccuratePrice(0.00001 * exchangeRate.get().asRawValue())) .orElseThrow(() -> createIlegalArgumentsException(accountCurrency, tradedSymbol)); } }
PipetteValueCalculator { public AccuratePrice calculatePipetteValue(final Currency accountCurrency, final ForexSymbol tradedSymbol, final Price tradeSymbolPrice) { if (accountCurrency.equals(tradedSymbol.getBaseCurrency())) { return new AccuratePrice(0.00001 / tradeSymbolPrice.asDouble()); } else if (accountCurrency.equals(tradedSymbol.getQuoteCurrency())) { return PIPETTE; } final Optional<AccuratePrice> exchangeRate = exchangeRateStore.getExchangeRate(tradedSymbol.getQuoteCurrency(), accountCurrency); return exchangeRate.map(rate -> new AccuratePrice(0.00001 * exchangeRate.get().asRawValue())) .orElseThrow(() -> createIlegalArgumentsException(accountCurrency, tradedSymbol)); } PipetteValueCalculator(final ExchangeRateStore exchangeRateStore); }
PipetteValueCalculator { public AccuratePrice calculatePipetteValue(final Currency accountCurrency, final ForexSymbol tradedSymbol, final Price tradeSymbolPrice) { if (accountCurrency.equals(tradedSymbol.getBaseCurrency())) { return new AccuratePrice(0.00001 / tradeSymbolPrice.asDouble()); } else if (accountCurrency.equals(tradedSymbol.getQuoteCurrency())) { return PIPETTE; } final Optional<AccuratePrice> exchangeRate = exchangeRateStore.getExchangeRate(tradedSymbol.getQuoteCurrency(), accountCurrency); return exchangeRate.map(rate -> new AccuratePrice(0.00001 * exchangeRate.get().asRawValue())) .orElseThrow(() -> createIlegalArgumentsException(accountCurrency, tradedSymbol)); } PipetteValueCalculator(final ExchangeRateStore exchangeRateStore); AccuratePrice calculatePipetteValue(final Currency accountCurrency, final ForexSymbol tradedSymbol,
            final Price tradeSymbolPrice); }
PipetteValueCalculator { public AccuratePrice calculatePipetteValue(final Currency accountCurrency, final ForexSymbol tradedSymbol, final Price tradeSymbolPrice) { if (accountCurrency.equals(tradedSymbol.getBaseCurrency())) { return new AccuratePrice(0.00001 / tradeSymbolPrice.asDouble()); } else if (accountCurrency.equals(tradedSymbol.getQuoteCurrency())) { return PIPETTE; } final Optional<AccuratePrice> exchangeRate = exchangeRateStore.getExchangeRate(tradedSymbol.getQuoteCurrency(), accountCurrency); return exchangeRate.map(rate -> new AccuratePrice(0.00001 * exchangeRate.get().asRawValue())) .orElseThrow(() -> createIlegalArgumentsException(accountCurrency, tradedSymbol)); } PipetteValueCalculator(final ExchangeRateStore exchangeRateStore); AccuratePrice calculatePipetteValue(final Currency accountCurrency, final ForexSymbol tradedSymbol,
            final Price tradeSymbolPrice);  }