Interface PositionRepository

All Superinterfaces:
org.springframework.data.repository.CrudRepository<Position,Long>, org.springframework.data.jpa.repository.JpaRepository<Position,Long>, org.springframework.data.jpa.repository.JpaSpecificationExecutor<Position>, org.springframework.data.repository.PagingAndSortingRepository<Position,Long>, org.springframework.data.repository.query.QueryByExampleExecutor<Position>, org.springframework.data.repository.Repository<Position,Long>

@Repository public interface PositionRepository extends org.springframework.data.jpa.repository.JpaRepository<Position,Long>, org.springframework.data.jpa.repository.JpaSpecificationExecutor<Position>
Position repository.
  • Method Summary

    Modifier and Type
    Method
    Description
    Retrieve all positions (sorted by uid).
    findByPositionId(long positionId)
    Find a position by its position id.
    Find positions with a specific status.
    Find positions with any of the status passed as parameter.
    Find positions with a status different from the one passed as a parameter.
    Returns the last position id used by a strategy.
    void
    updateAutoClose(Long uid, boolean value)
    Update autoclose.
    void
    updateForceClosing(Long uid, boolean value)
    Update force closing.
    void
    Update stop gain rule.
    void
    Update stop loss rule.

    Methods inherited from interface org.springframework.data.repository.CrudRepository

    count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findById, save

    Methods inherited from interface org.springframework.data.jpa.repository.JpaRepository

    deleteAllByIdInBatch, deleteAllInBatch, deleteAllInBatch, deleteInBatch, findAll, findAll, findAll, findAll, findAllById, flush, getById, getOne, saveAll, saveAllAndFlush, saveAndFlush

    Methods inherited from interface org.springframework.data.jpa.repository.JpaSpecificationExecutor

    count, findAll, findAll, findAll, findOne

    Methods inherited from interface org.springframework.data.repository.PagingAndSortingRepository

    findAll

    Methods inherited from interface org.springframework.data.repository.query.QueryByExampleExecutor

    count, exists, findAll, findBy, findOne
  • Method Details

    • findByPositionId

      Optional<Position> findByPositionId(long positionId)
      Find a position by its position id.
      Parameters:
      positionId - position id
      Returns:
      positions
    • findByOrderByUid

      List<Position> findByOrderByUid()
      Retrieve all positions (sorted by uid).
      Returns:
      positions
    • findByStatus

      List<Position> findByStatus(PositionStatusDTO status)
      Find positions with a specific status.
      Parameters:
      status - status
      Returns:
      positions
    • findByStatusNot

      List<Position> findByStatusNot(PositionStatusDTO status)
      Find positions with a status different from the one passed as a parameter.
      Parameters:
      status - status
      Returns:
      positions
    • findByStatusIn

      List<Position> findByStatusIn(List<PositionStatusDTO> status)
      Find positions with any of the status passed as parameter.
      Parameters:
      status - list of status
      Returns:
      positions
    • getLastPositionIdUsedByStrategy

      @Query("SELECT coalesce(max(p.positionId), 0) FROM Position p where p.strategy.uid = :strategyUid") Long getLastPositionIdUsedByStrategy(@Param("strategyUid") Long strategyUid)
      Returns the last position id used by a strategy.
      Parameters:
      strategyUid - strategy uid
      Returns:
      positions
    • updateStopGainRule

      @Transactional @Modifying @Query("update Position p set p.stopGainPercentageRule = :value where p.uid = :uid") void updateStopGainRule(@Param("uid") Long uid, @Param("value") Float value)
      Update stop gain rule.
      Parameters:
      uid - position uid
      value - new value
    • updateStopLossRule

      @Transactional @Modifying @Query("update Position p set p.stopLossPercentageRule = :value where p.uid = :uid") void updateStopLossRule(@Param("uid") Long uid, @Param("value") Float value)
      Update stop loss rule.
      Parameters:
      uid - position uid
      value - new value
    • updateAutoClose

      @Transactional @Modifying @Query("update Position p set p.autoClose = :value where p.uid = :uid") void updateAutoClose(@Param("uid") Long uid, @Param("value") boolean value)
      Update autoclose.
      Parameters:
      uid - position uid
      value - true to allow autoclose.
    • updateForceClosing

      @Transactional @Modifying @Query("update Position p set p.forceClosing = :value where p.uid = :uid") void updateForceClosing(@Param("uid") Long uid, @Param("value") boolean value)
      Update force closing.
      Parameters:
      uid - position uid
      value - true to force closing