Package org.ta4j.core

Class BaseBar

java.lang.Object
org.ta4j.core.BaseBar
All Implemented Interfaces:
Serializable, Bar

public class BaseBar
extends Object
implements Bar
Base implementation of a Bar.
See Also:
Serialized Form
  • Constructor Details

    • BaseBar

      public BaseBar(Duration timePeriod, ZonedDateTime endTime, Function<Number,​Num> numFunction)
      Constructor.
      Parameters:
      timePeriod - the time period
      endTime - the end time of the bar period
      numFunction - the numbers precision
    • BaseBar

      public BaseBar(Duration timePeriod, ZonedDateTime endTime, double openPrice, double highPrice, double lowPrice, double closePrice, double volume)
      Constructor.
      Parameters:
      timePeriod - the time period
      endTime - the end time of the bar period
      openPrice - the open price of the bar period
      highPrice - the highest price of the bar period
      lowPrice - the lowest price of the bar period
      closePrice - the close price of the bar period
      volume - the volume of the bar period
    • BaseBar

      public BaseBar(Duration timePeriod, ZonedDateTime endTime, double openPrice, double highPrice, double lowPrice, double closePrice, double volume, double amount)
      Constructor.
      Parameters:
      timePeriod - the time period
      endTime - the end time of the bar period
      openPrice - the open price of the bar period
      highPrice - the highest price of the bar period
      lowPrice - the lowest price of the bar period
      closePrice - the close price of the bar period
      volume - the volume of the bar period
      amount - the amount of the bar period
    • BaseBar

      public BaseBar(Duration timePeriod, ZonedDateTime endTime, double openPrice, double highPrice, double lowPrice, double closePrice, double volume, double amount, long trades, Function<Number,​Num> numFunction)
      Constructor.
      Parameters:
      timePeriod - the time period
      endTime - the end time of the bar period
      openPrice - the open price of the bar period
      highPrice - the highest price of the bar period
      lowPrice - the lowest price of the bar period
      closePrice - the close price of the bar period
      volume - the volume of the bar period
      amount - the amount of the bar period
      trades - the trades count of the bar period
      numFunction - the numbers precision
    • BaseBar

      public BaseBar(Duration timePeriod, ZonedDateTime endTime, BigDecimal openPrice, BigDecimal highPrice, BigDecimal lowPrice, BigDecimal closePrice, BigDecimal volume)
      Constructor.
      Parameters:
      timePeriod - the time period
      endTime - the end time of the bar period
      openPrice - the open price of the bar period
      highPrice - the highest price of the bar period
      lowPrice - the lowest price of the bar period
      closePrice - the close price of the bar period
      volume - the volume of the bar period
    • BaseBar

      public BaseBar(Duration timePeriod, ZonedDateTime endTime, BigDecimal openPrice, BigDecimal highPrice, BigDecimal lowPrice, BigDecimal closePrice, BigDecimal volume, BigDecimal amount)
      Constructor.
      Parameters:
      timePeriod - the time period
      endTime - the end time of the bar period
      openPrice - the open price of the bar period
      highPrice - the highest price of the bar period
      lowPrice - the lowest price of the bar period
      closePrice - the close price of the bar period
      volume - the volume of the bar period
      amount - the amount of the bar period
    • BaseBar

      public BaseBar(Duration timePeriod, ZonedDateTime endTime, BigDecimal openPrice, BigDecimal highPrice, BigDecimal lowPrice, BigDecimal closePrice, BigDecimal volume, BigDecimal amount, long trades, Function<Number,​Num> numFunction)
      Constructor.
      Parameters:
      timePeriod - the time period
      endTime - the end time of the bar period
      openPrice - the open price of the bar period
      highPrice - the highest price of the bar period
      lowPrice - the lowest price of the bar period
      closePrice - the close price of the bar period
      volume - the volume of the bar period
      amount - the amount of the bar period
      trades - the trades count of the bar period
      numFunction - the numbers precision
    • BaseBar

      public BaseBar(Duration timePeriod, ZonedDateTime endTime, String openPrice, String highPrice, String lowPrice, String closePrice, String volume)
      Constructor.
      Parameters:
      timePeriod - the time period
      endTime - the end time of the bar period
      openPrice - the open price of the bar period
      highPrice - the highest price of the bar period
      lowPrice - the lowest price of the bar period
      closePrice - the close price of the bar period
      volume - the volume of the bar period
    • BaseBar

      public BaseBar(Duration timePeriod, ZonedDateTime endTime, String openPrice, String highPrice, String lowPrice, String closePrice, String volume, String amount)
      Constructor.
      Parameters:
      timePeriod - the time period
      endTime - the end time of the bar period
      openPrice - the open price of the bar period
      highPrice - the highest price of the bar period
      lowPrice - the lowest price of the bar period
      closePrice - the close price of the bar period
      volume - the volume of the bar period
      amount - the amount of the bar period
    • BaseBar

      public BaseBar(Duration timePeriod, ZonedDateTime endTime, String openPrice, String highPrice, String lowPrice, String closePrice, String volume, String amount, String trades, Function<Number,​Num> numFunction)
      Constructor.
      Parameters:
      timePeriod - the time period
      endTime - the end time of the bar period
      openPrice - the open price of the bar period
      highPrice - the highest price of the bar period
      lowPrice - the lowest price of the bar period
      closePrice - the close price of the bar period
      volume - the volume of the bar period
      amount - the amount of the bar period
      trades - the trades count of the bar period
      numFunction - the numbers precision
    • BaseBar

      public BaseBar(Duration timePeriod, ZonedDateTime endTime, Num openPrice, Num highPrice, Num lowPrice, Num closePrice, Num volume, Num amount)
      Constructor.
      Parameters:
      timePeriod - the time period
      endTime - the end time of the bar period
      openPrice - the open price of the bar period
      highPrice - the highest price of the bar period
      lowPrice - the lowest price of the bar period
      closePrice - the close price of the bar period
      volume - the volume of the bar period
      amount - the amount of the bar period
    • BaseBar

      public BaseBar(Duration timePeriod, ZonedDateTime endTime, Num openPrice, Num highPrice, Num lowPrice, Num closePrice, Num volume, Num amount, long trades)
      Constructor.
      Parameters:
      timePeriod - the time period
      endTime - the end time of the bar period
      openPrice - the open price of the bar period
      highPrice - the highest price of the bar period
      lowPrice - the lowest price of the bar period
      closePrice - the close price of the bar period
      volume - the volume of the bar period
      amount - the amount of the bar period
      trades - the trades count of the bar period
  • Method Details

    • builder

      public static BaseBarBuilder builder()
      Returns BaseBarBuilder
      Returns:
      builder of class BaseBarBuilder
    • builder

      public static <T> ConvertibleBaseBarBuilder<T> builder(Function<T,​Num> conversionFunction, Class<T> clazz)
      Returns BaseBarBuilder
      Returns:
      builder of class BaseBarBuilder
    • getOpenPrice

      public Num getOpenPrice()
      Specified by:
      getOpenPrice in interface Bar
      Returns:
      the open price of the period
    • getLowPrice

      public Num getLowPrice()
      Specified by:
      getLowPrice in interface Bar
      Returns:
      the low price of the period
    • getHighPrice

      public Num getHighPrice()
      Specified by:
      getHighPrice in interface Bar
      Returns:
      the high price of the period
    • getClosePrice

      public Num getClosePrice()
      Specified by:
      getClosePrice in interface Bar
      Returns:
      the close price of the period
    • getVolume

      public Num getVolume()
      Specified by:
      getVolume in interface Bar
      Returns:
      the whole traded volume in the period
    • getTrades

      public long getTrades()
      Specified by:
      getTrades in interface Bar
      Returns:
      the number of trades in the period
    • getAmount

      public Num getAmount()
      Specified by:
      getAmount in interface Bar
      Returns:
      the whole traded amount (tradePrice x tradeVolume) of the period
    • getTimePeriod

      public Duration getTimePeriod()
      Specified by:
      getTimePeriod in interface Bar
      Returns:
      the time period of the bar
    • getBeginTime

      public ZonedDateTime getBeginTime()
      Specified by:
      getBeginTime in interface Bar
      Returns:
      the begin timestamp of the bar period
    • getEndTime

      public ZonedDateTime getEndTime()
      Specified by:
      getEndTime in interface Bar
      Returns:
      the end timestamp of the bar period
    • addTrade

      public void addTrade(Num tradeVolume, Num tradePrice)
      Adds a trade at the end of bar period.
      Specified by:
      addTrade in interface Bar
      Parameters:
      tradeVolume - the traded volume
      tradePrice - the price
    • addPrice

      public void addPrice(Num price)
      Specified by:
      addPrice in interface Bar
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object