Update of /cvsroot/tail/Tail/src/java/net/sf/tail/runner
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv20260/src/java/net/sf/tail/runner
Modified Files:
HistoryRunner.java Runner.java
Log Message:
Refatorao do Walker para Evaluator e criao dos testes.
Index: HistoryRunner.java
===================================================================
RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/runner/HistoryRunner.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** HistoryRunner.java 10 Jun 2007 17:01:06 -0000 1.6
--- HistoryRunner.java 5 Jul 2007 16:12:16 -0000 1.7
***************
*** 12,31 ****
public class HistoryRunner implements Runner {
- private int seriesSize;
-
private OperationType operationType;
private static final Logger LOG = Logger.getLogger(HistoryRunner.class);
! public HistoryRunner(int seriesSize, OperationType type) {
! this.seriesSize = seriesSize;
this.operationType = type;
}
! public List<Trade> run(Strategy strategy) {
LOG.info("running strategy " + strategy);
List<Trade> trades = new ArrayList<Trade>();
Trade lastTrade = new Trade(operationType);
! for (int i = 0; i < seriesSize; i++) {
if (strategy.shouldOperate(lastTrade, i) && lastTrade.isClosed()) {
trades.add(lastTrade);
--- 12,28 ----
public class HistoryRunner implements Runner {
private OperationType operationType;
private static final Logger LOG = Logger.getLogger(HistoryRunner.class);
! public HistoryRunner(OperationType type) {
this.operationType = type;
}
! public List<Trade> run(Strategy strategy, int start, int end) {
LOG.info("running strategy " + strategy);
List<Trade> trades = new ArrayList<Trade>();
Trade lastTrade = new Trade(operationType);
! for (int i = Math.max(start, 0); i < end; i++) {
if (strategy.shouldOperate(lastTrade, i) && lastTrade.isClosed()) {
trades.add(lastTrade);
***************
*** 35,41 ****
}
if (lastTrade.isOpened()) {
! lastTrade.exit(seriesSize - 1);
! LOG.debug("new trade for closing time: " + lastTrade);
! trades.add(lastTrade);
}
LOG.info("strategy run " + strategy);
--- 32,39 ----
}
if (lastTrade.isOpened()) {
! if (lastTrade.exit(end - 1)) {
! LOG.debug("new trade for closing time: " + lastTrade);
! trades.add(lastTrade);
! }
}
LOG.info("strategy run " + strategy);
***************
*** 44,50 ****
}
- public int getSeriesSize() {
- return seriesSize;
- }
-
}
--- 42,44 ----
Index: Runner.java
===================================================================
RCS file: /cvsroot/tail/Tail/src/java/net/sf/tail/runner/Runner.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Runner.java 18 May 2007 19:25:24 -0000 1.1
--- Runner.java 5 Jul 2007 16:12:16 -0000 1.2
***************
*** 8,11 ****
public interface Runner {
! List<Trade> run(Strategy strategy);
}
--- 8,11 ----
public interface Runner {
! List<Trade> run(Strategy strategy, int start, int end);
}
|