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-31 16:45:40
|
Update of /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/cache In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv2946/src/java/net/sf/tail/indicator/cache Modified Files: CachedIndicator.java Log Message: Refatoração de testes Index: CachedIndicator.java =================================================================== RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/cache/CachedIndicator.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CachedIndicator.java 18 May 2007 19:25:24 -0000 1.2 --- CachedIndicator.java 31 May 2007 16:45:40 -0000 1.3 *************** *** 7,10 **** --- 7,16 ---- import net.sf.tail.Indicator; + /** + * Cacheia o {@link Indicator} do construtor, impedindo que seja calculado duas vezes o mesmo Ãndice index do Indicator. + * + * @author Marcio + * + */ public class CachedIndicator implements Indicator { |
|
From: Márcio V. d. S. <mv...@us...> - 2007-05-31 16:45:40
|
Update of /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/tracker In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv2946/src/java/net/sf/tail/indicator/tracker Modified Files: WilliamsRIndicator.java RSIIndicator.java Removed Files: AverageLossIndicator.java HighestValueIndicator.java StandardDeviationIndicator.java LowestValueIndicator.java AverageGainIndicator.java Log Message: Refatoração de testes --- LowestValueIndicator.java DELETED --- --- AverageLossIndicator.java DELETED --- Index: RSIIndicator.java =================================================================== RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/tracker/RSIIndicator.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** RSIIndicator.java 17 May 2007 23:06:56 -0000 1.11 --- RSIIndicator.java 31 May 2007 16:45:39 -0000 1.12 *************** *** 2,5 **** --- 2,7 ---- import net.sf.tail.Indicator; + import net.sf.tail.indicator.helper.AverageGainIndicator; + import net.sf.tail.indicator.helper.AverageLossIndicator; public class RSIIndicator implements Indicator<Double> { *************** *** 15,22 **** public Double getValue(int index) { ! return 100d - 100d / (1 + rs(index)); } ! private Double rs(int index) { AverageGainIndicator averageGain = new AverageGainIndicator(indicator, timeFrame); AverageLossIndicator averageLoss = new AverageLossIndicator(indicator, timeFrame); --- 17,26 ---- public Double getValue(int index) { ! return 100d - 100d / (1 + relativeStrength(index)); } ! private Double relativeStrength(int index) { ! if(index == 0) ! return 0d; AverageGainIndicator averageGain = new AverageGainIndicator(indicator, timeFrame); AverageLossIndicator averageLoss = new AverageLossIndicator(indicator, timeFrame); --- HighestValueIndicator.java DELETED --- --- StandardDeviationIndicator.java DELETED --- --- AverageGainIndicator.java DELETED --- Index: WilliamsRIndicator.java =================================================================== RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/tracker/WilliamsRIndicator.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** WilliamsRIndicator.java 18 May 2007 19:25:24 -0000 1.8 --- WilliamsRIndicator.java 31 May 2007 16:45:39 -0000 1.9 *************** *** 3,6 **** --- 3,8 ---- import net.sf.tail.Indicator; import net.sf.tail.TimeSeries; + import net.sf.tail.indicator.helper.HighestValueIndicator; + import net.sf.tail.indicator.helper.LowestValueIndicator; import net.sf.tail.indicator.simple.ClosePriceIndicator; import net.sf.tail.indicator.simple.MaxPriceIndicator; *************** *** 17,23 **** private MinPriceIndicator minPriceIndicator; - - - // TODO - ver a complexidade dos construtores. public WilliamsRIndicator(TimeSeries timeSeries, int timeFrame) { this(new ClosePriceIndicator(timeSeries), timeFrame, new MaxPriceIndicator(timeSeries), new MinPriceIndicator( --- 19,22 ---- *************** *** 34,41 **** 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); --- 33,36 ---- |
|
From: Márcio V. d. S. <mv...@us...> - 2007-05-31 16:45:40
|
Update of /cvsroot/tail/Tail/lib In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv2946/lib Added Files: emma.jar Log Message: Refatoração de testes --- NEW FILE: emma.jar --- (This appears to be a binary file; contents omitted.) |
|
From: Márcio V. d. S. <mv...@us...> - 2007-05-31 16:45:40
|
Update of /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/oscilator In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv2946/src/test/net/sf/tail/indicator/oscilator Modified Files: StochasticOscilatorKTest.java StochasticOscilatorDTest.java Log Message: Refatoração de testes Index: StochasticOscilatorKTest.java =================================================================== RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/oscilator/StochasticOscilatorKTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** StochasticOscilatorKTest.java 19 May 2007 13:13:29 -0000 1.1 --- StochasticOscilatorKTest.java 31 May 2007 16:45:39 -0000 1.2 *************** *** 51,55 **** @Test ! public void test13daysJumping() { StochasticOscilatorK sof = new StochasticOscilatorK(data, 14); --- 51,55 ---- @Test ! public void testStochasticOscilatorKShouldWorkJumpingIndexes() { StochasticOscilatorK sof = new StochasticOscilatorK(data, 14); *************** *** 58,70 **** @Test(expected = IndexOutOfBoundsException.class) ! public void testWrongIndex() { StochasticOscilatorK sof = new StochasticOscilatorK(data, 14); sof.getValue(1300); } ! ! // 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(StochasticOscilatorKTest.class); --- 58,67 ---- @Test(expected = IndexOutOfBoundsException.class) ! public void testIndexGreatterThanTheIndicatorLenghtShouldThrowException() { StochasticOscilatorK sof = new StochasticOscilatorK(data, 14); sof.getValue(1300); } ! public static junit.framework.Test suite() { return new JUnit4TestAdapter(StochasticOscilatorKTest.class); Index: StochasticOscilatorDTest.java =================================================================== RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/oscilator/StochasticOscilatorDTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** StochasticOscilatorDTest.java 19 May 2007 13:13:29 -0000 1.1 --- StochasticOscilatorDTest.java 31 May 2007 16:45:40 -0000 1.2 *************** *** 67,71 **** @Test ! public void test13daysJumping() { StochasticOscilatorK sof = new StochasticOscilatorK(data, 14); --- 67,71 ---- @Test ! public void testStochasticOscilatorDShouldWorkJumpingIndexes() { StochasticOscilatorK sof = new StochasticOscilatorK(data, 14); *************** *** 77,81 **** @Test(expected = IndexOutOfBoundsException.class) ! public void testWrongIndex() { StochasticOscilatorK sof = new StochasticOscilatorK(data, 14); --- 77,81 ---- @Test(expected = IndexOutOfBoundsException.class) ! public void testIndexGreatterThanTheIndicatorLenghtShouldThrowException() { StochasticOscilatorK sof = new StochasticOscilatorK(data, 14); *************** *** 85,91 **** } - // 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(StochasticOscilatorDTest.class); --- 85,88 ---- |
|
From: Márcio V. d. S. <mv...@us...> - 2007-05-31 16:45:39
|
Update of /cvsroot/tail/Tail In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv2946 Modified Files: .classpath Log Message: Refatoração de testes Index: .classpath =================================================================== RCS file: /cvsroot/tail/Tail/.classpath,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** .classpath 14 May 2007 14:19:32 -0000 1.4 --- .classpath 31 May 2007 16:45:40 -0000 1.5 *************** *** 6,9 **** --- 6,10 ---- <classpathentry exported="true" kind="lib" path="lib/javacsv.jar"/> <classpathentry kind="lib" path="lib/junit-4.1.jar"/> + <classpathentry kind="lib" path="lib/emma.jar"/> <classpathentry kind="output" path="bin"/> </classpath> |
Update of /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/helper In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv2946/src/java/net/sf/tail/indicator/helper Added Files: AverageGainIndicator.java HighestValueIndicator.java StandardDeviationIndicator.java AverageLossIndicator.java CrossIndicator.java LowestValueIndicator.java Log Message: Refatoração de testes --- NEW FILE: LowestValueIndicator.java --- package net.sf.tail.indicator.helper; import net.sf.tail.Indicator; public class LowestValueIndicator implements Indicator<Double> { private final Indicator<? extends Number> indicator; private final int timeFrame; public LowestValueIndicator(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 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); } return lowest; } } --- NEW FILE: AverageLossIndicator.java --- package net.sf.tail.indicator.helper; import net.sf.tail.Indicator; public class AverageLossIndicator implements Indicator<Double> { private final Indicator<? extends Number> indicator; private final int timeFrame; public AverageLossIndicator(Indicator<? extends Number> indicator, int timeFrame) { this.indicator = indicator; this.timeFrame = timeFrame; } public Double getValue(int index) { double result = 0; for (int i = Math.max(1, index - timeFrame + 1); i <= index; i++) { if (indicator.getValue(i).doubleValue() < indicator.getValue(i - 1).doubleValue()) result += indicator.getValue(i - 1).doubleValue() - indicator.getValue(i).doubleValue(); } return result / Math.min(timeFrame, index + 1); } } --- NEW FILE: HighestValueIndicator.java --- package net.sf.tail.indicator.helper; import net.sf.tail.Indicator; public class HighestValueIndicator implements Indicator<Double> { 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); } return highest; } } --- NEW FILE: CrossIndicator.java --- package net.sf.tail.indicator.helper; import net.sf.tail.Indicator; public class CrossIndicator implements Indicator<Boolean> { private final Indicator<? extends Number> low; private final Indicator<? extends Number> up; public CrossIndicator(Indicator<? extends Number> up, Indicator<? extends Number> low) { this.up = up; this.low = low; } public Boolean getValue(int index) { if (index == 0 || up.getValue(index).doubleValue() >= (low.getValue(index).doubleValue())) return false; index--; if (up.getValue(index).doubleValue() > low.getValue(index).doubleValue()) return true; else { while (index > 0 && up.getValue(index).doubleValue() == low.getValue(index).doubleValue()) index--; if (index == 0) return false; if (up.getValue(index).doubleValue() > low.getValue(index).doubleValue()) return true; return false; } } public Indicator<? extends Number> getLow() { return low; } public Indicator<? extends Number> getUp() { return up; } } --- NEW FILE: AverageGainIndicator.java --- package net.sf.tail.indicator.helper; import net.sf.tail.Indicator; public class AverageGainIndicator implements Indicator<Double> { private final Indicator<? extends Number> indicator; private final int timeFrame; public AverageGainIndicator(Indicator<? extends Number> indicator, int timeFrame) { this.indicator = indicator; this.timeFrame = timeFrame; } public Double getValue(int index) { double result = 0; for (int i = Math.max(1, index - timeFrame + 1); i <= index; i++) { if (indicator.getValue(i).doubleValue() >= indicator.getValue(i - 1).doubleValue()) result += indicator.getValue(i).doubleValue() - indicator.getValue(i - 1).doubleValue(); } return result / Math.min(timeFrame, index + 1); } } --- NEW FILE: StandardDeviationIndicator.java --- package net.sf.tail.indicator.helper; import net.sf.tail.Indicator; import net.sf.tail.indicator.tracker.SMAIndicator; public class StandardDeviationIndicator implements Indicator<Double> { private Indicator<? extends Number> indicator; private int timeFrame; private SMAIndicator sma; public StandardDeviationIndicator(Indicator<? extends Number> indicator, int timeFrame) { this.indicator = indicator; this.timeFrame = timeFrame; sma = new SMAIndicator(indicator, timeFrame); } public Double getValue(int index) { double standardDeviation = 0.0; double average = sma.getValue(index); for (int i = Math.max(0, index - timeFrame + 1); i <= index; i++) { standardDeviation += Math.pow(indicator.getValue(i).doubleValue() - average, 2.0); } return Math.sqrt(standardDeviation); } } |
|
From: Márcio V. d. S. <mv...@us...> - 2007-05-31 16:45:22
|
Update of /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/helper In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv2928/src/java/net/sf/tail/indicator/helper Log Message: Directory /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/helper added to the repository |
|
From: Márcio V. d. S. <mv...@us...> - 2007-05-31 16:45:22
|
Update of /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/helper In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv2928/src/test/net/sf/tail/indicator/helper Log Message: Directory /cvsroot/tail/Tail/src/test/net/sf/tail/indicator/helper added to the repository |
|
From: Carlos <ma...@us...> - 2007-05-26 13:57:04
|
Update of /cvsroot/tail/Tail/src/java/net/sf/tail/strategy In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv11076/src/java/net/sf/tail/strategy Added Files: DistanceBetweenIndicatorsStrategy.java Log Message: Estratégia de diferença entre indicadores e seu teste. --- NEW FILE: DistanceBetweenIndicatorsStrategy.java --- package net.sf.tail.strategy; import net.sf.tail.Indicator; import net.sf.tail.Operation; import net.sf.tail.OperationType; import net.sf.tail.Strategy; /** * * Estratégia que recebe dois indicadores com uma diferença comum entre eles * e toma a decisão de compra do indicador que está representando a ação superior * caso a distance entre elas esteja abaixo de difference, e a decisão de venda * caso a distance entre elas esteja acima de difference. * * @author marcio * */ public class DistanceBetweenIndicatorsStrategy implements Strategy { private Indicator<? extends Number> upper; private Indicator<? extends Number> lower; private double distance; private double difference; public DistanceBetweenIndicatorsStrategy(Indicator<? extends Number> upper, Indicator<? extends Number> lower, double distance, double difference) { this.upper = upper; this.lower = lower; this.distance = distance; this.difference = difference; } public Operation shouldEnter(int index) { if((upper.getValue(index).doubleValue() - lower.getValue(index).doubleValue()) >= (difference + 1.0) * distance) { return new Operation(index, OperationType.BUY); } return null; } public Operation shouldExit(Operation entry, int index) { if((upper.getValue(index).doubleValue() - lower.getValue(index).doubleValue()) <= (1.0 - difference) * distance) { return new Operation(index, OperationType.SELL); } return null; } } |
|
From: Márcio V. d. S. <mv...@us...> - 2007-05-24 21:11:13
|
Update of /cvsroot/tail/Tail/src/java/net/sf/tail/strategy In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv32499/src/java/net/sf/tail/strategy Modified Files: MinValueStarterStrategy.java IndicatorCrossedIndicatorStrategy.java Added Files: PipeEnterStrategy.java Log Message: Refatoração de código e Criação da nova estratégia PipeEnterStrategy --- NEW FILE: PipeEnterStrategy.java --- package net.sf.tail.strategy; import net.sf.tail.Indicator; import net.sf.tail.Operation; import net.sf.tail.OperationType; import net.sf.tail.Strategy; /** * PipeEnterStrategy baseia a compra em um {@link Indicator} lower, no momento * em que o {@link Indicator} value o ultrapassa em sentido ascendente, e baseia * a venda em um {@link Indicator}} upper, no momento em que o * {@link Indicator} value o ultrapassa em sentido descendente. Estratégia muito * comum para indicadores que criam "tubos" de suporte e resistência, como por * exemplo o Bollinger Bands. * */ public class PipeEnterStrategy implements Strategy { private Indicator<? extends Number> upper; private Indicator<? extends Number> lower; private Indicator<? extends Number> value; public PipeEnterStrategy(Indicator<? extends Number> upper, Indicator<? extends Number> lower, Indicator<? extends Number> value) { this.upper = upper; this.lower = lower; this.value = value; } public Operation shouldEnter(int index) { if (isCrossed(index, value, upper)) return new Operation(index, OperationType.SELL); if (isCrossed(index, lower, value)) return new Operation(index, OperationType.BUY); return null; } public Operation shouldExit(Operation entry, int index) { if (isCrossed(index, lower, value)) return new Operation(index, OperationType.BUY); if (isCrossed(index, value, upper)) return new Operation(index, OperationType.SELL); return null; } private boolean isCrossed(int index, Indicator<? extends Number> up, Indicator<? extends Number> low) { if (index == 0 || up.getValue(index).doubleValue() >= (low.getValue(index).doubleValue())) return false; index--; if (up.getValue(index).doubleValue() > low.getValue(index).doubleValue()) return true; else { while (index > 0 && up.getValue(index).doubleValue() == low.getValue(index).doubleValue()) index--; if (index == 0) return false; if (up.getValue(index).doubleValue() > low.getValue(index).doubleValue()) return true; return false; } } public Indicator<? extends Number> getLower() { return lower; } public Indicator<? extends Number> getUpper() { return upper; } public Indicator<? extends Number> getValue() { return value; } } Index: MinValueStarterStrategy.java =================================================================== RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/strategy/MinValueStarterStrategy.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MinValueStarterStrategy.java 24 May 2007 20:09:25 -0000 1.2 --- MinValueStarterStrategy.java 24 May 2007 21:11:11 -0000 1.3 *************** *** 3,7 **** import net.sf.tail.Indicator; import net.sf.tail.Operation; - import net.sf.tail.OperationType; import net.sf.tail.Strategy; --- 3,6 ---- Index: IndicatorCrossedIndicatorStrategy.java =================================================================== RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/strategy/IndicatorCrossedIndicatorStrategy.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IndicatorCrossedIndicatorStrategy.java 19 May 2007 15:59:51 -0000 1.1 --- IndicatorCrossedIndicatorStrategy.java 24 May 2007 21:11:11 -0000 1.2 *************** *** 8,64 **** /** * ! * Strategy that buy when upper is above lower and cross and sell when lower is above upper and cross * @author tgthies ! * */ public class IndicatorCrossedIndicatorStrategy implements Strategy { ! private Indicator<Double> upper; ! private Indicator<Double> lower; ! ! public IndicatorCrossedIndicatorStrategy(Indicator<Double> upper, Indicator<Double> lower) { this.upper = upper; this.lower = lower; } ! public Operation shouldEnter(int index) { ! ! return whatShouldIDo(index, upper, lower, OperationType.BUY); ! } public Operation shouldExit(Operation entry, int index) { ! ! return whatShouldIDo(index, lower, upper, OperationType.SELL); ! } ! //FIXME Mudar o nome deste método ! private Operation whatShouldIDo(int index, Indicator<Double> up, Indicator<Double> low, OperationType type) { ! ! if(index == 0 || up.getValue(index).compareTo(low.getValue(index)) >= 0) ! return null; ! ! ! int previousCompare = up.getValue(index - 1).compareTo(low.getValue(index - 1)); ! ! if(previousCompare > 0) ! return new Operation(index, type); ! else if(previousCompare < 0) ! return null; ! ! else ! { ! int previousIndex = index - 2; ! while(previousIndex > 0 && up.getValue(previousIndex).compareTo(low.getValue(previousIndex)) == 0) ! previousIndex--; ! if(previousIndex == 0) ! return null; ! if(up.getValue(previousIndex).compareTo(low.getValue(previousIndex)) > 0) ! return new Operation(index, type); ! return null; ! } } - } --- 8,58 ---- /** * ! * Strategy that buy when upper is above lower and cross and sell when lower is ! * above upper and cross ! * * @author tgthies ! * */ public class IndicatorCrossedIndicatorStrategy implements Strategy { ! private Indicator<? extends Number> upper; ! private Indicator<? extends Number> lower; ! ! public IndicatorCrossedIndicatorStrategy(Indicator<? extends Number> upper, Indicator<? extends Number> lower) { this.upper = upper; this.lower = lower; } ! public Operation shouldEnter(int index) { ! if (isCrossed(index, upper, lower)) ! return new Operation(index, OperationType.BUY); ! return null; } public Operation shouldExit(Operation entry, int index) { ! if (isCrossed(index, lower, upper)) ! return new Operation(index, OperationType.SELL); ! return null; } ! ! private boolean isCrossed(int index, Indicator<? extends Number> up, Indicator<? extends Number> low) { ! ! if (index == 0 || up.getValue(index).doubleValue() >= (low.getValue(index).doubleValue())) ! return false; ! index--; ! if (up.getValue(index).doubleValue() > low.getValue(index).doubleValue()) ! return true; ! ! else { ! ! while (index > 0 && up.getValue(index).doubleValue() == low.getValue(index).doubleValue()) ! index--; ! if (index == 0) ! return false; ! if (up.getValue(index).doubleValue() > low.getValue(index).doubleValue()) ! return true; ! return false; } } } |
|
From: Márcio V. d. S. <mv...@us...> - 2007-05-24 21:11:12
|
Update of /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/tracker/bollingerbands In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv32499/src/java/net/sf/tail/indicator/tracker/bollingerbands Modified Files: BollingerBandsMiddleIndicator.java BollingerBandsUpperIndicator.java BollingerBandsLowerIndicator.java Log Message: Refatoração de código e Criação da nova estratégia PipeEnterStrategy Index: BollingerBandsMiddleIndicator.java =================================================================== RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/tracker/bollingerbands/BollingerBandsMiddleIndicator.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** BollingerBandsMiddleIndicator.java 18 May 2007 01:07:44 -0000 1.2 --- BollingerBandsMiddleIndicator.java 24 May 2007 21:11:11 -0000 1.3 *************** *** 4,7 **** --- 4,13 ---- import net.sf.tail.indicator.tracker.SMAIndicator; + /** + * Buy - Occurs when the price line cross from down to up de Bollinger Band Low. + * Sell - Occurs when the price line cross from up to down de Bollinger Band High. + * @author Marcio + * + */ public class BollingerBandsMiddleIndicator implements Indicator<Double> { private final Indicator<? extends Number> indicator; Index: BollingerBandsLowerIndicator.java =================================================================== RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/tracker/bollingerbands/BollingerBandsLowerIndicator.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** BollingerBandsLowerIndicator.java 18 May 2007 01:07:44 -0000 1.2 --- BollingerBandsLowerIndicator.java 24 May 2007 21:11:11 -0000 1.3 *************** *** 4,7 **** --- 4,14 ---- import net.sf.tail.indicator.tracker.StandardDeviationIndicator; + /** + * Buy - Occurs when the price line cross from down to up de Bollinger Band Low. + * Sell - Occurs when the price line cross from up to down de Bollinger Band High. + * @author Marcio + * + */ + public class BollingerBandsLowerIndicator implements Indicator<Double> { private final Indicator<? extends Number> indicator; Index: BollingerBandsUpperIndicator.java =================================================================== RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/indicator/tracker/bollingerbands/BollingerBandsUpperIndicator.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** BollingerBandsUpperIndicator.java 18 May 2007 01:07:44 -0000 1.2 --- BollingerBandsUpperIndicator.java 24 May 2007 21:11:11 -0000 1.3 *************** *** 4,7 **** --- 4,13 ---- import net.sf.tail.indicator.tracker.StandardDeviationIndicator; + /** + * Buy - Occurs when the price line cross from down to up de Bollinger Band Low. + * Sell - Occurs when the price line cross from up to down de Bollinger Band High. + * @author Marcio + * + */ public class BollingerBandsUpperIndicator implements Indicator<Double> { private final Indicator<? extends Number> indicator; |
|
From: Márcio V. d. S. <mv...@us...> - 2007-05-24 21:11:12
|
Update of /cvsroot/tail/Tail/src/test/net/sf/tail/strategy In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv32499/src/test/net/sf/tail/strategy Modified Files: IndicatorCrossedIndicatorStrategyTest.java Added Files: PipeEnterStrategyTest.java Log Message: Refatoração de código e Criação da nova estratégia PipeEnterStrategy Index: IndicatorCrossedIndicatorStrategyTest.java =================================================================== RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/strategy/IndicatorCrossedIndicatorStrategyTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IndicatorCrossedIndicatorStrategyTest.java 19 May 2007 15:59:51 -0000 1.1 --- IndicatorCrossedIndicatorStrategyTest.java 24 May 2007 21:11:11 -0000 1.2 *************** *** 16,32 **** public class IndicatorCrossedIndicatorStrategyTest { private Indicator<Double> first; private Indicator<Double> second; ! @Before public void setUp() throws Exception { ! ! first = new SampleIndicator(new double[] {4,7,9,6,3,2}); ! second = new SampleIndicator(new double[] {3,6,10,8,2,1}); ! ! } @Test ! public void testCrossedIndicator() ! { Strategy s = new IndicatorCrossedIndicatorStrategy(first, second); assertNull(s.shouldEnter(0)); --- 16,32 ---- public class IndicatorCrossedIndicatorStrategyTest { private Indicator<Double> first; + private Indicator<Double> second; ! @Before public void setUp() throws Exception { ! ! first = new SampleIndicator(new double[] { 4, 7, 9, 6, 3, 2 }); ! second = new SampleIndicator(new double[] { 3, 6, 10, 8, 2, 1 }); ! } + @Test ! public void testCrossedIndicator() { Strategy s = new IndicatorCrossedIndicatorStrategy(first, second); assertNull(s.shouldEnter(0)); *************** *** 42,94 **** assertEquals(exit.getType(), OperationType.SELL); assertNull(s.shouldEnter(5)); ! ! } @Test ! public void testEqualIndicatorsShouldEnter() ! { ! Indicator<Double> firstEqual = new SampleIndicator(new double[] {2,3,4,5,6,7}); ! Indicator<Double> secondEqual = new SampleIndicator(new double[] {2,3,4,5,6,7}); ! Strategy s = new IndicatorCrossedIndicatorStrategy(firstEqual, secondEqual); ! ! for(int i = 0; i < 6; i++) ! { assertNull(s.shouldEnter(i)); } } ! @Test ! public void testEqualIndicatorsShouldExit() ! { ! Indicator<Double> firstEqual = new SampleIndicator(new double[] {2,1,4,5,6,7}); ! Indicator<Double> secondEqual = new SampleIndicator(new double[] {1,3,4,5,6,7}); Strategy s = new IndicatorCrossedIndicatorStrategy(firstEqual, secondEqual); ! Operation enter = s.shouldEnter(1); ! assertNotNull(enter); assertEquals(enter.getType(), OperationType.BUY); ! ! for(int i = 2; i < 6; i++) ! { assertNull(s.shouldExit(enter, i)); } } ! @Test ! public void testEqualIndicatorsShouldEnterEqualsShouldExit() ! { ! Indicator<Double> firstEqual = new SampleIndicator(new double[] {2,1,4,5,6,7,10}); ! Indicator<Double> secondEqual = new SampleIndicator(new double[] {1,3,4,5,6,7,9}); Strategy s = new IndicatorCrossedIndicatorStrategy(firstEqual, secondEqual); ! Operation enter = s.shouldEnter(1); ! assertNotNull(enter); assertEquals(enter.getType(), OperationType.BUY); ! ! for(int i = 2; i < 6; i++) ! { assertNull(s.shouldExit(enter, i)); } --- 42,88 ---- assertEquals(exit.getType(), OperationType.SELL); assertNull(s.shouldEnter(5)); ! } + @Test ! public void testEqualIndicatorsShouldEnter() { ! Indicator<Double> firstEqual = new SampleIndicator(new double[] { 2, 3, 4, 5, 6, 7 }); ! Indicator<Double> secondEqual = new SampleIndicator(new double[] { 2, 3, 4, 5, 6, 7 }); ! Strategy s = new IndicatorCrossedIndicatorStrategy(firstEqual, secondEqual); ! ! for (int i = 0; i < 6; i++) { assertNull(s.shouldEnter(i)); } } ! @Test ! public void testEqualIndicatorsShouldExit() { ! Indicator<Double> firstEqual = new SampleIndicator(new double[] { 2, 1, 4, 5, 6, 7 }); ! Indicator<Double> secondEqual = new SampleIndicator(new double[] { 1, 3, 4, 5, 6, 7 }); Strategy s = new IndicatorCrossedIndicatorStrategy(firstEqual, secondEqual); ! Operation enter = s.shouldEnter(1); ! assertNotNull(enter); assertEquals(enter.getType(), OperationType.BUY); ! ! for (int i = 2; i < 6; i++) { assertNull(s.shouldExit(enter, i)); } } ! @Test ! public void testEqualIndicatorsShouldEnterEqualsShouldExit() { ! Indicator<Double> firstEqual = new SampleIndicator(new double[] { 2, 1, 4, 5, 6, 7, 10 }); ! Indicator<Double> secondEqual = new SampleIndicator(new double[] { 1, 3, 4, 5, 6, 7, 9 }); Strategy s = new IndicatorCrossedIndicatorStrategy(firstEqual, secondEqual); ! Operation enter = s.shouldEnter(1); ! assertNotNull(enter); assertEquals(enter.getType(), OperationType.BUY); ! ! for (int i = 2; i < 6; i++) { assertNull(s.shouldExit(enter, i)); } *************** *** 97,126 **** assertEquals(exit.getType(), OperationType.SELL); } ! @Test ! public void testEqualIndicatorsShouldNotBuy() ! { ! Indicator<Double> firstEqual = new SampleIndicator(new double[] {2,3,4,5,6,7,10}); ! Indicator<Double> secondEqual = new SampleIndicator(new double[] {1,3,4,5,6,7,9}); Strategy s = new IndicatorCrossedIndicatorStrategy(firstEqual, secondEqual); ! ! for(int i = 0; i < 7; i++) ! { assertNull(s.shouldEnter(i)); } ! ! firstEqual = new SampleIndicator(new double[] {2, 3, 4, 5, 6, 8}); ! secondEqual = new SampleIndicator(new double[] {2, 3, 4, 5, 6, 7}); ! ! for(int i = 0; i < 6; i++) ! { assertNull(s.shouldEnter(i)); } } ! public static junit.framework.Test suite() { return new JUnit4TestAdapter(IndicatorCrossedIndicatorStrategyTest.class); } ! ! } --- 91,116 ---- assertEquals(exit.getType(), OperationType.SELL); } ! @Test ! public void testEqualIndicatorsShouldNotBuy() { ! Indicator<Double> firstEqual = new SampleIndicator(new double[] { 2, 3, 4, 5, 6, 7, 10 }); ! Indicator<Double> secondEqual = new SampleIndicator(new double[] { 1, 3, 4, 5, 6, 7, 9 }); Strategy s = new IndicatorCrossedIndicatorStrategy(firstEqual, secondEqual); ! ! for (int i = 0; i < 7; i++) { assertNull(s.shouldEnter(i)); } ! ! firstEqual = new SampleIndicator(new double[] { 2, 3, 4, 5, 6, 8 }); ! secondEqual = new SampleIndicator(new double[] { 2, 3, 4, 5, 6, 7 }); ! ! for (int i = 0; i < 6; i++) { assertNull(s.shouldEnter(i)); } } ! public static junit.framework.Test suite() { return new JUnit4TestAdapter(IndicatorCrossedIndicatorStrategyTest.class); } ! } --- NEW FILE: PipeEnterStrategyTest.java --- package net.sf.tail.strategy; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import net.sf.tail.Operation; import net.sf.tail.OperationType; import net.sf.tail.sample.SampleIndicator; import org.junit.Before; import org.junit.Test; public class PipeEnterStrategyTest { private SampleIndicator upper; private SampleIndicator lower; @Before public void setUp() { upper = new SampleIndicator(new double[] { 30, 32, 33, 32, 35, 33, 32, 33, 31, 30, 31, 32, 32, 34, 35 }); lower = new SampleIndicator(new double[] { 10, 12, 13, 12, 15, 13, 12, 13, 11, 10, 11, 12, 12, 14, 15 }); } @Test public void testFirstSellLastBuy() { SampleIndicator value = new SampleIndicator(new double[] { 25, 27, 28, 27, 30, 33, 35, 37, 35, 29, 11, 10, 15, 30, 31 }); PipeEnterStrategy pipeEnter = new PipeEnterStrategy(upper, lower, value); assertNull(pipeEnter.shouldEnter(1)); assertNull(pipeEnter.shouldEnter(8)); assertNull(pipeEnter.shouldEnter(10)); Operation entry = new Operation(9, OperationType.SELL); assertEquals(entry, pipeEnter.shouldEnter(9)); assertNull(pipeEnter.shouldExit(entry, 11)); assertEquals(new Operation(12, OperationType.BUY), pipeEnter.shouldExit(entry, 12)); } @Test public void testFirstBuyLastSell() { SampleIndicator value = new SampleIndicator(new double[] { 8, 15, 16, 33, 40, 45, 47, 40, 32, 25, 15, 16, 11, 10, 12 }); PipeEnterStrategy pipeEnter = new PipeEnterStrategy(upper, lower, value); assertNull(pipeEnter.shouldEnter(0)); Operation entry = new Operation(1, OperationType.BUY); assertEquals(entry, pipeEnter.shouldEnter(1)); assertNull(pipeEnter.shouldEnter(8)); assertNull(pipeEnter.shouldEnter(10)); assertNull(pipeEnter.shouldExit(entry, 8)); assertEquals(new Operation(9, OperationType.SELL), pipeEnter.shouldExit(entry, 9)); } } |
|
From: Thies <tg...@us...> - 2007-05-24 20:09:52
|
Update of /cvsroot/tail/Tail/src/test/net/sf/tail/strategy In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv5656/src/test/net/sf/tail/strategy Modified Files: MinValueStarterStrategyTest.java Log Message: Refatoração da estratégia MinValueStarterStrategy e seu teste Index: MinValueStarterStrategyTest.java =================================================================== RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/strategy/MinValueStarterStrategyTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MinValueStarterStrategyTest.java 24 May 2007 18:50:20 -0000 1.1 --- MinValueStarterStrategyTest.java 24 May 2007 20:09:25 -0000 1.2 *************** *** 3,6 **** --- 3,7 ---- import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; + import junit.framework.JUnit4TestAdapter; import net.sf.tail.Operation; import net.sf.tail.OperationType; *************** *** 23,42 **** public void testStarterShouldWork() { ! Strategy neverBuy = new FakeStratetgy( new Operation[] { null, null, null, null, null } , new Operation[] { null, null, null, null, null }); ! Strategy stopper = new MinValueStarterStrategy(indicator,neverBuy, 93); ! assertNull(stopper.shouldEnter(0)); ! assertNull(stopper.shouldEnter(1)); Operation buy = new Operation(2,OperationType.BUY); ! assertEquals(buy, stopper.shouldEnter(2)); buy = new Operation(3,OperationType.BUY); ! assertEquals(buy, stopper.shouldEnter(3)); buy = new Operation(4,OperationType.BUY); ! assertEquals(buy, stopper.shouldEnter(4)); } } --- 24,50 ---- public void testStarterShouldWork() { ! Operation[] enter = new Operation[] { new Operation(0,OperationType.BUY), new Operation(1,OperationType.BUY), ! new Operation(2,OperationType.BUY), new Operation(3,OperationType.BUY), new Operation(4,OperationType.BUY) }; ! Operation[] exit = new Operation[] { null, null, null, null, null }; ! Strategy alwaysBuy = new FakeStratetgy( enter , exit); ! Strategy starter = new MinValueStarterStrategy(indicator,alwaysBuy, 93); ! assertNull(starter.shouldEnter(0)); ! ! assertNull(starter.shouldEnter(1)); Operation buy = new Operation(2,OperationType.BUY); ! assertEquals(buy, starter.shouldEnter(2)); buy = new Operation(3,OperationType.BUY); ! assertEquals(buy, starter.shouldEnter(3)); buy = new Operation(4,OperationType.BUY); ! assertEquals(buy, starter.shouldEnter(4)); } + public static junit.framework.Test suite() { + return new JUnit4TestAdapter(MinValueStarterStrategyTest.class); + } } |
|
From: Thies <tg...@us...> - 2007-05-24 20:09:52
|
Update of /cvsroot/tail/Tail/src/java/net/sf/tail/strategy In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv5656/src/java/net/sf/tail/strategy Modified Files: MinValueStarterStrategy.java Log Message: Refatoração da estratégia MinValueStarterStrategy e seu teste Index: MinValueStarterStrategy.java =================================================================== RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/strategy/MinValueStarterStrategy.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MinValueStarterStrategy.java 24 May 2007 18:51:36 -0000 1.1 --- MinValueStarterStrategy.java 24 May 2007 20:09:25 -0000 1.2 *************** *** 7,16 **** /** ! * MinValueStopperStrategy baseia a compra em uma {@link Strategy} enviada como ! * parâmetro, registrando o valor do {@link Indicator} enviado como parâmetro no ! * mesmo Ãndice de compra, e baseia a venda nessa mesma {@link Strategy} desde ! * que o valor registrado do {@link Indicator} na compra não tenha um decréscimo ! * maior que loss % ! * */ public class MinValueStarterStrategy implements Strategy { --- 7,13 ---- /** ! * MinValueStarterStrategy baseia a compra em uma {@link Strategy} enviada como ! * parâmetro desde que o valor atual esteja acima do {@link start}, ! * e baseia a venda nessa mesma {@link Strategy} */ public class MinValueStarterStrategy implements Strategy { *************** *** 20,37 **** private Indicator<? extends Number> indicator; ! private double value; ! public MinValueStarterStrategy(Indicator<? extends Number> indicator, Strategy strategy, double value) { this.strategy = strategy; ! this.value = value; this.indicator = indicator; } public Operation shouldEnter(int index) { ! if (value < indicator.getValue(index).doubleValue()) { ! return new Operation(index, OperationType.BUY); } ! return strategy.shouldEnter(index); } --- 17,34 ---- private Indicator<? extends Number> indicator; ! private double start; ! public MinValueStarterStrategy(Indicator<? extends Number> indicator, Strategy strategy, double start) { this.strategy = strategy; ! this.start = start; this.indicator = indicator; } public Operation shouldEnter(int index) { ! if (indicator.getValue(index).doubleValue() > start) { ! return strategy.shouldEnter(index); } ! return null; } |
|
From: Thies <tg...@us...> - 2007-05-24 18:51:36
|
Update of /cvsroot/tail/Tail/src/java/net/sf/tail/strategy In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv4225/src/java/net/sf/tail/strategy Added Files: MinValueStarterStrategy.java Log Message: Estrategia de start --- NEW FILE: MinValueStarterStrategy.java --- package net.sf.tail.strategy; import net.sf.tail.Indicator; import net.sf.tail.Operation; import net.sf.tail.OperationType; import net.sf.tail.Strategy; /** * MinValueStopperStrategy baseia a compra em uma {@link Strategy} enviada como * parâmetro, registrando o valor do {@link Indicator} enviado como parâmetro no * mesmo Ãndice de compra, e baseia a venda nessa mesma {@link Strategy} desde * que o valor registrado do {@link Indicator} na compra não tenha um decréscimo * maior que loss % * */ public class MinValueStarterStrategy implements Strategy { private Strategy strategy; private Indicator<? extends Number> indicator; private double value; public MinValueStarterStrategy(Indicator<? extends Number> indicator, Strategy strategy, double value) { this.strategy = strategy; this.value = value; this.indicator = indicator; } public Operation shouldEnter(int index) { if (value < indicator.getValue(index).doubleValue()) { return new Operation(index, OperationType.BUY); } return strategy.shouldEnter(index); } public Operation shouldExit(Operation entry, int index) { return strategy.shouldExit(entry, index); } public Strategy getStrategy() { return strategy; } } |
|
From: Thies <tg...@us...> - 2007-05-24 18:50:31
|
Update of /cvsroot/tail/Tail/src/test/net/sf/tail/strategy In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv3693/src/test/net/sf/tail/strategy Added Files: MinValueStarterStrategyTest.java Log Message: Testes para estratégia de start. --- NEW FILE: MinValueStarterStrategyTest.java --- package net.sf.tail.strategy; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import net.sf.tail.Operation; import net.sf.tail.OperationType; import net.sf.tail.Strategy; import net.sf.tail.sample.SampleIndicator; import org.junit.Before; import org.junit.Test; public class MinValueStarterStrategyTest { private SampleIndicator indicator; @Before public void setUp() throws Exception { indicator = new SampleIndicator(new double[] {90,92,96,95,94}); } @Test public void testStarterShouldWork() { Strategy neverBuy = new FakeStratetgy( new Operation[] { null, null, null, null, null } , new Operation[] { null, null, null, null, null }); Strategy stopper = new MinValueStarterStrategy(indicator,neverBuy, 93); assertNull(stopper.shouldEnter(0)); assertNull(stopper.shouldEnter(1)); Operation buy = new Operation(2,OperationType.BUY); assertEquals(buy, stopper.shouldEnter(2)); buy = new Operation(3,OperationType.BUY); assertEquals(buy, stopper.shouldEnter(3)); buy = new Operation(4,OperationType.BUY); assertEquals(buy, stopper.shouldEnter(4)); } } |
|
From: Thies <tg...@us...> - 2007-05-24 17:48:07
|
Update of /cvsroot/tail/Tail/src/java/net/sf/tail/runner In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv8598/src/java/net/sf/tail/runner Modified Files: HistoryRunner.java Log Message: Runner adaptado para efetuar uma trade iniciada por venda Index: HistoryRunner.java =================================================================== RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/runner/HistoryRunner.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** HistoryRunner.java 19 May 2007 14:16:51 -0000 1.3 --- HistoryRunner.java 24 May 2007 17:48:04 -0000 1.4 *************** *** 30,34 **** } else if(i + 1 == seriesSize){ ! exit = new Operation(i, OperationType.SELL); Trade t = new Trade(entry, exit); trades.add(t); --- 30,37 ---- } else if(i + 1 == seriesSize){ ! if(entry.getType().equals(OperationType.BUY)) ! exit = new Operation(i, OperationType.SELL); ! else ! exit = new Operation(i, OperationType.BUY); Trade t = new Trade(entry, exit); trades.add(t); |
|
From: Thies <tg...@us...> - 2007-05-24 17:47:16
|
Update of /cvsroot/tail/Tail/src/test/net/sf/tail/strategy In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv8544/src/test/net/sf/tail/strategy Modified Files: IndicatorOverIndicatorStrategyTest.java Log Message: Arrumado os imports Index: IndicatorOverIndicatorStrategyTest.java =================================================================== RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/strategy/IndicatorOverIndicatorStrategyTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** IndicatorOverIndicatorStrategyTest.java 19 May 2007 15:58:38 -0000 1.4 --- IndicatorOverIndicatorStrategyTest.java 24 May 2007 17:47:15 -0000 1.5 *************** *** 2,6 **** import static org.junit.Assert.assertEquals; - import static org.junit.Assert.assertNotNull; import junit.framework.JUnit4TestAdapter; import net.sf.tail.Indicator; --- 2,5 ---- |
|
From: Paulo S. <pau...@ca...> - 2007-05-19 19:40:34
|
--=20 Paulo E. A. Silveira Caelum Ensino e Solu=E7=F5es em Java http://www.caelum.com.br/ |
|
From: Thies <tg...@us...> - 2007-05-19 15:59:51
|
Update of /cvsroot/tail/Tail/src/test/net/sf/tail/strategy In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv25694/src/test/net/sf/tail/strategy Added Files: IndicatorCrossedIndicatorStrategyTest.java Log Message: Stochastic comentado, criado a estratégia IndicatorCrossedIndicator e seu teste --- NEW FILE: IndicatorCrossedIndicatorStrategyTest.java --- package net.sf.tail.strategy; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import junit.framework.JUnit4TestAdapter; import net.sf.tail.Indicator; import net.sf.tail.Operation; import net.sf.tail.OperationType; import net.sf.tail.Strategy; import net.sf.tail.sample.SampleIndicator; import org.junit.Before; import org.junit.Test; public class IndicatorCrossedIndicatorStrategyTest { private Indicator<Double> first; private Indicator<Double> second; @Before public void setUp() throws Exception { first = new SampleIndicator(new double[] {4,7,9,6,3,2}); second = new SampleIndicator(new double[] {3,6,10,8,2,1}); } @Test public void testCrossedIndicator() { Strategy s = new IndicatorCrossedIndicatorStrategy(first, second); assertNull(s.shouldEnter(0)); assertNull(s.shouldEnter(1)); Operation enter = s.shouldEnter(2); assertNotNull(enter); assertEquals(enter.getType(), OperationType.BUY); assertNull(s.shouldEnter(3)); assertNull(s.shouldEnter(4)); assertNull(s.shouldExit(enter, 3)); Operation exit = s.shouldExit(enter, 4); assertNotNull(exit); assertEquals(exit.getType(), OperationType.SELL); assertNull(s.shouldEnter(5)); } @Test public void testEqualIndicatorsShouldEnter() { Indicator<Double> firstEqual = new SampleIndicator(new double[] {2,3,4,5,6,7}); Indicator<Double> secondEqual = new SampleIndicator(new double[] {2,3,4,5,6,7}); Strategy s = new IndicatorCrossedIndicatorStrategy(firstEqual, secondEqual); for(int i = 0; i < 6; i++) { assertNull(s.shouldEnter(i)); } } @Test public void testEqualIndicatorsShouldExit() { Indicator<Double> firstEqual = new SampleIndicator(new double[] {2,1,4,5,6,7}); Indicator<Double> secondEqual = new SampleIndicator(new double[] {1,3,4,5,6,7}); Strategy s = new IndicatorCrossedIndicatorStrategy(firstEqual, secondEqual); Operation enter = s.shouldEnter(1); assertNotNull(enter); assertEquals(enter.getType(), OperationType.BUY); for(int i = 2; i < 6; i++) { assertNull(s.shouldExit(enter, i)); } } @Test public void testEqualIndicatorsShouldEnterEqualsShouldExit() { Indicator<Double> firstEqual = new SampleIndicator(new double[] {2,1,4,5,6,7,10}); Indicator<Double> secondEqual = new SampleIndicator(new double[] {1,3,4,5,6,7,9}); Strategy s = new IndicatorCrossedIndicatorStrategy(firstEqual, secondEqual); Operation enter = s.shouldEnter(1); assertNotNull(enter); assertEquals(enter.getType(), OperationType.BUY); for(int i = 2; i < 6; i++) { assertNull(s.shouldExit(enter, i)); } Operation exit = s.shouldExit(enter, 6); assertNotNull(exit); assertEquals(exit.getType(), OperationType.SELL); } @Test public void testEqualIndicatorsShouldNotBuy() { Indicator<Double> firstEqual = new SampleIndicator(new double[] {2,3,4,5,6,7,10}); Indicator<Double> secondEqual = new SampleIndicator(new double[] {1,3,4,5,6,7,9}); Strategy s = new IndicatorCrossedIndicatorStrategy(firstEqual, secondEqual); for(int i = 0; i < 7; i++) { assertNull(s.shouldEnter(i)); } firstEqual = new SampleIndicator(new double[] {2, 3, 4, 5, 6, 8}); secondEqual = new SampleIndicator(new double[] {2, 3, 4, 5, 6, 7}); for(int i = 0; i < 6; i++) { assertNull(s.shouldEnter(i)); } } public static junit.framework.Test suite() { return new JUnit4TestAdapter(IndicatorCrossedIndicatorStrategyTest.class); } } |
|
From: Thies <tg...@us...> - 2007-05-19 15:58:38
|
Update of /cvsroot/tail/Tail/src/test/net/sf/tail/strategy In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv25274/src/test/net/sf/tail/strategy Modified Files: IndicatorOverIndicatorStrategyTest.java Log Message: Organizado os imports e adicionado método para rodar no Eclipse 3.1 Index: IndicatorOverIndicatorStrategyTest.java =================================================================== RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/strategy/IndicatorOverIndicatorStrategyTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IndicatorOverIndicatorStrategyTest.java 19 May 2007 15:45:14 -0000 1.3 --- IndicatorOverIndicatorStrategyTest.java 19 May 2007 15:58:38 -0000 1.4 *************** *** 1,5 **** package net.sf.tail.strategy; ! import static org.junit.Assert.*; import net.sf.tail.Indicator; import net.sf.tail.Operation; --- 1,7 ---- package net.sf.tail.strategy; ! import static org.junit.Assert.assertEquals; ! import static org.junit.Assert.assertNotNull; ! import junit.framework.JUnit4TestAdapter; import net.sf.tail.Indicator; import net.sf.tail.Operation; *************** *** 44,47 **** --- 46,54 ---- public void tearDown() throws Exception { } + + + public static junit.framework.Test suite() { + return new JUnit4TestAdapter(IndicatorOverIndicatorStrategyTest.class); + } } |
|
From: Márcio V. d. S. <mv...@us...> - 2007-05-19 15:45:15
|
Update of /cvsroot/tail/Tail/src/test/net/sf/tail/strategy In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv20090/src/test/net/sf/tail/strategy Modified Files: IndicatorOverIndicatorStrategyTest.java Added Files: JustBuyOnceStrategyTest.java MinValueStopperStrategyTest.java Log Message: Criado teste para o HistoryRunner Criado JustBuyOnceStrategy Criado MinvalueStopperStrategy Index: IndicatorOverIndicatorStrategyTest.java =================================================================== RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/strategy/IndicatorOverIndicatorStrategyTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** IndicatorOverIndicatorStrategyTest.java 19 May 2007 13:23:22 -0000 1.2 --- IndicatorOverIndicatorStrategyTest.java 19 May 2007 15:45:14 -0000 1.3 *************** *** 32,45 **** 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()); } --- 32,41 ---- assertEquals(null, s.shouldEnter(0)); assertEquals(null, s.shouldEnter(1)); ! Operation buy = new Operation(2,OperationType.BUY); ! assertEquals(buy, s.shouldEnter(2)); assertEquals(null, s.shouldExit(buy, 3)); ! Operation sell = new Operation(4,OperationType.SELL); ! assertEquals(sell, s.shouldExit(buy, 4)); } --- NEW FILE: JustBuyOnceStrategyTest.java --- package net.sf.tail.strategy; import net.sf.tail.Operation; import net.sf.tail.OperationType; import net.sf.tail.Strategy; import static org.junit.Assert.*; import org.junit.Before; import org.junit.Test; public class JustBuyOnceStrategyTest { @Before public void setUp() throws Exception { } @Test public void testIfOnlyBuy(){ Strategy strategy = new JustBuyOnceStrategy(); Operation buy = new Operation(0,OperationType.BUY); assertEquals(buy, strategy.shouldEnter(0)); assertNull(strategy.shouldEnter(1)); assertNull(strategy.shouldExit(buy, 6)); } @Test public void testSameIndexShouldResultSameAwnser(){ Strategy strategy = new JustBuyOnceStrategy(); Operation buy = new Operation(0,OperationType.BUY); assertEquals(buy, strategy.shouldEnter(0)); assertEquals(buy, strategy.shouldEnter(0)); } } --- NEW FILE: MinValueStopperStrategyTest.java --- package net.sf.tail.strategy; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import net.sf.tail.Operation; import net.sf.tail.OperationType; import net.sf.tail.Strategy; import net.sf.tail.sample.SampleIndicator; import org.junit.Before; import org.junit.Test; public class MinValueStopperStrategyTest { private SampleIndicator indicator; @Before public void setUp() throws Exception { indicator = new SampleIndicator(new double[] {100,100,96,95,94}); } @Test public void testStopperShouldWork() { Strategy justBuy = new JustBuyOnceStrategy(); Strategy stopper = new MinValueStopperStrategy(indicator,justBuy,5); Operation buy = new Operation(0,OperationType.BUY); assertEquals(buy, stopper.shouldEnter(0)); assertNull(stopper.shouldExit(buy, 2)); assertNull(stopper.shouldExit(buy, 3)); Operation sell = new Operation(4,OperationType.SELL); assertEquals(sell, stopper.shouldExit(buy, 4)); } } |
|
From: Márcio V. d. S. <mv...@us...> - 2007-05-19 15:45:15
|
Update of /cvsroot/tail/Tail/src/java/net/sf/tail/strategy In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv20090/src/java/net/sf/tail/strategy Added Files: MinValueStopperStrategy.java JustBuyOnceStrategy.java Removed Files: StopDecoratorStrategy.java Log Message: Criado teste para o HistoryRunner Criado JustBuyOnceStrategy Criado MinvalueStopperStrategy --- StopDecoratorStrategy.java DELETED --- --- NEW FILE: JustBuyOnceStrategy.java --- package net.sf.tail.strategy; import net.sf.tail.Operation; import net.sf.tail.OperationType; import net.sf.tail.Strategy; public class JustBuyOnceStrategy implements Strategy { private boolean buyed; private int buyedIndex; public JustBuyOnceStrategy() { buyed = false; } public Operation shouldEnter(int index) { if(!buyed || buyedIndex == index ){ buyed = true; buyedIndex = index; return new Operation(index, OperationType.BUY); } return null; } public Operation shouldExit(Operation entry, int index) { return null; } } --- NEW FILE: MinValueStopperStrategy.java --- package net.sf.tail.strategy; import net.sf.tail.Indicator; import net.sf.tail.Operation; import net.sf.tail.OperationType; import net.sf.tail.Strategy; /** * MinValueStopperStrategy baseia a compra em uma {@link Strategy} enviada como parâmetro, * registrando o valor do {@link Indicator} enviado como parâmetro no mesmo Ãndice de compra, * e baseia a venda nessa mesma {@link Strategy} desde que o valor registrado do {@link Indicator} * na compra não tenha um decréscimo maior que loss % * */ public class MinValueStopperStrategy implements Strategy { private Strategy strategy; private double loss; private Indicator<? extends Number> indicator; private double value; public MinValueStopperStrategy(Indicator<? extends Number> indicator, Strategy strategy, int loss) { this.strategy = strategy; this.loss = (double) loss; this.indicator = indicator; } public Operation shouldEnter(int index) { if (strategy.shouldEnter(index) == null) { return null; } value = indicator.getValue(index).doubleValue(); return strategy.shouldEnter(index); } public Operation shouldExit(Operation entry, int index) { if (value - (value * (loss / 100)) > indicator.getValue(index).doubleValue()) { return new Operation(index, OperationType.SELL); } return strategy.shouldExit(entry, index); } public double getLoss() { return loss; } public Strategy getStrategy() { return strategy; } } |
|
From: Márcio V. d. S. <mv...@us...> - 2007-05-19 15:45:15
|
Update of /cvsroot/tail/Tail/src/test/net/sf/tail/runner In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv20090/src/test/net/sf/tail/runner Modified Files: HistoryRunnerTest.java Log Message: Criado teste para o HistoryRunner Criado JustBuyOnceStrategy Criado MinvalueStopperStrategy Index: HistoryRunnerTest.java =================================================================== RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/runner/HistoryRunnerTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** HistoryRunnerTest.java 19 May 2007 14:16:51 -0000 1.2 --- HistoryRunnerTest.java 19 May 2007 15:45:14 -0000 1.3 *************** *** 2,8 **** import static org.junit.Assert.assertEquals; - import java.util.List; - import net.sf.tail.Indicator; import net.sf.tail.Operation; --- 2,6 ---- *************** *** 12,16 **** import net.sf.tail.sample.SampleIndicator; import net.sf.tail.strategy.IndicatorOverIndicatorStrategy; - import org.junit.Before; import org.junit.Test; --- 10,13 ---- *************** *** 21,49 **** private Indicator<Double> second; ! private Strategy strategy; ! @Before public void setUp() throws Exception { ! first = new SampleIndicator(new double[] {4,7,9,6,3,2,3,3}); ! second = new SampleIndicator(new double[] {3,6,10,8,2,1,4,4}); strategy = new IndicatorOverIndicatorStrategy(first, second); } @Test ! public void testRun() { HistoryRunner historyRunner = new HistoryRunner(8); List<Trade> trades = historyRunner.run(strategy); assertEquals(2, trades.size()); ! Operation entry = new Operation(2,OperationType.BUY); ! Operation exit = new Operation(4,OperationType.SELL); ! Trade trade = new Trade(entry,exit); assertEquals(trade, trades.get(0)); ! ! entry = new Operation(6,OperationType.BUY); ! exit = new Operation(7,OperationType.SELL); ! trade = new Trade(entry,exit); assertEquals(trade, trades.get(1)); ! } --- 18,46 ---- private Indicator<Double> second; ! private Strategy strategy; ! @Before public void setUp() throws Exception { ! first = new SampleIndicator(new double[] { 4, 7, 9, 6, 3, 2, 3, 3 }); ! second = new SampleIndicator(new double[] { 3, 6, 10, 8, 2, 1, 4, 4 }); strategy = new IndicatorOverIndicatorStrategy(first, second); } @Test ! public void testRunMethod() { HistoryRunner historyRunner = new HistoryRunner(8); List<Trade> trades = historyRunner.run(strategy); assertEquals(2, trades.size()); ! Operation entry = new Operation(2, OperationType.BUY); ! Operation exit = new Operation(4, OperationType.SELL); ! Trade trade = new Trade(entry, exit); assertEquals(trade, trades.get(0)); ! ! entry = new Operation(6, OperationType.BUY); ! exit = new Operation(7, OperationType.SELL); ! trade = new Trade(entry, exit); assertEquals(trade, trades.get(1)); ! } |
|
From: Márcio V. d. S. <mv...@us...> - 2007-05-19 15:45:15
|
Update of /cvsroot/tail/Tail/src/java/net/sf/tail In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv20090/src/java/net/sf/tail Modified Files: Operation.java Log Message: Criado teste para o HistoryRunner Criado JustBuyOnceStrategy Criado MinvalueStopperStrategy Index: Operation.java =================================================================== RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/Operation.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Operation.java 19 May 2007 14:17:47 -0000 1.2 --- Operation.java 19 May 2007 15:45:13 -0000 1.3 *************** *** 6,9 **** --- 6,10 ---- private int index; + public Operation(int index, OperationType type) { this.type = type; *************** *** 29,31 **** --- 30,33 ---- } + } |