Class GenericCassandreStrategy
- java.lang.Object
-
- tech.cassandre.trading.bot.strategy.GenericCassandreStrategy
-
- All Implemented Interfaces:
CassandreStrategyInterface
- Direct Known Subclasses:
BasicCassandreStrategy
,BasicTa4jCassandreStrategy
public abstract class GenericCassandreStrategy extends Object implements CassandreStrategyInterface
Generic Cassandre strategy.
-
-
Constructor Summary
Constructors Constructor Description GenericCassandreStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canBuy(AccountDTO account, CurrencyPairDTO currencyPair, BigDecimal amount)
Returns true if we have enough assets to buy.boolean
canBuy(AccountDTO account, CurrencyPairDTO currencyPair, BigDecimal amount, BigDecimal minimumBalanceAfter)
Returns true if we have enough assets to buy and if minimumBalanceAfter is left on the account after.boolean
canSell(AccountDTO account, CurrencyDTO currency, BigDecimal amount)
Returns true if we have enough assets to sell.boolean
canSell(AccountDTO account, CurrencyDTO currency, BigDecimal amount, BigDecimal minimumBalanceAfter)
Returns true if we have enough assets to sell and if minimumBalanceAfter is left on the account after.Map<String,AccountDTO>
getAccounts()
Getter accounts.Optional<CurrencyAmountDTO>
getEstimatedBuyingCost(CurrencyPairDTO currencyPair, BigDecimal amount)
Returns the cost of buying an amount of a currency pair.Map<CurrencyPairDTO,TickerDTO>
getLastTicker()
Getter lastTicker.Map<String,OrderDTO>
getOrders()
Getter orders.Map<Long,PositionDTO>
getPositions()
Getter positions.PositionService
getPositionService()
Getter for positionService.Map<String,TradeDTO>
getTrades()
Getter trades.TradeService
getTradeService()
Getter for tradeService.void
restorePosition(PositionDTO position)
Restore position from database.void
restoreTrade(TradeDTO trade)
Restore trade from database.void
setPositionService(PositionService newPositionService)
Setter for positionService.void
setTradeService(TradeService newTradeService)
Setter for tradeService.-
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
accountUpdate, getRequestedCurrencyPairs, onAccountUpdate, onOrderUpdate, onPositionUpdate, onTickerUpdate, onTradeUpdate, orderUpdate, positionUpdate, tickerUpdate, tradeUpdate
-
-
-
-
Method Detail
-
setTradeService
public final void setTradeService(TradeService newTradeService)
Description copied from interface:CassandreStrategyInterface
Setter for tradeService.- Specified by:
setTradeService
in interfaceCassandreStrategyInterface
- Parameters:
newTradeService
- the tradeService to set
-
setPositionService
public final void setPositionService(PositionService newPositionService)
Description copied from interface:CassandreStrategyInterface
Setter for positionService.- Specified by:
setPositionService
in interfaceCassandreStrategyInterface
- Parameters:
newPositionService
- position service
-
getTradeService
public final TradeService getTradeService()
Description copied from interface:CassandreStrategyInterface
Getter for tradeService.- Specified by:
getTradeService
in interfaceCassandreStrategyInterface
- Returns:
- tradeService
-
getPositionService
public final PositionService getPositionService()
Description copied from interface:CassandreStrategyInterface
Getter for positionService.- Specified by:
getPositionService
in interfaceCassandreStrategyInterface
- Returns:
- positionService
-
restoreTrade
public final void restoreTrade(TradeDTO trade)
Description copied from interface:CassandreStrategyInterface
Restore trade from database.- Specified by:
restoreTrade
in interfaceCassandreStrategyInterface
- Parameters:
trade
- trade to restore
-
restorePosition
public final void restorePosition(PositionDTO position)
Description copied from interface:CassandreStrategyInterface
Restore position from database.- Specified by:
restorePosition
in interfaceCassandreStrategyInterface
- Parameters:
position
- position to restore
-
getAccounts
public final Map<String,AccountDTO> getAccounts()
Getter accounts.- Returns:
- accounts
-
getPositions
public final Map<Long,PositionDTO> getPositions()
Getter positions.- Returns:
- positions
-
getLastTicker
public final Map<CurrencyPairDTO,TickerDTO> getLastTicker()
Getter lastTicker.- Returns:
- lastTicker
-
getEstimatedBuyingCost
public final Optional<CurrencyAmountDTO> getEstimatedBuyingCost(CurrencyPairDTO currencyPair, BigDecimal amount)
Returns the cost of buying an amount of a currency pair.- Parameters:
currencyPair
- currency pairamount
- amount- Returns:
- cost
-
canBuy
public final boolean canBuy(AccountDTO account, CurrencyPairDTO currencyPair, BigDecimal amount)
Returns true if we have enough assets to buy.- Parameters:
account
- accountcurrencyPair
- currency pairamount
- amount- Returns:
- true if we there is enough money to buy
-
canBuy
public final boolean canBuy(AccountDTO account, CurrencyPairDTO currencyPair, BigDecimal amount, BigDecimal minimumBalanceAfter)
Returns true if we have enough assets to buy and if minimumBalanceAfter is left on the account after.- Parameters:
account
- accountcurrencyPair
- currency pairamount
- amountminimumBalanceAfter
- minimum balance that should be left after buying- Returns:
- true if we there is enough money to buy
-
canSell
public final boolean canSell(AccountDTO account, CurrencyDTO currency, BigDecimal amount)
Returns true if we have enough assets to sell.- Parameters:
account
- accountcurrency
- currency pairamount
- amount- Returns:
- true if we there is enough money to buy
-
canSell
public final boolean canSell(AccountDTO account, CurrencyDTO currency, BigDecimal amount, BigDecimal minimumBalanceAfter)
Returns true if we have enough assets to sell and if minimumBalanceAfter is left on the account after.- Parameters:
account
- accountcurrency
- currencyamount
- amountminimumBalanceAfter
- minimum balance that should be left after selling- Returns:
- true if we there is enough money to buy
-
-