/** * Creates a new second. * * @param second the second (0-59). * @param minute the minute (0-59). * @param hour the hour (0-23). * @param day the day (1-31). * @param month the month (1-12). * @param year the year (1900-9999). */ public Second(int second, int minute, int hour, int day, int month, int year) { this(second, new Minute(minute, hour, day, month, year)); }
/** * Creates a new second. * * @param second the second (0-59). * @param minute the minute (0-59). * @param hour the hour (0-23). * @param day the day (1-31). * @param month the month (1-12). * @param year the year (1900-9999). */ public Second(int second, int minute, int hour, int day, int month, int year) { this(second, new Minute(minute, hour, day, month, year)); }
/** * Returns the minute. * * @return The minute (never <code>null</code>). */ public Minute getMinute() { return new Minute(this.minute, new Hour(this.hour, this.day)); }
/** * Returns the minute. * * @return The minute (never {@code null}). */ public Minute getMinute() { return new Minute(this.minute, new Hour(this.hour, this.day)); }
int minute = Integer.parseInt(minstr); if ((minute >= 0) && (minute <= 59)) { result = new Minute(minute, new Hour(hour, day));
/** * Returns the minute preceding this one. * * @return The minute preceding this one. */ public RegularTimePeriod previous() { Minute result; if (this.minute != FIRST_MINUTE_IN_HOUR) { result = new Minute(this.minute - 1, getHour()); } else { Hour h = (Hour) getHour().previous(); if (h != null) { result = new Minute(LAST_MINUTE_IN_HOUR, h); } else { result = null; } } return result; }
/** * Returns the minute preceding this one. * * @return The minute preceding this one. */ @Override public RegularTimePeriod previous() { Minute result; if (this.minute != FIRST_MINUTE_IN_HOUR) { result = new Minute(this.minute - 1, getHour()); } else { Hour h = (Hour) getHour().previous(); if (h != null) { result = new Minute(LAST_MINUTE_IN_HOUR, h); } else { result = null; } } return result; }
/** * Returns the minute following this one. * * @return The minute following this one. */ @Override public RegularTimePeriod next() { Minute result; if (this.minute != LAST_MINUTE_IN_HOUR) { result = new Minute(this.minute + 1, getHour()); } else { // we are at the last minute in the hour... Hour nextHour = (Hour) getHour().next(); if (nextHour != null) { result = new Minute(FIRST_MINUTE_IN_HOUR, nextHour); } else { result = null; } } return result; }
/** * Returns the minute following this one. * * @return The minute following this one. */ public RegularTimePeriod next() { Minute result; if (this.minute != LAST_MINUTE_IN_HOUR) { result = new Minute(this.minute + 1, getHour()); } else { // we are at the last minute in the hour... Hour nextHour = (Hour) getHour().next(); if (nextHour != null) { result = new Minute(FIRST_MINUTE_IN_HOUR, nextHour); } else { result = null; } } return result; }
int minute = Integer.parseInt(minstr); if ((minute >= 0) && (minute <= 59)) { result = new Minute(minute, new Hour(hour, day));
if ((minute >= 0) && (minute <= 59)) { Minute m = new Minute(minute, new Hour(hour, day)); int second = Integer.parseInt(secstr); if ((second >= 0) && (second <= 59)) {
if ((minute >= 0) && (minute <= 59)) { Minute m = new Minute(minute, new Hour(hour, day)); int second = Integer.parseInt(secstr); if ((second >= 0) && (second <= 59)) {
private static org.jfree.data.time.TimeSeries buildChartTimeSeries(TimeSeries tickSeries, Indicator<Decimal> indicator, String name) { org.jfree.data.time.TimeSeries chartTimeSeries = new org.jfree.data.time.TimeSeries(name); for (int i = 0; i < tickSeries.getBarCount(); i++) { final Bar tick = tickSeries.getBar(i); chartTimeSeries.add(new Minute(Date.from(tick.getEndTime().toInstant())), indicator.getValue(i).doubleValue()); } return chartTimeSeries; }
/** * Builds a JFreeChart time series from a Ta4j time series and an indicator. * @param tickSeries the ta4j time series * @param indicator the indicator * @param name the name of the chart time series * @return the JFreeChart time series */ private static org.jfree.data.time.TimeSeries buildChartTimeSeries(TimeSeries tickSeries, Indicator<Decimal> indicator, String name) { org.jfree.data.time.TimeSeries chartTimeSeries = new org.jfree.data.time.TimeSeries(name); for (int i = 0; i < tickSeries.getTickCount(); i++) { Tick tick = tickSeries.getTick(i); chartTimeSeries.add(new Minute(Date.from(tick.getEndTime().toInstant())), indicator.getValue(i).toDouble()); } return chartTimeSeries; }
/** * Builds a JFreeChart time series from a Ta4j time series and an indicator. * @param tickSeries the ta4j time series * @param indicator the indicator * @param name the name of the chart time series * @return the JFreeChart time series */ private static org.jfree.data.time.TimeSeries buildChartTimeSeries(TimeSeries tickSeries, Indicator<Decimal> indicator, String name) { org.jfree.data.time.TimeSeries chartTimeSeries = new org.jfree.data.time.TimeSeries(name); for (int i = 0; i < tickSeries.getTickCount(); i++) { Tick tick = tickSeries.getTick(i); chartTimeSeries.add(new Minute(new Date(tick.getEndTime().toEpochSecond() * 1000)), indicator.getValue(i).toDouble()); } return chartTimeSeries; }
break; case 6: //Minute dataset.addOrUpdate(new Minute((Date)dcell) , new Double(ncell.toString())); break; case 7: //Second
Minute m0 = new Minute(0, new Hour(i, today)); Minute m1 = new Minute(15, new Hour(i, today)); Minute m2 = new Minute(30, new Hour(i, today)); Minute m3 = new Minute(45, new Hour(i, today)); Minute m4 = new Minute(0, new Hour(i + 1, today)); series1.add(new SimpleTimePeriod(m0.getStart(), m1.getStart()), Math.random()); series2.add(new SimpleTimePeriod(m1.getStart(), m2.getStart()), Math.random());
private static void addBuySellSignals(TimeSeries series, Strategy strategy, XYPlot plot) { // Running the strategy TimeSeriesManager seriesManager = new TimeSeriesManager(series); List<Trade> trades = seriesManager.run(strategy).getTrades(); // Adding markers to plot for (Trade trade : trades) { // Buy signal double buySignalTickTime = new Minute( Date.from(series.getBar(trade.getEntry().getIndex()).getEndTime().toInstant())) .getFirstMillisecond(); Marker buyMarker = new ValueMarker(buySignalTickTime); buyMarker.setPaint(Color.GREEN); buyMarker.setLabel("B"); plot.addDomainMarker(buyMarker); // Sell signal double sellSignalTickTime = new Minute( Date.from(series.getBar(trade.getExit().getIndex()).getEndTime().toInstant())) .getFirstMillisecond(); Marker sellMarker = new ValueMarker(sellSignalTickTime); sellMarker.setPaint(Color.RED); sellMarker.setLabel("S"); plot.addDomainMarker(sellMarker); } }
/** * Runs a strategy over a time series and adds the value markers * corresponding to buy/sell signals to the plot. * @param series a time series * @param strategy a trading strategy * @param plot the plot */ private static void addBuySellSignals(TimeSeries series, Strategy strategy, XYPlot plot) { // Running the strategy TimeSeriesManager seriesManager = new TimeSeriesManager(series); List<Trade> trades = seriesManager.run(strategy).getTrades(); // Adding markers to plot for (Trade trade : trades) { // Buy signal double buySignalTickTime = new Minute(Date.from(series.getTick(trade.getEntry().getIndex()).getEndTime().toInstant())).getFirstMillisecond(); Marker buyMarker = new ValueMarker(buySignalTickTime); buyMarker.setPaint(Color.GREEN); buyMarker.setLabel("B"); plot.addDomainMarker(buyMarker); // Sell signal double sellSignalTickTime = new Minute(Date.from(series.getTick(trade.getExit().getIndex()).getEndTime().toInstant())).getFirstMillisecond(); Marker sellMarker = new ValueMarker(sellSignalTickTime); sellMarker.setPaint(Color.RED); sellMarker.setLabel("S"); plot.addDomainMarker(sellMarker); } }
total += responseTimesMS[i][k].longValue(); dataset.add(new Minute(i, new Hour()), total, ac);