public void testUpdateIncapsulatedDataSeries() throws Exception {
    BarsDataSeriesFunction function = new BarsDataSeriesFunction();
    IDataSeries dataSeries = function.getSeries();

    assertEquals(0, dataSeries.getValues().length);

    Bar bar = new Bar(new Date(), TimeSpan.days(1), 10.0, 11.0, 9.0, 10.0, 1000L);
    function.append(bar);

    assertEquals(1, dataSeries.getValues().length);
    assertEquals(bar, dataSeries.getValues()[0]);
  }
Esempio n. 2
0
  /* (non-Javadoc)
   * @see org.eclipsetrader.ui.charts.IChartObjectFactory#createObject(org.eclipsetrader.core.charts.IDataSeries)
   */
  @Override
  public IChartObject createObject(IDataSeries source) {
    if (source == null) {
      return null;
    }

    IAdaptable[] values = source.getValues();
    Core core = Activator.getDefault() != null ? Activator.getDefault().getCore() : new Core();

    int lookback = core.cdl3OutsideLookback();
    if (values.length < lookback) {
      return null;
    }

    int startIdx = 0;
    int endIdx = values.length - 1;
    double[] inOpen = Util.getValuesForField(values, OHLCField.Open);
    double[] inHigh = Util.getValuesForField(values, OHLCField.High);
    double[] inLow = Util.getValuesForField(values, OHLCField.Low);
    double[] inClose = Util.getValuesForField(values, OHLCField.Close);

    MInteger outBegIdx = new MInteger();
    MInteger outNbElement = new MInteger();
    int[] outInteger = new int[values.length - lookback];

    core.cdl3Outside(
        startIdx, endIdx, inOpen, inHigh, inLow, inClose, outBegIdx, outNbElement, outInteger);

    return new PatternChart(getName(), values, lookback, outInteger);
  }