@Test public void unblocksCurrenciesWhenVolumeIsReturned() { cut.requestVolume(SYMBOL_EURUSD, SOME_PRICE, SOME_PRICE, SOME_STEP_SIZE).get().releaseVolume(); verify(currencyBlocker).unblockCurrencies(SYMBOL_EURUSD); }
@Override public Optional<UsedVolumeManagement> requestVolume(final ForexSymbol symbol, final Price currentPrice, final Price pipLostOnStopLoose, final Volume allowedStepSize) { if (!currencyBlocker.isTradingAllowed(symbol)) { return Optional.empty(); } currencyBlocker.blockCurrencies(symbol); final Volume volume = volumeRounder.round(volumeCalculator.calculateVolumeForTrade( pipetteValueCalculator.calculatePipetteValue(balance.getCurrency(), symbol, currentPrice), pipLostOnStopLoose, moneyProvider.calculateMoneyToRisk(balance)), allowedStepSize); return Optional.of(new UsedVolumeManagement() { @Override public void releaseVolume() { currencyBlocker.unblockCurrencies(symbol); } @Override public Volume getVolume() { return volume; } }); }
DefaultMoneyManagement implements MoneyManagement { @Override public Optional<UsedVolumeManagement> requestVolume(final ForexSymbol symbol, final Price currentPrice, final Price pipLostOnStopLoose, final Volume allowedStepSize) { if (!currencyBlocker.isTradingAllowed(symbol)) { return Optional.empty(); } currencyBlocker.blockCurrencies(symbol); final Volume volume = volumeRounder.round(volumeCalculator.calculateVolumeForTrade( pipetteValueCalculator.calculatePipetteValue(balance.getCurrency(), symbol, currentPrice), pipLostOnStopLoose, moneyProvider.calculateMoneyToRisk(balance)), allowedStepSize); return Optional.of(new UsedVolumeManagement() { @Override public void releaseVolume() { currencyBlocker.unblockCurrencies(symbol); } @Override public Volume getVolume() { return volume; } }); } }
DefaultMoneyManagement implements MoneyManagement { @Override public Optional<UsedVolumeManagement> requestVolume(final ForexSymbol symbol, final Price currentPrice, final Price pipLostOnStopLoose, final Volume allowedStepSize) { if (!currencyBlocker.isTradingAllowed(symbol)) { return Optional.empty(); } currencyBlocker.blockCurrencies(symbol); final Volume volume = volumeRounder.round(volumeCalculator.calculateVolumeForTrade( pipetteValueCalculator.calculatePipetteValue(balance.getCurrency(), symbol, currentPrice), pipLostOnStopLoose, moneyProvider.calculateMoneyToRisk(balance)), allowedStepSize); return Optional.of(new UsedVolumeManagement() { @Override public void releaseVolume() { currencyBlocker.unblockCurrencies(symbol); } @Override public Volume getVolume() { return volume; } }); } DefaultMoneyManagement();  DefaultMoneyManagement(final Ratio moneyPerTrade);   DefaultMoneyManagement(final TradeBlocker currencyBlocker, final RiskMoneyProvider moneyProvider,
            final PipetteValueCalculator pipetteValueCalculator, final VolumeCalculator volumeCalculator,
            final VolumeStepSizeRounder volumeRounder, final ExchangeRateStore exchangeRateStore); }
DefaultMoneyManagement implements MoneyManagement { @Override public Optional<UsedVolumeManagement> requestVolume(final ForexSymbol symbol, final Price currentPrice, final Price pipLostOnStopLoose, final Volume allowedStepSize) { if (!currencyBlocker.isTradingAllowed(symbol)) { return Optional.empty(); } currencyBlocker.blockCurrencies(symbol); final Volume volume = volumeRounder.round(volumeCalculator.calculateVolumeForTrade( pipetteValueCalculator.calculatePipetteValue(balance.getCurrency(), symbol, currentPrice), pipLostOnStopLoose, moneyProvider.calculateMoneyToRisk(balance)), allowedStepSize); return Optional.of(new UsedVolumeManagement() { @Override public void releaseVolume() { currencyBlocker.unblockCurrencies(symbol); } @Override public Volume getVolume() { return volume; } }); } DefaultMoneyManagement();  DefaultMoneyManagement(final Ratio moneyPerTrade);   DefaultMoneyManagement(final TradeBlocker currencyBlocker, final RiskMoneyProvider moneyProvider,
            final PipetteValueCalculator pipetteValueCalculator, final VolumeCalculator volumeCalculator,
            final VolumeStepSizeRounder volumeRounder, final ExchangeRateStore exchangeRateStore); @Override Optional<UsedVolumeManagement> requestVolume(final ForexSymbol symbol, final Price currentPrice,
            final Price pipLostOnStopLoose, final Volume allowedStepSize); @Override void updateBalance(final Money money); @Override void updateExchangeRate(final ForexSymbol currencyExchange, final Price exchangeRate); }
DefaultMoneyManagement implements MoneyManagement { @Override public Optional<UsedVolumeManagement> requestVolume(final ForexSymbol symbol, final Price currentPrice, final Price pipLostOnStopLoose, final Volume allowedStepSize) { if (!currencyBlocker.isTradingAllowed(symbol)) { return Optional.empty(); } currencyBlocker.blockCurrencies(symbol); final Volume volume = volumeRounder.round(volumeCalculator.calculateVolumeForTrade( pipetteValueCalculator.calculatePipetteValue(balance.getCurrency(), symbol, currentPrice), pipLostOnStopLoose, moneyProvider.calculateMoneyToRisk(balance)), allowedStepSize); return Optional.of(new UsedVolumeManagement() { @Override public void releaseVolume() { currencyBlocker.unblockCurrencies(symbol); } @Override public Volume getVolume() { return volume; } }); } DefaultMoneyManagement();  DefaultMoneyManagement(final Ratio moneyPerTrade);   DefaultMoneyManagement(final TradeBlocker currencyBlocker, final RiskMoneyProvider moneyProvider,
            final PipetteValueCalculator pipetteValueCalculator, final VolumeCalculator volumeCalculator,
            final VolumeStepSizeRounder volumeRounder, final ExchangeRateStore exchangeRateStore); @Override Optional<UsedVolumeManagement> requestVolume(final ForexSymbol symbol, final Price currentPrice,
            final Price pipLostOnStopLoose, final Volume allowedStepSize); @Override void updateBalance(final Money money); @Override void updateExchangeRate(final ForexSymbol currencyExchange, final Price exchangeRate);  }