Interface PositionService
-
- All Known Implementing Classes:
PositionServiceCassandreImplementation
public interface PositionService
Service allowing you to manage positions.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Map<Long,CurrencyAmountDTO>
amountsLockedByPosition()
Returns the amounts locked by every position.void
closePosition(long id)
Close position (no matter the rules).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.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
ordersUpdates(Set<OrderDTO> orders)
Method called by streams on orders updates.void
tickersUpdates(Set<TickerDTO> tickers)
Method called by streams on tickers updates.void
tradesUpdates(Set<TradeDTO> trades)
Method called by streams on trades updates.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
void closePosition(long id)
Close position (no matter the rules).- 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
-
ordersUpdates
void ordersUpdates(Set<OrderDTO> orders)
Method called by streams on orders updates.- Parameters:
orders
- orders updates
-
tradesUpdates
void tradesUpdates(Set<TradeDTO> trades)
Method called by streams on trades updates.- Parameters:
trades
- trades updates
-
tickersUpdates
void tickersUpdates(Set<TickerDTO> tickers)
Method called by streams on tickers updates.- Parameters:
tickers
- tickers updates
-
amountsLockedByPosition
Map<Long,CurrencyAmountDTO> amountsLockedByPosition()
Returns the amounts locked by every position.- Returns:
- amounts locked by every position
-
getGains
Map<CurrencyDTO,GainDTO> getGains()
Return the gains made by all closed positions.- Returns:
- gains by currency.
-
-