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.
-
-
Constructor Summary
Constructors Constructor Description BasicTa4jCassandreStrategy()
Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
accountUpdate(AccountDTO account)
Method called by streams at every account update.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 between two bars are added.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.void
onAccountUpdate(AccountDTO account)
Method triggered at every account update.void
onOrderUpdate(OrderDTO order)
Method triggered on every order update.void
onPositionStatusUpdate(PositionDTO position)
Method triggered on every position status update.void
onPositionUpdate(PositionDTO position)
Method triggered on every position update.void
onTickerUpdate(TickerDTO ticker)
Method triggered at every ticker update.void
onTradeUpdate(TradeDTO trade)
Method triggered on every trade update.void
orderUpdate(OrderDTO order)
Method called by streams on every order update.void
positionUpdate(PositionDTO position)
Method called by streams on every position update.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.void
tradeUpdate(TradeDTO trade)
Method called by streams on every trade update.-
Methods inherited from class tech.cassandre.trading.bot.strategy.GenericCassandreStrategy
canBuy, canBuy, canBuy, canBuy, canSell, canSell, canSell, canSell, getAccounts, getEstimatedBuyingCost, getLastTicker, getOrders, getPositions, getPositionService, getPreviousPositions, getTradeAccount, getTrades, getTradeService, setPositionService, setTradeService
-
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 between two bars are added.- 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
-
accountUpdate
public final void accountUpdate(AccountDTO account)
Description copied from interface:CassandreStrategyInterface
Method called by streams at every account update.- Parameters:
account
- account
-
tickerUpdate
public final void tickerUpdate(TickerDTO ticker)
Description copied from interface:CassandreStrategyInterface
Method called by streams at every ticker update.- Parameters:
ticker
- ticker
-
orderUpdate
public final void orderUpdate(OrderDTO order)
Description copied from interface:CassandreStrategyInterface
Method called by streams on every order update.- Parameters:
order
- order
-
tradeUpdate
public final void tradeUpdate(TradeDTO trade)
Description copied from interface:CassandreStrategyInterface
Method called by streams on every trade update.- Parameters:
trade
- trade
-
positionUpdate
public final void positionUpdate(PositionDTO position)
Description copied from interface:CassandreStrategyInterface
Method called by streams on every position update.- Parameters:
position
- trade
-
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 money 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 money 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 money 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 money 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 money to buy
-
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 money to buy
-
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 money to buy
-
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 money to buy
-
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
-
onAccountUpdate
public void onAccountUpdate(AccountDTO account)
Description copied from interface:CassandreStrategyInterface
Method triggered at every account update.- Parameters:
account
- account
-
onTickerUpdate
public void onTickerUpdate(TickerDTO ticker)
Description copied from interface:CassandreStrategyInterface
Method triggered at every ticker update.- Parameters:
ticker
- ticker
-
onOrderUpdate
public void onOrderUpdate(OrderDTO order)
Description copied from interface:CassandreStrategyInterface
Method triggered on every order update.- Parameters:
order
- order
-
onTradeUpdate
public void onTradeUpdate(TradeDTO trade)
Description copied from interface:CassandreStrategyInterface
Method triggered on every trade update.- Parameters:
trade
- trade
-
onPositionUpdate
public void onPositionUpdate(PositionDTO position)
Description copied from interface:CassandreStrategyInterface
Method triggered on every position update.- Parameters:
position
- position
-
onPositionStatusUpdate
public void onPositionStatusUpdate(PositionDTO position)
Description copied from interface:CassandreStrategyInterface
Method triggered on every position status update.- Parameters:
position
- position
-
-