Class 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.
    • Constructor Detail

      • PositionDTO

        public PositionDTO​(long newId,
                           StrategyDTO newStrategy,
                           CurrencyPairDTO newCurrencyPair,
                           BigDecimal newAmount,
                           String newOpenOrderId,
                           PositionRulesDTO newRules)
        Constructor.
        Parameters:
        newId - position id
        newStrategy - strategy
        newCurrencyPair - currency pair
        newAmount - amount
        newOpenOrderId - open order id
        newRules - 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
      • hashCode

        public final int hashCode()
        Overrides:
        hashCode in class Object
      • getDescription

        public final String getDescription()
        Get position description.
        Returns:
        description
      • getId

        public long getId()
        Technical ID.
      • getPositionId

        public Long getPositionId()
        An identifier that uniquely identifies the position.
      • getStrategy

        public StrategyDTO getStrategy()
        The strategy that created the position.
      • getCurrencyPair

        public CurrencyPairDTO getCurrencyPair()
        Currency pair.
      • 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.