Overview
Introduction
A trading bot is a computer program that can automatically place orders to a market or exchange without the need for human intervention. They are working for you 24/7 and never lose their focus.
Cassandre trading bot (available as a Spring boot starter) allows you to create and execute your trading strategy in seconds on several crypto exchanges.
Once the starter is added to your Spring Boot project, it will search for a class having the @CassandreStrategy annotation and extending BasicCassandreStrategy or BasicTa4jCassandreStrategy.
We also provide a dry mode and a spring boot starter to simulate a virtual exchange so you can backtest your strategies on historical and/or real-time data.
BasicCassandreStrategy
For a BasicCassandreStrategy, you have to implement :
- getRequestedCurrencyPairs() to indicate the list of currency pairs tickers you want to receive.
- getTradeAccount() to indicate which account on the exchange is the one you are using for trading.
BasicTa4jCassandreStrategy
For a BasicTa4jCassandreStrategy, you have to implement :
- getRequestedCurrencyPair() to indicate the currency pair tickers you want to receive.
- getTradeAccount() to indicate which account on the exchange is the one you are using for trading.
- getMaximumBarCount() to indicate how many bars you want to keep.
- getDelayBetweenTwoBars() to indicate the delay between two bars.
- getStrategy() to implement your own strategy.
- shouldEnter() to indicate what you want to do when it's time to buy.
- shouldExit() to indicate what you want to do when it's time to sell.
Data updates
To receive data from the exchange, you can override the following methods :
- onAccountsUpdates() to receive updates about your accounts.
- onTickersUpdates() to receive new tickers.
- onOrdersUpdates() to receive updates about your orders.
- onTradesUpdates() to receive updates about your trades.
- onPositionsUpdates() to receive updates about your positions.
- onPositionsStatusUpdates() to receive updates about positions status change.
Buying/selling
Inside your strategy, you can create market orders with the methods :
And limit orders with :
Positions
You can also create positions with :
On Positions, you can get the:
- The lowest calculated gain with getLowestCalculatedGain()
- The highest calculated gain with getHighestCalculatedGain()
- The latest calculated gain with getLatestCalculatedGain()
On a closed position, you can get the gain & fees with getGain()
TIP
If you don't know what a position is, read this position system explanation.