Class CassandreStrategyImplementation
- All Implemented Interfaces:
CassandreStrategyInterface
- Direct Known Subclasses:
CassandreStrategy
These are the classes used by Cassandre to manage a position.
- CassandreStrategyInterface list the methods a strategy type must implement to be able to interact with the Cassandre framework.
- CassandreStrategyConfiguration contains the configuration of the strategy.
- CassandreStrategyDependencies contains all the dependencies required by a strategy and provided by the Cassandre framework.
- CassandreStrategyImplementation is the default implementation of CassandreStrategyInterface, this code manages the interaction between Cassandre framework and a strategy.
- CassandreStrategy (class) is the class that every strategy used by user (BasicCassandreStrategy
must extend. It contains methods to access data and manage orders, trades, positions.
There are the classes used by the developer.
- CassandreStrategy (interface) is the annotation allowing you Cassandre to recognize a user strategy.
- BasicCassandreStrategy - User inherits this class this one to make a basic strategy.
-
Field Summary
Modifier and TypeFieldDescriptionprotected CassandreStrategyConfiguration
Cassandre configuration.protected CassandreStrategyDependencies
Cassandre dependencies.protected final Map<CurrencyPairDTO,
TickerDTO> Last tickers received.protected final Map<String,
AccountDTO> The accounts owned by the user.Fields inherited from class tech.cassandre.trading.bot.util.base.Base
ACCOUNT_MAPPER, CANDLE_MAPPER, CURRENCY_MAPPER, logger, ORDER_MAPPER, POSITION_MAPPER, STRATEGY_MAPPER, TICKER_MAPPER, TRADE_MAPPER, UTIL_MAPPER
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
accountsUpdates
(Set<AccountDTO> accounts) Method called by streams on accounts updates.Get strategy configuration.final BigDecimal
getLastPriceForCurrencyPair
(@NonNull CurrencyPairDTO currencyPair) Returns the last price received for a currency pair.getLastTickerByCurrencyPair
(@NonNull CurrencyPairDTO currencyPair) Return the last ticker for a currency pair.final void
initializeAccounts
(Map<String, AccountDTO> newAccounts) Initialize strategy accounts with exchange accounts data retrieved at Cassandre startup.final void
ordersUpdates
(Set<OrderDTO> orders) Method called by streams on orders updates.final void
positionsUpdates
(Set<PositionDTO> positions) Method called by streams on positions updates.final void
setConfiguration
(CassandreStrategyConfiguration cassandreStrategyConfiguration) Set strategy configuration.final void
setDependencies
(CassandreStrategyDependencies cassandreStrategyDependencies) Set strategy dependencies.void
tickersUpdates
(Set<TickerDTO> tickers) Method called by streams on tickers updates.final void
tradesUpdates
(Set<TradeDTO> trades) Method called by streams on trades updates.protected void
Update strategy positions with tickers updates.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface tech.cassandre.trading.bot.strategy.internal.CassandreStrategyInterface
getRequestedCurrencyPairs, getTradeAccount, initialize, onAccountsUpdates, onOrdersUpdates, onPositionsStatusUpdates, onPositionsUpdates, onTickersUpdates, onTradesUpdates
-
Field Details
-
configuration
Cassandre configuration. -
dependencies
Cassandre dependencies. -
userAccounts
The accounts owned by the user. -
lastTickers
Last tickers received.
-
-
Constructor Details
-
CassandreStrategyImplementation
public CassandreStrategyImplementation()
-
-
Method Details
-
setConfiguration
Description copied from interface:CassandreStrategyInterface
Set strategy configuration.- Specified by:
setConfiguration
in interfaceCassandreStrategyInterface
- Parameters:
cassandreStrategyConfiguration
- cassandre strategy configuration
-
getConfiguration
Description copied from interface:CassandreStrategyInterface
Get strategy configuration.- Specified by:
getConfiguration
in interfaceCassandreStrategyInterface
- Returns:
- cassandre strategy configuration
-
setDependencies
Description copied from interface:CassandreStrategyInterface
Set strategy dependencies.- Specified by:
setDependencies
in interfaceCassandreStrategyInterface
- Parameters:
cassandreStrategyDependencies
- cassandre strategy dependencies
-
initializeAccounts
Description copied from interface:CassandreStrategyInterface
Initialize strategy accounts with exchange accounts data retrieved at Cassandre startup.- Specified by:
initializeAccounts
in interfaceCassandreStrategyInterface
- Parameters:
newAccounts
- accounts
-
accountsUpdates
Description copied from interface:CassandreStrategyInterface
Method called by streams on accounts updates.- Specified by:
accountsUpdates
in interfaceCassandreStrategyInterface
- Parameters:
accounts
- accounts updates
-
tickersUpdates
Description copied from interface:CassandreStrategyInterface
Method called by streams on tickers updates.- Specified by:
tickersUpdates
in interfaceCassandreStrategyInterface
- Parameters:
tickers
- tickers updates
-
getLastPriceForCurrencyPair
Description copied from interface:CassandreStrategyInterface
Returns the last price received for a currency pair.- Specified by:
getLastPriceForCurrencyPair
in interfaceCassandreStrategyInterface
- Parameters:
currencyPair
- currency pair- Returns:
- last price
-
getLastTickerByCurrencyPair
public final Optional<TickerDTO> getLastTickerByCurrencyPair(@NonNull @NonNull CurrencyPairDTO currencyPair) Return the last ticker for a currency pair.- Parameters:
currencyPair
- currency pair- Returns:
- last ticker received
-
ordersUpdates
Description copied from interface:CassandreStrategyInterface
Method called by streams on orders updates.- Specified by:
ordersUpdates
in interfaceCassandreStrategyInterface
- Parameters:
orders
- orders updates
-
tradesUpdates
Description copied from interface:CassandreStrategyInterface
Method called by streams on trades updates.- Specified by:
tradesUpdates
in interfaceCassandreStrategyInterface
- Parameters:
trades
- trades updates
-
positionsUpdates
Description copied from interface:CassandreStrategyInterface
Method called by streams on positions updates.- Specified by:
positionsUpdates
in interfaceCassandreStrategyInterface
- Parameters:
positions
- positions updates
-
updatePositionsWithTickersUpdates
Update strategy positions with tickers updates.- Parameters:
tickers
- tickers updates
-