Strategy

Classes managing the user strategy.

To run 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).

getPositionService()

Getter for position service.

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

getTradeAccount()

Strategy developer must implement this method to tell the bot which account from the accounts you own is the trading one.

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.

onPositionStatusUpdate()

Method triggered on every position status update.

GenericCassandreStrategy

GenericCassandreStrategy is an abstract implementation of CassandreStrategyInterface inherited by all strategies provided by Cassandre (BasicCassandreStrategy & BasicTa4jCassandreStrategy).

BasicCassandreStrategy.

BasicCassandreStrategy is a basic Cassandre strategy.

Method

Description

getRequestedCurrencyPairs()

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

getTradeAccount()

Implements this method to tell the bot which accounts from the accounts you own is the trading one.

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

onPositionStatusUpdate()

Method triggered on every position status update

getTradeService()

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

canBuy()

Returns true is you have enough assets to buy

canSell()

Returns true is you have enough assets to sell

BasicTa4jCassandreStrategy.

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

Method

Description

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

canBuy()

Returns true is you have enough assets to buy

canSell()

Returns true is you have enough assets to sell