Interface PositionService

All Known Implementing Classes:
PositionServiceCassandreImplementation

public interface PositionService
Service managing positions.
  • Method Details

    • createLongPosition

      PositionCreationResultDTO createLongPosition(CassandreStrategy 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(CassandreStrategy 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 positionUid, PositionRulesDTO newRules)
      Update position rules.
      Parameters:
      positionUid - position uid
      newRules - new rules
    • closePosition

      OrderCreationResultDTO closePosition(CassandreStrategyInterface strategy, long positionUid, TickerDTO ticker)
      Close a position.
      Parameters:
      strategy - strategy
      positionUid - position uid
      ticker - ticker
      Returns:
      order creation result
    • setAutoClose

      void setAutoClose(long positionUid, boolean value)
      Set auto close value on a specific position. If true, Cassandre will close the position according to rules. if false, Cassandre will never close the position itself.
      Parameters:
      positionUid - position uid
      value - auto close value
    • forcePositionClosing

      void forcePositionClosing(long positionUid)
      Force a position to close (no matter the rules).
      Parameters:
      positionUid - position uid
    • getPositionByUid

      Optional<PositionDTO> getPositionByUid(long positionUid)
      Get position by position uid.
      Parameters:
      positionUid - position uid
      Returns:
      position
    • getPositions

      Set<PositionDTO> getPositions()
      Get positions.
      Returns:
      position list
    • 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.
    • getGains

      Map<CurrencyDTO,GainDTO> getGains(long strategyUid)
      Return the gains made by all closed positions of a strategy. If strategyUid equals 0, returns all the gains.
      Parameters:
      strategyUid - strategy uid
      Returns:
      gains by currency.