Subversion Repositories Integrator Subversion

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
778 blopes 1
package br.com.kronus.app;
2
 
3
import java.io.IOException;
4
import java.util.ArrayList;
5
import java.util.List;
6
 
7
import br.com.kronus.core.Candle;
8
import br.com.kronus.core.DetectorGatilhos;
9
import br.com.kronus.core.PadraoGatilho;
10
import br.com.robo.sim.CandleExcelReader;
11
 
12
public class MainKronusGatilho {
13
 
14
        public static void main(String[] args) {
15
                System.out.println("INICIANDO ANÁLISE KRONUS...");
16
 
17
                List<Candle> candles = new ArrayList<Candle>();
18
        CandleExcelReader reader = new CandleExcelReader();
19
        try {
20
            candles = reader.lerCandles("/dados.xls");
21
            System.out.println("CANDLES LIDOS: " + candles.size());
22
        } catch (IOException e) {
23
            e.printStackTrace();
24
        }
25
 
26
        List<Candle> candlesHistorico = new ArrayList<Candle>();
27
        DetectorGatilhos detector = new DetectorGatilhos(true); // true = logs no System.out
28
//        DetectorGatilhosKronus detectorGatilhosKronus = new DetectorGatilhosKronus();
29
 
30
        // PERCORRER CADA CANDLE
31
        for (Candle novoCandle : candles) {
32
                candlesHistorico.add(novoCandle);
33
//              exibirDadosCandle(novoCandle);
34
 
35
            PadraoGatilho padrao = detector.processarCandleTempoReal(candlesHistorico);
36
 
37
            if (padrao != null) {
38
                System.out.println("=== PADRÃO FECHADO ===");
39
                System.out.println("GR: " + padrao.getReferencia().getContador());
40
                System.out.println("G1: " + padrao.getGatilho1().getContador());
41
                System.out.println("G2: " + padrao.getGatilho2().getContador());
42
                System.out.println("G3: " + padrao.getGatilho3().getContador());
43
                if (padrao.getGatilho4() != null) {
44
                    System.out.println("G4: " + padrao.getGatilho4().getContador());
45
                } else {
46
                    System.out.println("Sem G4 (padrão encerrou no G3).");
47
                }
48
 
49
                // Aqui você pode:
50
                // - sinalizar uma possível operação
51
                // - gravar no banco
52
                // - atualizar o dashboard JSF em tempo real
53
            }          
54
        }
55
        }
56
 
57
        private static void exibirDadosCandle(Candle candle) {
58
                System.out.println("===== CANDLE [" + candle.getContador() + "] =====");
59
                System.out.println("HORA: " + candle.getTime());
60
                System.out.println("ABERTURA: " + candle.getAbertura());
61
                System.out.println("FECHAMENDO: " + candle.getFechamento());
62
                System.out.println("MÁXIMA: " + candle.getMaxima());
63
                System.out.println("MÍNIMA: " + candle.getMinima());
64
                System.out.println("===============");
65
                System.out.println("");
66
        }
67
 
68
}