Class PositionDTO
- java.lang.Object
-
- tech.cassandre.trading.bot.dto.position.PositionDTO
-
public class PositionDTO extends Object
DTO representing a position. A position is the amount of a security, commodity or currency which is owned by an individual, dealer, institution, or other fiscal entity.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PositionDTO.PositionDTOBuilder
-
Constructor Summary
Constructors Constructor Description PositionDTO(long newId, StrategyDTO newStrategy, CurrencyPairDTO newCurrencyPair, BigDecimal newAmount, String newOpenOrderId, PositionRulesDTO newRules)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static PositionDTO.PositionDTOBuilder
builder()
void
closePositionWithOrderId(String newCloseOrderId)
Close position with order id.boolean
equals(Object o)
CurrencyAmountDTO
getAmount()
Amount that was ordered.OrderDTO
getClosingOrder()
The order created to close the position.String
getClosingOrderId()
The order id created to open the position.CurrencyPairDTO
getCurrencyPair()
Currency pair.String
getDescription()
Get position description.GainDTO
getGain()
Returns the gain of the position.Optional<GainDTO>
getHighestCalculatedGain()
Getter highestCalculatedGain.CurrencyAmountDTO
getHighestPrice()
Highest price reached by tis position.long
getId()
Technical ID.Optional<GainDTO>
getLatestCalculatedGain()
Getter latestCalculatedGain.CurrencyAmountDTO
getLatestPrice()
Latest price for this position.Optional<GainDTO>
getLowestCalculatedGain()
Getter lowestCalculatedGain.CurrencyAmountDTO
getLowestPrice()
Lowest price reached by tis position.OrderDTO
getOpeningOrder()
The order created to open the position.String
getOpeningOrderId()
The order id created to open the position.Long
getPositionId()
An identifier that uniquely identifies the position.PositionRulesDTO
getRules()
Position rules.PositionStatusDTO
getStatus()
Position status.StrategyDTO
getStrategy()
The strategy that created the position.PositionTypeDTO
getType()
Position type.int
hashCode()
boolean
orderUpdate(OrderDTO updatedOrder)
Method called by on every order update.boolean
shouldBeClosed()
Returns true if the position should be closed.boolean
tickerUpdate(TickerDTO ticker)
Method called by on every ticker update.String
toString()
boolean
tradeUpdate(TradeDTO trade)
Method called by on every trade update.
-
-
-
Constructor Detail
-
PositionDTO
public PositionDTO(long newId, StrategyDTO newStrategy, CurrencyPairDTO newCurrencyPair, BigDecimal newAmount, String newOpenOrderId, PositionRulesDTO newRules)
Constructor.- Parameters:
newId
- position idnewStrategy
- strategynewCurrencyPair
- currency pairnewAmount
- amountnewOpenOrderId
- open order idnewRules
- position rules
-
-
Method Detail
-
orderUpdate
public final boolean orderUpdate(OrderDTO updatedOrder)
Method called by on every order update.- Parameters:
updatedOrder
- order- Returns:
- true if the the order updated the position.
-
tradeUpdate
public boolean tradeUpdate(TradeDTO trade)
Method called by on every trade update.- Parameters:
trade
- trade- Returns:
- true if the the trade updated the position.
-
tickerUpdate
public final boolean tickerUpdate(TickerDTO ticker)
Method called by on every ticker update.- Parameters:
ticker
- ticker- Returns:
- true if the the ticker updated the position.
-
shouldBeClosed
public boolean shouldBeClosed()
Returns true if the position should be closed.- Returns:
- true if the rules says the position should be closed.
-
closePositionWithOrderId
public final void closePositionWithOrderId(String newCloseOrderId)
Close position with order id.- Parameters:
newCloseOrderId
- the closeOrderId to set
-
getLowestCalculatedGain
public final Optional<GainDTO> getLowestCalculatedGain()
Getter lowestCalculatedGain.- Returns:
- lowestCalculatedGain
-
getHighestCalculatedGain
public final Optional<GainDTO> getHighestCalculatedGain()
Getter highestCalculatedGain.- Returns:
- highestCalculatedGain
-
getLatestCalculatedGain
public final Optional<GainDTO> getLatestCalculatedGain()
Getter latestCalculatedGain.- Returns:
- latestCalculatedGain
-
getGain
public GainDTO getGain()
Returns the gain of the position. Of course the position should be closed to have a gain.- Returns:
- gain
-
getDescription
public final String getDescription()
Get position description.- Returns:
- description
-
builder
public static PositionDTO.PositionDTOBuilder builder()
-
getId
public long getId()
Technical ID.
-
getPositionId
public Long getPositionId()
An identifier that uniquely identifies the position.
-
getType
public PositionTypeDTO getType()
Position type.
-
getStrategy
public StrategyDTO getStrategy()
The strategy that created the position.
-
getCurrencyPair
public CurrencyPairDTO getCurrencyPair()
Currency pair.
-
getAmount
public CurrencyAmountDTO getAmount()
Amount that was ordered.
-
getRules
public PositionRulesDTO getRules()
Position rules.
-
getStatus
public PositionStatusDTO getStatus()
Position status.
-
getOpeningOrderId
public String getOpeningOrderId()
The order id created to open the position.
-
getOpeningOrder
public OrderDTO getOpeningOrder()
The order created to open the position.
-
getClosingOrderId
public String getClosingOrderId()
The order id created to open the position.
-
getClosingOrder
public OrderDTO getClosingOrder()
The order created to close the position.
-
getLowestPrice
public CurrencyAmountDTO getLowestPrice()
Lowest price reached by tis position.
-
getHighestPrice
public CurrencyAmountDTO getHighestPrice()
Highest price reached by tis position.
-
getLatestPrice
public CurrencyAmountDTO getLatestPrice()
Latest price for this position.
-
-