use of tech.cassandre.trading.bot.service.TradeService in project cassandre-trading-bot by cassandre-tech.
the class BasicTa4jCassandreStrategyTestMock method tradeService.
@Bean
@Primary
public TradeService tradeService() {
TradeService service = mock(TradeService.class);
// Returns three values.
Set<OrderDTO> reply = new LinkedHashSet<>();
// Order 01.
reply.add(OrderDTO.builder().orderId("000001").type(BID).strategy(strategyDTO).currencyPair(BTC_USDT).build());
// Order 02.
reply.add(OrderDTO.builder().orderId("000002").type(BID).strategy(strategyDTO).currencyPair(BTC_USDT).build());
// Order 03.
reply.add(OrderDTO.builder().orderId("000003").type(BID).strategy(strategyDTO).currencyPair(BTC_USDT).build());
// Order 04.
reply.add(OrderDTO.builder().orderId("000004").type(BID).strategy(strategyDTO).currencyPair(BTC_USDT).build());
given(service.getOrders()).willReturn(reply);
// Returns three values for getTrades().
Set<TradeDTO> replyGetTrades = new LinkedHashSet<>();
// Trade 01.
replyGetTrades.add(TradeDTO.builder().tradeId("0000001").orderId("000001").type(BID).currencyPair(BTC_USDT).build());
// Trade 02.
replyGetTrades.add(TradeDTO.builder().tradeId("0000002").orderId("000002").type(BID).currencyPair(BTC_USDT).build());
// Trade 03.
replyGetTrades.add(TradeDTO.builder().tradeId("0000003").orderId("000003").type(BID).currencyPair(BTC_USDT).build());
given(service.getTrades()).willReturn(replyGetTrades);
return service;
}
use of tech.cassandre.trading.bot.service.TradeService in project cassandre-trading-bot by cassandre-tech.
the class BasicCassandreStrategyTestMock method tradeService.
@Bean
@Primary
public TradeService tradeService() {
TradeService service = mock(TradeService.class);
// Returns three values for getOpenOrders().
Set<OrderDTO> replyGetOpenOrders = new LinkedHashSet<>();
// Order 01.
replyGetOpenOrders.add(OrderDTO.builder().orderId("000001").type(BID).strategy(strategyDTO).currencyPair(ETH_BTC).timestamp(createZonedDateTime("01-01-2020")).build());
// Order 02.
replyGetOpenOrders.add(OrderDTO.builder().orderId("000002").type(BID).strategy(strategyDTO).currencyPair(ETH_BTC).timestamp(createZonedDateTime("01-02-2020")).build());
// Order 03.
replyGetOpenOrders.add(OrderDTO.builder().orderId("000003").type(BID).strategy(strategyDTO).currencyPair(ETH_BTC).timestamp(createZonedDateTime("01-03-2020")).build());
given(service.getOrders()).willReturn(replyGetOpenOrders);
// Returns three values for getTrades().
Set<TradeDTO> replyGetTrades = new LinkedHashSet<>();
// Trade 01.
replyGetTrades.add(TradeDTO.builder().tradeId("0000001").orderId("000001").type(BID).currencyPair(ETH_BTC).timestamp(createZonedDateTime("01-01-2020")).build());
// Trade 02.
replyGetTrades.add(TradeDTO.builder().tradeId("0000002").orderId("000001").type(BID).currencyPair(ETH_BTC).timestamp(createZonedDateTime("01-02-2020")).build());
// Trade 03.
replyGetTrades.add(TradeDTO.builder().tradeId("0000003").orderId("000001").type(BID).currencyPair(ETH_BTC).timestamp(createZonedDateTime("01-03-2020")).build());
given(service.getTrades()).willReturn(replyGetTrades);
return service;
}
use of tech.cassandre.trading.bot.service.TradeService in project cassandre-trading-bot by cassandre-tech.
the class Issue427TestMock method tradeService.
@Bean
@Primary
public TradeService tradeService() {
TradeService service = mock(TradeService.class);
// getOrders() replies.
LinkedHashSet<OrderDTO> orders = new LinkedHashSet<>();
orders.add(OrderDTO.builder().orderId("ORDER_000001").type(ASK).currencyPair(ETH_BTC).amount(new CurrencyAmountDTO("1", ETH_BTC.getBaseCurrency())).averagePrice(new CurrencyAmountDTO("3", ETH_BTC.getQuoteCurrency())).limitPrice(new CurrencyAmountDTO("5", ETH_BTC.getQuoteCurrency())).leverage("leverage1").status(NEW).cumulativeAmount(new CurrencyAmountDTO("2", ETH_BTC.getBaseCurrency())).userReference("MY_REF_1").timestamp(ZonedDateTime.of(2018, 1, 1, 0, 0, 0, 0, ZoneId.of("UTC"))).build());
orders.add(OrderDTO.builder().orderId("ORDER_000002").type(ASK).currencyPair(ETH_BTC).amount(new CurrencyAmountDTO("1", ETH_BTC.getBaseCurrency())).averagePrice(new CurrencyAmountDTO("3", ETH_BTC.getQuoteCurrency())).limitPrice(new CurrencyAmountDTO("5", ETH_BTC.getQuoteCurrency())).leverage("leverage1").status(NEW).cumulativeAmount(new CurrencyAmountDTO("2", ETH_BTC.getBaseCurrency())).userReference("MY_REF_1").timestamp(ZonedDateTime.of(2018, 1, 1, 0, 0, 0, 0, ZoneId.of("UTC"))).build());
given(service.getOrders()).willReturn(orders);
return service;
}
use of tech.cassandre.trading.bot.service.TradeService in project cassandre-trading-bot by cassandre-tech.
the class Issue426TestMock method tradeService.
@Bean
@Primary
public TradeService tradeService() {
TradeService service = mock(TradeService.class);
// getTrades() replies.
given(service.getTrades()).willReturn(Set.of(TradeDTO.builder().tradeId("TRADE_000001").type(ASK).orderId("ORDER_000001").currencyPair(ETH_BTC).amount(new CurrencyAmountDTO("0.5", ETH_BTC.getBaseCurrency())).price(new CurrencyAmountDTO("1", ETH_BTC.getQuoteCurrency())).build(), TradeDTO.builder().tradeId("TRADE_000001").type(ASK).orderId("ORDER_000001").currencyPair(ETH_BTC).amount(new CurrencyAmountDTO("0.5", ETH_BTC.getBaseCurrency())).price(new CurrencyAmountDTO("2", ETH_BTC.getQuoteCurrency())).build(), TradeDTO.builder().tradeId("TRADE_000002").type(ASK).orderId("ORDER_000001").currencyPair(ETH_BTC).amount(new CurrencyAmountDTO("0.5", ETH_BTC.getBaseCurrency())).price(new CurrencyAmountDTO("2", ETH_BTC.getQuoteCurrency())).build(), TradeDTO.builder().tradeId("TRADE_000003").type(ASK).orderId("ORDER_000002").currencyPair(ETH_BTC).amount(new CurrencyAmountDTO("0.5", ETH_BTC.getBaseCurrency())).price(new CurrencyAmountDTO("2", ETH_BTC.getQuoteCurrency())).build()));
// getOrders() replies.
LinkedHashSet<OrderDTO> orders = new LinkedHashSet<>();
orders.add(OrderDTO.builder().orderId("ORDER_000001").type(ASK).currencyPair(ETH_BTC).strategy(strategyDTO).amount(new CurrencyAmountDTO("1", ETH_BTC.getBaseCurrency())).averagePrice(new CurrencyAmountDTO("3", ETH_BTC.getQuoteCurrency())).limitPrice(new CurrencyAmountDTO("5", ETH_BTC.getQuoteCurrency())).leverage("leverage1").status(NEW).cumulativeAmount(new CurrencyAmountDTO("2", ETH_BTC.getBaseCurrency())).userReference("MY_REF_1").timestamp(ZonedDateTime.of(2018, 1, 1, 0, 0, 0, 0, ZoneId.of("UTC"))).build());
orders.add(OrderDTO.builder().orderId("ORDER_000001").type(ASK).strategy(strategyDTO).currencyPair(ETH_BTC).amount(new CurrencyAmountDTO("1", ETH_BTC.getBaseCurrency())).averagePrice(new CurrencyAmountDTO("3", ETH_BTC.getQuoteCurrency())).limitPrice(new CurrencyAmountDTO("5", ETH_BTC.getQuoteCurrency())).leverage("leverage1").status(FILLED).cumulativeAmount(new CurrencyAmountDTO("2", ETH_BTC.getBaseCurrency())).userReference("MY_REF_1").timestamp(ZonedDateTime.of(2018, 1, 1, 0, 0, 0, 0, ZoneId.of("UTC"))).build());
given(service.getOrders()).willReturn(orders);
return service;
}
Aggregations