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 TypeMethodDescriptionRetrieve all positions (sorted by uid).findByPositionId
(long positionId) Find a position by its position id.findByStatus
(PositionStatusDTO status) Find positions with a specific status.findByStatusIn
(List<PositionStatusDTO> status) Find positions with any of the status passed as parameter.findByStatusNot
(PositionStatusDTO status) Find positions with a status different from the one passed as a parameter.getLastPositionIdUsedByStrategy
(Long strategyUid) 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
updateStopGainRule
(Long uid, Float value) Update stop gain rule.void
updateStopLossRule
(Long uid, Float value) 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
Find a position by its position id.- Parameters:
positionId
- position id- Returns:
- positions
-
findByOrderByUid
Retrieve all positions (sorted by uid).- Returns:
- positions
-
findByStatus
Find positions with a specific status.- Parameters:
status
- status- Returns:
- positions
-
findByStatusNot
Find positions with a status different from the one passed as a parameter.- Parameters:
status
- status- Returns:
- positions
-
findByStatusIn
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 uidvalue
- 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 uidvalue
- 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 uidvalue
- 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 uidvalue
- true to force closing
-