Class GenericCassandreStrategy

    • Field Detail

      • currencyMapper

        protected final CurrencyMapper currencyMapper
        Currency mapper.
      • orderMapper

        protected final OrderMapper orderMapper
        Order mapper.
      • tradeMapper

        protected final TradeMapper tradeMapper
        Trade mapper.
      • positionMapper

        protected final PositionMapper positionMapper
        Position mapper.
    • Constructor Detail

      • GenericCassandreStrategy

        public GenericCassandreStrategy()
    • Method Detail

      • getStrategyDTO

        public final StrategyDTO getStrategyDTO()
        Getter strategyDTO.
        Returns:
        strategyDTO
      • getAccounts

        public final Map<String,​AccountDTO> getAccounts()
        Returns list of accounts.
        Returns:
        accounts
      • getAccountByAccountId

        public final Optional<AccountDTO> getAccountByAccountId​(String accountId)
        Search and return and account by its id.
        Parameters:
        accountId - account id
        Returns:
        account
      • getAmountsLockedByPosition

        public final Map<Long,​CurrencyAmountDTO> getAmountsLockedByPosition()
        Getter amountsLockedByPosition.
        Returns:
        amountsLockedByPosition
      • getAmountsLockedByCurrency

        public final BigDecimal getAmountsLockedByCurrency​(CurrencyDTO currency)
        Returns the amount locked by currency.
        Parameters:
        currency - currency
        Returns:
        amount
      • getLastTickerByCurrencyPair

        public final Optional<TickerDTO> getLastTickerByCurrencyPair​(String currencyPair)
        Return the last ticker for a currency pair.
        Parameters:
        currencyPair - currency pair
        Returns:
        last ticker received
      • getLastTickerByCurrencyPair

        public final Optional<TickerDTO> getLastTickerByCurrencyPair​(CurrencyPairDTO currencyPair)
        Return the last ticker for a currency pair.
        Parameters:
        currencyPair - currency pair
        Returns:
        last ticker received
      • getOrders

        public final Map<String,​OrderDTO> getOrders()
        Returns list of orders.
        Returns:
        orders
      • getOrderByOrderId

        public final Optional<OrderDTO> getOrderByOrderId​(String orderId)
        Get an order by its id.
        Parameters:
        orderId - order id
        Returns:
        order
      • getTrades

        public final Map<String,​TradeDTO> getTrades()
        Returns list of trades.
        Returns:
        trades
      • getTradeByTradeId

        public final Optional<TradeDTO> getTradeByTradeId​(String tradeId)
        Get a trade by its id.
        Parameters:
        tradeId - trade id
        Returns:
        trade
      • getPositions

        public final Map<Long,​PositionDTO> getPositions()
        Returns list of positions.
        Returns:
        positions
      • getPositionByPositionId

        public final Optional<PositionDTO> getPositionByPositionId​(long positionId)
        Get a position by its id.
        Parameters:
        positionId - position id
        Returns:
        position
      • createBuyMarketOrder

        public OrderCreationResultDTO createBuyMarketOrder​(CurrencyPairDTO currencyPair,
                                                           BigDecimal amount)
        Creates a buy market order.
        Parameters:
        currencyPair - currency pair
        amount - amount
        Returns:
        order result (order id or error)
      • createSellMarketOrder

        public OrderCreationResultDTO createSellMarketOrder​(CurrencyPairDTO currencyPair,
                                                            BigDecimal amount)
        Creates a sell market order.
        Parameters:
        currencyPair - currency pair
        amount - amount
        Returns:
        order result (order id or error)
      • createBuyLimitOrder

        public OrderCreationResultDTO createBuyLimitOrder​(CurrencyPairDTO currencyPair,
                                                          BigDecimal amount,
                                                          BigDecimal limitPrice)
        Creates a buy limit order.
        Parameters:
        currencyPair - currency pair
        amount - amount
        limitPrice - the highest acceptable price
        Returns:
        order result (order id or error)
      • createSellLimitOrder

        public OrderCreationResultDTO createSellLimitOrder​(CurrencyPairDTO currencyPair,
                                                           BigDecimal amount,
                                                           BigDecimal limitPrice)
        Creates a sell limit order.
        Parameters:
        currencyPair - currency pair
        amount - amount
        limitPrice - the lowest acceptable price
        Returns:
        order result (order id or error)
      • createLongPosition

        public PositionCreationResultDTO createLongPosition​(CurrencyPairDTO currencyPair,
                                                            BigDecimal amount,
                                                            PositionRulesDTO rules)
        Creates a long position with its associated rules. Long position is nothing but buying share. If you are bullish (means you think that price of X share will rise) at that time you buy some amount of Share is called taking Long Position in share.
        Parameters:
        currencyPair - currency pair
        amount - amount
        rules - rules
        Returns:
        position creation result
      • createShortPosition

        public PositionCreationResultDTO createShortPosition​(CurrencyPairDTO currencyPair,
                                                             BigDecimal amount,
                                                             PositionRulesDTO rules)
        Creates a short position with its associated rules. Short position is nothing but selling share. If you are bearish (means you think that price of xyz share are going to fall) at that time you sell some amount of share is called taking Short Position in share.
        Parameters:
        currencyPair - currency pair
        amount - amount
        rules - rules
        Returns:
        position creation result
      • getEstimatedBuyingCost

        public final Optional<CurrencyAmountDTO> getEstimatedBuyingCost​(CurrencyPairDTO currencyPair,
                                                                        BigDecimal amount)
        Returns the cost of buying an amount of a currency pair.
        Parameters:
        currencyPair - currency pair
        amount - amount
        Returns:
        cost
      • canBuy

        public final boolean canBuy​(CurrencyPairDTO currencyPair,
                                    BigDecimal amount)
        Returns true if we have enough assets to buy.
        Parameters:
        currencyPair - currency pair
        amount - amount
        Returns:
        true if we there is enough assets to buy
      • canBuy

        public final boolean canBuy​(CurrencyPairDTO currencyPair,
                                    BigDecimal amount,
                                    BigDecimal minimumBalanceAfter)
        Returns true if we have enough assets to buy.
        Parameters:
        currencyPair - currency pair
        amount - amount
        minimumBalanceAfter - 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,
                                    CurrencyPairDTO currencyPair,
                                    BigDecimal amount)
        Returns true if we have enough assets to buy.
        Parameters:
        account - account
        currencyPair - currency pair
        amount - amount
        Returns:
        true if we there is enough assets 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 - account
        currencyPair - currency pair
        amount - amount
        minimumBalanceAfter - minimum balance that should be left after buying
        Returns:
        true if we there is enough assets to buy
      • canSell

        public final boolean canSell​(CurrencyDTO currency,
                                     BigDecimal amount)
        Returns true if we have enough assets to sell.
        Parameters:
        currency - currency
        amount - amount
        Returns:
        true if we there is enough assets to sell
      • canSell

        public final boolean canSell​(CurrencyDTO currency,
                                     BigDecimal amount,
                                     BigDecimal minimumBalanceAfter)
        Returns true if we have enough assets to sell.
        Parameters:
        currency - currency
        amount - amount
        minimumBalanceAfter - minimum balance that should be left after selling
        Returns:
        true if we there is enough assets to sell
      • canSell

        public final boolean canSell​(AccountDTO account,
                                     CurrencyDTO currency,
                                     BigDecimal amount)
        Returns true if we have enough assets to sell.
        Parameters:
        account - account
        currency - currency pair
        amount - amount
        Returns:
        true if we there is enough assets to sell
      • 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 - account
        currency - currency
        amount - amount
        minimumBalanceAfter - minimum balance that should be left after selling
        Returns:
        true if we there is enough assets to sell