List of usage examples for org.jfree.data.time RegularTimePeriod next
public abstract RegularTimePeriod next();
null
if some limit has been reached. From source file:info.financialecology.finance.utilities.datastruct.VersatileTimeSeries.java
/** * Creates a new time series with the natural logarithm (base e) of values of each data * point of this time series. /*from w w w . j a v a 2 s .c o m*/ * * @param name the label of the new time series * @return a new time series with the log values */ public VersatileTimeSeries operatorLn(String name) { VersatileTimeSeries ats = new VersatileTimeSeries(name); RegularTimePeriod currentTime = getTimePeriod(0); for (int i = 0; i < this.getItemCount(); i++) { ats.add(currentTime, Math.log(this.getValue(i).doubleValue())); currentTime = currentTime.next(); } return ats; }
From source file:info.financialecology.finance.utilities.datastruct.VersatileTimeSeries.java
/** * Creates a new time series by applying the first-order backward difference * operator to this time series. This can be used for instance to compute the * log returns series from log prices.//ww w . jav a2 s . c om * * @param name the label of the new time series * @return a new time series with the difference values */ public VersatileTimeSeries operatorDifference(String name) { VersatileTimeSeries ats = new VersatileTimeSeries(name); RegularTimePeriod currentTime = getTimePeriod(0); RegularTimePeriod startTime = getTimePeriod(0); ats.add(currentTime, 0); for (int i = 1; i < this.getItemCount(); i++) { currentTime = currentTime.next(); ats.add(currentTime, this.getValue(i).doubleValue() - this.getValue(i - 1).doubleValue()); } ats.update(startTime, ats.getValue(1)); // Difference not defined for first data point, so choose the simplest interpolation return ats; }
From source file:com.afunms.system.manage.equipManager.java
/** * Creates a sample dataset./*from w ww . ja va 2s. co m*/ * * @param count * the item count. * * @return the dataset. */ private XYDataset createForceDataset(final int count) { final TimeSeriesCollection dataset = new TimeSeriesCollection(); final TimeSeries s1 = new TimeSeries("", Minute.class); RegularTimePeriod start = new Minute(); double force = 3.0; for (int i = 0; i < count; i++) { s1.add(start, force); start = start.next(); force = Math.max(0.5, force + (Math.random() - 0.5) * 0.5); } dataset.addSeries(s1); return dataset; }
From source file:com.afunms.system.manage.equipManager.java
/** * Creates a sample dataset.// w w w .j av a 2s . com * * @param count * the item count. * * @return the dataset. */ private XYDataset createDirectionDataset(final int count) { final TimeSeriesCollection dataset = new TimeSeriesCollection(); final TimeSeries s1 = new TimeSeries("", Minute.class); RegularTimePeriod start = new Minute(); double direction = 180.0; for (int i = 0; i < count; i++) { s1.add(start, direction); start = start.next(); direction = direction + (Math.random() - 0.5) * 15.0; if (direction < 0.0) { direction = direction + 360.0; } else if (direction > 360.0) { direction = direction - 360.0; } } dataset.addSeries(s1); return dataset; }
From source file:info.financialecology.finance.utilities.datastruct.VersatileTimeSeries.java
/** * Constructs a time series object with the unique identifier <code>key</code> * and values taken from the double array <code>dal</code>. * //from ww w . j a va 2 s.co m * @param key the unique identifier of the time series * @param dal the values provided as a double array * @param startTime optional startTime of the series */ public VersatileTimeSeries(String key, DoubleArrayList dal, RegularTimePeriod... startTimeOpt) { super(key); internalParams = new InternalParams(); RegularTimePeriod currentTime; if (startTimeOpt.length != 0) { Assertion.assertStrict(startTimeOpt.length == 1, Level.ERR, "Only one " + "optional argument allowed for startTime, but " + startTimeOpt.length + " provided"); currentTime = startTimeOpt[0]; if (currentTime instanceof org.jfree.data.time.Second) this.getInternalParams().overrideTimePeriod(TIME_PERIOD.SECOND); else if (currentTime instanceof org.jfree.data.time.Minute) this.getInternalParams().overrideTimePeriod(TIME_PERIOD.MINUTE); else if (currentTime instanceof org.jfree.data.time.Hour) this.getInternalParams().overrideTimePeriod(TIME_PERIOD.HOUR); else if (currentTime instanceof org.jfree.data.time.Day) this.getInternalParams().overrideTimePeriod(TIME_PERIOD.DAY); else if (currentTime instanceof org.jfree.data.time.Week) this.getInternalParams().overrideTimePeriod(TIME_PERIOD.WEEK); else if (currentTime instanceof org.jfree.data.time.Month) this.getInternalParams().overrideTimePeriod(TIME_PERIOD.MONTH); else if (currentTime instanceof org.jfree.data.time.Quarter) this.getInternalParams().overrideTimePeriod(TIME_PERIOD.QUARTER); else if (currentTime instanceof org.jfree.data.time.Year) this.getInternalParams().overrideTimePeriod(TIME_PERIOD.YEAR); else Assertion.assertOrKill(false, "The time period " + currentTime.getClass() + " is not implemented "); } else { // set a default start time if not provided by caller currentTime = new Day(1, 1, 2014); this.getInternalParams().overrideTimePeriod(TIME_PERIOD.DAY); } for (int i = 0; i < dal.size(); i++) { this.add(currentTime, dal.get(i)); currentTime = currentTime.next(); } }
From source file:info.financialecology.finance.utilities.datastruct.VersatileTimeSeries.java
/** * Constructs a time series object with the unique identifier <code>key</code> * and values taken from the DoubleTimeSeries <code>dts</code>. * /*www . jav a 2 s .c om*/ * @param key the unique identifier of the time series * @param dts the values provided as a {@link DoubleTimeSeries} * @param startTime optional startTime of the series */ public VersatileTimeSeries(String key, DoubleTimeSeries dts, RegularTimePeriod... startTimeOpt) { super(key); internalParams = new InternalParams(); RegularTimePeriod currentTime; if (startTimeOpt.length != 0) { Assertion.assertOrKill(startTimeOpt.length == 1, "Only one " + "optional argument allowed for startTime, but " + startTimeOpt.length + " provided"); currentTime = startTimeOpt[0]; if (currentTime instanceof org.jfree.data.time.Second) this.getInternalParams().overrideTimePeriod(TIME_PERIOD.SECOND); else if (currentTime instanceof org.jfree.data.time.Minute) this.getInternalParams().overrideTimePeriod(TIME_PERIOD.MINUTE); else if (currentTime instanceof org.jfree.data.time.Hour) this.getInternalParams().overrideTimePeriod(TIME_PERIOD.HOUR); else if (currentTime instanceof org.jfree.data.time.Day) this.getInternalParams().overrideTimePeriod(TIME_PERIOD.DAY); else if (currentTime instanceof org.jfree.data.time.Week) this.getInternalParams().overrideTimePeriod(TIME_PERIOD.WEEK); else if (currentTime instanceof org.jfree.data.time.Month) this.getInternalParams().overrideTimePeriod(TIME_PERIOD.MONTH); else if (currentTime instanceof org.jfree.data.time.Quarter) this.getInternalParams().overrideTimePeriod(TIME_PERIOD.QUARTER); else if (currentTime instanceof org.jfree.data.time.Year) this.getInternalParams().overrideTimePeriod(TIME_PERIOD.YEAR); else Assertion.assertOrKill(false, "The time period " + currentTime.getClass() + " is not implemented "); } else { // set a default start time if not provided by caller currentTime = new Day(1, 1, 2014); // TODO set this to TICK once the class is implemented this.getInternalParams().overrideTimePeriod(TIME_PERIOD.DAY); } for (int i = 0; i < dts.size(); i++) { this.add(currentTime, dts.getValue(i)); currentTime = currentTime.next(); } }