Strategy

Classes managing the user strategy.

To create its strategy, the developer must create a class with the @CassandreStrategy annotation and must extend BasicCassandreStrategy or BasicTa4jCassandreStrategy.

Strategy annotation.

The @CassandreStrategy annotation allows the developer to mark its class as a Strategy and declares it as a Spring bean.

Parameter

Description

name

Name of the strategy (Optional).

CassandreStrategyInterface.

CassandreStrategyInterface is the interface that all provided strategy templates provided by Cassandre must implement.

Method

Description

getTradeService()

Getter for trade service.

setTradeService()

Setter for trade service (not available to the strategy developer).

accountUpdate()

Method called by streams at every account update (not available to the strategy developer).

tickerUpdate()

Method called by streams at every ticker update (not available to the strategy developer).

orderUpdate()

Method called by streams on every order update (not available to the strategy developer).

tradeUpdate()

Method called by streams on every trade update (not available to the strategy developer).

positionUpdate()

Method called by streams on every position update (not available to the strategy developer).

getRequestedCurrencyPairs()

Strategy developer must implement this method to tell the bot which currency pairs your strategy will receive

onAccountUpdate()

Method triggered at every account update

onTickerUpdate()

Method triggered at every ticker update

onOrderUpdate()

Method triggered on every order update

onTradeUpdate()

Method triggered on every trade update

onPositionUpdate()

Method triggered on every position update

BasicCassandreStrategy.

BasicCassandreStrategy is a very basic Cassandre strategy.

Method

Description

getRequestedCurrencyPairs()

Implements this method to tell the bot which currency pairs your strategy will receive via the onTickerUpdate() method.

onAccountUpdate()

Method triggered at every account update.

onTickerUpdate()

Method triggered at every ticker update.

onOrderUpdate()

Method triggered on every order update.

onTradeUpdate()

Method triggered on every trade update.

onPositionUpdate()

Method triggered on every position update.

getTradeService()

Returns the trade service you can use to retrieve and create order.

BasicTa4jCassandreStrategy.

BasicTa4jCassandreStrategy add ta4j to a BasicCassandreStrategy. Compared to BasicCassandreStrategy, the following methods are added :

Method

Description

getRequestedCurrencyPair()

Implements this method to tell the bot which currency pair your strategy will receive.

getMaximumBarCount()

Implements this method to tell the bot how many bars you want to keep in your bar series.

getDelayBetweenTwoBars()

Implements this method to tell the bot how many bars you want to keep in your bar series.

getStrategy()

Implements this method to tell the bot which strategy to apply.

shouldEnter()

Called when your strategy says you should enter.

shouldExit()

Called when your strategy says your should exit.