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,
                           String newOpenOrderId,
                           PositionRulesDTO newRules)
        Constructor.
        Parameters:
        newId - position id
        newOpenOrderId - open order id
        newRules - position rules
    • Method Detail

      • setCloseOrderId

        public final void setCloseOrderId​(String newCloseOrderId)
        Setter for closeOrderId.
        Parameters:
        newCloseOrderId - the closeOrderId to set
      • tradeUpdate

        public void tradeUpdate​(TradeDTO trade)
        Method called by on every trade update.
        Parameters:
        trade - trade
      • shouldBeClosed

        public boolean shouldBeClosed​(TickerDTO ticker)
        Returns true if the position should be closed.
        Parameters:
        ticker - ticker
        Returns:
        true if the rules says the position should be closed.
      • getGain

        public GainDTO getGain()
        Returns the gain of the position. Of course the position should be closed to have a gain.
        Returns:
        gain
      • getId

        public final long getId()
        Getter for id.
        Returns:
        id
      • getStatus

        public final PositionStatusDTO getStatus()
        Getter for status.
        Returns:
        status
      • getCurrencyPair

        public final CurrencyPairDTO getCurrencyPair()
        Get currency pair.
        Returns:
        currency pair
      • getRules

        public final PositionRulesDTO getRules()
        Getter rules.
        Returns:
        rules
      • getOpenTrade

        public final TradeDTO getOpenTrade()
        Getter for openTrade.
        Returns:
        openTrade
      • getCloseTrade

        public final TradeDTO getCloseTrade()
        Getter for closeTrade.
        Returns:
        closeTrade
      • getOpenOrderId

        public final String getOpenOrderId()
        Getter openOrderId.
        Returns:
        openOrderId
      • getLastCalculatedGain

        public final Optional<GainDTO> getLastCalculatedGain()
        Getter last calculated gain from the last ticker received.
        Returns:
        lastCalculatedGain
      • getCloseOrderId

        public final String getCloseOrderId()
        Getter closeOrderId.
        Returns:
        closeOrderId
      • hashCode

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