use of org.ta4j.core.analysis.criteria.TotalProfitCriterion in project ta4j by ta4j.
the class CCICorrectionStrategy method main.
public static void main(String[] args) {
// Getting the time series
TimeSeries series = CsvTradesLoader.loadBitstampSeries();
// Building the trading strategy
Strategy strategy = buildStrategy(series);
// Running the strategy
TimeSeriesManager seriesManager = new TimeSeriesManager(series);
TradingRecord tradingRecord = seriesManager.run(strategy);
System.out.println("Number of trades for the strategy: " + tradingRecord.getTradeCount());
// Analysis
System.out.println("Total profit for the strategy: " + new TotalProfitCriterion().calculate(series, tradingRecord));
}
use of org.ta4j.core.analysis.criteria.TotalProfitCriterion in project ta4j by ta4j.
the class GlobalExtremaStrategy method main.
public static void main(String[] args) {
// Getting the time series
TimeSeries series = CsvTradesLoader.loadBitstampSeries();
// Building the trading strategy
Strategy strategy = buildStrategy(series);
// Running the strategy
TimeSeriesManager seriesManager = new TimeSeriesManager(series);
TradingRecord tradingRecord = seriesManager.run(strategy);
System.out.println("Number of trades for the strategy: " + tradingRecord.getTradeCount());
// Analysis
System.out.println("Total profit for the strategy: " + new TotalProfitCriterion().calculate(series, tradingRecord));
}
use of org.ta4j.core.analysis.criteria.TotalProfitCriterion in project ta4j by ta4j.
the class MovingMomentumStrategy method main.
public static void main(String[] args) {
// Getting the time series
TimeSeries series = CsvTradesLoader.loadBitstampSeries();
// Building the trading strategy
Strategy strategy = buildStrategy(series);
// Running the strategy
TimeSeriesManager seriesManager = new TimeSeriesManager(series);
TradingRecord tradingRecord = seriesManager.run(strategy);
System.out.println("Number of trades for the strategy: " + tradingRecord.getTradeCount());
// Analysis
System.out.println("Total profit for the strategy: " + new TotalProfitCriterion().calculate(series, tradingRecord));
}
use of org.ta4j.core.analysis.criteria.TotalProfitCriterion in project ta4j by ta4j.
the class RSI2Strategy method main.
public static void main(String[] args) {
// Getting the time series
TimeSeries series = CsvTradesLoader.loadBitstampSeries();
// Building the trading strategy
Strategy strategy = buildStrategy(series);
// Running the strategy
TimeSeriesManager seriesManager = new TimeSeriesManager(series);
TradingRecord tradingRecord = seriesManager.run(strategy);
System.out.println("Number of trades for the strategy: " + tradingRecord.getTradeCount());
// Analysis
System.out.println("Total profit for the strategy: " + new TotalProfitCriterion().calculate(series, tradingRecord));
}
use of org.ta4j.core.analysis.criteria.TotalProfitCriterion in project ta4j by ta4j.
the class WalkForward method main.
public static void main(String[] args) {
// Splitting the series into slices
TimeSeries series = CsvTradesLoader.loadBitstampSeries();
List<TimeSeries> subseries = splitSeries(series, Duration.ofHours(6), Duration.ofDays(7));
// Building the map of strategies
Map<Strategy, String> strategies = buildStrategiesMap(series);
// The analysis criterion
AnalysisCriterion profitCriterion = new TotalProfitCriterion();
for (TimeSeries slice : subseries) {
// For each sub-series...
System.out.println("Sub-series: " + slice.getSeriesPeriodDescription());
TimeSeriesManager sliceManager = new TimeSeriesManager(slice);
for (Map.Entry<Strategy, String> entry : strategies.entrySet()) {
Strategy strategy = entry.getKey();
String name = entry.getValue();
// For each strategy...
TradingRecord tradingRecord = sliceManager.run(strategy);
double profit = profitCriterion.calculate(slice, tradingRecord);
System.out.println("\tProfit for " + name + ": " + profit);
}
Strategy bestStrategy = profitCriterion.chooseBest(sliceManager, new ArrayList<Strategy>(strategies.keySet()));
System.out.println("\t\t--> Best strategy: " + strategies.get(bestStrategy) + "\n");
}
}
Aggregations