本文整理汇总了Java中eu.verdelhan.ta4j.TimeSeries.getTick方法的典型用法代码示例。如果您正苦于以下问题:Java TimeSeries.getTick方法的具体用法?Java TimeSeries.getTick怎么用?Java TimeSeries.getTick使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eu.verdelhan.ta4j.TimeSeries
的用法示例。
在下文中一共展示了TimeSeries.getTick方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createOHLCDataset
import eu.verdelhan.ta4j.TimeSeries; //导入方法依赖的package包/类
/**
* Builds a JFreeChart OHLC dataset from a ta4j time series.
* @param series a time series
* @return an Open-High-Low-Close dataset
*/
private static OHLCDataset createOHLCDataset(TimeSeries series) {
final int nbTicks = series.getTickCount();
Date[] dates = new Date[nbTicks];
double[] opens = new double[nbTicks];
double[] highs = new double[nbTicks];
double[] lows = new double[nbTicks];
double[] closes = new double[nbTicks];
double[] volumes = new double[nbTicks];
for (int i = 0; i < nbTicks; i++) {
Tick tick = series.getTick(i);
dates[i] = new Date(tick.getEndTime().toEpochSecond() * 1000);
opens[i] = tick.getOpenPrice().toDouble();
highs[i] = tick.getMaxPrice().toDouble();
lows[i] = tick.getMinPrice().toDouble();
closes[i] = tick.getClosePrice().toDouble();
volumes[i] = tick.getVolume().toDouble();
}
OHLCDataset dataset = new DefaultHighLowDataset("btc", dates, highs, lows, opens, closes, volumes);
return dataset;
}
示例2: for
import eu.verdelhan.ta4j.TimeSeries; //导入方法依赖的package包/类
/**
* 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.addOrUpdate(new Day(tick.getEndTime().toDate()),
indicator.getValue(i).toDouble());
}
return chartTimeSeries;
}
示例3: buildChartTimeSeries
import eu.verdelhan.ta4j.TimeSeries; //导入方法依赖的package包/类
/**
* 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;
}
示例4: buildChartTimeSeries
import eu.verdelhan.ta4j.TimeSeries; //导入方法依赖的package包/类
/**
* 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;
}
示例5: createAdditionalDataset
import eu.verdelhan.ta4j.TimeSeries; //导入方法依赖的package包/类
/**
* Builds an additional JFreeChart dataset from a ta4j time series.
* @param series a time series
* @return an additional dataset
*/
private static TimeSeriesCollection createAdditionalDataset(TimeSeries series) {
ClosePriceIndicator indicator = new ClosePriceIndicator(series);
TimeSeriesCollection dataset = new TimeSeriesCollection();
org.jfree.data.time.TimeSeries chartTimeSeries = new org.jfree.data.time.TimeSeries("Btc price");
for (int i = 0; i < series.getTickCount(); i++) {
Tick tick = series.getTick(i);
chartTimeSeries.add(new Second(new Date(tick.getEndTime().toEpochSecond() * 1000)), indicator.getValue(i).toDouble());
}
dataset.addSeries(chartTimeSeries);
return dataset;
}
示例6: buildChartTimeSeries
import eu.verdelhan.ta4j.TimeSeries; //导入方法依赖的package包/类
/**
* 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 Day(Date.from(tick.getEndTime().toInstant())), indicator.getValue(i).toDouble());
}
return chartTimeSeries;
}
示例7: testGetValue
import eu.verdelhan.ta4j.TimeSeries; //导入方法依赖的package包/类
@Test
public void testGetValue() {
TimeSeries data = new TimeSeries(StubDataTestUtils.createTickData("/TEST_COUNT_BACK_LINE_TC3.stub", DateTimeFormat.forPattern("dd-MM-YYYY")));
CountBackStopLossIndicator cbsl = new CountBackStopLossIndicator(data, data.getTick(4), 4);
// Fine grain checks for each index
assertNull(cbsl.getValue(0));
assertNull(cbsl.getValue(1));
assertNull(cbsl.getValue(2));
assertNull(cbsl.getValue(3));
assertNotNull(cbsl.getValue(4)); // <-- Entry tick
assertEquals(5.07, cbsl.getValue(4).toDouble(), 0.01);
assertNotNull(cbsl.getValue(5));
assertEquals(5.27, cbsl.getValue(5).toDouble(), 0.01);
assertNotNull(cbsl.getValue(6));
assertEquals(5.41, cbsl.getValue(6).toDouble(), 0.01);
assertNotNull(cbsl.getValue(7));
assertEquals(5.41, cbsl.getValue(7).toDouble(), 0.01);
assertNotNull(cbsl.getValue(8));
assertEquals(5.41, cbsl.getValue(8).toDouble(), 0.01);
assertNotNull(cbsl.getValue(9));
assertEquals(5.41, cbsl.getValue(9).toDouble(), 0.01);
assertNotNull(cbsl.getValue(10));
assertEquals(5.41, cbsl.getValue(10).toDouble(), 0.01);
assertNotNull(cbsl.getValue(11));
assertEquals(5.41, cbsl.getValue(11).toDouble(), 0.01);
assertNotNull(cbsl.getValue(12));
assertEquals(5.41, cbsl.getValue(12).toDouble(), 0.01);
assertNotNull(cbsl.getValue(13));
assertEquals(5.41, cbsl.getValue(13).toDouble(), 0.01);
assertNotNull(cbsl.getValue(14));
assertEquals(5.41, cbsl.getValue(14).toDouble(), 0.01);
assertNotNull(cbsl.getValue(15));
assertEquals(5.41, cbsl.getValue(15).toDouble(), 0.01);
assertNotNull(cbsl.getValue(16));
assertEquals(5.41, cbsl.getValue(16).toDouble(), 0.01);
assertNotNull(cbsl.getValue(17));
assertEquals(5.41, cbsl.getValue(17).toDouble(), 0.01);
assertNotNull(cbsl.getValue(18));
assertEquals(5.41, cbsl.getValue(18).toDouble(), 0.01);
assertNotNull(cbsl.getValue(19));
assertEquals(5.41, cbsl.getValue(19).toDouble(), 0.01);
assertNotNull(cbsl.getValue(20));
assertEquals(5.41, cbsl.getValue(20).toDouble(), 0.01);
assertNotNull(cbsl.getValue(21));
assertEquals(5.41, cbsl.getValue(21).toDouble(), 0.01);
assertNotNull(cbsl.getValue(22));
assertEquals(5.41, cbsl.getValue(22).toDouble(), 0.01);
assertNotNull(cbsl.getValue(23));
assertEquals(5.49, cbsl.getValue(23).toDouble(), 0.01);
assertNotNull(cbsl.getValue(24));
assertEquals(5.49, cbsl.getValue(24).toDouble(), 0.01);
assertNotNull(cbsl.getValue(25));
assertEquals(5.49, cbsl.getValue(25).toDouble(), 0.01);
assertNotNull(cbsl.getValue(26));
assertEquals(5.61, cbsl.getValue(26).toDouble(), 0.01);
assertNotNull(cbsl.getValue(27));
assertEquals(5.63, cbsl.getValue(27).toDouble(), 0.01);
assertNotNull(cbsl.getValue(28));
assertEquals(5.63, cbsl.getValue(28).toDouble(), 0.01);
assertNotNull(cbsl.getValue(29));
assertEquals(5.63, cbsl.getValue(29).toDouble(), 0.01);
assertNotNull(cbsl.getValue(30));
assertEquals(5.63, cbsl.getValue(30).toDouble(), 0.01);
assertNotNull(cbsl.getValue(31));
assertEquals(5.77, cbsl.getValue(31).toDouble(), 0.01);
assertNotNull(cbsl.getValue(32));
assertEquals(5.77, cbsl.getValue(32).toDouble(), 0.01);
}