You can subscribe to this list here.
| 2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(148) |
Jun
(48) |
Jul
(107) |
Aug
(292) |
Sep
(301) |
Oct
(530) |
Nov
(142) |
Dec
(37) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2008 |
Jan
|
Feb
|
Mar
(4) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Márcio V. d. S. <mv...@us...> - 2007-05-18 19:25:27
|
Update of /cvsroot/tail/Tail/src/test/net/sf/tail In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv4018/src/test/net/sf/tail Added Files: Operation.java OperationType.java Strategy.java Trade.java Log Message: começando fase 2 (Strategy, Operation e Runner) --- NEW FILE: Operation.java --- package net.sf.tail; public class Operation { private OperationType type; private int index; public Operation(int index, OperationType type) { this.type = type; this.index = index; } public OperationType getType() { return type; } public int getIndex() { return index; } } --- NEW FILE: Trade.java --- package net.sf.tail; public class Trade { private Operation entry; private Operation exit; public Trade(Operation entry, Operation exit) { this.entry = entry; this.exit = exit; } public Operation getEntry() { return entry; } public Operation getExit() { return exit; } } --- NEW FILE: OperationType.java --- package net.sf.tail; public enum OperationType { BUY, SELL; } --- NEW FILE: Strategy.java --- package net.sf.tail; public interface Strategy { Operation shouldEnter(int index); Operation shouldExit(Operation entry, int index); } |
|
From: Márcio V. d. S. <mv...@us...> - 2007-05-18 19:25:24
|
Update of /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/strategy In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv4018/src/test/net/sf/tail/indicator/strategy Added Files: IndicatorOverIndicatorStrategy.java IndicatorOverIndicatorStrategyTest.java StopDecoratorStrategy.java Log Message: começando fase 2 (Strategy, Operation e Runner) --- NEW FILE: StopDecoratorStrategy.java --- package net.sf.tail.indicator.strategy; import net.sf.tail.Indicator; import net.sf.tail.Operation; import net.sf.tail.OperationType; import net.sf.tail.Strategy; public class StopDecoratorStrategy implements Strategy { private Strategy strategy; private double loss; public StopDecoratorStrategy(double loss, Strategy strategy) { this.strategy = strategy; this.loss= loss; // 0.05? 5? } public Operation shouldEnter(int index) { return strategy.shouldEnter(index); } public Operation shouldExit(Operation entry, int index) { //if( perdi X%) return strategy.shouldExit(entry, index); } } --- NEW FILE: IndicatorOverIndicatorStrategy.java --- package net.sf.tail.indicator.strategy; import net.sf.tail.Indicator; import net.sf.tail.Operation; import net.sf.tail.OperationType; import net.sf.tail.Strategy; public class IndicatorOverIndicatorStrategy implements Strategy { private Indicator<Double> first; private Indicator<Double> second; public IndicatorOverIndicatorStrategy(Indicator<Double> first, Indicator<Double> second) { this.first = first; this.second = second; } public Operation shouldEnter(int index) { if(first.getValue(index).compareTo(second.getValue(index)) < 0) { return new Operation(index, OperationType.BUY); } return null; } public Operation shouldExit(Operation entry, int index) { if(first.getValue(index).compareTo(second.getValue(index)) > 0) { return new Operation(index, OperationType.SELL); } return null; } } --- NEW FILE: IndicatorOverIndicatorStrategyTest.java --- package net.sf.tail.indicator.strategy; import static org.junit.Assert.*; import net.sf.tail.Indicator; import net.sf.tail.Operation; import net.sf.tail.OperationType; import net.sf.tail.Strategy; import org.junit.After; import org.junit.Before; import org.junit.Test; public class IndicatorOverIndicatorStrategyTest { private Indicator<Double> first; private Indicator<Double> second; @Before public void setUp() throws Exception { first = new Indicator<Double>() { double values[] = {4,7,9,6,3,2}; public Double getValue(int index) { return values[index]; } }; // mudar para SAmpleIndicator (no pacote de testes mesmo) second = new Indicator<Double>() { double values[] = {3,6,10,8,2,1}; public Double getValue(int index) { return values[index]; } }; } @Test public void testOverIndicators() { Strategy s = new IndicatorOverIndicatorStrategy(first, second); assertEquals(null, s.shouldEnter(0)); assertEquals(null, s.shouldEnter(1)); Operation buy = s.shouldEnter(2); assertNotNull(buy); assertEquals(OperationType.BUY, buy.getType()); assertEquals(null, s.shouldExit(buy, 3)); Operation sell = s.shouldExit(buy, 4); assertNotNull(sell); assertEquals(OperationType.SELL, sell.getType()); } @After public void tearDown() throws Exception { } } |
|
From: Márcio V. d. S. <mv...@us...> - 2007-05-18 19:25:24
|
Update of /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/cache In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv4018/src/java/net/sf/tail/indicator/cache Modified Files: CachedIndicator.java Log Message: começando fase 2 (Strategy, Operation e Runner) Index: CachedIndicator.java =================================================================== RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/cache/CachedIndicator.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CachedIndicator.java 18 May 2007 01:07:45 -0000 1.1 --- CachedIndicator.java 18 May 2007 19:25:24 -0000 1.2 *************** *** 11,15 **** private final Indicator<? extends Number> indicator; - // TODO - A melhor solução é realmente List<Number> ? private List<Number> results; --- 11,14 ---- |
|
From: Márcio V. d. S. <mv...@us...> - 2007-05-18 19:25:24
|
Update of /cvsroot/tail/Tail/src/java/net/sf/tail/runner In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv4018/src/java/net/sf/tail/runner Added Files: HistoryRunner.java Runner.java Log Message: começando fase 2 (Strategy, Operation e Runner) --- NEW FILE: HistoryRunner.java --- package net.sf.tail.runner; import java.util.ArrayList; import java.util.List; import net.sf.tail.Operation; import net.sf.tail.OperationType; import net.sf.tail.Strategy; import net.sf.tail.Trade; public class HistoryRunner implements Runner { private int seriesSize; public HistoryRunner(int seriesSize) { this.seriesSize = seriesSize; } public List<Trade> run(Strategy strategy) { List<Trade> trades = new ArrayList<Trade>(); Operation entry = null; Operation exit = null; for (int i = 0; i < seriesSize; i++) { entry = strategy.shouldEnter(i); if (entry != null) { for (i++; i < seriesSize; i++) { exit = strategy.shouldExit(entry, i); if (exit != null) { Trade t = new Trade(entry, exit); trades.add(t); } else if(i + 1 == seriesSize){ exit = new Operation(seriesSize, OperationType.SELL); Trade t = new Trade(entry, exit); trades.add(t); } } } } return trades; } public int getSeriesSize() { return seriesSize; } } --- NEW FILE: Runner.java --- package net.sf.tail.runner; import java.util.List; import net.sf.tail.Strategy; import net.sf.tail.Trade; public interface Runner { List<Trade> run(Strategy strategy); } |
|
From: Márcio V. d. S. <mv...@us...> - 2007-05-18 19:25:24
|
Update of /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/tracker In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv4018/src/java/net/sf/tail/indicator/tracker Modified Files: WilliamsRIndicator.java EMAIndicator.java Log Message: começando fase 2 (Strategy, Operation e Runner) Index: WilliamsRIndicator.java =================================================================== RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/tracker/WilliamsRIndicator.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** WilliamsRIndicator.java 18 May 2007 01:07:44 -0000 1.7 --- WilliamsRIndicator.java 18 May 2007 19:25:24 -0000 1.8 *************** *** 16,20 **** private MinPriceIndicator minPriceIndicator; ! // TODO - ver a complexidade dos construtores. public WilliamsRIndicator(TimeSeries timeSeries, int timeFrame) { --- 16,22 ---- private MinPriceIndicator minPriceIndicator; ! ! ! // TODO - ver a complexidade dos construtores. public WilliamsRIndicator(TimeSeries timeSeries, int timeFrame) { Index: EMAIndicator.java =================================================================== RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/tracker/EMAIndicator.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** EMAIndicator.java 17 May 2007 23:06:56 -0000 1.11 --- EMAIndicator.java 18 May 2007 19:25:24 -0000 1.12 *************** *** 3,6 **** --- 3,7 ---- import net.sf.tail.Indicator; + //TODO: pequena explicacao public class EMAIndicator implements Indicator<Double> { |
|
From: Márcio V. d. S. <mv...@us...> - 2007-05-18 19:25:24
|
Update of /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/oscilator In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv4018/src/java/net/sf/tail/indicator/oscilator Modified Files: StochasticOscilatorFast.java Log Message: começando fase 2 (Strategy, Operation e Runner) Index: StochasticOscilatorFast.java =================================================================== RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/oscilator/StochasticOscilatorFast.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** StochasticOscilatorFast.java 18 May 2007 01:07:44 -0000 1.2 --- StochasticOscilatorFast.java 18 May 2007 19:25:24 -0000 1.3 *************** *** 10,13 **** --- 10,14 ---- public StochasticOscilatorFast(ClosePriceIndicator indicator, MinPriceIndicator indicator2, MaxPriceIndicator indicator3, int i) { + // TODO Auto-generated constructor stub } |
|
From: Márcio V. d. S. <mv...@us...> - 2007-05-18 19:25:14
|
Update of /cvsroot/tail/Tail/src/java/net/sf/tail/runner In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv3962/src/java/net/sf/tail/runner Log Message: Directory /cvsroot/tail/Tail/src/java/net/sf/tail/runner added to the repository |
|
From: Márcio V. d. S. <mv...@us...> - 2007-05-18 19:25:13
|
Update of /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/strategy In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv3962/src/test/net/sf/tail/indicator/strategy Log Message: Directory /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/strategy added to the repository |
|
From: Márcio V. d. S. <mv...@us...> - 2007-05-18 01:07:48
|
Update of /cvsroot/tail/Tail/src/test/net/sf/tail/indicator In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv21729/src/test/net/sf/tail/indicator Modified Files: SMAIndicatorTest.java StandardDeviationIndicatorTest.java HighestValueIndicatorTest.java WilliamsRIndicatorTest.java AverageLossIndicatorTest.java LowestValueIndicatorTest.java Removed Files: CachedIndicatorTest.java Log Message: refatoração de código (control + shift + f) Index: AverageLossIndicatorTest.java =================================================================== RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/AverageLossIndicatorTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** AverageLossIndicatorTest.java 17 May 2007 23:04:57 -0000 1.4 --- AverageLossIndicatorTest.java 18 May 2007 01:07:44 -0000 1.5 *************** *** 17,21 **** @Before ! public void prepare() throws Exception { data = new SampleTimeSeries(new double[] { 1, 2, 3, 4, 3, 4, 5, 4, 3, 3, 4, 3, 2 }); } --- 17,21 ---- @Before ! public void setUp() throws Exception { data = new SampleTimeSeries(new double[] { 1, 2, 3, 4, 3, 4, 5, 4, 3, 3, 4, 3, 2 }); } Index: WilliamsRIndicatorTest.java =================================================================== RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/WilliamsRIndicatorTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** WilliamsRIndicatorTest.java 17 May 2007 23:04:57 -0000 1.3 --- WilliamsRIndicatorTest.java 18 May 2007 01:07:44 -0000 1.4 *************** *** 20,24 **** @Before ! public void prepare() throws Exception { List<Tick> ticks = new ArrayList<Tick>(); --- 20,24 ---- @Before ! public void setUp() throws Exception { List<Tick> ticks = new ArrayList<Tick>(); --- CachedIndicatorTest.java DELETED --- Index: LowestValueIndicatorTest.java =================================================================== RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/LowestValueIndicatorTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** LowestValueIndicatorTest.java 17 May 2007 23:04:57 -0000 1.2 --- LowestValueIndicatorTest.java 18 May 2007 01:07:44 -0000 1.3 *************** *** 13,25 **** public class LowestValueIndicatorTest { ! private TimeSeries data; ! @Before ! public void prepare() throws Exception { ! data = new SampleTimeSeries(new double[] { 1, 2, 3, 4, 3, 4, 5, 6, 4, 3, 2, 4, 3, 1 }); ! } ! @Test ! public void testAverageGain5() throws Exception { LowestValueIndicator lowestValue = new LowestValueIndicator(new ClosePriceIndicator(data), 5); --- 13,25 ---- public class LowestValueIndicatorTest { ! private TimeSeries data; ! @Before ! public void setUp() throws Exception { ! data = new SampleTimeSeries(new double[] { 1, 2, 3, 4, 3, 4, 5, 6, 4, 3, 2, 4, 3, 1 }); ! } ! @Test ! public void testAverageGain5() throws Exception { LowestValueIndicator lowestValue = new LowestValueIndicator(new ClosePriceIndicator(data), 5); *************** *** 34,39 **** assertEquals(2d, lowestValue.getValue(12), 0.01); ! } ! @Test public void test10daysJumping() { --- 34,39 ---- assertEquals(2d, lowestValue.getValue(12), 0.01); ! } ! @Test public void test10daysJumping() { *************** *** 48,53 **** } ! // Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede Linux) ! //e o JUnit4 public static junit.framework.Test suite() { return new JUnit4TestAdapter(RSIIndicatorTest.class); --- 48,54 ---- } ! // Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede ! // Linux) ! // e o JUnit4 public static junit.framework.Test suite() { return new JUnit4TestAdapter(RSIIndicatorTest.class); Index: StandardDeviationIndicatorTest.java =================================================================== RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/StandardDeviationIndicatorTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** StandardDeviationIndicatorTest.java 17 May 2007 21:29:16 -0000 1.1 --- StandardDeviationIndicatorTest.java 18 May 2007 01:07:44 -0000 1.2 *************** *** 12,67 **** public class StandardDeviationIndicatorTest { ! private TimeSeries data; ! @Before ! public void prepare() throws Exception { ! data = new SampleTimeSeries(new double[] { 1, 2, 3, 4, 3, 4, 5, 4, 3, 0, 9 }); ! } ! @Test ! public void testStandardDeviation4() throws Exception { ! StandardDeviationIndicator sdv = new StandardDeviationIndicator(new ClosePriceIndicator(data), 4); ! assertEquals(0d, sdv.getValue(0), 0.1); ! assertEquals(Math.sqrt(0.5), sdv.getValue(1), 0.1); ! assertEquals(Math.sqrt(2.0), sdv.getValue(2), 0.1); ! assertEquals(Math.sqrt(5.0), sdv.getValue(3), 0.1); ! assertEquals(Math.sqrt(2.0), sdv.getValue(4), 0.1); ! assertEquals(1, sdv.getValue(5), 0.1); ! assertEquals(Math.sqrt(2.0), sdv.getValue(6), 0.1); ! assertEquals(Math.sqrt(2.0), sdv.getValue(7), 0.1); ! assertEquals(Math.sqrt(2.0), sdv.getValue(8), 0.1); ! assertEquals(Math.sqrt(14.0), sdv.getValue(9), 0.1); ! assertEquals(Math.sqrt(42.0), sdv.getValue(10), 0.1); ! ! } ! ! @Test ! public void testStandardDeviation2() throws Exception { ! StandardDeviationIndicator sdv = new StandardDeviationIndicator(new ClosePriceIndicator(data), 2); ! assertEquals(0d, sdv.getValue(0), 0.1); ! assertEquals(Math.sqrt(0.5), sdv.getValue(1), 0.1); ! assertEquals(Math.sqrt(0.5), sdv.getValue(2), 0.1); ! assertEquals(Math.sqrt(0.5), sdv.getValue(3), 0.1); ! assertEquals(Math.sqrt(4.5), sdv.getValue(9), 0.1); ! assertEquals(Math.sqrt(40.5), sdv.getValue(10), 0.1); ! ! } ! ! ! ! @Test(expected = IndexOutOfBoundsException.class) ! public void testWrongIndex() { ! StandardDeviationIndicator quoteSDV = new StandardDeviationIndicator(new ClosePriceIndicator(data), 3); ! quoteSDV.getValue(13); ! } ! ! // Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede Linux) ! //e o JUnit4 public static junit.framework.Test suite() { ! return new JUnit4TestAdapter(StandardDeviationIndicatorTest.class); } } --- 12,64 ---- public class StandardDeviationIndicatorTest { ! private TimeSeries data; ! @Before ! public void setUp() throws Exception { ! data = new SampleTimeSeries(new double[] { 1, 2, 3, 4, 3, 4, 5, 4, 3, 0, 9 }); ! } ! @Test ! public void testStandardDeviation4() throws Exception { ! StandardDeviationIndicator sdv = new StandardDeviationIndicator(new ClosePriceIndicator(data), 4); ! assertEquals(0d, sdv.getValue(0), 0.1); ! assertEquals(Math.sqrt(0.5), sdv.getValue(1), 0.1); ! assertEquals(Math.sqrt(2.0), sdv.getValue(2), 0.1); ! assertEquals(Math.sqrt(5.0), sdv.getValue(3), 0.1); ! assertEquals(Math.sqrt(2.0), sdv.getValue(4), 0.1); ! assertEquals(1, sdv.getValue(5), 0.1); ! assertEquals(Math.sqrt(2.0), sdv.getValue(6), 0.1); ! assertEquals(Math.sqrt(2.0), sdv.getValue(7), 0.1); ! assertEquals(Math.sqrt(2.0), sdv.getValue(8), 0.1); ! assertEquals(Math.sqrt(14.0), sdv.getValue(9), 0.1); ! assertEquals(Math.sqrt(42.0), sdv.getValue(10), 0.1); ! } ! @Test ! public void testStandardDeviation2() throws Exception { ! StandardDeviationIndicator sdv = new StandardDeviationIndicator(new ClosePriceIndicator(data), 2); ! assertEquals(0d, sdv.getValue(0), 0.1); ! assertEquals(Math.sqrt(0.5), sdv.getValue(1), 0.1); ! assertEquals(Math.sqrt(0.5), sdv.getValue(2), 0.1); ! assertEquals(Math.sqrt(0.5), sdv.getValue(3), 0.1); ! assertEquals(Math.sqrt(4.5), sdv.getValue(9), 0.1); ! assertEquals(Math.sqrt(40.5), sdv.getValue(10), 0.1); ! ! } ! ! @Test(expected = IndexOutOfBoundsException.class) ! public void testWrongIndex() { ! StandardDeviationIndicator quoteSDV = new StandardDeviationIndicator(new ClosePriceIndicator(data), 3); ! quoteSDV.getValue(13); ! } ! ! // Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede ! // Linux) ! // e o JUnit4 public static junit.framework.Test suite() { ! return new JUnit4TestAdapter(StandardDeviationIndicatorTest.class); } } Index: SMAIndicatorTest.java =================================================================== RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/SMAIndicatorTest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SMAIndicatorTest.java 17 May 2007 23:04:57 -0000 1.5 --- SMAIndicatorTest.java 18 May 2007 01:07:44 -0000 1.6 *************** *** 1,6 **** package net.sf.tail.indicator; ! import java.util.Arrays; ! import net.sf.tail.SampleTimeSeries; import net.sf.tail.TimeSeries; --- 1,6 ---- package net.sf.tail.indicator; ! import static org.junit.Assert.assertEquals; ! import junit.framework.JUnit4TestAdapter; import net.sf.tail.SampleTimeSeries; import net.sf.tail.TimeSeries; *************** *** 8,17 **** import net.sf.tail.indicator.tracker.SMAIndicator; - import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; - import junit.framework.JUnit4TestAdapter; - public class SMAIndicatorTest { --- 8,14 ---- *************** *** 19,23 **** @Before ! public void prepare() throws Exception { data = new SampleTimeSeries(new double[] { 1, 2, 3, 4, 3, 4, 5, 4, 3, 3, 4, 3, 2 }); } --- 16,20 ---- @Before ! public void setUp() throws Exception { data = new SampleTimeSeries(new double[] { 1, 2, 3, 4, 3, 4, 5, 4, 3, 3, 4, 3, 2 }); } *************** *** 49,61 **** } - @Test - public void testIncreaseArrayMethod() { - double[] d = new double[200]; - Arrays.fill(d, 10); - TimeSeries dataMax = new SampleTimeSeries(d); - SMAIndicator quoteSMA = new SMAIndicator(new ClosePriceIndicator(dataMax), 100); - assertEquals(10d, quoteSMA.getValue(105)); - } - @Test(expected = IndexOutOfBoundsException.class) public void testWrongIndex() { --- 46,49 ---- Index: HighestValueIndicatorTest.java =================================================================== RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/HighestValueIndicatorTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** HighestValueIndicatorTest.java 17 May 2007 23:04:57 -0000 1.2 --- HighestValueIndicatorTest.java 18 May 2007 01:07:44 -0000 1.3 *************** *** 13,25 **** public class HighestValueIndicatorTest { ! private TimeSeries data; ! @Before ! public void prepare() throws Exception { ! data = new SampleTimeSeries(new double[] { 1, 2, 3, 4, 3, 4, 5, 6, 4, 3, 3, 4, 3, 2 }); ! } ! @Test ! public void testAverageGain5() throws Exception { HighestValueIndicator highestValue = new HighestValueIndicator(new ClosePriceIndicator(data), 5); --- 13,25 ---- public class HighestValueIndicatorTest { ! private TimeSeries data; ! @Before ! public void setUp() throws Exception { ! data = new SampleTimeSeries(new double[] { 1, 2, 3, 4, 3, 4, 5, 6, 4, 3, 3, 4, 3, 2 }); ! } ! @Test ! public void testAverageGain5() throws Exception { HighestValueIndicator highestValue = new HighestValueIndicator(new ClosePriceIndicator(data), 5); *************** *** 34,39 **** assertEquals(4d, highestValue.getValue(12), 0.01); ! } ! @Test public void test10daysJumping() { --- 34,39 ---- assertEquals(4d, highestValue.getValue(12), 0.01); ! } ! @Test public void test10daysJumping() { *************** *** 48,53 **** } ! // Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede Linux) ! //e o JUnit4 public static junit.framework.Test suite() { return new JUnit4TestAdapter(RSIIndicatorTest.class); --- 48,54 ---- } ! // Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede ! // Linux) ! // e o JUnit4 public static junit.framework.Test suite() { return new JUnit4TestAdapter(RSIIndicatorTest.class); |
|
From: Márcio V. d. S. <mv...@us...> - 2007-05-18 01:07:48
|
Update of /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/tracker/bollingerbands In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv21729/src/java/net/sf/tail/indicator/tracker/bollingerbands Modified Files: BollingerBandsUpperIndicator.java BollingerBandsLowerIndicator.java BollingerBandsMiddleIndicator.java Log Message: refatoração de código (control + shift + f) Index: BollingerBandsMiddleIndicator.java =================================================================== RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/tracker/bollingerbands/BollingerBandsMiddleIndicator.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BollingerBandsMiddleIndicator.java 17 May 2007 22:42:31 -0000 1.1 --- BollingerBandsMiddleIndicator.java 18 May 2007 01:07:44 -0000 1.2 *************** *** 6,21 **** public class BollingerBandsMiddleIndicator implements Indicator<Double> { private final Indicator<? extends Number> indicator; ! ! public BollingerBandsMiddleIndicator(SMAIndicator smaIndicator) ! { this.indicator = smaIndicator; } ! ! public BollingerBandsMiddleIndicator(Indicator <? extends Number> indicator) ! { this.indicator = indicator; } ! ! public Double getValue(int index) { return indicator.getValue(index).doubleValue(); --- 6,18 ---- public class BollingerBandsMiddleIndicator implements Indicator<Double> { private final Indicator<? extends Number> indicator; ! ! public BollingerBandsMiddleIndicator(SMAIndicator smaIndicator) { this.indicator = smaIndicator; } ! ! public BollingerBandsMiddleIndicator(Indicator<? extends Number> indicator) { this.indicator = indicator; } ! public Double getValue(int index) { return indicator.getValue(index).doubleValue(); Index: BollingerBandsLowerIndicator.java =================================================================== RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/tracker/bollingerbands/BollingerBandsLowerIndicator.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BollingerBandsLowerIndicator.java 17 May 2007 22:42:31 -0000 1.1 --- BollingerBandsLowerIndicator.java 18 May 2007 01:07:44 -0000 1.2 *************** *** 4,23 **** import net.sf.tail.indicator.tracker.StandardDeviationIndicator; ! public class BollingerBandsLowerIndicator implements Indicator<Double>{ private final Indicator<? extends Number> indicator; private final BollingerBandsMiddleIndicator bbm; ! ! public BollingerBandsLowerIndicator(BollingerBandsMiddleIndicator bbm, StandardDeviationIndicator standardDeviation) ! { this.bbm = bbm; this.indicator = standardDeviation; } ! ! public BollingerBandsLowerIndicator(BollingerBandsMiddleIndicator bbm, Indicator <? extends Number> indicator) ! { this.bbm = bbm; this.indicator = indicator; } ! public Double getValue(int index) { return bbm.getValue(index).doubleValue() - 2 * indicator.getValue(index).doubleValue(); --- 4,22 ---- import net.sf.tail.indicator.tracker.StandardDeviationIndicator; ! public class BollingerBandsLowerIndicator implements Indicator<Double> { private final Indicator<? extends Number> indicator; + private final BollingerBandsMiddleIndicator bbm; ! ! public BollingerBandsLowerIndicator(BollingerBandsMiddleIndicator bbm, StandardDeviationIndicator standardDeviation) { this.bbm = bbm; this.indicator = standardDeviation; } ! ! public BollingerBandsLowerIndicator(BollingerBandsMiddleIndicator bbm, Indicator<? extends Number> indicator) { this.bbm = bbm; this.indicator = indicator; } ! public Double getValue(int index) { return bbm.getValue(index).doubleValue() - 2 * indicator.getValue(index).doubleValue(); Index: BollingerBandsUpperIndicator.java =================================================================== RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/tracker/bollingerbands/BollingerBandsUpperIndicator.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BollingerBandsUpperIndicator.java 17 May 2007 22:42:31 -0000 1.1 --- BollingerBandsUpperIndicator.java 18 May 2007 01:07:44 -0000 1.2 *************** *** 6,23 **** public class BollingerBandsUpperIndicator implements Indicator<Double> { private final Indicator<? extends Number> indicator; private final BollingerBandsMiddleIndicator bbm; ! ! public BollingerBandsUpperIndicator(BollingerBandsMiddleIndicator bbm, StandardDeviationIndicator standardDeviation) ! { this.bbm = bbm; this.indicator = standardDeviation; } ! ! public BollingerBandsUpperIndicator(BollingerBandsMiddleIndicator bbm, Indicator <? extends Number> indicator) ! { this.bbm = bbm; this.indicator = indicator; } ! public Double getValue(int index) { return bbm.getValue(index).doubleValue() + 2 * indicator.getValue(index).doubleValue(); --- 6,22 ---- public class BollingerBandsUpperIndicator implements Indicator<Double> { private final Indicator<? extends Number> indicator; + private final BollingerBandsMiddleIndicator bbm; ! ! public BollingerBandsUpperIndicator(BollingerBandsMiddleIndicator bbm, StandardDeviationIndicator standardDeviation) { this.bbm = bbm; this.indicator = standardDeviation; } ! ! public BollingerBandsUpperIndicator(BollingerBandsMiddleIndicator bbm, Indicator<? extends Number> indicator) { this.bbm = bbm; this.indicator = indicator; } ! public Double getValue(int index) { return bbm.getValue(index).doubleValue() + 2 * indicator.getValue(index).doubleValue(); |
|
From: Márcio V. d. S. <mv...@us...> - 2007-05-18 01:07:47
|
Update of /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/bollingerbands In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv21729/src/test/net/sf/tail/indicator/bollingerbands Modified Files: BollingerBandsUpperIndicatorTest.java BollingerBandsMiddleIndicatorTest.java BollingerBandsLowerIndicatorTest.java Log Message: refatoração de código (control + shift + f) Index: BollingerBandsMiddleIndicatorTest.java =================================================================== RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/bollingerbands/BollingerBandsMiddleIndicatorTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BollingerBandsMiddleIndicatorTest.java 17 May 2007 22:42:31 -0000 1.1 --- BollingerBandsMiddleIndicatorTest.java 18 May 2007 01:07:45 -0000 1.2 *************** *** 14,44 **** public class BollingerBandsMiddleIndicatorTest { private TimeSeries data; ! @Before ! public void setUp() throws Exception { data = new SampleTimeSeries(new double[] { 1, 2, 3, 4, 3, 4, 5, 4, 3, 3, 4, 3, 2 }); } ! @Test public void testBollingerBandsMiddleUsingSMA() throws Exception { SMAIndicator sma = new SMAIndicator(new ClosePriceIndicator(data), 3); BollingerBandsMiddleIndicator bbmSMA = new BollingerBandsMiddleIndicator(sma); ! for (int i = 0; i < data.getSize(); i++) { assertEquals(sma.getValue(i), bbmSMA.getValue(i)); } ! } ! @Test(expected = IndexOutOfBoundsException.class) public void testWrongIndex() { SMAIndicator sma = new SMAIndicator(new ClosePriceIndicator(data), 3); BollingerBandsMiddleIndicator bbmSMA = new BollingerBandsMiddleIndicator(sma); ! bbmSMA.getValue(data.getSize()); } ! ! //Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede Linux) ! //e o JUnit4 public static junit.framework.Test suite() { return new JUnit4TestAdapter(BollingerBandsMiddleIndicatorTest.class); --- 14,45 ---- public class BollingerBandsMiddleIndicatorTest { private TimeSeries data; ! @Before ! public void setUp() throws Exception { data = new SampleTimeSeries(new double[] { 1, 2, 3, 4, 3, 4, 5, 4, 3, 3, 4, 3, 2 }); } ! @Test public void testBollingerBandsMiddleUsingSMA() throws Exception { SMAIndicator sma = new SMAIndicator(new ClosePriceIndicator(data), 3); BollingerBandsMiddleIndicator bbmSMA = new BollingerBandsMiddleIndicator(sma); ! for (int i = 0; i < data.getSize(); i++) { assertEquals(sma.getValue(i), bbmSMA.getValue(i)); } ! } ! @Test(expected = IndexOutOfBoundsException.class) public void testWrongIndex() { SMAIndicator sma = new SMAIndicator(new ClosePriceIndicator(data), 3); BollingerBandsMiddleIndicator bbmSMA = new BollingerBandsMiddleIndicator(sma); ! bbmSMA.getValue(data.getSize()); } ! ! // Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede ! // Linux) ! // e o JUnit4 public static junit.framework.Test suite() { return new JUnit4TestAdapter(BollingerBandsMiddleIndicatorTest.class); Index: BollingerBandsLowerIndicatorTest.java =================================================================== RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/bollingerbands/BollingerBandsLowerIndicatorTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BollingerBandsLowerIndicatorTest.java 17 May 2007 22:42:31 -0000 1.1 --- BollingerBandsLowerIndicatorTest.java 18 May 2007 01:07:45 -0000 1.2 *************** *** 17,26 **** private TimeSeries data; ! @Before ! public void setUp() throws Exception { data = new SampleTimeSeries(new double[] { 1, 2, 3, 4, 3, 4, 5, 4, 3, 3, 4, 3, 2 }); } ! @Test public void testBollingerBandsLowerUsingSMAAndStandardDeviation() throws Exception { --- 17,26 ---- private TimeSeries data; ! @Before ! public void setUp() throws Exception { data = new SampleTimeSeries(new double[] { 1, 2, 3, 4, 3, 4, 5, 4, 3, 3, 4, 3, 2 }); } ! @Test public void testBollingerBandsLowerUsingSMAAndStandardDeviation() throws Exception { *************** *** 31,40 **** StandardDeviationIndicator standardDeviation = new StandardDeviationIndicator(closePrice, timeFrame); BollingerBandsLowerIndicator bblSMA = new BollingerBandsLowerIndicator(bbmSMA, standardDeviation); ! for (int i = 0; i < data.getSize(); i++) { assertEquals(sma.getValue(i) - 2 * standardDeviation.getValue(i), bblSMA.getValue(i)); } } ! @Test(expected = IndexOutOfBoundsException.class) public void testWrongIndex() { --- 31,40 ---- StandardDeviationIndicator standardDeviation = new StandardDeviationIndicator(closePrice, timeFrame); BollingerBandsLowerIndicator bblSMA = new BollingerBandsLowerIndicator(bbmSMA, standardDeviation); ! for (int i = 0; i < data.getSize(); i++) { assertEquals(sma.getValue(i) - 2 * standardDeviation.getValue(i), bblSMA.getValue(i)); } } ! @Test(expected = IndexOutOfBoundsException.class) public void testWrongIndex() { *************** *** 45,52 **** StandardDeviationIndicator standardDeviation = new StandardDeviationIndicator(closePrice, timeFrame); BollingerBandsLowerIndicator bblSMA = new BollingerBandsLowerIndicator(bbmSMA, standardDeviation); ! bblSMA.getValue(data.getSize()); } ! public static junit.framework.Test suite() { return new JUnit4TestAdapter(BollingerBandsLowerIndicatorTest.class); --- 45,52 ---- StandardDeviationIndicator standardDeviation = new StandardDeviationIndicator(closePrice, timeFrame); BollingerBandsLowerIndicator bblSMA = new BollingerBandsLowerIndicator(bbmSMA, standardDeviation); ! bblSMA.getValue(data.getSize()); } ! public static junit.framework.Test suite() { return new JUnit4TestAdapter(BollingerBandsLowerIndicatorTest.class); Index: BollingerBandsUpperIndicatorTest.java =================================================================== RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/bollingerbands/BollingerBandsUpperIndicatorTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BollingerBandsUpperIndicatorTest.java 17 May 2007 22:42:31 -0000 1.1 --- BollingerBandsUpperIndicatorTest.java 18 May 2007 01:07:45 -0000 1.2 *************** *** 15,26 **** public class BollingerBandsUpperIndicatorTest { ! private TimeSeries data; ! @Before ! public void setUp() throws Exception { data = new SampleTimeSeries(new double[] { 1, 2, 3, 4, 3, 4, 5, 4, 3, 3, 4, 3, 2 }); } ! @Test public void testBollingerBandsUpperUsingSMAAndStandardDeviation() throws Exception { --- 15,26 ---- public class BollingerBandsUpperIndicatorTest { ! private TimeSeries data; ! @Before ! public void setUp() throws Exception { data = new SampleTimeSeries(new double[] { 1, 2, 3, 4, 3, 4, 5, 4, 3, 3, 4, 3, 2 }); } ! @Test public void testBollingerBandsUpperUsingSMAAndStandardDeviation() throws Exception { *************** *** 31,40 **** StandardDeviationIndicator standardDeviation = new StandardDeviationIndicator(closePrice, timeFrame); BollingerBandsUpperIndicator bbuSMA = new BollingerBandsUpperIndicator(bbmSMA, standardDeviation); ! for (int i = 0; i < data.getSize(); i++) { assertEquals(sma.getValue(i) + 2 * standardDeviation.getValue(i), bbuSMA.getValue(i)); } } ! @Test(expected = IndexOutOfBoundsException.class) public void testWrongIndex() { --- 31,40 ---- StandardDeviationIndicator standardDeviation = new StandardDeviationIndicator(closePrice, timeFrame); BollingerBandsUpperIndicator bbuSMA = new BollingerBandsUpperIndicator(bbmSMA, standardDeviation); ! for (int i = 0; i < data.getSize(); i++) { assertEquals(sma.getValue(i) + 2 * standardDeviation.getValue(i), bbuSMA.getValue(i)); } } ! @Test(expected = IndexOutOfBoundsException.class) public void testWrongIndex() { *************** *** 45,55 **** StandardDeviationIndicator standardDeviation = new StandardDeviationIndicator(closePrice, timeFrame); BollingerBandsUpperIndicator bbuSMA = new BollingerBandsUpperIndicator(bbmSMA, standardDeviation); ! bbuSMA.getValue(data.getSize()); } ! public static junit.framework.Test suite() { return new JUnit4TestAdapter(BollingerBandsUpperIndicatorTest.class); } ! } --- 45,55 ---- StandardDeviationIndicator standardDeviation = new StandardDeviationIndicator(closePrice, timeFrame); BollingerBandsUpperIndicator bbuSMA = new BollingerBandsUpperIndicator(bbmSMA, standardDeviation); ! bbuSMA.getValue(data.getSize()); } ! public static junit.framework.Test suite() { return new JUnit4TestAdapter(BollingerBandsUpperIndicatorTest.class); } ! } |
|
From: Márcio V. d. S. <mv...@us...> - 2007-05-18 01:07:47
|
Update of /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/tracker In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv21729/src/java/net/sf/tail/indicator/tracker Modified Files: WilliamsRIndicator.java StandardDeviationIndicator.java HighestValueIndicator.java LowestValueIndicator.java Removed Files: CachedIndicator.java Log Message: refatoração de código (control + shift + f) Index: WilliamsRIndicator.java =================================================================== RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/tracker/WilliamsRIndicator.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** WilliamsRIndicator.java 17 May 2007 23:06:56 -0000 1.6 --- WilliamsRIndicator.java 18 May 2007 01:07:44 -0000 1.7 *************** *** 18,27 **** // TODO - ver a complexidade dos construtores. ! public WilliamsRIndicator(TimeSeries timeSeries, int timeFrame) ! { ! this(new ClosePriceIndicator(timeSeries), timeFrame, new MaxPriceIndicator(timeSeries), new MinPriceIndicator(timeSeries)); } ! ! public WilliamsRIndicator(Indicator<? extends Number> indicator, int timeFrame, MaxPriceIndicator maxPriceIndicator, MinPriceIndicator minPriceIndicator) { this.indicator = indicator; this.timeFrame = timeFrame; --- 18,28 ---- // TODO - ver a complexidade dos construtores. ! public WilliamsRIndicator(TimeSeries timeSeries, int timeFrame) { ! this(new ClosePriceIndicator(timeSeries), timeFrame, new MaxPriceIndicator(timeSeries), new MinPriceIndicator( ! timeSeries)); } ! ! public WilliamsRIndicator(Indicator<? extends Number> indicator, int timeFrame, ! MaxPriceIndicator maxPriceIndicator, MinPriceIndicator minPriceIndicator) { this.indicator = indicator; this.timeFrame = timeFrame; Index: HighestValueIndicator.java =================================================================== RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/tracker/HighestValueIndicator.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** HighestValueIndicator.java 17 May 2007 22:45:34 -0000 1.1 --- HighestValueIndicator.java 18 May 2007 01:07:44 -0000 1.2 *************** *** 6,21 **** private final Indicator<? extends Number> indicator; private final int timeFrame; ! public HighestValueIndicator(Indicator<? extends Number> indicator, int timeFrame) { this.indicator = indicator; this.timeFrame = timeFrame; } ! public Double getValue(int index) { int start = Math.max(0, index - timeFrame + 1); Double highest = (Double) indicator.getValue(start); for (int i = start + 1; i <= index; i++) { ! if(highest.doubleValue() < indicator.getValue(i).doubleValue()) highest = (Double) indicator.getValue(i); } --- 6,22 ---- private final Indicator<? extends Number> indicator; + private final int timeFrame; ! public HighestValueIndicator(Indicator<? extends Number> indicator, int timeFrame) { this.indicator = indicator; this.timeFrame = timeFrame; } ! public Double getValue(int index) { int start = Math.max(0, index - timeFrame + 1); Double highest = (Double) indicator.getValue(start); for (int i = start + 1; i <= index; i++) { ! if (highest.doubleValue() < indicator.getValue(i).doubleValue()) highest = (Double) indicator.getValue(i); } Index: StandardDeviationIndicator.java =================================================================== RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/tracker/StandardDeviationIndicator.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** StandardDeviationIndicator.java 17 May 2007 21:47:24 -0000 1.2 --- StandardDeviationIndicator.java 18 May 2007 01:07:44 -0000 1.3 *************** *** 6,20 **** private Indicator<? extends Number> indicator; private int timeFrame; ! ! public StandardDeviationIndicator(Indicator<? extends Number> indicator, int timeFrame) ! { this.indicator = indicator; this.timeFrame = timeFrame; } ! public Double getValue(int index) { SMAIndicator sma = new SMAIndicator(indicator, timeFrame); ! double standardDeviation = 0.0; double avarage = sma.getValue(index); --- 6,20 ---- private Indicator<? extends Number> indicator; + private int timeFrame; ! ! public StandardDeviationIndicator(Indicator<? extends Number> indicator, int timeFrame) { this.indicator = indicator; this.timeFrame = timeFrame; } ! public Double getValue(int index) { SMAIndicator sma = new SMAIndicator(indicator, timeFrame); ! double standardDeviation = 0.0; double avarage = sma.getValue(index); *************** *** 25,34 **** } - - - - - - - } --- 25,27 ---- --- CachedIndicator.java DELETED --- Index: LowestValueIndicator.java =================================================================== RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/tracker/LowestValueIndicator.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** LowestValueIndicator.java 17 May 2007 22:45:34 -0000 1.1 --- LowestValueIndicator.java 18 May 2007 01:07:44 -0000 1.2 *************** *** 6,11 **** private final Indicator<? extends Number> indicator; private final int timeFrame; ! public LowestValueIndicator(Indicator<? extends Number> indicator, int timeFrame) { this.indicator = indicator; --- 6,12 ---- private final Indicator<? extends Number> indicator; + private final int timeFrame; ! public LowestValueIndicator(Indicator<? extends Number> indicator, int timeFrame) { this.indicator = indicator; *************** *** 17,21 **** Double lowest = (Double) indicator.getValue(start); for (int i = start + 1; i <= index; i++) { ! if(lowest.doubleValue() > indicator.getValue(i).doubleValue()) lowest = (Double) indicator.getValue(i); } --- 18,22 ---- Double lowest = (Double) indicator.getValue(start); for (int i = start + 1; i <= index; i++) { ! if (lowest.doubleValue() > indicator.getValue(i).doubleValue()) lowest = (Double) indicator.getValue(i); } |
|
From: Márcio V. d. S. <mv...@us...> - 2007-05-18 01:07:47
|
Update of /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/oscilator In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv21729/src/test/net/sf/tail/indicator/oscilator Modified Files: StochasticOscilatorFastTest.java Log Message: refatoração de código (control + shift + f) Index: StochasticOscilatorFastTest.java =================================================================== RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/oscilator/StochasticOscilatorFastTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** StochasticOscilatorFastTest.java 17 May 2007 23:04:58 -0000 1.1 --- StochasticOscilatorFastTest.java 18 May 2007 01:07:44 -0000 1.2 *************** *** 45,53 **** @Test public void testStochasticOscilatorParam14() { ! StochasticOscilatorFast sof = new StochasticOscilatorFast(new ClosePriceIndicator(data), ! new MinPriceIndicator(data), new MaxPriceIndicator(data), 14); ! assertEquals(313d/3.50, sof.getValue(0), 0.01); ! assertEquals(1000d/10.81, sof.getValue(12), 0.01); assertEquals(57.81, sof.getValue(13), 0.01); } --- 45,53 ---- @Test public void testStochasticOscilatorParam14() { ! StochasticOscilatorFast sof = new StochasticOscilatorFast(new ClosePriceIndicator(data), new MinPriceIndicator( ! data), new MaxPriceIndicator(data), 14); ! assertEquals(313d / 3.50, sof.getValue(0), 0.01); ! assertEquals(1000d / 10.81, sof.getValue(12), 0.01); assertEquals(57.81, sof.getValue(13), 0.01); } *************** *** 55,60 **** @Test public void test13daysJumping() { ! StochasticOscilatorFast sof = new StochasticOscilatorFast(new ClosePriceIndicator(data), ! new MinPriceIndicator(data), new MaxPriceIndicator(data), 14); assertEquals(57.81, sof.getValue(13), 0.01); } --- 55,60 ---- @Test public void test13daysJumping() { ! StochasticOscilatorFast sof = new StochasticOscilatorFast(new ClosePriceIndicator(data), new MinPriceIndicator( ! data), new MaxPriceIndicator(data), 14); assertEquals(57.81, sof.getValue(13), 0.01); } *************** *** 62,67 **** @Test(expected = IndexOutOfBoundsException.class) public void testWrongIndex() { ! StochasticOscilatorFast sof = new StochasticOscilatorFast(new ClosePriceIndicator(data), ! new MinPriceIndicator(data), new MaxPriceIndicator(data), 14); sof.getValue(1300); } --- 62,67 ---- @Test(expected = IndexOutOfBoundsException.class) public void testWrongIndex() { ! StochasticOscilatorFast sof = new StochasticOscilatorFast(new ClosePriceIndicator(data), new MinPriceIndicator( ! data), new MaxPriceIndicator(data), 14); sof.getValue(1300); } |
|
From: Márcio V. d. S. <mv...@us...> - 2007-05-18 01:07:47
|
Update of /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/oscilator In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv21729/src/java/net/sf/tail/indicator/oscilator Modified Files: StochasticOscilatorFast.java Removed Files: osciladores_aqui Log Message: refatoração de código (control + shift + f) --- osciladores_aqui DELETED --- Index: StochasticOscilatorFast.java =================================================================== RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/oscilator/StochasticOscilatorFast.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** StochasticOscilatorFast.java 17 May 2007 23:06:56 -0000 1.1 --- StochasticOscilatorFast.java 18 May 2007 01:07:44 -0000 1.2 *************** *** 8,12 **** public class StochasticOscilatorFast extends Object implements Indicator<Double> { ! public StochasticOscilatorFast(ClosePriceIndicator indicator, MinPriceIndicator indicator2, MaxPriceIndicator indicator3, int i) { // TODO Auto-generated constructor stub } --- 8,13 ---- public class StochasticOscilatorFast extends Object implements Indicator<Double> { ! public StochasticOscilatorFast(ClosePriceIndicator indicator, MinPriceIndicator indicator2, ! MaxPriceIndicator indicator3, int i) { // TODO Auto-generated constructor stub } |
|
From: Márcio V. d. S. <mv...@us...> - 2007-05-18 01:07:47
|
Update of /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/cache In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv21729/src/test/net/sf/tail/indicator/cache Added Files: CachedIndicatorTest.java Log Message: refatoração de código (control + shift + f) --- NEW FILE: CachedIndicatorTest.java --- package net.sf.tail.indicator.cache; import java.util.Arrays; import net.sf.tail.SampleTimeSeries; import net.sf.tail.TimeSeries; import net.sf.tail.indicator.cache.CachedIndicator; import net.sf.tail.indicator.simple.ClosePriceIndicator; import net.sf.tail.indicator.tracker.SMAIndicator; import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; import junit.framework.JUnit4TestAdapter; public class CachedIndicatorTest { private TimeSeries data; @Before public void setUp() throws Exception { data = new SampleTimeSeries(new double[] { 1, 2, 3, 4, 3, 4, 5, 4, 3, 3, 4, 3, 2 }); } @Test public void testCachedIndicatorShouldBeEqualsSMAIndicator() throws Exception { SMAIndicator sma = new SMAIndicator(new ClosePriceIndicator(data), 3); CachedIndicator cache = new CachedIndicator(sma); for (int i = 0; i < 10; i++) { assertEquals(sma.getValue(i), cache.getValue(i)); } } @Test public void testIfCacheWorks() { SMAIndicator sma = new SMAIndicator(new ClosePriceIndicator(data), 3); CachedIndicator cache = new CachedIndicator(sma); cache.getValue(4); assertEquals(sma.getValue(4), cache.getValue(4)); } @Test public void testIncreaseArrayMethod() { double[] d = new double[200]; Arrays.fill(d, 10); TimeSeries dataMax = new SampleTimeSeries(d); SMAIndicator quoteSMA = new SMAIndicator(new ClosePriceIndicator(dataMax), 100); CachedIndicator cache = new CachedIndicator(quoteSMA); assertEquals(10d, cache.getValue(105)); } @Test(expected = IndexOutOfBoundsException.class) public void testWrongIndex() { SMAIndicator quoteSMA = new SMAIndicator(new ClosePriceIndicator(data), 3); CachedIndicator cache = new CachedIndicator(quoteSMA); cache.getValue(13); } // Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede // Linux) // e o JUnit4 public static junit.framework.Test suite() { return new JUnit4TestAdapter(CachedIndicatorTest.class); } } |
|
From: Márcio V. d. S. <mv...@us...> - 2007-05-18 01:07:47
|
Update of /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/cache In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv21729/src/java/net/sf/tail/indicator/cache Added Files: CachedIndicator.java Log Message: refatoração de código (control + shift + f) --- NEW FILE: CachedIndicator.java --- package net.sf.tail.indicator.cache; import java.util.ArrayList; import java.util.Collections; import java.util.List; import net.sf.tail.Indicator; public class CachedIndicator implements Indicator { private final Indicator<? extends Number> indicator; // TODO - A melhor solução é realmente List<Number> ? private List<Number> results; public CachedIndicator(Indicator<? extends Number> indicator) { this.indicator = indicator; results = new ArrayList<Number>(); } public Number getValue(int index) { increaseLength(index); if (results.get(index) == null) { results.set(index, indicator.getValue(index)); } return results.get(index); } private void increaseLength(int index) { if (results.size() <= index) { results.addAll(Collections.<Number> nCopies(index - results.size() + 1, null)); } } } |
|
From: Márcio V. d. S. <mv...@us...> - 2007-05-18 01:07:35
|
Update of /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/cache In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv21715/src/test/net/sf/tail/indicator/cache Log Message: Directory /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/cache added to the repository |
|
From: Márcio V. d. S. <mv...@us...> - 2007-05-18 01:07:34
|
Update of /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/cache In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv21715/src/java/net/sf/tail/indicator/cache Log Message: Directory /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/cache added to the repository |
|
From: Márcio V. d. S. <mv...@us...> - 2007-05-17 23:07:00
|
Update of /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/tracker In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv3463/src/java/net/sf/tail/indicator/tracker Modified Files: SMAIndicator.java CachedIndicator.java WilliamsRIndicator.java EMAIndicator.java AverageLossIndicator.java RSIIndicator.java AverageGainIndicator.java Log Message: Refatoração de código Index: EMAIndicator.java =================================================================== RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/tracker/EMAIndicator.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** EMAIndicator.java 17 May 2007 21:30:55 -0000 1.10 --- EMAIndicator.java 17 May 2007 23:06:56 -0000 1.11 *************** *** 6,26 **** private final Indicator<? extends Number> indicator; private final int timeFrame; ! public EMAIndicator(Indicator<? extends Number> indicator, int timeFrame) { this.indicator = indicator; this.timeFrame = timeFrame; } ! ! private double multiplier(){ ! return 2 / (double)(timeFrame + 1); } ! public Double getValue(int index) { ! if(index + 1 < timeFrame) ! return new SMAIndicator(indicator,timeFrame).getValue(index); ! double emaPrev = getValue(index - 1).doubleValue(); ! return ( ( indicator.getValue(index).doubleValue() - emaPrev ) * multiplier()) + emaPrev; } } --- 6,27 ---- private final Indicator<? extends Number> indicator; + private final int timeFrame; ! public EMAIndicator(Indicator<? extends Number> indicator, int timeFrame) { this.indicator = indicator; this.timeFrame = timeFrame; } ! ! private double multiplier() { ! return 2 / (double) (timeFrame + 1); } ! public Double getValue(int index) { ! if (index + 1 < timeFrame) ! return new SMAIndicator(indicator, timeFrame).getValue(index); ! double emaPrev = getValue(index - 1).doubleValue(); ! return ((indicator.getValue(index).doubleValue() - emaPrev) * multiplier()) + emaPrev; } } Index: AverageLossIndicator.java =================================================================== RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/tracker/AverageLossIndicator.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AverageLossIndicator.java 17 May 2007 21:30:54 -0000 1.2 --- AverageLossIndicator.java 17 May 2007 23:06:56 -0000 1.3 *************** *** 6,11 **** private final Indicator<? extends Number> indicator; private final int timeFrame; ! public AverageLossIndicator(Indicator<? extends Number> indicator, int timeFrame) { this.indicator = indicator; --- 6,12 ---- private final Indicator<? extends Number> indicator; + private final int timeFrame; ! public AverageLossIndicator(Indicator<? extends Number> indicator, int timeFrame) { this.indicator = indicator; Index: RSIIndicator.java =================================================================== RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/tracker/RSIIndicator.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** RSIIndicator.java 17 May 2007 21:30:55 -0000 1.10 --- RSIIndicator.java 17 May 2007 23:06:56 -0000 1.11 *************** *** 6,11 **** private final Indicator<? extends Number> indicator; private final int timeFrame; ! public RSIIndicator(Indicator<? extends Number> indicator, int timeFrame) { this.indicator = indicator; --- 6,12 ---- private final Indicator<? extends Number> indicator; + private final int timeFrame; ! public RSIIndicator(Indicator<? extends Number> indicator, int timeFrame) { this.indicator = indicator; Index: SMAIndicator.java =================================================================== RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/tracker/SMAIndicator.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** SMAIndicator.java 17 May 2007 21:30:54 -0000 1.8 --- SMAIndicator.java 17 May 2007 23:06:56 -0000 1.9 *************** *** 6,11 **** private final Indicator<? extends Number> indicator; private final int timeFrame; ! public SMAIndicator(Indicator<? extends Number> indicator, int timeFrame) { this.indicator = indicator; --- 6,12 ---- private final Indicator<? extends Number> indicator; + private final int timeFrame; ! public SMAIndicator(Indicator<? extends Number> indicator, int timeFrame) { this.indicator = indicator; *************** *** 16,25 **** double sum = 0.0; for (int i = Math.max(0, index - timeFrame + 1); i <= index; i++) { ! sum += indicator.getValue(i).doubleValue(); } ! return sum / Math.min(timeFrame, index + 1); } - } --- 17,25 ---- double sum = 0.0; for (int i = Math.max(0, index - timeFrame + 1); i <= index; i++) { ! sum += indicator.getValue(i).doubleValue(); } ! return sum / Math.min(timeFrame, index + 1); } } Index: AverageGainIndicator.java =================================================================== RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/tracker/AverageGainIndicator.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AverageGainIndicator.java 17 May 2007 21:30:55 -0000 1.2 --- AverageGainIndicator.java 17 May 2007 23:06:56 -0000 1.3 *************** *** 6,11 **** private final Indicator<? extends Number> indicator; private final int timeFrame; ! public AverageGainIndicator(Indicator<? extends Number> indicator, int timeFrame) { this.indicator = indicator; --- 6,12 ---- private final Indicator<? extends Number> indicator; + private final int timeFrame; ! public AverageGainIndicator(Indicator<? extends Number> indicator, int timeFrame) { this.indicator = indicator; Index: WilliamsRIndicator.java =================================================================== RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/tracker/WilliamsRIndicator.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** WilliamsRIndicator.java 17 May 2007 22:58:07 -0000 1.5 --- WilliamsRIndicator.java 17 May 2007 23:06:56 -0000 1.6 *************** *** 8,17 **** public class WilliamsRIndicator implements Indicator<Double> { ! private final Indicator<? extends Number> indicator; private final int timeFrame; private MaxPriceIndicator maxPriceIndicator; private MinPriceIndicator minPriceIndicator; ! public WilliamsRIndicator(TimeSeries timeSeries, int timeFrame) { --- 8,21 ---- public class WilliamsRIndicator implements Indicator<Double> { ! private final Indicator<? extends Number> indicator; + private final int timeFrame; + private MaxPriceIndicator maxPriceIndicator; + private MinPriceIndicator minPriceIndicator; ! ! // TODO - ver a complexidade dos construtores. public WilliamsRIndicator(TimeSeries timeSeries, int timeFrame) { *************** *** 25,38 **** this.minPriceIndicator = minPriceIndicator; } ! public Double getValue(int index) { HighestValueIndicator highestHigh = new HighestValueIndicator(maxPriceIndicator, timeFrame); LowestValueIndicator lowestMin = new LowestValueIndicator(minPriceIndicator, timeFrame); ! double highestHighPrice = highestHigh.getValue(index); double lowestLowPrice = lowestMin.getValue(index); ! ! return ((highestHighPrice - indicator.getValue(index).doubleValue()) / (highestHighPrice - lowestLowPrice)) * -100d; } } - --- 29,46 ---- this.minPriceIndicator = minPriceIndicator; } ! public Double getValue(int index) { + /* + * TODO - Pensar em otimização ou maior número de indicadores ? + * + */ HighestValueIndicator highestHigh = new HighestValueIndicator(maxPriceIndicator, timeFrame); LowestValueIndicator lowestMin = new LowestValueIndicator(minPriceIndicator, timeFrame); ! double highestHighPrice = highestHigh.getValue(index); double lowestLowPrice = lowestMin.getValue(index); ! ! return ((highestHighPrice - indicator.getValue(index).doubleValue()) / (highestHighPrice - lowestLowPrice)) ! * -100d; } } Index: CachedIndicator.java =================================================================== RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/tracker/CachedIndicator.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** CachedIndicator.java 17 May 2007 21:42:16 -0000 1.6 --- CachedIndicator.java 17 May 2007 23:06:56 -0000 1.7 *************** *** 9,15 **** public class CachedIndicator implements Indicator { - private final Indicator<? extends Number> indicator; private List<Number> results; --- 9,15 ---- public class CachedIndicator implements Indicator { private final Indicator<? extends Number> indicator; + //TODO - A melhor solução é realmente List<Number> ? private List<Number> results; *************** *** 17,22 **** this.indicator = indicator; results = new ArrayList<Number>(); ! } ! public Number getValue(int index) { increaseLength(index); --- 17,22 ---- this.indicator = indicator; results = new ArrayList<Number>(); ! } ! public Number getValue(int index) { increaseLength(index); *************** *** 34,38 **** } - - } --- 34,36 ---- |
|
From: Márcio V. d. S. <mv...@us...> - 2007-05-17 23:07:00
|
Update of /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/simple In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv3463/src/java/net/sf/tail/indicator/simple Modified Files: PreviousPriceIndicator.java ClosePriceIndicator.java VolumeIndicator.java OpenPriceIndicator.java ConstantIndicator.java VariationIndicator.java MaxPriceIndicator.java TradeIndicator.java MinPriceIndicator.java AmountIndicator.java Log Message: Refatoração de código Index: PreviousPriceIndicator.java =================================================================== RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/simple/PreviousPriceIndicator.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PreviousPriceIndicator.java 12 May 2007 19:17:09 -0000 1.1 --- PreviousPriceIndicator.java 17 May 2007 23:06:56 -0000 1.2 *************** *** 6,17 **** public class PreviousPriceIndicator implements Indicator<Double> { ! private TimeSeries data; ! public PreviousPriceIndicator(TimeSeries data) { ! this.data = data; ! } ! public Double getValue(int index) { ! return data.getTick(index).getPreviousPrice(); ! } } --- 6,17 ---- public class PreviousPriceIndicator implements Indicator<Double> { ! private TimeSeries data; ! public PreviousPriceIndicator(TimeSeries data) { ! this.data = data; ! } ! public Double getValue(int index) { ! return data.getTick(index).getPreviousPrice(); ! } } Index: VolumeIndicator.java =================================================================== RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/simple/VolumeIndicator.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** VolumeIndicator.java 17 May 2007 20:16:11 -0000 1.1 --- VolumeIndicator.java 17 May 2007 23:06:56 -0000 1.2 *************** *** 6,17 **** public class VolumeIndicator implements Indicator<Double> { ! private TimeSeries data; ! public VolumeIndicator(TimeSeries data) { ! this.data = data; ! } ! public Double getValue(int index) { ! return data.getTick(index).getVolume(); ! } } \ No newline at end of file --- 6,17 ---- public class VolumeIndicator implements Indicator<Double> { ! private TimeSeries data; ! public VolumeIndicator(TimeSeries data) { ! this.data = data; ! } ! public Double getValue(int index) { ! return data.getTick(index).getVolume(); ! } } \ No newline at end of file Index: OpenPriceIndicator.java =================================================================== RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/simple/OpenPriceIndicator.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** OpenPriceIndicator.java 12 May 2007 17:45:51 -0000 1.2 --- OpenPriceIndicator.java 17 May 2007 23:06:56 -0000 1.3 *************** *** 6,17 **** public class OpenPriceIndicator implements Indicator<Double> { ! private TimeSeries data; ! public OpenPriceIndicator(TimeSeries data) { ! this.data = data; ! } ! public Double getValue(int index) { ! return data.getTick(index).getOpenPrice(); ! } } \ No newline at end of file --- 6,17 ---- public class OpenPriceIndicator implements Indicator<Double> { ! private TimeSeries data; ! public OpenPriceIndicator(TimeSeries data) { ! this.data = data; ! } ! public Double getValue(int index) { ! return data.getTick(index).getOpenPrice(); ! } } \ No newline at end of file Index: MinPriceIndicator.java =================================================================== RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/simple/MinPriceIndicator.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MinPriceIndicator.java 12 May 2007 17:45:51 -0000 1.2 --- MinPriceIndicator.java 17 May 2007 23:06:56 -0000 1.3 *************** *** 6,17 **** public class MinPriceIndicator implements Indicator<Double> { ! private TimeSeries data; ! public MinPriceIndicator(TimeSeries data) { ! this.data = data; ! } ! public Double getValue(int index) { ! return data.getTick(index).getMinPrice(); ! } } --- 6,17 ---- public class MinPriceIndicator implements Indicator<Double> { ! private TimeSeries data; ! public MinPriceIndicator(TimeSeries data) { ! this.data = data; ! } ! public Double getValue(int index) { ! return data.getTick(index).getMinPrice(); ! } } Index: VariationIndicator.java =================================================================== RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/simple/VariationIndicator.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** VariationIndicator.java 17 May 2007 20:16:11 -0000 1.2 --- VariationIndicator.java 17 May 2007 23:06:56 -0000 1.3 *************** *** 6,17 **** public class VariationIndicator implements Indicator<Double> { ! private TimeSeries data; ! public VariationIndicator(TimeSeries data) { ! this.data = data; ! } ! public Double getValue(int index) { ! return data.getTick(index).getVariation(); ! } } --- 6,17 ---- public class VariationIndicator implements Indicator<Double> { ! private TimeSeries data; ! public VariationIndicator(TimeSeries data) { ! this.data = data; ! } ! public Double getValue(int index) { ! return data.getTick(index).getVariation(); ! } } Index: ClosePriceIndicator.java =================================================================== RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/simple/ClosePriceIndicator.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ClosePriceIndicator.java 12 May 2007 14:23:35 -0000 1.2 --- ClosePriceIndicator.java 17 May 2007 23:06:56 -0000 1.3 *************** *** 6,17 **** public class ClosePriceIndicator implements Indicator<Double> { ! private TimeSeries data; ! public ClosePriceIndicator(TimeSeries data) { ! this.data = data; ! } ! public Double getValue(int index) { ! return data.getTick(index).getClosePrice(); ! } } --- 6,17 ---- public class ClosePriceIndicator implements Indicator<Double> { ! private TimeSeries data; ! public ClosePriceIndicator(TimeSeries data) { ! this.data = data; ! } ! public Double getValue(int index) { ! return data.getTick(index).getClosePrice(); ! } } Index: ConstantIndicator.java =================================================================== RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/simple/ConstantIndicator.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ConstantIndicator.java 12 May 2007 14:23:35 -0000 1.2 --- ConstantIndicator.java 17 May 2007 23:06:56 -0000 1.3 *************** *** 3,17 **** import net.sf.tail.Indicator; - public class ConstantIndicator<T extends Number> implements Indicator<T> { ! private T value; ! public ConstantIndicator(T t) { ! this.value = t; ! } ! public T getValue(int index) { ! return value; ! } } --- 3,16 ---- import net.sf.tail.Indicator; public class ConstantIndicator<T extends Number> implements Indicator<T> { ! private T value; ! public ConstantIndicator(T t) { ! this.value = t; ! } ! public T getValue(int index) { ! return value; ! } } Index: TradeIndicator.java =================================================================== RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/simple/TradeIndicator.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TradeIndicator.java 12 May 2007 19:17:09 -0000 1.1 --- TradeIndicator.java 17 May 2007 23:06:56 -0000 1.2 *************** *** 6,17 **** public class TradeIndicator implements Indicator<Integer> { ! private TimeSeries data; ! public TradeIndicator(TimeSeries data) { ! this.data = data; ! } ! public Integer getValue(int index) { ! return data.getTick(index).getTrades(); ! } } \ No newline at end of file --- 6,17 ---- public class TradeIndicator implements Indicator<Integer> { ! private TimeSeries data; ! public TradeIndicator(TimeSeries data) { ! this.data = data; ! } ! public Integer getValue(int index) { ! return data.getTick(index).getTrades(); ! } } \ No newline at end of file Index: AmountIndicator.java =================================================================== RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/simple/AmountIndicator.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AmountIndicator.java 17 May 2007 20:16:11 -0000 1.1 --- AmountIndicator.java 17 May 2007 23:06:56 -0000 1.2 *************** *** 6,17 **** public class AmountIndicator implements Indicator<Double> { ! private TimeSeries data; ! public AmountIndicator(TimeSeries data) { ! this.data = data; ! } ! public Double getValue(int index) { ! return data.getTick(index).getAmount(); ! } } \ No newline at end of file --- 6,17 ---- public class AmountIndicator implements Indicator<Double> { ! private TimeSeries data; ! public AmountIndicator(TimeSeries data) { ! this.data = data; ! } ! public Double getValue(int index) { ! return data.getTick(index).getAmount(); ! } } \ No newline at end of file Index: MaxPriceIndicator.java =================================================================== RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/simple/MaxPriceIndicator.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MaxPriceIndicator.java 12 May 2007 17:45:51 -0000 1.2 --- MaxPriceIndicator.java 17 May 2007 23:06:56 -0000 1.3 *************** *** 6,17 **** public class MaxPriceIndicator implements Indicator<Double> { ! private TimeSeries data; ! public MaxPriceIndicator(TimeSeries data) { ! this.data = data; ! } ! public Double getValue(int index) { ! return data.getTick(index).getMaxPrice(); ! } } --- 6,17 ---- public class MaxPriceIndicator implements Indicator<Double> { ! private TimeSeries data; ! public MaxPriceIndicator(TimeSeries data) { ! this.data = data; ! } ! public Double getValue(int index) { ! return data.getTick(index).getMaxPrice(); ! } } |
|
From: Márcio V. d. S. <mv...@us...> - 2007-05-17 23:07:00
|
Update of /cvsroot/tail/Tail/src/java/net/sf/tail/reader In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv3463/src/java/net/sf/tail/reader Modified Files: CedroTimeSeriesLoader.java Log Message: Refatoração de código Index: CedroTimeSeriesLoader.java =================================================================== RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/reader/CedroTimeSeriesLoader.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CedroTimeSeriesLoader.java 14 May 2007 16:30:19 -0000 1.5 --- CedroTimeSeriesLoader.java 17 May 2007 23:06:57 -0000 1.6 *************** *** 17,23 **** import com.csvreader.CsvReader; ! ! public class CedroTimeSeriesLoader implements TimeSeriesLoader{ ! public TimeSeries load(InputStream stream) throws IOException { --- 17,21 ---- import com.csvreader.CsvReader; ! public class CedroTimeSeriesLoader implements TimeSeriesLoader { public TimeSeries load(InputStream stream) throws IOException { *************** *** 27,35 **** List<Tick> ticks = new ArrayList<Tick>(); ! while(reader.readRecord()) ! { SimpleDateFormat simpleDate; ! if(reader.get(0).length() > 10) simpleDate = new SimpleDateFormat("dd/M/yyyy HH:mm:ss"); else --- 25,32 ---- List<Tick> ticks = new ArrayList<Tick>(); ! while (reader.readRecord()) { SimpleDateFormat simpleDate; ! if (reader.get(0).length() > 10) simpleDate = new SimpleDateFormat("dd/M/yyyy HH:mm:ss"); else *************** *** 38,46 **** Date date = null; - try { date = simpleDate.parse(reader.get(0)); } catch (ParseException e) { e.printStackTrace(); } --- 35,43 ---- Date date = null; try { date = simpleDate.parse(reader.get(0)); } catch (ParseException e) { e.printStackTrace(); + // TODO - Pensar em estrutura de tratamento de erros. } *************** *** 56,60 **** double quantity = java.lang.Double.parseDouble(reader.get(9)); ! Tick tick = new Tick(timestamp, open, close, high, low, change, previous, volumeAmount, volumeFinancier, (int)quantity); ticks.add(0, tick); } --- 53,58 ---- double quantity = java.lang.Double.parseDouble(reader.get(9)); ! Tick tick = new Tick(timestamp, open, close, high, low, change, previous, volumeAmount, volumeFinancier, ! (int) quantity); ticks.add(0, tick); } |
|
From: Márcio V. d. S. <mv...@us...> - 2007-05-17 23:07:00
|
Update of /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/oscilator In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv3463/src/java/net/sf/tail/indicator/oscilator Added Files: StochasticOscilatorFast.java Log Message: Refatoração de código --- NEW FILE: StochasticOscilatorFast.java --- package net.sf.tail.indicator.oscilator; import net.sf.tail.Indicator; import net.sf.tail.indicator.simple.ClosePriceIndicator; import net.sf.tail.indicator.simple.MaxPriceIndicator; import net.sf.tail.indicator.simple.MinPriceIndicator; public class StochasticOscilatorFast extends Object implements Indicator<Double> { public StochasticOscilatorFast(ClosePriceIndicator indicator, MinPriceIndicator indicator2, MaxPriceIndicator indicator3, int i) { // TODO Auto-generated constructor stub } public Double getValue(int index) { // TODO Auto-generated method stub return null; } } |
|
From: Márcio V. d. S. <mv...@us...> - 2007-05-17 23:07:00
|
Update of /cvsroot/tail/Tail/src/java/net/sf/tail In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv3463/src/java/net/sf/tail Modified Files: Tick.java Indicator.java TimeSeries.java Log Message: Refatoração de código Index: Indicator.java =================================================================== RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/Indicator.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Indicator.java 12 May 2007 14:23:35 -0000 1.2 --- Indicator.java 17 May 2007 23:06:56 -0000 1.3 *************** *** 2,5 **** public interface Indicator<T> { ! public T getValue(int index); } --- 2,5 ---- public interface Indicator<T> { ! public T getValue(int index); } Index: Tick.java =================================================================== RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/Tick.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Tick.java 17 May 2007 21:30:54 -0000 1.7 --- Tick.java 17 May 2007 23:06:56 -0000 1.8 *************** *** 6,17 **** --- 6,26 ---- private Timestamp data; + private double openPrice; + private double closePrice; + private double maxPrice; + private double minPrice; + private double variation; + private double previousPrice; + private double amount; + private double volume; + private int trades; *************** *** 22,49 **** public Tick(Timestamp data, double openPrice, double closePrice, double maxPrice, double minPrice, ! double variation,double previousPrice,double amount,double volume,int trades) { ! super(); this.data = data; this.openPrice = openPrice; this.closePrice = closePrice; ! this.maxPrice = maxPrice; ! this.minPrice = minPrice; ! this.variation = variation; ! this.previousPrice = previousPrice; ! this.amount = amount; this.volume = volume; this.trades = trades; } ! public Tick(double openPrice, double closePrice, double maxPrice, double minPrice) ! { ! super(); this.openPrice = openPrice; this.closePrice = closePrice; ! this.maxPrice = maxPrice; ! this.minPrice = minPrice; } - public double getClosePrice() { return closePrice; --- 31,56 ---- public Tick(Timestamp data, double openPrice, double closePrice, double maxPrice, double minPrice, ! double variation, double previousPrice, double amount, double volume, int trades) { ! super(); this.data = data; this.openPrice = openPrice; this.closePrice = closePrice; ! this.maxPrice = maxPrice; ! this.minPrice = minPrice; ! this.variation = variation; ! this.previousPrice = previousPrice; ! this.amount = amount; this.volume = volume; this.trades = trades; } ! public Tick(double openPrice, double closePrice, double maxPrice, double minPrice) { ! super(); this.openPrice = openPrice; this.closePrice = closePrice; ! this.maxPrice = maxPrice; ! this.minPrice = minPrice; } public double getClosePrice() { return closePrice; *************** *** 58,72 **** } - public double getMaxPrice() { return maxPrice; } - public double getAmount() { return amount; } - public double getVolume() { return volume; --- 65,76 ---- *************** *** 75,91 **** @Override public boolean equals(Object obj) { ! if(obj instanceof Tick) ! { Tick tick = (Tick) obj; ! return (variation == tick.getVariation()) && ! (closePrice == tick.getClosePrice()) && ! (data.equals(tick.getData())) && ! (maxPrice == tick.getMaxPrice()) && ! (minPrice == tick.getMinPrice()) && ! (openPrice == tick.getOpenPrice()) && ! (previousPrice == getPreviousPrice()) && ! (trades == tick.getTrades()) && ! (amount == tick.getAmount()) && ! (volume == tick.getVolume()); } return false; --- 79,89 ---- @Override public boolean equals(Object obj) { ! if (obj instanceof Tick) { Tick tick = (Tick) obj; ! return (variation == tick.getVariation()) && (closePrice == tick.getClosePrice()) ! && (data.equals(tick.getData())) && (maxPrice == tick.getMaxPrice()) ! && (minPrice == tick.getMinPrice()) && (openPrice == tick.getOpenPrice()) ! && (previousPrice == getPreviousPrice()) && (trades == tick.getTrades()) ! && (amount == tick.getAmount()) && (volume == tick.getVolume()); } return false; *************** *** 96,105 **** } - public double getMinPrice() { return minPrice; } - public double getPreviousPrice() { return previousPrice; --- 94,101 ---- *************** *** 110,113 **** } - } --- 106,108 ---- Index: TimeSeries.java =================================================================== RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/TimeSeries.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TimeSeries.java 12 May 2007 15:37:07 -0000 1.2 --- TimeSeries.java 17 May 2007 23:06:56 -0000 1.3 *************** *** 3,8 **** public interface TimeSeries { ! Tick getTick(int i); ! int getSize(); } --- 3,9 ---- public interface TimeSeries { ! Tick getTick(int i); ! ! int getSize(); } |
|
From: Márcio V. d. S. <mv...@us...> - 2007-05-17 23:05:05
|
Update of /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/simple In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv2571/src/test/net/sf/tail/indicator/simple Modified Files: TradeIndicatorTest.java PreviousPriceIndicatorTest.java OpenPriceIndicatorTest.java ClosePriceIndicatorTest.java VariationPriceIndicatorTest.java MinPriceIndicatorTest.java VolumeIndicatorTest.java MaxPriceIndicatorTest.java ConstantIndicatorTest.java AmountIndicatorTest.java Log Message: extraindo novos Indicadores Index: VolumeIndicatorTest.java =================================================================== RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/simple/VolumeIndicatorTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** VolumeIndicatorTest.java 17 May 2007 20:16:11 -0000 1.1 --- VolumeIndicatorTest.java 17 May 2007 23:04:58 -0000 1.2 *************** *** 11,40 **** public class VolumeIndicatorTest { ! private VolumeIndicator volumeIndicator; ! TimeSeries timeSeries; @Before ! public void setUp(){ timeSeries = new SampleTimeSeries(); volumeIndicator = new VolumeIndicator(timeSeries); } ! @Test ! public void testIndicatorShouldRetrieveTickVolume() ! { for (int i = 0; i < 10; i++) { assertEquals(volumeIndicator.getValue(i), timeSeries.getTick(i).getVolume()); ! } } @Test(expected = IndexOutOfBoundsException.class) ! public void testWrongIndex() ! { volumeIndicator.getValue(10); } ! // Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede Linux) ! //e o JUnit4 public static junit.framework.Test suite() { ! return new JUnit4TestAdapter(VolumeIndicatorTest.class); } } --- 11,41 ---- public class VolumeIndicatorTest { ! private VolumeIndicator volumeIndicator; ! TimeSeries timeSeries; @Before ! public void setUp() { timeSeries = new SampleTimeSeries(); volumeIndicator = new VolumeIndicator(timeSeries); } ! @Test ! public void testIndicatorShouldRetrieveTickVolume() { for (int i = 0; i < 10; i++) { assertEquals(volumeIndicator.getValue(i), timeSeries.getTick(i).getVolume()); ! } } + @Test(expected = IndexOutOfBoundsException.class) ! public void testWrongIndex() { volumeIndicator.getValue(10); } ! ! // Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede ! // Linux) ! // e o JUnit4 public static junit.framework.Test suite() { ! return new JUnit4TestAdapter(VolumeIndicatorTest.class); } } Index: AmountIndicatorTest.java =================================================================== RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/simple/AmountIndicatorTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AmountIndicatorTest.java 17 May 2007 20:16:11 -0000 1.1 --- AmountIndicatorTest.java 17 May 2007 23:04:58 -0000 1.2 *************** *** 11,41 **** public class AmountIndicatorTest { ! private AmountIndicator amountIndicator; ! TimeSeries timeSeries; @Before ! public void setUp(){ timeSeries = new SampleTimeSeries(); amountIndicator = new AmountIndicator(timeSeries); ! } ! @Test ! public void testIndicatorShouldRetrieveTickAmountPrice() ! { for (int i = 0; i < 10; i++) { assertEquals(amountIndicator.getValue(i), timeSeries.getTick(i).getAmount()); ! } } @Test(expected = IndexOutOfBoundsException.class) ! public void testWrongIndex() ! { amountIndicator.getValue(10); } ! // Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede Linux) ! //e o JUnit4 public static junit.framework.Test suite() { ! return new JUnit4TestAdapter(AmountIndicatorTest.class); } } --- 11,42 ---- public class AmountIndicatorTest { ! private AmountIndicator amountIndicator; ! TimeSeries timeSeries; @Before ! public void setUp() { timeSeries = new SampleTimeSeries(); amountIndicator = new AmountIndicator(timeSeries); ! } ! @Test ! public void testIndicatorShouldRetrieveTickAmountPrice() { for (int i = 0; i < 10; i++) { assertEquals(amountIndicator.getValue(i), timeSeries.getTick(i).getAmount()); ! } } + @Test(expected = IndexOutOfBoundsException.class) ! public void testWrongIndex() { amountIndicator.getValue(10); } ! ! // Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede ! // Linux) ! // e o JUnit4 public static junit.framework.Test suite() { ! return new JUnit4TestAdapter(AmountIndicatorTest.class); } } Index: MaxPriceIndicatorTest.java =================================================================== RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/simple/MaxPriceIndicatorTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** MaxPriceIndicatorTest.java 17 May 2007 20:16:11 -0000 1.4 --- MaxPriceIndicatorTest.java 17 May 2007 23:04:58 -0000 1.5 *************** *** 12,42 **** public class MaxPriceIndicatorTest { private MaxPriceIndicator maxPriceIndicator; ! TimeSeries timeSeries; ! @Before ! public void setUp(){ timeSeries = new SampleTimeSeries(); maxPriceIndicator = new MaxPriceIndicator(timeSeries); ! } ! @Test ! public void testIndicatorShouldRetrieveTickMaxPrice() ! { for (int i = 0; i < 10; i++) { assertEquals(maxPriceIndicator.getValue(i), timeSeries.getTick(i).getMaxPrice()); ! } } @Test(expected = IndexOutOfBoundsException.class) ! public void testWrongIndex() ! { maxPriceIndicator.getValue(10); } ! ! // Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede Linux) ! //e o JUnit4 public static junit.framework.Test suite() { ! return new JUnit4TestAdapter(MaxPriceIndicatorTest.class); } } --- 12,42 ---- public class MaxPriceIndicatorTest { private MaxPriceIndicator maxPriceIndicator; ! TimeSeries timeSeries; ! @Before ! public void setUp() { timeSeries = new SampleTimeSeries(); maxPriceIndicator = new MaxPriceIndicator(timeSeries); ! } ! @Test ! public void testIndicatorShouldRetrieveTickMaxPrice() { for (int i = 0; i < 10; i++) { assertEquals(maxPriceIndicator.getValue(i), timeSeries.getTick(i).getMaxPrice()); ! } } + @Test(expected = IndexOutOfBoundsException.class) ! public void testWrongIndex() { maxPriceIndicator.getValue(10); } ! ! // Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede ! // Linux) ! // e o JUnit4 public static junit.framework.Test suite() { ! return new JUnit4TestAdapter(MaxPriceIndicatorTest.class); } } Index: TradeIndicatorTest.java =================================================================== RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/simple/TradeIndicatorTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TradeIndicatorTest.java 17 May 2007 20:16:11 -0000 1.4 --- TradeIndicatorTest.java 17 May 2007 23:04:58 -0000 1.5 *************** *** 12,41 **** public class TradeIndicatorTest { private TradeIndicator tradeIndicator; ! TimeSeries timeSeries; ! @Before ! public void setUp(){ timeSeries = new SampleTimeSeries(); tradeIndicator = new TradeIndicator(timeSeries); ! } ! @Test ! public void testIndicatorShouldRetrieveTickTrade() ! { for (int i = 0; i < 10; i++) { ! assertEquals(tradeIndicator.getValue(i),timeSeries.getTick(i).getTrades()); ! } } @Test(expected = IndexOutOfBoundsException.class) ! public void testWrongIndex() ! { tradeIndicator.getValue(10); } ! // Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede Linux) ! //e o JUnit4 public static junit.framework.Test suite() { ! return new JUnit4TestAdapter(TradeIndicatorTest.class); } } --- 12,42 ---- public class TradeIndicatorTest { private TradeIndicator tradeIndicator; ! TimeSeries timeSeries; ! @Before ! public void setUp() { timeSeries = new SampleTimeSeries(); tradeIndicator = new TradeIndicator(timeSeries); ! } ! @Test ! public void testIndicatorShouldRetrieveTickTrade() { for (int i = 0; i < 10; i++) { ! assertEquals(tradeIndicator.getValue(i), timeSeries.getTick(i).getTrades()); ! } } + @Test(expected = IndexOutOfBoundsException.class) ! public void testWrongIndex() { tradeIndicator.getValue(10); } ! ! // Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede ! // Linux) ! // e o JUnit4 public static junit.framework.Test suite() { ! return new JUnit4TestAdapter(TradeIndicatorTest.class); } } Index: ConstantIndicatorTest.java =================================================================== RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/simple/ConstantIndicatorTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ConstantIndicatorTest.java 12 May 2007 19:22:27 -0000 1.1 --- ConstantIndicatorTest.java 17 May 2007 23:04:58 -0000 1.2 *************** *** 6,23 **** import org.junit.Test; - public class ConstantIndicatorTest { private ConstantIndicator<Double> constantIndicator; ! @Before ! public void setUp() ! { ! constantIndicator = new ConstantIndicator<Double>(30.33); } ! @Test ! public void TestConstant() ! { assertEquals(30.33, constantIndicator.getValue(10)); assertEquals(30.33, constantIndicator.getValue(1)); --- 6,20 ---- import org.junit.Test; public class ConstantIndicatorTest { private ConstantIndicator<Double> constantIndicator; ! @Before ! public void setUp() { ! constantIndicator = new ConstantIndicator<Double>(30.33); } ! @Test ! public void TestConstant() { assertEquals(30.33, constantIndicator.getValue(10)); assertEquals(30.33, constantIndicator.getValue(1)); *************** *** 25,33 **** assertEquals(30.33, constantIndicator.getValue(30)); } ! ! //Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede Linux) ! //e o JUnit4 public static junit.framework.Test suite() { ! return new JUnit4TestAdapter(ConstantIndicatorTest.class); } } --- 22,31 ---- assertEquals(30.33, constantIndicator.getValue(30)); } ! ! // Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede ! // Linux) ! // e o JUnit4 public static junit.framework.Test suite() { ! return new JUnit4TestAdapter(ConstantIndicatorTest.class); } } Index: OpenPriceIndicatorTest.java =================================================================== RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/simple/OpenPriceIndicatorTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** OpenPriceIndicatorTest.java 17 May 2007 20:16:11 -0000 1.4 --- OpenPriceIndicatorTest.java 17 May 2007 23:04:58 -0000 1.5 *************** *** 12,40 **** public class OpenPriceIndicatorTest { private OpenPriceIndicator openPriceIndicator; ! TimeSeries timeSeries; ! @Before ! public void setUp(){ timeSeries = new SampleTimeSeries(); ! openPriceIndicator = new OpenPriceIndicator(timeSeries); } ! @Test ! public void testIndicatorShouldRetrieveTickOpenPrice() ! { for (int i = 0; i < 10; i++) { assertEquals(openPriceIndicator.getValue(i), timeSeries.getTick(i).getOpenPrice()); ! } } @Test(expected = IndexOutOfBoundsException.class) ! public void testWrongIndex() ! { openPriceIndicator.getValue(10); } ! // Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede Linux) ! //e o JUnit4 public static junit.framework.Test suite() { ! return new JUnit4TestAdapter(OpenPriceIndicatorTest.class); } } --- 12,41 ---- public class OpenPriceIndicatorTest { private OpenPriceIndicator openPriceIndicator; ! TimeSeries timeSeries; ! @Before ! public void setUp() { timeSeries = new SampleTimeSeries(); ! openPriceIndicator = new OpenPriceIndicator(timeSeries); } ! @Test ! public void testIndicatorShouldRetrieveTickOpenPrice() { for (int i = 0; i < 10; i++) { assertEquals(openPriceIndicator.getValue(i), timeSeries.getTick(i).getOpenPrice()); ! } } + @Test(expected = IndexOutOfBoundsException.class) ! public void testWrongIndex() { openPriceIndicator.getValue(10); } ! ! // Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede ! // Linux) ! // e o JUnit4 public static junit.framework.Test suite() { ! return new JUnit4TestAdapter(OpenPriceIndicatorTest.class); } } Index: VariationPriceIndicatorTest.java =================================================================== RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/simple/VariationPriceIndicatorTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** VariationPriceIndicatorTest.java 17 May 2007 20:16:11 -0000 1.2 --- VariationPriceIndicatorTest.java 17 May 2007 23:04:58 -0000 1.3 *************** *** 11,42 **** public class VariationPriceIndicatorTest { ! private VariationIndicator variationIndicator; private TimeSeries timeSeries; ! @Before ! public void setUp(){ timeSeries = new SampleTimeSeries(); variationIndicator = new VariationIndicator(timeSeries); ! } ! @Test ! ! public void testIndicatorShouldRetrieveTickVariation() ! { for (int i = 0; i < 10; i++) { assertEquals(variationIndicator.getValue(i), timeSeries.getTick(i).getVariation()); ! } } @Test(expected = IndexOutOfBoundsException.class) ! public void testWrongIndex() ! { variationIndicator.getValue(10); } ! // Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede Linux) ! //e o JUnit4 public static junit.framework.Test suite() { ! return new JUnit4TestAdapter(VariationPriceIndicatorTest.class); } } --- 11,43 ---- public class VariationPriceIndicatorTest { ! private VariationIndicator variationIndicator; + private TimeSeries timeSeries; ! @Before ! public void setUp() { timeSeries = new SampleTimeSeries(); variationIndicator = new VariationIndicator(timeSeries); ! } ! @Test ! public void testIndicatorShouldRetrieveTickVariation() { for (int i = 0; i < 10; i++) { assertEquals(variationIndicator.getValue(i), timeSeries.getTick(i).getVariation()); ! } } + @Test(expected = IndexOutOfBoundsException.class) ! public void testWrongIndex() { variationIndicator.getValue(10); } ! ! // Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede ! // Linux) ! // e o JUnit4 public static junit.framework.Test suite() { ! return new JUnit4TestAdapter(VariationPriceIndicatorTest.class); } } Index: MinPriceIndicatorTest.java =================================================================== RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/simple/MinPriceIndicatorTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** MinPriceIndicatorTest.java 17 May 2007 20:16:11 -0000 1.4 --- MinPriceIndicatorTest.java 17 May 2007 23:04:58 -0000 1.5 *************** *** 12,40 **** public class MinPriceIndicatorTest { private MinPriceIndicator minPriceIndicator; ! TimeSeries timeSeries; ! @Before ! public void setUp(){ timeSeries = new SampleTimeSeries(); minPriceIndicator = new MinPriceIndicator(timeSeries); } ! @Test ! public void testIndicatorShouldRetrieveTickMinPrice() ! { for (int i = 0; i < 10; i++) { assertEquals(minPriceIndicator.getValue(i), timeSeries.getTick(i).getMinPrice()); ! } } @Test(expected = IndexOutOfBoundsException.class) ! public void testWrongIndex() ! { minPriceIndicator.getValue(10); } ! // Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede Linux) ! //e o JUnit4 public static junit.framework.Test suite() { ! return new JUnit4TestAdapter(MinPriceIndicatorTest.class); } } --- 12,41 ---- public class MinPriceIndicatorTest { private MinPriceIndicator minPriceIndicator; ! TimeSeries timeSeries; ! @Before ! public void setUp() { timeSeries = new SampleTimeSeries(); minPriceIndicator = new MinPriceIndicator(timeSeries); } ! @Test ! public void testIndicatorShouldRetrieveTickMinPrice() { for (int i = 0; i < 10; i++) { assertEquals(minPriceIndicator.getValue(i), timeSeries.getTick(i).getMinPrice()); ! } } + @Test(expected = IndexOutOfBoundsException.class) ! public void testWrongIndex() { minPriceIndicator.getValue(10); } ! ! // Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede ! // Linux) ! // e o JUnit4 public static junit.framework.Test suite() { ! return new JUnit4TestAdapter(MinPriceIndicatorTest.class); } } Index: ClosePriceIndicatorTest.java =================================================================== RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/simple/ClosePriceIndicatorTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ClosePriceIndicatorTest.java 17 May 2007 20:16:11 -0000 1.4 --- ClosePriceIndicatorTest.java 17 May 2007 23:04:58 -0000 1.5 *************** *** 4,8 **** import junit.framework.JUnit4TestAdapter; - import net.sf.tail.SampleTimeSeries; import net.sf.tail.TimeSeries; --- 4,7 ---- *************** *** 13,43 **** public class ClosePriceIndicatorTest { private ClosePriceIndicator closePrice; ! TimeSeries timeSeries; ! @Before ! public void setUp(){ timeSeries = new SampleTimeSeries(); closePrice = new ClosePriceIndicator(timeSeries); } ! @Test ! public void testIndicatorShouldRetrieveTickClosePrice() ! { ! for (int i = 0; i < 10; i++) { ! assertEquals(closePrice.getValue(i), timeSeries.getTick(i).getClosePrice()); ! } } @Test(expected = IndexOutOfBoundsException.class) ! public void testWrongIndex() ! { closePrice.getValue(10); } ! // Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede Linux) ! //e o JUnit4 public static junit.framework.Test suite() { ! return new JUnit4TestAdapter(ClosePriceIndicatorTest.class); } } --- 12,43 ---- public class ClosePriceIndicatorTest { private ClosePriceIndicator closePrice; ! TimeSeries timeSeries; ! @Before ! public void setUp() { timeSeries = new SampleTimeSeries(); closePrice = new ClosePriceIndicator(timeSeries); } ! @Test ! public void testIndicatorShouldRetrieveTickClosePrice() { ! for (int i = 0; i < 10; i++) { ! assertEquals(closePrice.getValue(i), timeSeries.getTick(i).getClosePrice()); ! } } + @Test(expected = IndexOutOfBoundsException.class) ! public void testWrongIndex() { closePrice.getValue(10); } ! ! // Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede ! // Linux) ! // e o JUnit4 public static junit.framework.Test suite() { ! return new JUnit4TestAdapter(ClosePriceIndicatorTest.class); } } Index: PreviousPriceIndicatorTest.java =================================================================== RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/simple/PreviousPriceIndicatorTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PreviousPriceIndicatorTest.java 17 May 2007 20:16:11 -0000 1.4 --- PreviousPriceIndicatorTest.java 17 May 2007 23:04:58 -0000 1.5 *************** *** 12,42 **** public class PreviousPriceIndicatorTest { private PreviousPriceIndicator previousPriceIndicator; ! TimeSeries timeSeries; ! @Before ! public void setUp(){ timeSeries = new SampleTimeSeries(); previousPriceIndicator = new PreviousPriceIndicator(timeSeries); ! } ! @Test ! public void testIndicatorShouldRetrieveTickPreviousPrice() ! { for (int i = 0; i < 10; i++) { ! assertEquals(previousPriceIndicator.getValue(i),timeSeries.getTick(i).getPreviousPrice()); ! } } @Test(expected = IndexOutOfBoundsException.class) ! public void testWrongIndex() ! { previousPriceIndicator.getValue(10); } ! ! // Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede Linux) ! //e o JUnit4 public static junit.framework.Test suite() { ! return new JUnit4TestAdapter(PreviousPriceIndicatorTest.class); } } --- 12,42 ---- public class PreviousPriceIndicatorTest { private PreviousPriceIndicator previousPriceIndicator; ! TimeSeries timeSeries; ! @Before ! public void setUp() { timeSeries = new SampleTimeSeries(); previousPriceIndicator = new PreviousPriceIndicator(timeSeries); ! } ! @Test ! public void testIndicatorShouldRetrieveTickPreviousPrice() { for (int i = 0; i < 10; i++) { ! assertEquals(previousPriceIndicator.getValue(i), timeSeries.getTick(i).getPreviousPrice()); ! } } + @Test(expected = IndexOutOfBoundsException.class) ! public void testWrongIndex() { previousPriceIndicator.getValue(10); } ! ! // Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede ! // Linux) ! // e o JUnit4 public static junit.framework.Test suite() { ! return new JUnit4TestAdapter(PreviousPriceIndicatorTest.class); } } |
|
From: Márcio V. d. S. <mv...@us...> - 2007-05-17 23:05:04
|
Update of /cvsroot/tail/Tail/src/test/net/sf/tail/indicator In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv2571/src/test/net/sf/tail/indicator Modified Files: RSIIndicatorTest.java SMAIndicatorTest.java HighestValueIndicatorTest.java WilliamsRIndicatorTest.java AverageGainIndicatorTest.java AverageLossIndicatorTest.java EMAIndicatorTest.java CachedIndicatorTest.java LowestValueIndicatorTest.java Log Message: extraindo novos Indicadores Index: AverageLossIndicatorTest.java =================================================================== RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/AverageLossIndicatorTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** AverageLossIndicatorTest.java 17 May 2007 20:16:12 -0000 1.3 --- AverageLossIndicatorTest.java 17 May 2007 23:04:57 -0000 1.4 *************** *** 14,43 **** public class AverageLossIndicatorTest { ! private TimeSeries data; ! @Before ! public void prepare() throws Exception { ! data = new SampleTimeSeries(new double[] { 1, 2, 3, 4, 3, 4, 5, 4, 3, 3, 4, 3, 2 }); ! } ! @Test ! public void testAverageGain5() throws Exception { ! AverageLossIndicator averageLoss = new AverageLossIndicator(new ClosePriceIndicator(data), 5); ! assertEquals(1d/5d, averageLoss.getValue(5), 0.01); ! assertEquals(1d/5d, averageLoss.getValue(6), 0.01); ! assertEquals(2d/5d, averageLoss.getValue(7), 0.01); ! assertEquals(3d/5d, averageLoss.getValue(8), 0.01); ! assertEquals(2d/5d, averageLoss.getValue(9), 0.01); ! assertEquals(2d/5d, averageLoss.getValue(10), 0.01); ! assertEquals(3d/5d, averageLoss.getValue(11), 0.01); ! assertEquals(3d/5d, averageLoss.getValue(12), 0.01); - } - @Test public void test10daysJumping() { AverageLossIndicator averageLoss = new AverageLossIndicator(new ClosePriceIndicator(data), 5); ! assertEquals(2d/5d, averageLoss.getValue(10), 0.01); } --- 14,43 ---- public class AverageLossIndicatorTest { ! private TimeSeries data; ! @Before ! public void prepare() throws Exception { ! data = new SampleTimeSeries(new double[] { 1, 2, 3, 4, 3, 4, 5, 4, 3, 3, 4, 3, 2 }); ! } ! @Test ! public void testAverageGain5() throws Exception { ! AverageLossIndicator averageLoss = new AverageLossIndicator(new ClosePriceIndicator(data), 5); ! assertEquals(1d / 5d, averageLoss.getValue(5), 0.01); ! assertEquals(1d / 5d, averageLoss.getValue(6), 0.01); ! assertEquals(2d / 5d, averageLoss.getValue(7), 0.01); ! assertEquals(3d / 5d, averageLoss.getValue(8), 0.01); ! assertEquals(2d / 5d, averageLoss.getValue(9), 0.01); ! assertEquals(2d / 5d, averageLoss.getValue(10), 0.01); ! assertEquals(3d / 5d, averageLoss.getValue(11), 0.01); ! assertEquals(3d / 5d, averageLoss.getValue(12), 0.01); ! ! } @Test public void test10daysJumping() { AverageLossIndicator averageLoss = new AverageLossIndicator(new ClosePriceIndicator(data), 5); ! assertEquals(2d / 5d, averageLoss.getValue(10), 0.01); } *************** *** 48,53 **** } ! // Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede Linux) ! //e o JUnit4 public static junit.framework.Test suite() { return new JUnit4TestAdapter(RSIIndicatorTest.class); --- 48,54 ---- } ! // Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede ! // Linux) ! // e o JUnit4 public static junit.framework.Test suite() { return new JUnit4TestAdapter(RSIIndicatorTest.class); Index: AverageGainIndicatorTest.java =================================================================== RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/AverageGainIndicatorTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** AverageGainIndicatorTest.java 17 May 2007 20:16:12 -0000 1.4 --- AverageGainIndicatorTest.java 17 May 2007 23:04:57 -0000 1.5 *************** *** 14,43 **** public class AverageGainIndicatorTest { ! private TimeSeries data; ! @Before ! public void prepare() throws Exception { ! data = new SampleTimeSeries(new double[] { 1, 2, 3, 4, 3, 4, 5, 4, 3, 3, 4, 3, 2 }); ! } ! @Test ! public void testAverageGain5() throws Exception { AverageGainIndicator averageGain = new AverageGainIndicator(new ClosePriceIndicator(data), 5); ! assertEquals(4d/5d, averageGain.getValue(5), 0.01); ! assertEquals(4d/5d, averageGain.getValue(6), 0.01); ! assertEquals(3d/5d, averageGain.getValue(7), 0.01); ! assertEquals(2d/5d, averageGain.getValue(8), 0.01); ! assertEquals(2d/5d, averageGain.getValue(9), 0.01); ! assertEquals(2d/5d, averageGain.getValue(10), 0.01); ! assertEquals(1d/5d, averageGain.getValue(11), 0.01); ! assertEquals(1d/5d, averageGain.getValue(12), 0.01); - } - @Test public void test10daysJumping() { AverageGainIndicator averageGain = new AverageGainIndicator(new ClosePriceIndicator(data), 5); ! assertEquals(2d/5d, averageGain.getValue(10), 0.01); } --- 14,43 ---- public class AverageGainIndicatorTest { ! private TimeSeries data; ! @Before ! public void prepare() throws Exception { ! data = new SampleTimeSeries(new double[] { 1, 2, 3, 4, 3, 4, 5, 4, 3, 3, 4, 3, 2 }); ! } ! @Test ! public void testAverageGain5() throws Exception { AverageGainIndicator averageGain = new AverageGainIndicator(new ClosePriceIndicator(data), 5); ! assertEquals(4d / 5d, averageGain.getValue(5), 0.01); ! assertEquals(4d / 5d, averageGain.getValue(6), 0.01); ! assertEquals(3d / 5d, averageGain.getValue(7), 0.01); ! assertEquals(2d / 5d, averageGain.getValue(8), 0.01); ! assertEquals(2d / 5d, averageGain.getValue(9), 0.01); ! assertEquals(2d / 5d, averageGain.getValue(10), 0.01); ! assertEquals(1d / 5d, averageGain.getValue(11), 0.01); ! assertEquals(1d / 5d, averageGain.getValue(12), 0.01); ! ! } @Test public void test10daysJumping() { AverageGainIndicator averageGain = new AverageGainIndicator(new ClosePriceIndicator(data), 5); ! assertEquals(2d / 5d, averageGain.getValue(10), 0.01); } *************** *** 48,53 **** } ! // Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede Linux) ! //e o JUnit4 public static junit.framework.Test suite() { return new JUnit4TestAdapter(RSIIndicatorTest.class); --- 48,54 ---- } ! // Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede ! // Linux) ! // e o JUnit4 public static junit.framework.Test suite() { return new JUnit4TestAdapter(RSIIndicatorTest.class); Index: WilliamsRIndicatorTest.java =================================================================== RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/WilliamsRIndicatorTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** WilliamsRIndicatorTest.java 17 May 2007 20:16:12 -0000 1.2 --- WilliamsRIndicatorTest.java 17 May 2007 23:04:57 -0000 1.3 *************** *** 18,96 **** public class WilliamsRIndicatorTest { private TimeSeries data; - - @Before - public void prepare() throws Exception { - - List<Tick> ticks = new ArrayList<Tick>(); - ticks.add(new Tick(44.98,45.05, 45.17,44.96)); - ticks.add(new Tick(45.05,45.10,45.15,44.99)); - ticks.add(new Tick(45.11,45.19,45.32,45.11)); - ticks.add(new Tick(45.19,45.14,45.25,45.04)); - ticks.add(new Tick(45.12,45.15, 45.20,45.10)); - ticks.add(new Tick(45.15,45.14, 45.20,45.10)); - ticks.add(new Tick(45.13,45.10,45.16,45.07)); - ticks.add(new Tick(45.12,45.15,45.22,45.10)); - ticks.add(new Tick(45.15,45.22,45.27,45.14)); - ticks.add(new Tick(45.24,45.43,45.45,45.20)); - ticks.add(new Tick(45.43,45.44,45.50,45.39)); - ticks.add(new Tick(45.43,45.55,45.60,45.35)); - ticks.add(new Tick(45.58,45.55,45.61,45.39)); - - data = new DefaultTimeSeries(ticks); - - } ! @Test ! public void testWR5() throws Exception { ! WilliamsRIndicator wr = new WilliamsRIndicator(new ClosePriceIndicator(data), 5, new MaxPriceIndicator(data), new MinPriceIndicator(data)); ! ! assertEquals(-47.22, wr.getValue(4), 0.01); ! assertEquals(-54.55, wr.getValue(5), 0.01); ! assertEquals(-78.57, wr.getValue(6), 0.01); ! assertEquals(-47.62, wr.getValue(7), 0.01); ! assertEquals(-25.00, wr.getValue(8), 0.01); ! assertEquals(-5.26, wr.getValue(9), 0.01); ! assertEquals(-13.95, wr.getValue(10), 0.01); ! ! ! } ! ! @Test ! public void testWR10() { ! WilliamsRIndicator wr = new WilliamsRIndicator(new ClosePriceIndicator(data), 10, new MaxPriceIndicator(data), new MinPriceIndicator(data)); ! ! assertEquals(-4.08, wr.getValue(9), 0.01); ! assertEquals(-11.77, wr.getValue(10), 0.01); ! assertEquals(-8.93, wr.getValue(11), 0.01); ! assertEquals(-10.53, wr.getValue(12), 0.01); ! ! } ! ! @Test ! public void testValueLessThenTimeFrame() ! { ! WilliamsRIndicator wr = new WilliamsRIndicator(new ClosePriceIndicator(data), 100, new MaxPriceIndicator(data), new MinPriceIndicator(data)); ! ! assertEquals(-100d * (0.12 / 0.21), wr.getValue(0), 0.01); ! assertEquals(-100d * (0.07 / 0.21), wr.getValue(1), 0.01); ! assertEquals(-100d * (0.13 / 0.36), wr.getValue(2), 0.01); ! assertEquals(-100d * (0.18 / 0.36), wr.getValue(3), 0.01); ! } ! ! @Test(expected = IndexOutOfBoundsException.class) ! public void testWrongIndex() { ! WilliamsRIndicator wr = new WilliamsRIndicator(new ClosePriceIndicator(data), 100, new MaxPriceIndicator(data), new MinPriceIndicator(data)); ! wr.getValue(13); ! } ! ! //Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede Linux) ! //e o JUnit4 ! public static junit.framework.Test suite() { ! return new JUnit4TestAdapter(WilliamsRIndicatorTest.class); ! } } --- 18,94 ---- public class WilliamsRIndicatorTest { private TimeSeries data; + @Before + public void prepare() throws Exception { ! List<Tick> ticks = new ArrayList<Tick>(); ! ticks.add(new Tick(44.98, 45.05, 45.17, 44.96)); ! ticks.add(new Tick(45.05, 45.10, 45.15, 44.99)); ! ticks.add(new Tick(45.11, 45.19, 45.32, 45.11)); ! ticks.add(new Tick(45.19, 45.14, 45.25, 45.04)); ! ticks.add(new Tick(45.12, 45.15, 45.20, 45.10)); ! ticks.add(new Tick(45.15, 45.14, 45.20, 45.10)); ! ticks.add(new Tick(45.13, 45.10, 45.16, 45.07)); ! ticks.add(new Tick(45.12, 45.15, 45.22, 45.10)); ! ticks.add(new Tick(45.15, 45.22, 45.27, 45.14)); ! ticks.add(new Tick(45.24, 45.43, 45.45, 45.20)); ! ticks.add(new Tick(45.43, 45.44, 45.50, 45.39)); ! ticks.add(new Tick(45.43, 45.55, 45.60, 45.35)); ! ticks.add(new Tick(45.58, 45.55, 45.61, 45.39)); ! data = new DefaultTimeSeries(ticks); ! } ! @Test ! public void testWR5() throws Exception { ! WilliamsRIndicator wr = new WilliamsRIndicator(new ClosePriceIndicator(data), 5, new MaxPriceIndicator(data), ! new MinPriceIndicator(data)); ! assertEquals(-47.22, wr.getValue(4), 0.01); ! assertEquals(-54.55, wr.getValue(5), 0.01); ! assertEquals(-78.57, wr.getValue(6), 0.01); ! assertEquals(-47.62, wr.getValue(7), 0.01); ! assertEquals(-25.00, wr.getValue(8), 0.01); ! assertEquals(-5.26, wr.getValue(9), 0.01); ! assertEquals(-13.95, wr.getValue(10), 0.01); ! ! } ! ! @Test ! public void testWR10() { ! WilliamsRIndicator wr = new WilliamsRIndicator(new ClosePriceIndicator(data), 10, new MaxPriceIndicator(data), ! new MinPriceIndicator(data)); ! ! assertEquals(-4.08, wr.getValue(9), 0.01); ! assertEquals(-11.77, wr.getValue(10), 0.01); ! assertEquals(-8.93, wr.getValue(11), 0.01); ! assertEquals(-10.53, wr.getValue(12), 0.01); ! ! } ! ! @Test ! public void testValueLessThenTimeFrame() { ! WilliamsRIndicator wr = new WilliamsRIndicator(new ClosePriceIndicator(data), 100, new MaxPriceIndicator(data), ! new MinPriceIndicator(data)); ! ! assertEquals(-100d * (0.12 / 0.21), wr.getValue(0), 0.01); ! assertEquals(-100d * (0.07 / 0.21), wr.getValue(1), 0.01); ! assertEquals(-100d * (0.13 / 0.36), wr.getValue(2), 0.01); ! assertEquals(-100d * (0.18 / 0.36), wr.getValue(3), 0.01); ! } ! ! @Test(expected = IndexOutOfBoundsException.class) ! public void testWrongIndex() { ! WilliamsRIndicator wr = new WilliamsRIndicator(new ClosePriceIndicator(data), 100, new MaxPriceIndicator(data), ! new MinPriceIndicator(data)); ! wr.getValue(13); ! } ! ! // Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede ! // Linux) ! // e o JUnit4 ! public static junit.framework.Test suite() { ! return new JUnit4TestAdapter(WilliamsRIndicatorTest.class); ! } } Index: CachedIndicatorTest.java =================================================================== RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/CachedIndicatorTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CachedIndicatorTest.java 17 May 2007 21:30:55 -0000 1.1 --- CachedIndicatorTest.java 17 May 2007 23:04:57 -0000 1.2 *************** *** 1,5 **** package net.sf.tail.indicator; - import java.util.Arrays; --- 1,4 ---- *************** *** 18,56 **** public class CachedIndicatorTest { ! private TimeSeries data; ! @Before ! public void prepare() throws Exception { ! data = new SampleTimeSeries(new double[] { 1, 2, 3, 4, 3, 4, 5, 4, 3, 3, 4, 3, 2 }); ! } ! @Test ! public void testCachedIndicatorShouldBeEqualsSMAIndicator() throws Exception { ! SMAIndicator sma = new SMAIndicator(new ClosePriceIndicator(data), 3); ! CachedIndicator cache = new CachedIndicator(sma); ! ! for (int i = 0; i < 10; i++) { ! assertEquals(sma.getValue(i) , cache.getValue(i)); } ! } ! ! @Test public void testIfCacheWorks() { ! SMAIndicator sma = new SMAIndicator(new ClosePriceIndicator(data), 3); ! CachedIndicator cache = new CachedIndicator(sma); ! cache.getValue(4); ! assertEquals(sma.getValue(4) , cache.getValue(4)); } ! @Test public void testIncreaseArrayMethod() { ! double[] d = new double[200]; ! Arrays.fill(d, 10); ! TimeSeries dataMax = new SampleTimeSeries(d ); SMAIndicator quoteSMA = new SMAIndicator(new ClosePriceIndicator(dataMax), 100); CachedIndicator cache = new CachedIndicator(quoteSMA); assertEquals(10d, cache.getValue(105)); } ! @Test(expected = IndexOutOfBoundsException.class) public void testWrongIndex() { --- 17,55 ---- public class CachedIndicatorTest { ! private TimeSeries data; ! @Before ! public void prepare() throws Exception { ! data = new SampleTimeSeries(new double[] { 1, 2, 3, 4, 3, 4, 5, 4, 3, 3, 4, 3, 2 }); ! } ! @Test ! public void testCachedIndicatorShouldBeEqualsSMAIndicator() throws Exception { ! SMAIndicator sma = new SMAIndicator(new ClosePriceIndicator(data), 3); ! CachedIndicator cache = new CachedIndicator(sma); ! ! for (int i = 0; i < 10; i++) { ! assertEquals(sma.getValue(i), cache.getValue(i)); } ! } ! ! @Test public void testIfCacheWorks() { ! SMAIndicator sma = new SMAIndicator(new ClosePriceIndicator(data), 3); ! CachedIndicator cache = new CachedIndicator(sma); ! cache.getValue(4); ! assertEquals(sma.getValue(4), cache.getValue(4)); } ! @Test public void testIncreaseArrayMethod() { ! double[] d = new double[200]; ! Arrays.fill(d, 10); ! TimeSeries dataMax = new SampleTimeSeries(d); SMAIndicator quoteSMA = new SMAIndicator(new ClosePriceIndicator(dataMax), 100); CachedIndicator cache = new CachedIndicator(quoteSMA); assertEquals(10d, cache.getValue(105)); } ! @Test(expected = IndexOutOfBoundsException.class) public void testWrongIndex() { *************** *** 59,67 **** cache.getValue(13); } ! ! //Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede Linux) ! //e o JUnit4 public static junit.framework.Test suite() { ! return new JUnit4TestAdapter(CachedIndicatorTest.class); } } --- 58,67 ---- cache.getValue(13); } ! ! // Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede ! // Linux) ! // e o JUnit4 public static junit.framework.Test suite() { ! return new JUnit4TestAdapter(CachedIndicatorTest.class); } } Index: LowestValueIndicatorTest.java =================================================================== RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/LowestValueIndicatorTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** LowestValueIndicatorTest.java 17 May 2007 22:46:00 -0000 1.1 --- LowestValueIndicatorTest.java 17 May 2007 23:04:57 -0000 1.2 *************** *** 24,29 **** LowestValueIndicator lowestValue = new LowestValueIndicator(new ClosePriceIndicator(data), 5); ! assertEquals(1d, lowestValue.getValue(5), 0.01); ! assertEquals(2d, lowestValue.getValue(6), 0.01); assertEquals(3d, lowestValue.getValue(7), 0.01); assertEquals(3d, lowestValue.getValue(8), 0.01); --- 24,30 ---- LowestValueIndicator lowestValue = new LowestValueIndicator(new ClosePriceIndicator(data), 5); ! assertEquals(1d, lowestValue.getValue(4), 0.01); ! assertEquals(2d, lowestValue.getValue(5), 0.01); ! assertEquals(3d, lowestValue.getValue(6), 0.01); assertEquals(3d, lowestValue.getValue(7), 0.01); assertEquals(3d, lowestValue.getValue(8), 0.01); *************** *** 32,36 **** assertEquals(2d, lowestValue.getValue(11), 0.01); assertEquals(2d, lowestValue.getValue(12), 0.01); - assertEquals(1d, lowestValue.getValue(13), 0.01); } --- 33,36 ---- Index: RSIIndicatorTest.java =================================================================== RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/RSIIndicatorTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** RSIIndicatorTest.java 13 May 2007 01:00:06 -0000 1.4 --- RSIIndicatorTest.java 17 May 2007 23:04:57 -0000 1.5 *************** *** 17,21 **** @Before public void setUp() { ! data = new SampleTimeSeries(new double[] {50.45, 50.30, 50.20, 50.15, 50.05, 50.06, 50.10, 50.08 , 50.03 , 50.07 , 50.01 , 50.14 , 50.22, 50.43, 50.50, 50.56, 50.52, 50.70, 50.55, 50.62, 50.90, 50.82, 50.86, 51.20, 51.30, 51.10}); } --- 17,23 ---- @Before public void setUp() { ! data = new SampleTimeSeries(new double[] { 50.45, 50.30, 50.20, 50.15, 50.05, 50.06, 50.10, 50.08, 50.03, ! 50.07, 50.01, 50.14, 50.22, 50.43, 50.50, 50.56, 50.52, 50.70, 50.55, 50.62, 50.90, 50.82, 50.86, ! 51.20, 51.30, 51.10 }); } *************** *** 48,53 **** } ! // Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede Linux) ! //e o JUnit4 public static junit.framework.Test suite() { return new JUnit4TestAdapter(RSIIndicatorTest.class); --- 50,56 ---- } ! // Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede ! // Linux) ! // e o JUnit4 public static junit.framework.Test suite() { return new JUnit4TestAdapter(RSIIndicatorTest.class); Index: SMAIndicatorTest.java =================================================================== RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/SMAIndicatorTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SMAIndicatorTest.java 12 May 2007 17:34:01 -0000 1.4 --- SMAIndicatorTest.java 17 May 2007 23:04:57 -0000 1.5 *************** *** 1,5 **** package net.sf.tail.indicator; - import java.util.Arrays; --- 1,4 ---- *************** *** 17,48 **** public class SMAIndicatorTest { ! private TimeSeries data; ! @Before ! public void prepare() throws Exception { ! data = new SampleTimeSeries(new double[] { 1, 2, 3, 4, 3, 4, 5, 4, 3, 3, 4, 3, 2 }); ! } ! @Test ! public void testSMA3() throws Exception { ! SMAIndicator sma = new SMAIndicator(new ClosePriceIndicator(data), 3); ! assertEquals(1.0, sma.getValue(0)); ! assertEquals(1.5, sma.getValue(1)); ! assertEquals(2.0, sma.getValue(2)); ! assertEquals(3.0, sma.getValue(3)); ! assertEquals(10.0 / 3, sma.getValue(4)); ! assertEquals(11.0 / 3, sma.getValue(5)); ! assertEquals(4.0, sma.getValue(6)); ! assertEquals(13.0 / 3, sma.getValue(7)); ! assertEquals(4.0, sma.getValue(8)); ! assertEquals(10.0 / 3, sma.getValue(9)); ! assertEquals(10.0 / 3, sma.getValue(10)); ! assertEquals(10.0 / 3, sma.getValue(11)); ! assertEquals(3.0, sma.getValue(12)); ! } ! ! @Test public void test3daysJumping() { SMAIndicator quoteSMA = new SMAIndicator(new ClosePriceIndicator(data), 3); --- 16,47 ---- public class SMAIndicatorTest { ! private TimeSeries data; ! @Before ! public void prepare() throws Exception { ! data = new SampleTimeSeries(new double[] { 1, 2, 3, 4, 3, 4, 5, 4, 3, 3, 4, 3, 2 }); ! } ! @Test ! public void testSMA3() throws Exception { ! SMAIndicator sma = new SMAIndicator(new ClosePriceIndicator(data), 3); ! assertEquals(1.0, sma.getValue(0)); ! assertEquals(1.5, sma.getValue(1)); ! assertEquals(2.0, sma.getValue(2)); ! assertEquals(3.0, sma.getValue(3)); ! assertEquals(10.0 / 3, sma.getValue(4)); ! assertEquals(11.0 / 3, sma.getValue(5)); ! assertEquals(4.0, sma.getValue(6)); ! assertEquals(13.0 / 3, sma.getValue(7)); ! assertEquals(4.0, sma.getValue(8)); ! assertEquals(10.0 / 3, sma.getValue(9)); ! assertEquals(10.0 / 3, sma.getValue(10)); ! assertEquals(10.0 / 3, sma.getValue(11)); ! assertEquals(3.0, sma.getValue(12)); ! } ! ! @Test public void test3daysJumping() { SMAIndicator quoteSMA = new SMAIndicator(new ClosePriceIndicator(data), 3); *************** *** 50,62 **** } ! @Test public void testIncreaseArrayMethod() { ! double[] d = new double[200]; ! Arrays.fill(d, 10); ! TimeSeries dataMax = new SampleTimeSeries(d ); SMAIndicator quoteSMA = new SMAIndicator(new ClosePriceIndicator(dataMax), 100); assertEquals(10d, quoteSMA.getValue(105)); } ! @Test(expected = IndexOutOfBoundsException.class) public void testWrongIndex() { --- 49,61 ---- } ! @Test public void testIncreaseArrayMethod() { ! double[] d = new double[200]; ! Arrays.fill(d, 10); ! TimeSeries dataMax = new SampleTimeSeries(d); SMAIndicator quoteSMA = new SMAIndicator(new ClosePriceIndicator(dataMax), 100); assertEquals(10d, quoteSMA.getValue(105)); } ! @Test(expected = IndexOutOfBoundsException.class) public void testWrongIndex() { *************** *** 64,72 **** assertEquals(3d, quoteSMA.getValue(13)); } ! ! //Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede Linux) ! //e o JUnit4 public static junit.framework.Test suite() { ! return new JUnit4TestAdapter(SMAIndicatorTest.class); } } --- 63,72 ---- assertEquals(3d, quoteSMA.getValue(13)); } ! ! // Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede ! // Linux) ! // e o JUnit4 public static junit.framework.Test suite() { ! return new JUnit4TestAdapter(SMAIndicatorTest.class); } } Index: EMAIndicatorTest.java =================================================================== RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/EMAIndicatorTest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** EMAIndicatorTest.java 12 May 2007 19:39:09 -0000 1.5 --- EMAIndicatorTest.java 17 May 2007 23:04:57 -0000 1.6 *************** *** 12,16 **** import static org.junit.Assert.assertEquals; ! import junit.framework.JUnit4TestAdapter; public class EMAIndicatorTest { --- 12,16 ---- import static org.junit.Assert.assertEquals; ! import junit.framework.JUnit4TestAdapter; public class EMAIndicatorTest { *************** *** 21,26 **** public void setUp() { ! data = new SampleTimeSeries(new double[] { 64.75, 63.79, 63.73, 63.73, 63.55, 63.19, 63.91, 63.85, 62.95, 63.37, ! 61.33, 61.51 }); } --- 21,26 ---- public void setUp() { ! data = new SampleTimeSeries(new double[] { 64.75, 63.79, 63.73, 63.73, 63.55, 63.19, 63.91, 63.85, 62.95, ! 63.37, 61.33, 61.51 }); } *************** *** 53,58 **** } ! // Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede Linux) ! //e o JUnit4 public static junit.framework.Test suite() { return new JUnit4TestAdapter(EMAIndicatorTest.class); --- 53,59 ---- } ! // Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede ! // Linux) ! // e o JUnit4 public static junit.framework.Test suite() { return new JUnit4TestAdapter(EMAIndicatorTest.class); Index: HighestValueIndicatorTest.java =================================================================== RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/HighestValueIndicatorTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** HighestValueIndicatorTest.java 17 May 2007 22:46:00 -0000 1.1 --- HighestValueIndicatorTest.java 17 May 2007 23:04:57 -0000 1.2 *************** *** 24,27 **** --- 24,28 ---- HighestValueIndicator highestValue = new HighestValueIndicator(new ClosePriceIndicator(data), 5); + assertEquals(4d, highestValue.getValue(4), 0.01); assertEquals(4d, highestValue.getValue(5), 0.01); assertEquals(5d, highestValue.getValue(6), 0.01); *************** *** 31,36 **** assertEquals(6d, highestValue.getValue(10), 0.01); assertEquals(6d, highestValue.getValue(11), 0.01); ! assertEquals(6d, highestValue.getValue(12), 0.01); ! assertEquals(4d, highestValue.getValue(13), 0.01); } --- 32,36 ---- assertEquals(6d, highestValue.getValue(10), 0.01); assertEquals(6d, highestValue.getValue(11), 0.01); ! assertEquals(4d, highestValue.getValue(12), 0.01); } *************** *** 39,43 **** public void test10daysJumping() { HighestValueIndicator highestValue = new HighestValueIndicator(new ClosePriceIndicator(data), 5); ! assertEquals(6, highestValue.getValue(12), 0.01); } --- 39,43 ---- public void test10daysJumping() { HighestValueIndicator highestValue = new HighestValueIndicator(new ClosePriceIndicator(data), 5); ! assertEquals(4, highestValue.getValue(12), 0.01); } |