package roart.talib;

import java.time.LocalDate;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.apache.commons.lang3.tuple.Pair;
import org.jfree.data.category.DefaultCategoryDataset;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.ta4j.core.BaseTimeSeries;
import org.ta4j.core.TimeSeries;
import org.ta4j.core.indicators.EMAIndicator;
import org.ta4j.core.indicators.MACDIndicator;
import org.ta4j.core.indicators.StochasticRSIIndicator;
import org.ta4j.core.indicators.helpers.ClosePriceIndicator;
import org.ta4j.core.num.DoubleNum;
import org.ta4j.core.num.Num;
import org.ta4j.core.num.PrecisionNum;

import com.tictactec.ta.lib.Core;
import com.tictactec.ta.lib.MAType;
import com.tictactec.ta.lib.MInteger;

import roart.common.constants.Constants;
import roart.common.util.ArraysUtil;
import roart.model.StockItem;
import roart.model.data.MarketData;
import roart.model.data.PeriodData;
import roart.stockutil.StockDao;
import roart.stockutil.StockUtil;

public abstract class Ta4j extends Ta {

    protected TimeSeries getClosedSeries(double[] values, int size) {
        LocalDate date = LocalDate.now();
        TimeSeries series = new BaseTimeSeries();
        for (int i = 0; i < size; i++) {
            Num open = null;
            Num high = null;
            Num low = null;
            Num close = PrecisionNum.valueOf(values[i]);
            Num volume = null;
            LocalDate aDate = date.minusDays(size - 1 - i);
            ZonedDateTime endTime = aDate.atStartOfDay(ZoneOffset.UTC);
            series.addBar(endTime, open, high, low, close, volume);
        }
        return series;
    }

    protected TimeSeries getThreeSeries(double[] values, double low[], double high[], int size) {
        LocalDate date = LocalDate.now();
        TimeSeries series = new BaseTimeSeries();
        for (int i = 0; i < size; i++) {
            Num open = null;
            Num high = PrecisionNum.valueOf(high[i]);
            Num low = PrecisionNum.valueOf(low[i]);
            Num close = PrecisionNum.valueOf(values[i]);
            Num volume = null;
            LocalDate aDate = date.minusDays(size - 1 - i);
            ZonedDateTime endTime = aDate.atStartOfDay(ZoneOffset.UTC);
            series.addBar(endTime, open, high, low, close, volume);
        }
        return series;
    }



}

@@ -1836,22 +1836,21 @@
 ouble%5B%5D 
-values
+close
 , double
@@ -2029,32 +2029,35 @@
         Num open
+Num
  = null;%0A       
@@ -2069,16 +2069,19 @@
 Num high
+Num
  = Preci
@@ -2125,16 +2125,19 @@
  Num low
+Num
  = Preci
@@ -2174,32 +2174,35 @@
        Num close
+Num
  = PrecisionNum.
@@ -2201,38 +2201,37 @@
 sionNum.valueOf(
-values
+close
 %5Bi%5D);%0A          
@@ -2234,32 +2234,35 @@
       Num volume
+Num
  = null;%0A       
@@ -2429,34 +2429,46 @@
 open
+Num
 , high
+Num
 , low
+Num
 , close
+Num
 , volume
 );%0A 
@@ -2455,32 +2455,35 @@
 closeNum, volume
+Num
 );%0A        %7D%0A   

Add new TA lib (I67).