Class PositionServiceCassandreImplementation

java.lang.Object
tech.cassandre.trading.bot.util.base.Base
tech.cassandre.trading.bot.util.base.service.BaseService
tech.cassandre.trading.bot.service.PositionServiceCassandreImplementation
All Implemented Interfaces:
PositionService

public class PositionServiceCassandreImplementation extends BaseService implements PositionService
Position service - Implementation of PositionService.
  • Constructor Details

  • Method Details

    • createLongPosition

      public final PositionCreationResultDTO createLongPosition(@NonNull @NonNull CassandreStrategy strategy, @NonNull @NonNull CurrencyPairDTO currencyPair, @NonNull @NonNull BigDecimal amount, @NonNull @NonNull PositionRulesDTO rules)
      Description copied from interface: PositionService
      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.
      Specified by:
      createLongPosition in interface PositionService
      Parameters:
      strategy - strategy
      currencyPair - currency pair
      amount - amount
      rules - rules
      Returns:
      position creation result
    • createShortPosition

      public final PositionCreationResultDTO createShortPosition(@NonNull @NonNull CassandreStrategy strategy, @NonNull @NonNull CurrencyPairDTO currencyPair, @NonNull @NonNull BigDecimal amount, @NonNull @NonNull PositionRulesDTO rules)
      Description copied from interface: PositionService
      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.
      Specified by:
      createShortPosition in interface PositionService
      Parameters:
      strategy - strategy
      currencyPair - currency pair
      amount - amount
      rules - rules
      Returns:
      position creation result
    • updatePositionRules

      public final void updatePositionRules(long positionUid, @NonNull @NonNull PositionRulesDTO newRules)
      Description copied from interface: PositionService
      Update position rules.
      Specified by:
      updatePositionRules in interface PositionService
      Parameters:
      positionUid - position uid
      newRules - new rules
    • closePosition

      public final OrderCreationResultDTO closePosition(@NonNull @NonNull CassandreStrategyInterface strategy, long positionUid, @NonNull @NonNull TickerDTO ticker)
      Description copied from interface: PositionService
      Close a position.
      Specified by:
      closePosition in interface PositionService
      Parameters:
      strategy - strategy
      positionUid - position uid
      ticker - ticker
      Returns:
      order creation result
    • setAutoClose

      public final void setAutoClose(long positionUid, boolean value)
      Description copied from interface: PositionService
      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.
      Specified by:
      setAutoClose in interface PositionService
      Parameters:
      positionUid - position uid
      value - auto close value
    • forcePositionClosing

      public final void forcePositionClosing(long positionUid)
      Description copied from interface: PositionService
      Force a position to close (no matter the rules).
      Specified by:
      forcePositionClosing in interface PositionService
      Parameters:
      positionUid - position uid
    • getPositions

      public final Set<PositionDTO> getPositions()
      Description copied from interface: PositionService
      Get positions.
      Specified by:
      getPositions in interface PositionService
      Returns:
      position list
    • getPositionByUid

      public final Optional<PositionDTO> getPositionByUid(long positionUid)
      Description copied from interface: PositionService
      Get position by position uid.
      Specified by:
      getPositionByUid in interface PositionService
      Parameters:
      positionUid - position uid
      Returns:
      position
    • getAmountsLockedByPosition

      public final Map<Long,CurrencyAmountDTO> getAmountsLockedByPosition()
      Description copied from interface: PositionService
      Returns the amounts locked by each position.
      Specified by:
      getAmountsLockedByPosition in interface PositionService
      Returns:
      amounts locked by each position
    • getGains

      public final Map<CurrencyDTO,GainDTO> getGains(long strategyUid)
      Description copied from interface: PositionService
      Return the gains made by all closed positions of a strategy. If strategyUid equals 0, returns all the gains.
      Specified by:
      getGains in interface PositionService
      Parameters:
      strategyUid - strategy uid
      Returns:
      gains by currency.
    • getGains

      public final Map<CurrencyDTO,GainDTO> getGains()
      Description copied from interface: PositionService
      Return the gains made by all closed positions.
      Specified by:
      getGains in interface PositionService
      Returns:
      gains by currency.