Create your strategy

Your strategy is in src/main/java/com/example/

Choose the requested currency pair.

This is done by implementing getRequestedCurrencyPair() this way :

public CurrencyPairDTO getRequestedCurrencyPair() {
return new CurrencyPairDTO(BTC, USDT);

Choose your trading account.

On the exchange, you usually have several accounts and Cassandre needs to know which one of your account is the trading one (for example, to calculate if you have enough assets to buy/sell). So the following method gives you as a parameter the list of accounts and you have to return the trading one :

public Optional<AccountDTO> getTradeAccount(Set<AccountDTO> accounts) {
.filter(a -> "trade".equals(a.getName()))

Choose the number of bars.

This is done by implementing getMaximumBarCount() this way :

public int getMaximumBarCount() {
return 10;

Choose the delay between two bars.

This is done by implementing getDelayBetweenTwoBars() this way :

public Duration getDelayBetweenTwoBars() {
return Duration.ofDays(1);

This method allows you, for example, to receive tickers every second, but only add one to the bar every day.

Create your strategy.

Now it's time to implement your own strategy, here, we chose Simple Moving Average (SMA) :

public Strategy getStrategy() {
ClosePriceIndicator closePrice = new ClosePriceIndicator(getSeries());
SMAIndicator sma = new SMAIndicator(closePrice, getMaximumBarCount());
return new BaseStrategy(new UnderIndicatorRule(sma, closePrice), new OverIndicatorRule(sma, closePrice));