use of tech.cassandre.trading.bot.service.MarketService in project cassandre-trading-bot by cassandre-tech.
the class BasicTa4jCassandreStrategyTestMock method marketService.
@Bean
@Primary
public MarketService marketService() {
MarketService service = mock(MarketService.class);
// We don't use the getTickers method.
given(service.getTickers(any())).willThrow(new NotAvailableFromExchangeException("Not available in test"));
// Returns three values.
given(service.getTicker(BTC_USDT)).willReturn(Optional.of(TickerDTO.builder().currencyPair(BTC_USDT).timestamp(BaseTest.createZonedDateTime(1)).open(new BigDecimal(100)).high(new BigDecimal(100)).low(new BigDecimal(100)).last(new BigDecimal(100)).volume(new BigDecimal(1060)).build()), Optional.of(TickerDTO.builder().currencyPair(BTC_USDT).timestamp(BaseTest.createZonedDateTime(2)).open(new BigDecimal(100)).high(new BigDecimal(100)).low(new BigDecimal(100)).last(new BigDecimal(100)).volume(new BigDecimal(1060)).build()), Optional.of(TickerDTO.builder().currencyPair(BTC_USDT).timestamp(BaseTest.createZonedDateTime(3)).open(new BigDecimal(110)).high(new BigDecimal(110)).low(new BigDecimal(110)).last(new BigDecimal(110)).volume(new BigDecimal(1070)).build()), Optional.of(TickerDTO.builder().currencyPair(BTC_USDT).timestamp(BaseTest.createZonedDateTime(4)).open(new BigDecimal(100)).high(new BigDecimal(100)).low(new BigDecimal(100)).last(new BigDecimal(100)).volume(new BigDecimal(1060)).build()), Optional.of(TickerDTO.builder().currencyPair(BTC_USDT).timestamp(BaseTest.createZonedDateTime(5)).open(new BigDecimal(140)).high(new BigDecimal(140)).low(new BigDecimal(140)).last(new BigDecimal(140)).volume(new BigDecimal(1080)).build()), Optional.of(TickerDTO.builder().currencyPair(BTC_USDT).timestamp(BaseTest.createZonedDateTime(6)).open(new BigDecimal(100)).high(new BigDecimal(100)).low(new BigDecimal(100)).last(new BigDecimal(100)).volume(new BigDecimal(1060)).build()), Optional.of(TickerDTO.builder().currencyPair(BTC_USDT).timestamp(BaseTest.createZonedDateTime(7)).open(new BigDecimal(119)).high(new BigDecimal(119)).low(new BigDecimal(119)).last(new BigDecimal(119)).volume(new BigDecimal(1090)).build()), Optional.of(TickerDTO.builder().currencyPair(BTC_USDT).timestamp(BaseTest.createZonedDateTime(8)).open(new BigDecimal(100)).high(new BigDecimal(100)).low(new BigDecimal(100)).last(new BigDecimal(100)).volume(new BigDecimal(1060)).build()), Optional.of(TickerDTO.builder().currencyPair(BTC_USDT).timestamp(BaseTest.createZonedDateTime(9)).open(new BigDecimal(100)).high(new BigDecimal(100)).low(new BigDecimal(100)).last(new BigDecimal(100)).volume(new BigDecimal(1100)).build()), Optional.of(TickerDTO.builder().currencyPair(BTC_USDT).timestamp(BaseTest.createZonedDateTime(10)).open(new BigDecimal(100)).high(new BigDecimal(100)).low(new BigDecimal(100)).last(new BigDecimal(100)).volume(new BigDecimal(1060)).build()), Optional.of(TickerDTO.builder().currencyPair(BTC_USDT).timestamp(BaseTest.createZonedDateTime(11)).open(new BigDecimal(110)).high(new BigDecimal(110)).low(new BigDecimal(110)).last(new BigDecimal(110)).volume(new BigDecimal(1100)).build()), Optional.of(TickerDTO.builder().currencyPair(BTC_USDT).timestamp(BaseTest.createZonedDateTime(12)).open(new BigDecimal(100)).high(new BigDecimal(100)).low(new BigDecimal(100)).last(new BigDecimal(100)).volume(new BigDecimal(1060)).build()), Optional.of(TickerDTO.builder().currencyPair(BTC_USDT).timestamp(BaseTest.createZonedDateTime(13)).open(new BigDecimal(120)).high(new BigDecimal(120)).low(new BigDecimal(120)).last(new BigDecimal(120)).volume(new BigDecimal(1120)).build()), Optional.of(TickerDTO.builder().currencyPair(BTC_USDT).timestamp(BaseTest.createZonedDateTime(14)).open(new BigDecimal(100)).high(new BigDecimal(100)).low(new BigDecimal(100)).last(new BigDecimal(100)).volume(new BigDecimal(1060)).build()), Optional.of(TickerDTO.builder().currencyPair(BTC_USDT).timestamp(BaseTest.createZonedDateTime(15)).open(new BigDecimal(130)).high(new BigDecimal(130)).low(new BigDecimal(130)).last(new BigDecimal(130)).volume(new BigDecimal(1130)).build()), Optional.empty());
return service;
}
use of tech.cassandre.trading.bot.service.MarketService in project cassandre-trading-bot by cassandre-tech.
the class PositionServiceDryModeTestMock method marketService.
@Bean
@Primary
public MarketService marketService() {
// Creates the mock.
MarketService marketService = mock(MarketService.class);
// We don't use the getTickers method.
given(marketService.getTickers(any())).willThrow(new NotAvailableFromExchangeException("Not available during tests"));
// Replies for ETH / BTC.
given(marketService.getTicker(ETH_BTC)).willReturn(Optional.empty());
// Replies for ETH / USDT.
given(marketService.getTicker(ETH_USDT)).willReturn(Optional.empty());
return marketService;
}
use of tech.cassandre.trading.bot.service.MarketService in project cassandre-trading-bot by cassandre-tech.
the class BasicCassandreStrategyTestMock method marketService.
@Bean
@Primary
public MarketService marketService() {
MarketService service = mock(MarketService.class);
// We don't use the getTickers method.
given(service.getTickers(any())).willThrow(new NotAvailableFromExchangeException("Not available during tests"));
// Returns three values for ETH/BTC.
given(service.getTicker(ETH_BTC)).willReturn(BaseTest.getFakeTicker(ETH_BTC, new BigDecimal("1")), BaseTest.getFakeTicker(ETH_BTC, new BigDecimal("2")), BaseTest.getFakeTicker(ETH_BTC, new BigDecimal("3")), BaseTest.getFakeTicker(ETH_BTC, new BigDecimal("4")), BaseTest.getFakeTicker(ETH_BTC, new BigDecimal("5")), BaseTest.getFakeTicker(ETH_BTC, new BigDecimal("6")), Optional.empty());
// Returns one value for ETH/USDT.
given(service.getTicker(ETH_USDT)).willReturn(BaseTest.getFakeTicker(ETH_USDT, new BigDecimal("10000")), Optional.empty());
return service;
}
use of tech.cassandre.trading.bot.service.MarketService in project cassandre-trading-bot by cassandre-tech.
the class Issue426TestMock method marketService.
@Bean
@Primary
public MarketService marketService() {
// Creates the mock.
MarketService marketService = mock(MarketService.class);
// Replies for ETH/BTC.
given(marketService.getTicker(ETH_BTC)).willReturn(Optional.of(TickerDTO.builder().currencyPair(ETH_BTC).timestamp(createZonedDateTime(1)).last(new BigDecimal("0.2")).build()), Optional.of(TickerDTO.builder().currencyPair(ETH_BTC).timestamp(createZonedDateTime(2)).last(new BigDecimal("0.3")).build()), Optional.of(TickerDTO.builder().currencyPair(ETH_BTC).timestamp(createZonedDateTime(3)).last(new BigDecimal("0.4")).build()), Optional.of(TickerDTO.builder().currencyPair(ETH_BTC).timestamp(createZonedDateTime(4)).last(new BigDecimal("0.4")).build()));
// Replies for ETH/USDT.
given(marketService.getTicker(ETH_USDT)).willReturn(Optional.of(TickerDTO.builder().currencyPair(ETH_USDT).timestamp(createZonedDateTime(5)).last(new BigDecimal("0.3")).build()), Optional.of(TickerDTO.builder().currencyPair(ETH_USDT).timestamp(createZonedDateTime(6)).last(new BigDecimal("0.3")).build()), Optional.of(TickerDTO.builder().currencyPair(ETH_USDT).timestamp(createZonedDateTime(7)).last(new BigDecimal("0.6")).build()), Optional.of(TickerDTO.builder().currencyPair(ETH_USDT).timestamp(createZonedDateTime(8)).last(new BigDecimal("0.1")).build()));
return marketService;
}
use of tech.cassandre.trading.bot.service.MarketService in project cassandre-trading-bot by cassandre-tech.
the class Issue427TestMock method marketService.
@Bean
@Primary
public MarketService marketService() {
// Creates the mock.
MarketService marketService = mock(MarketService.class);
// Replies for ETH/BTC.
given(marketService.getTicker(ETH_BTC)).willReturn(Optional.of(TickerDTO.builder().currencyPair(ETH_BTC).timestamp(createZonedDateTime(1)).last(new BigDecimal("0.2")).build()), Optional.of(TickerDTO.builder().currencyPair(ETH_BTC).timestamp(createZonedDateTime(2)).last(new BigDecimal("0.3")).build()), Optional.of(TickerDTO.builder().currencyPair(ETH_BTC).timestamp(createZonedDateTime(3)).last(new BigDecimal("0.4")).build()), Optional.of(TickerDTO.builder().currencyPair(ETH_BTC).timestamp(createZonedDateTime(4)).last(new BigDecimal("0.4")).build()));
// Replies for ETH/USDT.
given(marketService.getTicker(ETH_USDT)).willReturn(Optional.of(TickerDTO.builder().currencyPair(ETH_USDT).timestamp(createZonedDateTime(5)).last(new BigDecimal("0.3")).build()), Optional.of(TickerDTO.builder().currencyPair(ETH_USDT).timestamp(createZonedDateTime(6)).last(new BigDecimal("0.3")).build()), Optional.of(TickerDTO.builder().currencyPair(ETH_USDT).timestamp(createZonedDateTime(7)).last(new BigDecimal("0.6")).build()), Optional.of(TickerDTO.builder().currencyPair(ETH_USDT).timestamp(createZonedDateTime(8)).last(new BigDecimal("0.1")).build()));
return marketService;
}
Aggregations