Interface PositionRepository
-
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<Position,Long>
,org.springframework.data.jpa.repository.JpaRepository<Position,Long>
,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>
Position
repository.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description List<Position>
findByOrderById()
Retrieve all positions (sorted by id).Optional<Position>
findByPositionId(long positionId)
Find a position by its position id.List<Position>
findByStatus(PositionStatusDTO status)
Find positions with a specific status.List<Position>
findByStatusIn(Set<PositionStatusDTO> status)
Find positions with any of specific status.List<Position>
findByStatusNot(PositionStatusDTO status)
Find positions without a specific status.Long
getLastPositionIdUsedByStrategy(Long strategyId)
Returns the last position id used by a strategy.void
updateForceClosing(Long id, boolean value)
Update force closing.void
updateStopGainRule(Long id, Float value)
Update stop gain rule.void
updateStopLossRule(Long id, 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
-
-
-
-
Method Detail
-
findByPositionId
Optional<Position> findByPositionId(long positionId)
Find a position by its position id.- Parameters:
positionId
- position id- Returns:
- positions
-
findByOrderById
List<Position> findByOrderById()
Retrieve all positions (sorted by id).- 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 without a specific status.- Parameters:
status
- status- Returns:
- positions
-
findByStatusIn
List<Position> findByStatusIn(Set<PositionStatusDTO> status)
Find positions with any of specific status.- Parameters:
status
- list of status- Returns:
- positions
-
getLastPositionIdUsedByStrategy
@Query("SELECT coalesce(max(p.positionId), 0) FROM Position p where p.strategy.id = :strategyId") Long getLastPositionIdUsedByStrategy(@Param("strategyId") Long strategyId)
Returns the last position id used by a strategy.- Parameters:
strategyId
- strategy id- Returns:
- positions
-
updateStopGainRule
@Transactional @Modifying @Query("update Position p set p.stopGainPercentageRule = :value where p.id = :id") void updateStopGainRule(@Param("id") Long id, @Param("value") Float value)
Update stop gain rule.- Parameters:
id
- position idvalue
- new value
-
updateStopLossRule
@Transactional @Modifying @Query("update Position p set p.stopLossPercentageRule = :value where p.id = :id") void updateStopLossRule(@Param("id") Long id, @Param("value") Float value)
Update stop loss rule.- Parameters:
id
- position idvalue
- new value
-
updateForceClosing
@Transactional @Modifying @Query("update Position p set p.forceClosing = :value where p.id = :id") void updateForceClosing(@Param("id") Long id, @Param("value") boolean value)
Update force closing.- Parameters:
id
- position idvalue
- true to force closing
-
-