Interface PositionService
-
- All Known Implementing Classes:
PositionServiceCassandreImplementation
public interface PositionService
Service allowing you to manage your positions.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description OrderCreationResultDTO
closePosition(GenericCassandreStrategy strategy, long id, TickerDTO ticker)
Close a position - This method is used by Cassandre internally.PositionCreationResultDTO
createLongPosition(GenericCassandreStrategy strategy, CurrencyPairDTO currencyPair, BigDecimal amount, PositionRulesDTO rules)
Creates a long position with its associated rules.PositionCreationResultDTO
createShortPosition(GenericCassandreStrategy strategy, CurrencyPairDTO currencyPair, BigDecimal amount, PositionRulesDTO rules)
Creates a short position with its associated rules.void
forcePositionClosing(long id)
Force a position to close (no matter the rules) - This method can be use by user code.Map<Long,CurrencyAmountDTO>
getAmountsLockedByPosition()
Returns the amounts locked by each position.Map<CurrencyDTO,GainDTO>
getGains()
Return the gains made by all closed positions.Optional<PositionDTO>
getPositionById(long id)
Get position by id.Set<PositionDTO>
getPositions()
Get positions.void
updatePositionRules(long id, PositionRulesDTO newRules)
Update position rules.
-
-
-
Method Detail
-
createLongPosition
PositionCreationResultDTO createLongPosition(GenericCassandreStrategy strategy, CurrencyPairDTO currencyPair, BigDecimal amount, PositionRulesDTO rules)
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.- Parameters:
strategy
- strategycurrencyPair
- currency pairamount
- amountrules
- rules- Returns:
- position creation result
-
createShortPosition
PositionCreationResultDTO createShortPosition(GenericCassandreStrategy strategy, CurrencyPairDTO currencyPair, BigDecimal amount, PositionRulesDTO rules)
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.- Parameters:
strategy
- strategycurrencyPair
- currency pairamount
- amountrules
- rules- Returns:
- position creation result
-
updatePositionRules
void updatePositionRules(long id, PositionRulesDTO newRules)
Update position rules.- Parameters:
id
- position idnewRules
- new rules
-
closePosition
OrderCreationResultDTO closePosition(GenericCassandreStrategy strategy, long id, TickerDTO ticker)
Close a position - This method is used by Cassandre internally.- Parameters:
strategy
- strategyid
- position idticker
- ticker- Returns:
- order creation result
-
forcePositionClosing
void forcePositionClosing(long id)
Force a position to close (no matter the rules) - This method can be use by user code.- Parameters:
id
- position id
-
getPositions
Set<PositionDTO> getPositions()
Get positions.- Returns:
- position list
-
getPositionById
Optional<PositionDTO> getPositionById(long id)
Get position by id.- Parameters:
id
- id- Returns:
- position
-
getAmountsLockedByPosition
Map<Long,CurrencyAmountDTO> getAmountsLockedByPosition()
Returns the amounts locked by each position.- Returns:
- amounts locked by each position
-
getGains
Map<CurrencyDTO,GainDTO> getGains()
Return the gains made by all closed positions.- Returns:
- gains by currency.
-
-