Interface PositionService

    • Method Detail

      • createLongPosition

        PositionCreationResultDTO createLongPosition​(GenericCassandreStrategy strategy,
                                                     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:
        strategy - strategy
        currencyPair - currency pair
        amount - amount
        rules - rules
        Returns:
        position creation result
      • createShortPosition

        PositionCreationResultDTO createShortPosition​(GenericCassandreStrategy strategy,
                                                      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 X share are going to fall) at that time you sell some amount of share is called taking Short Position in share.
        Parameters:
        strategy - strategy
        currencyPair - currency pair
        amount - amount
        rules - rules
        Returns:
        position creation result
      • updatePositionRules

        void updatePositionRules​(long id,
                                 PositionRulesDTO newRules)
        Update position rules.
        Parameters:
        id - position id
        newRules - new rules
      • closePosition

        void closePosition​(long id)
        Close position (no matter the rules).
        Parameters:
        id - position id
      • getPositions

        Set<PositionDTO> getPositions()
        Get positions.
        Returns:
        position list
      • getPositionById

        Optional<PositionDTO> getPositionById​(long id)
        Get position by id.
        Parameters:
        id - id
        Returns:
        position
      • ordersUpdates

        void ordersUpdates​(Set<OrderDTO> orders)
        Method called by streams on orders updates.
        Parameters:
        orders - orders updates
      • tradesUpdates

        void tradesUpdates​(Set<TradeDTO> trades)
        Method called by streams on trades updates.
        Parameters:
        trades - trades updates
      • tickersUpdates

        void tickersUpdates​(Set<TickerDTO> tickers)
        Method called by streams on tickers updates.
        Parameters:
        tickers - tickers updates
      • amountsLockedByPosition

        Map<Long,​CurrencyAmountDTO> amountsLockedByPosition()
        Returns the amounts locked by every position.
        Returns:
        amounts locked by every position
      • getGains

        Map<CurrencyDTO,​GainDTO> getGains()
        Return the gains made by all closed positions.
        Returns:
        gains by currency.