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, orderMapper, positionMapper, tradeMapper
-
-
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.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.abstract void
shouldEnter()
Called when your strategy says you should enter.abstract void
shouldExit()
Called when your strategy says your should exit.void
tickerUpdate(TickerDTO ticker)
Method called by streams at every ticker update.-
Methods inherited from class tech.cassandre.trading.bot.strategy.GenericCassandreStrategy
accountUpdate, canBuy, canBuy, canBuy, canBuy, canSell, canSell, canSell, canSell, createBuyLimitOrder, createBuyMarketOrder, createLongPosition, createSellLimitOrder, createSellMarketOrder, getAccountByAccountId, getAccounts, getEstimatedBuyingCost, getGains, getLastTickerByCurrencyPair, getLastTickerByCurrencyPair, getLastTickers, getOrderByOrderId, getOrders, getPositionByPositionId, getPositions, getStrategyDTO, getTradeAccount, getTradeByTradeId, getTrades, onAccountUpdate, onOrderUpdate, onPositionStatusUpdate, onPositionUpdate, onTickerUpdate, onTradeUpdate, orderUpdate, positionUpdate, setOrderRepository, setPositionRepository, setPositionService, setStrategyDTO, setTradeRepository, setTradeService, tradeUpdate
-
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
-
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
-
tickerUpdate
public final void tickerUpdate(TickerDTO ticker)
Description copied from interface:CassandreStrategyInterface
Method called by streams at every ticker update.- Specified by:
tickerUpdate
in interfaceCassandreStrategyInterface
- Overrides:
tickerUpdate
in classGenericCassandreStrategy
- Parameters:
ticker
- ticker
-
canBuy
public final boolean canBuy(BigDecimal amount)
Returns true if we have enough assets to buy.- Parameters:
amount
- amount- Returns:
- true if we there is 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 there is 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 there is 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 there is 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 there is 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 there is 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 there is 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 there is enough assets to sell
-
shouldEnter
public abstract void shouldEnter()
Called when your strategy says you should enter.
-
shouldExit
public abstract void shouldExit()
Called when your strategy says your should exit.
-
getSeries
public final org.ta4j.core.BarSeries getSeries()
Getter for series.- Returns:
- series
-
-