package roart.category;

import java.util.List;
import java.util.Map;

import roart.config.MyConfig;
import roart.indicator.Indicator;
import roart.indicator.IndicatorMACD;
import roart.indicator.IndicatorRSI;
import roart.indicator.IndicatorSTOCHRSI;
import roart.model.ResultItemTableRow;
import roart.model.StockItem;
import roart.predictor.Predictor;
import roart.predictor.PredictorLSTM;
import roart.util.Constants;
import roart.util.MarketData;
import roart.util.PeriodData;
import roart.util.StockDao;
import roart.util.StockUtil;

public class CategoryPrice extends Category {

    Map<String, MarketData> marketdatamap;
    Map<String, PeriodData> periodDataMap;
    Map<String, Integer>[] periodmap;

    public CategoryPrice(MyConfig conf, String string, List<StockItem> stocks,
            Map<String, MarketData> marketdatamap,
            Map<String, PeriodData> periodDataMap,
            Map<String, Integer>[] periodmap) throws Exception {
        super(conf, string, stocks);
        this.marketdatamap = marketdatamap;
        this.periodmap = periodmap;
        this.periodDataMap = periodDataMap;
        indicators.add(new IndicatorMACD(conf, title + " MACD", marketdatamap, periodDataMap, periodmap, title, Constants.PRICECOLUMN));
        indicators.add(new IndicatorRSI(conf, title + " RSI", marketdatamap, periodDataMap, periodmap, title, Constants.PRICECOLUMN));
        indicators.add(new IndicatorSTOCHRSI(conf, title + " SRSI", marketdatamap, periodDataMap, periodmap, title, Constants.PRICECOLUMN));
        predictors.add(new PredictorLSTM(conf, title + "LSTM", marketdatamap, periodDataMap, periodmap, title, Constants.PRICECOLUMN));
    }

    @Override
    public void addResultItemTitle(ResultItemTableRow r) {
        try {
            if (StockUtil.hasSpecial(stocks, Constants.PRICECOLUMN)) {
                r.add(title);
                r.add("Currency");
                for (Indicator indicator : indicators) {
                    if (indicator.isEnabled()) {
                        r.addarr(indicator.getResultItemTitle());
                    }
                }
                for (Predictor predictor : predictors) {
                    if (predictor.isEnabled()) {
                        r.addarr(predictor.getResultItemTitle());
                    }
                }
            }
        } catch (Exception e) {
            log.error(Constants.EXCEPTION, e);
        }
    }

    @Override
    public void addResultItem(ResultItemTableRow r, StockItem stock) {
        try {
            if (StockUtil.hasSpecial(stocks, Constants.PRICECOLUMN)) {
                r.add(stock.getPrice());
                r.add(stock.getCurrency());
                for (Indicator indicator : indicators) {
                    if (indicator.isEnabled()) {
                        r.addarr(indicator.getResultItem(stock));
                    }
                }
                for (Predictor predictor : predictors) {
                    if (predictor.isEnabled()) {
                        r.addarr(predictor.getResultItem(stock));
                    }
                }
           }
        } catch (Exception e) {
            log.error(Constants.EXCEPTION, e);
        }
    }

}


@@ -1916,36 +1916,36 @@
 or (
-In
+Pre
 dic
-a
 tor 
-in
+pre
 dic
-a
 tor : 
-in
+pre
 dic
-a
 tors
@@ -1964,38 +1964,38 @@
             if (
-in
+pre
 dic
-a
 tor.isEnabled())
@@ -2022,38 +2022,38 @@
        r.addarr(
-in
+pre
 dic
-a
 tor.getResultIte
@@ -2128,36 +2128,36 @@
 or (
-Pre
+In
 dic
+a
 tor 
-pre
+in
 dic
+a
 tor : 
-pre
+in
 dic
+a
 tors
@@ -2176,38 +2176,38 @@
             if (
-pre
+in
 dic
+a
 tor.isEnabled())
@@ -2234,38 +2234,38 @@
        r.addarr(
-pre
+in
 dic
+a
 tor.getResultIte
@@ -2705,36 +2705,36 @@
 or (
-In
+Pre
 dic
-a
 tor 
-in
+pre
 dic
-a
 tor : 
-in
+pre
 dic
-a
 tors
@@ -2753,38 +2753,38 @@
             if (
-in
+pre
 dic
-a
 tor.isEnabled())
@@ -2811,38 +2811,38 @@
        r.addarr(
-in
+pre
 dic
-a
 tor.getResultIte
@@ -2917,36 +2917,36 @@
 or (
-Pre
+In
 dic
+a
 tor 
-pre
+in
 dic
+a
 tor : 
-pre
+in
 dic
+a
 tors
@@ -2965,38 +2965,38 @@
             if (
-pre
+in
 dic
+a
 tor.isEnabled())
@@ -3023,38 +3023,38 @@
        r.addarr(
-pre
+in
 dic
+a
 tor.getResultIte

Move predictor result.