Class PositionService
java.lang.Object
com.bluebell.greenhouse.radicle.services.AbstractGenericEntityService<Position, PositionRepository>
com.bluebell.greenhouse.radicle.services.position.PositionService
@Service
@Transactional(readOnly=true)
public class PositionService
extends AbstractGenericEntityService<Position, PositionRepository>
Service-layer for
Position entities.- Version:
- 3.0.6
- Author:
- Stephen Prizio
-
Constructor Summary
ConstructorsConstructorDescriptionPositionService(PositionRepository positionRepository, AccountLedgerRepository accountLedgerRepository, TransactionRepository transactionRepository, AccountLedgerService accountLedgerService, SymbolService symbolService, StrategyService strategyService, PositionLifecycleService positionLifecycleService, PositionDTOConverter positionDTOConverter) Creates the service. -
Method Summary
Modifier and TypeMethodDescriptionclosePosition(Position position, String positionClosed, Account account) Closes the givenPositionand computes returns and drawdown.createNewPosition(CreateUpdatePositionDTO data, Account account) Creates a newPosition.booleanDeletes the position a reference identifies.booleandeletePosition(Position position) Deletes the givenPositionand all child entities.findPositionById(Long id, Account account) findPositionByPositionNumber(long positionNumber, Account account) findPositionsByOpenState(Account account, boolean open) Returns positions for the given account filtered by open state.Generates insights for the position a reference identifies.generatePositionInsights(Position position) GeneratesPositionInsightsdescribing the givenPosition's performance.longGenerates a unique position number.Returns the detail payload for the given position reference.intrecalculatePositions(Account account) Recalculates all positions for the givenAccount.Resolves the position a reference identifies.org.springframework.data.domain.Page<Position> searchPositions(PositionFilter filter, int page, int pageSize, org.springframework.data.domain.Sort sort) Returns a paginatedPageofPositions matching the given filter.org.springframework.data.domain.Page<PositionSummaryView> searchPositionSummaries(PositionFilter filter, int page, int pageSize, org.springframework.data.domain.Sort sort) Returns a page of flat position rows for the given filter.updatePosition(OwnedPositionRef ref, CreateUpdatePositionDTO data, Account account) Updates the position a reference identifies.updatePosition(Position position, CreateUpdatePositionDTO data, Account account) Updates an existingPosition.Methods inherited from class AbstractGenericEntityService
refreshEntity, resolveEntity, resolveEntity, resolveEntity
-
Constructor Details
-
PositionService
public PositionService(PositionRepository positionRepository, AccountLedgerRepository accountLedgerRepository, TransactionRepository transactionRepository, AccountLedgerService accountLedgerService, SymbolService symbolService, StrategyService strategyService, PositionLifecycleService positionLifecycleService, PositionDTOConverter positionDTOConverter) Creates the service.- Parameters:
positionRepository-PositionRepositoryaccountLedgerRepository-AccountLedgerRepositorytransactionRepository-TransactionRepositoryaccountLedgerService-AccountLedgerServicesymbolService-SymbolServicestrategyService-StrategyServicepositionLifecycleService-PositionLifecycleServicepositionDTOConverter-PositionDTOConverter
-
-
Method Details
-
generateUniquePositionNumber
public long generateUniquePositionNumber()Generates a unique position number.- Returns:
- position number
-
findPositionByPositionNumber
-
findPositionById
-
findPositionsByOpenState
-
searchPositions
public org.springframework.data.domain.Page<Position> searchPositions(PositionFilter filter, int page, int pageSize, org.springframework.data.domain.Sort sort) Returns a paginatedPageofPositions matching the given filter.- Parameters:
filter-PositionFilterpage- current pagepageSize- page sizesort-Sort- Returns:
PageofPosition
-
searchPositionSummaries
public org.springframework.data.domain.Page<PositionSummaryView> searchPositionSummaries(PositionFilter filter, int page, int pageSize, org.springframework.data.domain.Sort sort) Returns a page of flat position rows for the given filter.- Parameters:
filter-PositionFilterpage- page numberpageSize- page sizesort-Sort- Returns:
PageofPositionSummaryView
-
resolveOwned
Resolves the position a reference identifies.- Parameters:
ref-OwnedPositionRef- Returns:
Position
-
generatePositionInsights
Generates insights for the position a reference identifies.- Parameters:
ref-OwnedPositionRef- Returns:
PositionInsights
-
updatePosition
@Transactional public Position updatePosition(OwnedPositionRef ref, CreateUpdatePositionDTO data, Account account) Updates the position a reference identifies.- Parameters:
ref-OwnedPositionRefdata-CreateUpdatePositionDTOaccount- owningAccount- Returns:
- updated
Position
-
deletePosition
Deletes the position a reference identifies.- Parameters:
ref-OwnedPositionRef- Returns:
- true when the position was deleted
-
getPositionDetail
Returns the detail payload for the given position reference.- Parameters:
ref-OwnedPositionRef- Returns:
PositionDTO
-
generatePositionInsights
GeneratesPositionInsightsdescribing the givenPosition's performance. Open positions have no realized performance to report and resolve to an empty insights payload.- Parameters:
position-Position- Returns:
PositionInsights
-
createNewPosition
Creates a newPosition.- Parameters:
data-CreateUpdatePositionDTOaccount-Account- Returns:
- new
Position
-
recalculatePositions
-
updatePosition
@Transactional public Position updatePosition(Position position, CreateUpdatePositionDTO data, Account account) Updates an existingPosition.- Parameters:
position-Positiondata-CreateUpdatePositionDTOaccount-Account- Returns:
- updated
Position
-
closePosition
-
deletePosition
-