Class BasicTa4jCassandreStrategy
- java.lang.Object
-
- tech.cassandre.trading.bot.strategy.GenericCassandreStrategy
-
- tech.cassandre.trading.bot.strategy.BasicTa4jCassandreStrategy
-
- All Implemented Interfaces:
CassandreStrategyInterface
public abstract class BasicTa4jCassandreStrategy extends GenericCassandreStrategy
Basic ta4j strategy.
-
-
Field Summary
-
Fields inherited from class tech.cassandre.trading.bot.strategy.GenericCassandreStrategy
currencyMapper, exchangeService, importedTickersRepository, logger, orderMapper, orderRepository, positionFlux, positionMapper, positionRepository, positionService, tickerMapper, tradeMapper, tradeRepository, tradeService
-
-
Constructor Summary
Constructors Constructor Description BasicTa4jCassandreStrategy()
Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
canBuy(BigDecimal amount)
Returns true if we have enough assets to buy.boolean
canBuy(BigDecimal amount, BigDecimal minimumBalanceAfter)
Returns true if we have enough assets to buy.boolean
canBuy(AccountDTO account, BigDecimal amount)
Returns true if we have enough assets to buy.boolean
canBuy(AccountDTO account, BigDecimal amount, BigDecimal minimumBalanceAfter)
Returns true if we have enough assets to buy and if minimumBalanceAfter is left on the account after.boolean
canSell(BigDecimal amount)
Returns true if we have enough assets to sell.boolean
canSell(BigDecimal amount, BigDecimal minimumBalanceAfter)
Returns true if we have enough assets to sell.boolean
canSell(AccountDTO account, BigDecimal amount)
Returns true if we have enough assets to sell.boolean
canSell(AccountDTO account, BigDecimal amount, BigDecimal minimumBalanceAfter)
Returns true if we have enough assets to sell and if minimumBalanceAfter is left on the account after.abstract Duration
getDelayBetweenTwoBars()
Implements this method to set the time that should separate two bars.org.ta4j.core.Strategy
getExecutedStrategy()
Returns the executed strategy.abstract int
getMaximumBarCount()
Implements this method to tell the bot how many bars you want to keep in your bar series.abstract CurrencyPairDTO
getRequestedCurrencyPair()
Implements this method to tell the bot which currency pair your strategy will receive.Set<CurrencyPairDTO>
getRequestedCurrencyPairs()
Implements this method to tell the bot which currency pairs your strategy will receive.org.ta4j.core.BarSeries
getSeries()
Getter for series.abstract org.ta4j.core.Strategy
getStrategy()
Implements this method to tell the bot which strategy to apply.boolean
isHistoricalImport()
Getter for historical data import.void
setHistoricalImport(boolean historicalImport)
Setter for historical data import.abstract void
shouldEnter()
Called when your strategy think you should enter.abstract void
shouldExit()
Called when your strategy think you should exit.void
tickersUpdates(Set<TickerDTO> tickers)
Method called by streams on tickers updates.void
updateStrategy(org.ta4j.core.Strategy newStrategy)
Update the Ta4j strategy used by Cassandre strategy.-
Methods inherited from class tech.cassandre.trading.bot.strategy.GenericCassandreStrategy
accountsUpdates, canBuy, canBuy, canBuy, canBuy, canSell, canSell, canSell, canSell, closePosition, createBuyLimitOrder, createBuyMarketOrder, createLongPosition, createSellLimitOrder, createSellMarketOrder, createShortPosition, getAccountByAccountId, getAccounts, getAmountsLockedByCurrency, getAmountsLockedByPosition, getEstimatedBuyableAmount, getEstimatedBuyingCost, getExchangeService, getGains, getImportedTickers, getImportedTickers, getLastPriceForCurrencyPair, getLastTickerByCurrencyPair, getLastTickers, getOrderByOrderId, getOrders, getPositionByPositionId, getPositions, getStrategyDTO, getTradeAccount, getTradeByTradeId, getTrades, initialize, initializeAccounts, onAccountsUpdates, onOrdersUpdates, onPositionsStatusUpdates, onPositionsUpdates, onTickersUpdates, onTradesUpdates, ordersUpdates, positionsUpdates, setExchangeService, setImportedTickersRepository, setOrderRepository, setPositionFlux, setPositionRepository, setPositionService, setStrategy, setTradeRepository, setTradeService, tradesUpdates, updatePositionRules
-
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.CassandreStrategyInterface
getTradeAccount
-
-
-
-
Method Detail
-
getRequestedCurrencyPair
public abstract CurrencyPairDTO getRequestedCurrencyPair()
Implements this method to tell the bot which currency pair your strategy will receive.- Returns:
- the list of currency pairs tickers your want to receive
-
getMaximumBarCount
public abstract int getMaximumBarCount()
Implements this method to tell the bot how many bars you want to keep in your bar series.- Returns:
- maximum bar count.
-
getDelayBetweenTwoBars
public abstract Duration getDelayBetweenTwoBars()
Implements this method to set the time that should separate two bars.- Returns:
- temporal amount
-
getStrategy
public abstract org.ta4j.core.Strategy getStrategy()
Implements this method to tell the bot which strategy to apply.- Returns:
- strategy
-
getExecutedStrategy
public final org.ta4j.core.Strategy getExecutedStrategy()
Returns the executed strategy.- Returns:
- strategy
-
updateStrategy
public void updateStrategy(org.ta4j.core.Strategy newStrategy)
Update the Ta4j strategy used by Cassandre strategy.- Parameters:
newStrategy
- strategy
-
getRequestedCurrencyPairs
public final Set<CurrencyPairDTO> getRequestedCurrencyPairs()
Description copied from interface:CassandreStrategyInterface
Implements this method to tell the bot which currency pairs your strategy will receive.- Returns:
- the list of currency pairs tickers your want to receive in this strategy
-
tickersUpdates
public final void tickersUpdates(Set<TickerDTO> tickers)
Description copied from interface:CassandreStrategyInterface
Method called by streams on tickers updates.- Specified by:
tickersUpdates
in interfaceCassandreStrategyInterface
- Overrides:
tickersUpdates
in classGenericCassandreStrategy
- Parameters:
tickers
- tickers updates
-
canBuy
public final boolean canBuy(BigDecimal amount)
Returns true if we have enough assets to buy.- Parameters:
amount
- amount- Returns:
- true if we have enough assets to buy
-
canBuy
public final boolean canBuy(BigDecimal amount, BigDecimal minimumBalanceAfter)
Returns true if we have enough assets to buy.- Parameters:
amount
- amountminimumBalanceAfter
- minimum balance that should be left after buying- Returns:
- true if we have enough assets to buy
-
canBuy
public final boolean canBuy(AccountDTO account, BigDecimal amount)
Returns true if we have enough assets to buy.- Parameters:
account
- accountamount
- amount- Returns:
- true if we have enough assets to buy
-
canBuy
public final boolean canBuy(AccountDTO account, BigDecimal amount, BigDecimal minimumBalanceAfter)
Returns true if we have enough assets to buy and if minimumBalanceAfter is left on the account after.- Parameters:
account
- accountamount
- amountminimumBalanceAfter
- minimum balance that should be left after buying- Returns:
- true if we have enough assets to buy
-
canSell
public final boolean canSell(BigDecimal amount, BigDecimal minimumBalanceAfter)
Returns true if we have enough assets to sell.- Parameters:
amount
- amountminimumBalanceAfter
- minimum balance that should be left after buying- Returns:
- true if we have enough assets to sell
-
canSell
public final boolean canSell(BigDecimal amount)
Returns true if we have enough assets to sell.- Parameters:
amount
- amount- Returns:
- true if we have enough assets to sell
-
canSell
public final boolean canSell(AccountDTO account, BigDecimal amount)
Returns true if we have enough assets to sell.- Parameters:
account
- accountamount
- amount- Returns:
- true if we have enough assets to sell
-
canSell
public final boolean canSell(AccountDTO account, BigDecimal amount, BigDecimal minimumBalanceAfter)
Returns true if we have enough assets to sell and if minimumBalanceAfter is left on the account after.- Parameters:
account
- accountamount
- amountminimumBalanceAfter
- minimum balance that should be left after selling- Returns:
- true if we have enough assets to sell
-
shouldEnter
public abstract void shouldEnter()
Called when your strategy think you should enter.
-
shouldExit
public abstract void shouldExit()
Called when your strategy think you should exit.
-
getSeries
public final org.ta4j.core.BarSeries getSeries()
Getter for series.- Returns:
- series
-
isHistoricalImport
public boolean isHistoricalImport()
Getter for historical data import.- Returns:
- isHistoricalImport
-
setHistoricalImport
public void setHistoricalImport(boolean historicalImport)
Setter for historical data import.- Parameters:
historicalImport
- historicalImport
-
-