@Test public void testCreate() { Optional<OrderCreatedDto> id = hitbtcWsService.create("", from, to, amount, price); HitbtcCreateRequestDto request = messageCaptor.getValue(); HitbtcCreateRequestDto.OrderBody params = request.getParams(); assertThat(request.getMethod()).isEqualTo("newOrder"); assertThat(params.getSide()).isEqualTo("buy"); assertThat(params.getPrice()).isEqualTo(price); assertThat(params.getQuantity()).isEqualTo(amount); }
@Override @SneakyThrows public Optional<OrderCreatedDto> create(String tryToAssignId, TradingCurrency from, TradingCurrency to, BigDecimal amount, BigDecimal price) { PairSymbol pair = cfg.pairFromCurrencyOrThrow(from, to); BigDecimal calcAmount = DefaultInvertHandler.amountFromOrig(pair, amount, price); BigDecimal calcPrice = DefaultInvertHandler.priceFromOrig(pair, price); String side = DefaultInvertHandler.amountToBuyOrSell(calcAmount); ObjectWebSocketSender sender = rxConnected.get().sender(); HitbtcCreateRequestDto requestDto = new HitbtcCreateRequestDto(tryToAssignId, pair.getSymbol(), side, calcPrice, calcAmount.abs()); log.info("Sent WS request {} to {}", requestDto, name()); RxMoreObservables .sendObjectMessage(sender, requestDto) .subscribe(); return Optional.empty(); }
HitbtcWsService extends BaseWsClient implements CreateOrder { @Override @SneakyThrows public Optional<OrderCreatedDto> create(String tryToAssignId, TradingCurrency from, TradingCurrency to, BigDecimal amount, BigDecimal price) { PairSymbol pair = cfg.pairFromCurrencyOrThrow(from, to); BigDecimal calcAmount = DefaultInvertHandler.amountFromOrig(pair, amount, price); BigDecimal calcPrice = DefaultInvertHandler.priceFromOrig(pair, price); String side = DefaultInvertHandler.amountToBuyOrSell(calcAmount); ObjectWebSocketSender sender = rxConnected.get().sender(); HitbtcCreateRequestDto requestDto = new HitbtcCreateRequestDto(tryToAssignId, pair.getSymbol(), side, calcPrice, calcAmount.abs()); log.info("Sent WS request {} to {}", requestDto, name()); RxMoreObservables .sendObjectMessage(sender, requestDto) .subscribe(); return Optional.empty(); } }
HitbtcWsService extends BaseWsClient implements CreateOrder { @Override @SneakyThrows public Optional<OrderCreatedDto> create(String tryToAssignId, TradingCurrency from, TradingCurrency to, BigDecimal amount, BigDecimal price) { PairSymbol pair = cfg.pairFromCurrencyOrThrow(from, to); BigDecimal calcAmount = DefaultInvertHandler.amountFromOrig(pair, amount, price); BigDecimal calcPrice = DefaultInvertHandler.priceFromOrig(pair, price); String side = DefaultInvertHandler.amountToBuyOrSell(calcAmount); ObjectWebSocketSender sender = rxConnected.get().sender(); HitbtcCreateRequestDto requestDto = new HitbtcCreateRequestDto(tryToAssignId, pair.getSymbol(), side, calcPrice, calcAmount.abs()); log.info("Sent WS request {} to {}", requestDto, name()); RxMoreObservables .sendObjectMessage(sender, requestDto) .subscribe(); return Optional.empty(); } HitbtcWsService(HitbtcConfig cfg); }
HitbtcWsService extends BaseWsClient implements CreateOrder { @Override @SneakyThrows public Optional<OrderCreatedDto> create(String tryToAssignId, TradingCurrency from, TradingCurrency to, BigDecimal amount, BigDecimal price) { PairSymbol pair = cfg.pairFromCurrencyOrThrow(from, to); BigDecimal calcAmount = DefaultInvertHandler.amountFromOrig(pair, amount, price); BigDecimal calcPrice = DefaultInvertHandler.priceFromOrig(pair, price); String side = DefaultInvertHandler.amountToBuyOrSell(calcAmount); ObjectWebSocketSender sender = rxConnected.get().sender(); HitbtcCreateRequestDto requestDto = new HitbtcCreateRequestDto(tryToAssignId, pair.getSymbol(), side, calcPrice, calcAmount.abs()); log.info("Sent WS request {} to {}", requestDto, name()); RxMoreObservables .sendObjectMessage(sender, requestDto) .subscribe(); return Optional.empty(); } HitbtcWsService(HitbtcConfig cfg); @Override @SneakyThrows Optional<OrderCreatedDto> create(String tryToAssignId, TradingCurrency from, TradingCurrency to,
                                            BigDecimal amount, BigDecimal price); @Override String name(); }
HitbtcWsService extends BaseWsClient implements CreateOrder { @Override @SneakyThrows public Optional<OrderCreatedDto> create(String tryToAssignId, TradingCurrency from, TradingCurrency to, BigDecimal amount, BigDecimal price) { PairSymbol pair = cfg.pairFromCurrencyOrThrow(from, to); BigDecimal calcAmount = DefaultInvertHandler.amountFromOrig(pair, amount, price); BigDecimal calcPrice = DefaultInvertHandler.priceFromOrig(pair, price); String side = DefaultInvertHandler.amountToBuyOrSell(calcAmount); ObjectWebSocketSender sender = rxConnected.get().sender(); HitbtcCreateRequestDto requestDto = new HitbtcCreateRequestDto(tryToAssignId, pair.getSymbol(), side, calcPrice, calcAmount.abs()); log.info("Sent WS request {} to {}", requestDto, name()); RxMoreObservables .sendObjectMessage(sender, requestDto) .subscribe(); return Optional.empty(); } HitbtcWsService(HitbtcConfig cfg); @Override @SneakyThrows Optional<OrderCreatedDto> create(String tryToAssignId, TradingCurrency from, TradingCurrency to,
                                            BigDecimal amount, BigDecimal price); @Override String name();  }