当前位置: 首页>>代码示例>>Java>>正文


Java StandardDeviationIndicator类代码示例

本文整理汇总了Java中org.ta4j.core.indicators.statistics.StandardDeviationIndicator的典型用法代码示例。如果您正苦于以下问题:Java StandardDeviationIndicator类的具体用法?Java StandardDeviationIndicator怎么用?Java StandardDeviationIndicator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


StandardDeviationIndicator类属于org.ta4j.core.indicators.statistics包,在下文中一共展示了StandardDeviationIndicator类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: PercentBIndicator

import org.ta4j.core.indicators.statistics.StandardDeviationIndicator; //导入依赖的package包/类
/**
 * Constructor.
 * @param indicator an indicator (usually close price)
 * @param timeFrame the time frame
 * @param k the K multiplier (usually 2.0)
 */
public PercentBIndicator(Indicator<Decimal> indicator, int timeFrame, Decimal k) {
    super(indicator);
    this.indicator = indicator;
    this.bbm = new BollingerBandsMiddleIndicator(new SMAIndicator(indicator, timeFrame));
    StandardDeviationIndicator sd = new StandardDeviationIndicator(indicator, timeFrame);
    this.bbu = new BollingerBandsUpperIndicator(bbm, sd, k);
    this.bbl = new BollingerBandsLowerIndicator(bbm, sd, k);;
}
 
开发者ID:ta4j,项目名称:ta4j,代码行数:15,代码来源:PercentBIndicator.java

示例2: bollingerBandWidthUsingSMAAndStandardDeviation

import org.ta4j.core.indicators.statistics.StandardDeviationIndicator; //导入依赖的package包/类
@Test
public void bollingerBandWidthUsingSMAAndStandardDeviation() {

    SMAIndicator sma = new SMAIndicator(closePrice, 5);
    StandardDeviationIndicator standardDeviation = new StandardDeviationIndicator(closePrice, 5);
    
    BollingerBandsMiddleIndicator bbmSMA = new BollingerBandsMiddleIndicator(sma);
    BollingerBandsUpperIndicator bbuSMA = new BollingerBandsUpperIndicator(bbmSMA, standardDeviation);
    BollingerBandsLowerIndicator bblSMA = new BollingerBandsLowerIndicator(bbmSMA, standardDeviation);

    BollingerBandWidthIndicator bandwidth = new BollingerBandWidthIndicator(bbuSMA, bbmSMA, bblSMA);
    
    assertDecimalEquals(bandwidth.getValue(0), 0.0);
    assertDecimalEquals(bandwidth.getValue(1), 36.3636);
    assertDecimalEquals(bandwidth.getValue(2), 66.6423);
    assertDecimalEquals(bandwidth.getValue(3), 60.2443);
    assertDecimalEquals(bandwidth.getValue(4), 71.0767);
    assertDecimalEquals(bandwidth.getValue(5), 69.9394);
    assertDecimalEquals(bandwidth.getValue(6), 62.7043);
    assertDecimalEquals(bandwidth.getValue(7), 56.0178);
    assertDecimalEquals(bandwidth.getValue(8), 27.683);
    assertDecimalEquals(bandwidth.getValue(9), 12.6491);
    assertDecimalEquals(bandwidth.getValue(10), 12.6491);
    assertDecimalEquals(bandwidth.getValue(11), 24.2956);
    assertDecimalEquals(bandwidth.getValue(12), 68.3332);
    assertDecimalEquals(bandwidth.getValue(13), 85.1469);
    assertDecimalEquals(bandwidth.getValue(14), 112.8481);
    assertDecimalEquals(bandwidth.getValue(15), 108.1682);
    assertDecimalEquals(bandwidth.getValue(16), 66.9328);
    assertDecimalEquals(bandwidth.getValue(17), 56.5194);
    assertDecimalEquals(bandwidth.getValue(18), 28.1091);
    assertDecimalEquals(bandwidth.getValue(19), 32.5362);
}
 
开发者ID:ta4j,项目名称:ta4j,代码行数:34,代码来源:BollingerBandWidthIndicatorTest.java

示例3: bollingerBandsUpperUsingSMAAndStandardDeviation

import org.ta4j.core.indicators.statistics.StandardDeviationIndicator; //导入依赖的package包/类
@Test
public void bollingerBandsUpperUsingSMAAndStandardDeviation() {

    BollingerBandsMiddleIndicator bbmSMA = new BollingerBandsMiddleIndicator(sma);
    StandardDeviationIndicator standardDeviation = new StandardDeviationIndicator(closePrice, timeFrame);
    BollingerBandsUpperIndicator bbuSMA = new BollingerBandsUpperIndicator(bbmSMA, standardDeviation);

    assertDecimalEquals(bbuSMA.getK(), 2);

    assertDecimalEquals(bbuSMA.getValue(0), 1);
    assertDecimalEquals(bbuSMA.getValue(1), 2.5);
    assertDecimalEquals(bbuSMA.getValue(2), 3.633);
    assertDecimalEquals(bbuSMA.getValue(3), 4.633);
    assertDecimalEquals(bbuSMA.getValue(4), 4.2761);
    assertDecimalEquals(bbuSMA.getValue(5), 4.6094);
    assertDecimalEquals(bbuSMA.getValue(6), 5.633);
    assertDecimalEquals(bbuSMA.getValue(7), 5.2761);
    assertDecimalEquals(bbuSMA.getValue(8), 5.633);
    assertDecimalEquals(bbuSMA.getValue(9), 4.2761);

    BollingerBandsUpperIndicator bbuSMAwithK = new BollingerBandsUpperIndicator(bbmSMA, standardDeviation, Decimal.valueOf("1.5"));

    assertDecimalEquals(bbuSMAwithK.getK(), 1.5);

    assertDecimalEquals(bbuSMAwithK.getValue(0), 1);
    assertDecimalEquals(bbuSMAwithK.getValue(1), 2.25);
    assertDecimalEquals(bbuSMAwithK.getValue(2), 3.2247);
    assertDecimalEquals(bbuSMAwithK.getValue(3), 4.2247);
    assertDecimalEquals(bbuSMAwithK.getValue(4), 4.0404);
    assertDecimalEquals(bbuSMAwithK.getValue(5), 4.3737);
    assertDecimalEquals(bbuSMAwithK.getValue(6), 5.2247);
    assertDecimalEquals(bbuSMAwithK.getValue(7), 5.0404);
    assertDecimalEquals(bbuSMAwithK.getValue(8), 5.2247);
    assertDecimalEquals(bbuSMAwithK.getValue(9), 4.0404);
}
 
开发者ID:ta4j,项目名称:ta4j,代码行数:36,代码来源:BollingerBandsUpperIndicatorTest.java

示例4: bollingerBandsLowerUsingSMAAndStandardDeviation

import org.ta4j.core.indicators.statistics.StandardDeviationIndicator; //导入依赖的package包/类
@Test
public void bollingerBandsLowerUsingSMAAndStandardDeviation() {

    BollingerBandsMiddleIndicator bbmSMA = new BollingerBandsMiddleIndicator(sma);
    StandardDeviationIndicator standardDeviation = new StandardDeviationIndicator(closePrice, timeFrame);
    BollingerBandsLowerIndicator bblSMA = new BollingerBandsLowerIndicator(bbmSMA, standardDeviation);

    assertDecimalEquals(bblSMA.getK(), 2);

    assertDecimalEquals(bblSMA.getValue(0), 1);
    assertDecimalEquals(bblSMA.getValue(1), 0.5);
    assertDecimalEquals(bblSMA.getValue(2), 0.367);
    assertDecimalEquals(bblSMA.getValue(3), 1.367);
    assertDecimalEquals(bblSMA.getValue(4), 2.3905);
    assertDecimalEquals(bblSMA.getValue(5), 2.7239);
    assertDecimalEquals(bblSMA.getValue(6), 2.367);

    BollingerBandsLowerIndicator bblSMAwithK = new BollingerBandsLowerIndicator(bbmSMA, standardDeviation, Decimal.valueOf("1.5"));

    assertDecimalEquals(bblSMAwithK.getK(), 1.5);

    assertDecimalEquals(bblSMAwithK.getValue(0), 1);
    assertDecimalEquals(bblSMAwithK.getValue(1), 0.75);
    assertDecimalEquals(bblSMAwithK.getValue(2), 0.7752);
    assertDecimalEquals(bblSMAwithK.getValue(3), 1.7752);
    assertDecimalEquals(bblSMAwithK.getValue(4), 2.6262);
    assertDecimalEquals(bblSMAwithK.getValue(5), 2.9595);
    assertDecimalEquals(bblSMAwithK.getValue(6), 2.7752);
}
 
开发者ID:ta4j,项目名称:ta4j,代码行数:30,代码来源:BollingerBandsLowerIndicatorTest.java

示例5: main

import org.ta4j.core.indicators.statistics.StandardDeviationIndicator; //导入依赖的package包/类
public static void main(String[] args) {

        /**
         * Getting time series
         */
        TimeSeries series = CsvTicksLoader.loadAppleIncSeries();

        /**
         * Creating indicators
         */
        // Close price
        ClosePriceIndicator closePrice = new ClosePriceIndicator(series);
        EMAIndicator avg14 = new EMAIndicator(closePrice, 14);
        StandardDeviationIndicator sd14 = new StandardDeviationIndicator(closePrice, 14);

        // Bollinger bands
        BollingerBandsMiddleIndicator middleBBand = new BollingerBandsMiddleIndicator(avg14);
        BollingerBandsLowerIndicator lowBBand = new BollingerBandsLowerIndicator(middleBBand, sd14);
        BollingerBandsUpperIndicator upBBand = new BollingerBandsUpperIndicator(middleBBand, sd14);

        /**
         * Building chart dataset
         */
        TimeSeriesCollection dataset = new TimeSeriesCollection();
        dataset.addSeries(buildChartTimeSeries(series, closePrice, "Apple Inc. (AAPL) - NASDAQ GS"));
        dataset.addSeries(buildChartTimeSeries(series, lowBBand, "Low Bollinger Band"));
        dataset.addSeries(buildChartTimeSeries(series, upBBand, "High Bollinger Band"));

        /**
         * Creating the chart
         */
        JFreeChart chart = ChartFactory.createTimeSeriesChart(
                "Apple Inc. 2013 Close Prices", // title
                "Date", // x-axis label
                "Price Per Unit", // y-axis label
                dataset, // data
                true, // create legend?
                true, // generate tooltips?
                false // generate URLs?
                );
        XYPlot plot = (XYPlot) chart.getPlot();
        DateAxis axis = (DateAxis) plot.getDomainAxis();
        axis.setDateFormatOverride(new SimpleDateFormat("yyyy-MM-dd"));

        /**
         * Displaying the chart
         */
        displayChart(chart);
    }
 
开发者ID:ta4j,项目名称:ta4j,代码行数:50,代码来源:IndicatorsToChart.java

示例6: getStrategy

import org.ta4j.core.indicators.statistics.StandardDeviationIndicator; //导入依赖的package包/类
public Strategy getStrategy() {
	
	final ClosePriceIndicator closePrice = new ClosePriceIndicator(timeSeries);
	final SMAIndicator sma = new SMAIndicator(closePrice, bbPeriod);
	
	final BollingerBandsMiddleIndicator bbmiddle = new BollingerBandsMiddleIndicator(sma);
	final StandardDeviationIndicator sd = new StandardDeviationIndicator(closePrice, bbPeriod);
	 
	final BollingerBandsUpperIndicator bbup = new BollingerBandsUpperIndicator(bbmiddle, sd, Decimal.valueOf(deviationUp));
	final BollingerBandsUpperIndicator bbdown = new BollingerBandsUpperIndicator(bbmiddle, sd, Decimal.valueOf(deviationDown));

	final Rule buyingRule = new UnderIndicatorRule(closePrice, bbdown);
	final Rule sellingRule = new OverIndicatorRule(closePrice, bbup).or(new StopLossRule(closePrice, Decimal.valueOf(2)));

	final BaseStrategy strategy = new BaseStrategy(buyingRule, sellingRule);
	
	return strategy;
}
 
开发者ID:jnidzwetzki,项目名称:crypto-bot,代码行数:19,代码来源:BBreakoutStrategy.java


注:本文中的org.ta4j.core.indicators.statistics.StandardDeviationIndicator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。