ta4j-examples/src/main/java/ta4jexamples/walkforward/WalkForward.java
public static List<TimeSeries> splitSeries(TimeSeries series, Duration splitDuration, Duration sliceDuration) {
        ArrayList<TimeSeries> subseries = new ArrayList<>();
        if (splitDuration != null && !splitDuration.isZero()
                && sliceDuration != null && !sliceDuration.isZero()) {

            List<Integer> beginIndexes = getSplitBeginIndexes(series, splitDuration);
            for (Integer subseriesBegin : beginIndexes) {
                subseries.add(subseries(series, subseriesBegin, sliceDuration));
            }
        }
        return subseries;
    }
public static List<TimeSeries> splitSeries(TimeSeries series, Duration splitDuration, Duration sliceDuration) {
        ArrayList<TimeSeries> subseries = new ArrayList<>();
        if (splitDuration != null && !splitDuration.isZero()
                && sliceDuration != null && !sliceDuration.isZero()) {

            List<Integer> beginIndexes = getSplitBeginIndexes(series, splitDuration);
            for (Integer subseriesBegin : beginIndexes) {
                subseries.add(subseries(series, subseriesBegin, sliceDuration));
            }
        }
        return subseries;
    }
public static List < TimeSeries > splitSeries ( TimeSeries series , Duration splitDuration , Duration sliceDuration ) { ArrayList < TimeSeries > subseries = new ArrayList <> ( ) ; if ( splitDuration != null && ! splitDuration . isZero ( ) && sliceDuration != null && ! sliceDuration . isZero ( ) ) { List < Integer > beginIndexes = getSplitBeginIndexes ( series , splitDuration ) ; for ( Integer subseriesBegin : beginIndexes ) { subseries . add ( subseries ( series , subseriesBegin , sliceDuration ) ) ; } } return subseries ; }
Splits the time series into sub-series lasting sliceDuration.<br>
The current time series is splitted every splitDuration.<br>
The last sub-series may last less than sliceDuration.
@param series the time series to split
@param splitDuration the duration between 2 splits
@param sliceDuration the duration of each sub-series
@return a list of sub-series
Splits the time series into sub - series lasting sliceDuration . <br > The current time series is splitted every splitDuration . <br > The last sub - series may last less than sliceDuration .