Update of /cvsroot/tail/Tail/src/java/net/sf/tail/strategy
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv9952/src/java/net/sf/tail/strategy
Added Files:
StopDecoratorStrategy.java IndicatorOverIndicatorStrategy.java
Log Message:
Movendo o pacote strategy do teste para o src
--- NEW FILE: StopDecoratorStrategy.java ---
package net.sf.tail.strategy;
import net.sf.tail.Operation;
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);
}
public double getLoss() {
return loss;
}
public Strategy getStrategy() {
return strategy;
}
}
--- NEW FILE: IndicatorOverIndicatorStrategy.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;
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;
}
}
|