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

        OrderCreationResultDTO closePosition​(GenericCassandreStrategy strategy,
                                             long id,
                                             TickerDTO ticker)
        Close a position - This method is used by Cassandre internally.
        Parameters:
        strategy - strategy
        id - position id
        ticker - ticker
        Returns:
        order creation result
      • forcePositionClosing

        void forcePositionClosing​(long id)
        Force a position to close (no matter the rules) - This method can be use by user code.
        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
      • getAmountsLockedByPosition

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

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