Interface PositionService
- All Known Implementing Classes:
PositionServiceCassandreImplementation
public interface PositionService
Service managing positions.
-
Method Summary
Modifier and TypeMethodDescriptionclosePosition
(CassandreStrategyInterface strategy, long positionUid, TickerDTO ticker) Close a position.createLongPosition
(CassandreStrategy strategy, CurrencyPairDTO currencyPair, BigDecimal amount, PositionRulesDTO rules) Creates a long position with its associated rules.createShortPosition
(CassandreStrategy strategy, CurrencyPairDTO currencyPair, BigDecimal amount, PositionRulesDTO rules) Creates a short position with its associated rules.void
forcePositionClosing
(long positionUid) Force a position to close (no matter the rules).Returns the amounts locked by each position.getGains()
Return the gains made by all closed positions.getGains
(long strategyUid) Return the gains made by all closed positions of a strategy.getPositionByUid
(long positionUid) Get position by position uid.Get positions.void
setAutoClose
(long positionUid, boolean value) Set auto close value on a specific position.void
updatePositionRules
(long positionUid, PositionRulesDTO newRules) Update position rules.
-
Method Details
-
createLongPosition
PositionCreationResultDTO createLongPosition(CassandreStrategy 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(CassandreStrategy 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
Update position rules.- Parameters:
positionUid
- position uidnewRules
- new rules
-
closePosition
OrderCreationResultDTO closePosition(CassandreStrategyInterface strategy, long positionUid, TickerDTO ticker) Close a position.- Parameters:
strategy
- strategypositionUid
- position uidticker
- ticker- Returns:
- order creation result
-
setAutoClose
void setAutoClose(long positionUid, boolean value) Set auto close value on a specific position. If true, Cassandre will close the position according to rules. if false, Cassandre will never close the position itself.- Parameters:
positionUid
- position uidvalue
- auto close value
-
forcePositionClosing
void forcePositionClosing(long positionUid) Force a position to close (no matter the rules).- Parameters:
positionUid
- position uid
-
getPositionByUid
Get position by position uid.- Parameters:
positionUid
- position uid- Returns:
- position
-
getPositions
Set<PositionDTO> getPositions()Get positions.- Returns:
- position list
-
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.
-
getGains
Return the gains made by all closed positions of a strategy. If strategyUid equals 0, returns all the gains.- Parameters:
strategyUid
- strategy uid- Returns:
- gains by currency.
-