Example #1
0
void LOWPASS::setIndicatorSettings (Setting &dict)
{
  setDefaults();
  
  if (! dict.count())
    return;
  
  QString s;
  dict.getData(colorLabel, s);
  if (s.length())
    color.setNamedColor(s);
    
  dict.getData(lineTypeLabel, s);
  if (s.length())
    lineType = (PlotLine::LineType) s.toInt();

  dict.getData(labelLabel, s);
  if (s.length())
    label = s;
      
  dict.getData(inputLabel, s);
  if (s.length())
    input = (BarData::InputType) s.toInt();

  dict.getData(freqLabel, s);
  if (s.length())
    freq = s.toFloat();
    
  dict.getData(widthLabel, s);
  if (s.length())
    width = s.toFloat();
}
Example #2
0
void ExScript::setIndicatorSettings (Setting &dict)
{
  setDefaults();
  
  if (! dict.count())
    return;
  
  QString s;
  dict.getData(colorLabel, s);
  if (s.length())
    color.setNamedColor(s);

  dict.getData(labelLabel, s);
  if (s.length())
    label = s;

  dict.getData(lineTypeLabel, s);
  if (s.length())
    lineType = (PlotLine::LineType) s.toInt();

  dict.getData(scriptPathLabel, s);
  if (s.length())
    scriptPath = s;

  dict.getData(comlineParmsLabel, s);
  if (s.length())
    comlineParms = s;

  dict.getData(dateLabel, s);
  if (s.length())
    dateFlag = s.toInt();

  dict.getData(openLabel, s);
  if (s.length())
    openFlag = s.toInt();

  dict.getData(highLabel, s);
  if (s.length())
    highFlag = s.toInt();

  dict.getData(lowLabel, s);
  if (s.length())
    lowFlag = s.toInt();

  dict.getData(closeLabel, s);
  if (s.length())
    closeFlag = s.toInt();

  dict.getData(volumeLabel, s);
  if (s.length())
    volumeFlag = s.toInt();

  dict.getData(oiLabel, s);
  if (s.length())
    oiFlag = s.toInt();

  dict.getData(timeoutLabel, s);
  if (s.length())
    seconds = s.toInt();
}
Example #3
0
void SINWAV::setIndicatorSettings (Setting &dict)
{
  setDefaults();

  if (! dict.count())
    return;

  QString s;
  dict.getData(colorSinLabel, s);
  if (s.length())
    colorSin.setNamedColor(s);

  dict.getData(colorLeadLabel, s);
  if (s.length())
    colorLead.setNamedColor(s);

  dict.getData(labelSinLabel, s);
  if (s.length())
    labelSin = s;

  dict.getData(labelLeadLabel, s);
  if (s.length())
    labelLead = s;

  dict.getData(lineTypeSinLabel, s);
  if (s.length())
    lineTypeSin = (PlotLine::LineType) s.toInt();

  dict.getData(lineTypeLeadLabel, s);
  if (s.length())
    lineTypeLead = (PlotLine::LineType) s.toInt();
}
Example #4
0
void THERM::setIndicatorSettings (Setting &dict)
{
  setDefaults();
  
  if (! dict.count())
    return;
  
  QString s;
  dict.getData(upColorLabel, s);
  if (s.length())
    upColor.setNamedColor(s);
    
  dict.getData(downColorLabel, s);
  if (s.length())
    downColor.setNamedColor(s);
  
  dict.getData(threshColorLabel, s);
  if (s.length())
    threshColor.setNamedColor(s);
  
  dict.getData(maColorLabel, s);
  if (s.length())
    maColor.setNamedColor(s);
    
  dict.getData(labelLabel, s);
  if (s.length())
    label = s;
    
  dict.getData(thresholdLabel, s);
  if (s.length())
    threshold = s.toFloat();
  
  dict.getData(smoothingLabel, s);
  if (s.length())
    smoothing = s.toInt();
  
  dict.getData(smoothTypeLabel, s);
  if (s.length())
    smoothType = s.toInt();
  
  dict.getData(maLineTypeLabel, s);
  if (s.length())
    maLineType = (PlotLine::LineType) s.toInt();

  dict.getData(maLabelLabel, s);
  if (s.length())
    maLabel = s;
    
  dict.getData(maPeriodLabel, s);
  if (s.length())
    maPeriod = s.toInt();

  dict.getData(maTypeLabel, s);
  if (s.length())
    maType = s.toInt();
}
Example #5
0
void TALIB::setIndicatorSettings (Setting &dict)
{
  setDefaults();
  
  if (! dict.count())
    return;

  QString s;
  dict.getString(s);
  parms.parse(s);
}
Example #6
0
void PP::setIndicatorSettings (Setting &dict)
{
  setDefaults();
  
  if (! dict.count())
    return;
  
  QString s;
  dict.getData(resColorLabel, s);
  if (s.length())
    resColor.setNamedColor(s);
    
  dict.getData(supColorLabel, s);
  if (s.length())
    supColor.setNamedColor(s);
  
  dict.getData(resLineTypeLabel, s);
  if (s.length())
    resLineType = (PlotLine::LineType) s.toInt();

  dict.getData(supLineTypeLabel, s);
  if (s.length())
    supLineType = (PlotLine::LineType) s.toInt();
  
  dict.getData(resLabelLabel, s);
  if (s.length())
    resLabel = s;
      
  dict.getData(resLabel2Label, s);
  if (s.length())
    resLabel2 = s;
  
  dict.getData(resLabel3Label, s);
  if (s.length())
    resLabel3 = s;

  dict.getData(supLabelLabel, s);
  if (s.length())
    supLabel = s;

  dict.getData(supLabel2Label, s);
  if (s.length())
    supLabel2 = s;

  dict.getData(supLabel3Label, s);
  if (s.length())
    supLabel3 = s;

  dict.getData(labelLabel, s);
  if (s.length())
    label = s;
}
Example #7
0
void CUS::setIndicatorSettings (Setting &dict)
{
  formulaList.clear();

  if (! dict.count())
    return;

  QString ts = "script";
  QString s;
  dict.getData(ts, s);
  if (s.length())
    formulaList = QStringList::split("|", s, FALSE);

  ts = "version";
  dict.getData(ts, s);
  if (s.length())
    version = s.toDouble();
}
Example #8
0
void CUS::includeCUS (QString &d, QStringList &rl)
{
  QStringList l = QStringList::split(")", d, FALSE);
  QStringList l2 = QStringList::split("(", l[0], FALSE);
  QString i = l2[1];
  i = i.stripWhiteSpace();

  Config config;
  QString s, s2;
  config.getData(Config::IndicatorPath, s);
  config.getData(Config::IndicatorGroup, s2);
  s.append("/" + s2 + "/" + i);

  Setting dict;
  config.getIndicator(s, dict);

  if (! dict.count())
    return;

  QString ts = "script";
  dict.getData(ts, s);
  if (s.length())
    rl = QStringList::split("|", s, FALSE);
}
Example #9
0
void BARS::setIndicatorSettings (Setting &dict)
{
  setDefaults();

  if (! dict.count())
    return;

  QString s;
  dict.getData(labelLabel, s);
  if (s.length())
    label = s;

  dict.getData(lineTypeLabel, s);
  if (s.length())
    lineType = (PlotLine::LineType) s.toInt();

  dict.getData(methodLabel, s);
  if (s.length())
    method = s;

  dict.getData(barUpColorLabel, s);
  if (s.length())
    barUpColor.setNamedColor(s);

  dict.getData(barDownColorLabel, s);
  if (s.length())
    barDownColor.setNamedColor(s);

  dict.getData(barNeutralColorLabel, s);
  if (s.length())
    barNeutralColor.setNamedColor(s);

  dict.getData(candleColorLabel, s);
  if (s.length())
    candleColor.setNamedColor(s);

  dict.getData(maColorLabel, s);
  if (s.length())
    maColor.setNamedColor(s);

  dict.getData(maLineTypeLabel, s);
  if (s.length())
    maLineType = (PlotLine::LineType) s.toInt();

  dict.getData(maPeriodLabel, s);
  if (s.length())
    maPeriod = s.toInt();

  dict.getData(maLabelLabel, s);
  if (s.length())
    maLabel = s;

  dict.getData(maTypeLabel, s);
  if (s.length())
    maType = s.toInt();

  dict.getData(maInputLabel, s);
  if (s.length())
    maInput = (BarData::InputType) s.toInt();

  dict.getData(maColor2Label, s);
  if (s.length())
    maColor2.setNamedColor(s);

  dict.getData(maLineType2Label, s);
  if (s.length())
    maLineType2 = (PlotLine::LineType) s.toInt();

  dict.getData(maPeriod2Label, s);
  if (s.length())
    maPeriod2 = s.toInt();

  dict.getData(maLabel2Label, s);
  if (s.length())
    maLabel2 = s;

  dict.getData(maType2Label, s);
  if (s.length())
    maType2 = s.toInt();

  dict.getData(maInput2Label, s);
  if (s.length())
    maInput2 = (BarData::InputType) s.toInt();

  dict.getData(maColor3Label, s);
  if (s.length())
    maColor3.setNamedColor(s);

  dict.getData(maLineType3Label, s);
  if (s.length())
    maLineType3 = (PlotLine::LineType) s.toInt();

  dict.getData(maPeriod3Label, s);
  if (s.length())
    maPeriod3 = s.toInt();

  dict.getData(maLabel3Label, s);
  if (s.length())
    maLabel3 = s;

  dict.getData(maType3Label, s);
  if (s.length())
    maType3 = s.toInt();

  dict.getData(maInput3Label, s);
  if (s.length())
    maInput3 = (BarData::InputType) s.toInt();

  dict.getData(maColor4Label, s);
  if (s.length())
    maColor4.setNamedColor(s);

  dict.getData(maLineType4Label, s);
  if (s.length())
    maLineType4 = (PlotLine::LineType) s.toInt();

  dict.getData(maPeriod4Label, s);
  if (s.length())
    maPeriod4 = s.toInt();

  dict.getData(maLabel4Label, s);
  if (s.length())
    maLabel4 = s;

  dict.getData(maType4Label, s);
  if (s.length())
    maType4 = s.toInt();

  dict.getData(maInput4Label, s);
  if (s.length())
    maInput4 = (BarData::InputType) s.toInt();

  dict.getData(pfXColorLabel, s);
  if (s.length())
    pfXColor.setNamedColor(s);

  dict.getData(pfOColorLabel, s);
  if (s.length())
    pfOColor.setNamedColor(s);

  dict.getData(pfReversalLabel, s);
  if (s.length())
    pfReversal = s.toInt();

  dict.getData(pfMethodLabel, s);
  if (s.length())
    pfMethod = s;
}
Example #10
0
void CSV::parse ()
{
  Setting rule;
  getRule(rule);

  if (! rule.count())
  {
    QString s(tr("Empty rule"));
    printStatusLogMessage(s);
    downloadComplete();
    return;
  }

  QString ts = "Rule";
  QString ts2, s;
  rule.getData(ts, ts2);
  if (! ts2.contains("Date:"))
  {
    QString ss(tr("Rule missing Date field"));
    printStatusLogMessage(ss);
    downloadComplete();
    return;
  }

  ts = "Delimiter";
  rule.getData(ts, s);
  if (! s.length())
  {
    QString ss(tr("Delimiter not found"));
    printStatusLogMessage(ss);
    downloadComplete();
    return;
  }
  setDelimiter(s);

  if (dateRange->isChecked())
  {
    if (sdate->date() >= edate->date() || edate->date() <= sdate->date())
    {
      QString ss = stringDone + " " + QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss");
      printStatusLogMessage(ss);
      downloadComplete();
      return;
    }
  }

  QString type;
  ts = "Type";
  rule.getData(ts, type);
  if (! type.length())
  {
    QString ss(tr("Type not found"));
    printStatusLogMessage(ss);
    downloadComplete();
    return;
  }

  ts = "Rule";
  rule.getData(ts, ts2);
  QStringList fieldList = QStringList::split(",", ts2, FALSE);
  if (! fieldList.count())
  {
    QString ss(tr("No rule found"));
    printStatusLogMessage(ss);
    downloadComplete();
    return;
  }

  // get the directory path offset
  ts = "Directory";
  QString directory;
  rule.getData(ts, directory);
  if (! directory.length())
  {
    QString ss(tr("Directory not found"));
    printStatusLogMessage(ss);
    downloadComplete();
    return;
  }

  // get the symbol filter
  ts = "SymbolFilter";
  rule.getData(ts, ts2);
  QStringList symbolFilter = QStringList::split(",", ts2, FALSE);

  // check for time field and set the tickflag
  bool tickFlag = FALSE;
  ts = "Rule";
  rule.getData(ts, ts2);
  if (ts2.contains("Time"))
    tickFlag = TRUE;
  else
  {
    if (ts2.contains("HHMMSS"))
      tickFlag = TRUE;
  }

  QStringList list;
  file->getFile(list);

  int loop;
  for (loop = 0; loop < (int) list.count(); loop++)
  {
    if (cancelFlag)
      break;

    QFile f(list[loop]);
    if (! f.open(QIODevice::ReadOnly))
      continue;
    Q3TextStream stream(&f);

    QString symbol = symbolOveride;
    if (! symbol.length() && fieldList.findIndex("Symbol") == -1)
    {
      QStringList l = QStringList::split("/", list[loop], FALSE);
      symbol = l[l.count() - 1];

      if (symbol.right(4).contains(".txt"))
        symbol.truncate(symbol.length() - 4);

      if (symbol.right(4).contains(".TXT"))
        symbol.truncate(symbol.length() - 4);

      while (symbol.contains("_"))
        symbol = symbol.remove(symbol.find("_", 0, TRUE), 1);
    }

    QString path;
    if (! type.compare("Stocks"))
    {
      QString tmp = "Stocks/" + directory;
      createDirectory(tmp, path);
      if (! path.length())
      {
        QString ss(tr("CSVPlugin::Unable to create directory"));
        printStatusLogMessage(ss);
        downloadComplete();
        f.close();
        return;
      }
    }
    else
    {
      if (! type.compare("Futures"))
      {
        QString tmp = "Futures/" + directory;
        createDirectory(tmp, path);
        if (! path.length())
        {
          QString ss(tr("CSVPlugin::Unable to create directory"));
          printStatusLogMessage(ss);
          downloadComplete();
          f.close();
          return;
        }
      }
    }

    path.append("/");

    if (symbol.length())
    {
      QString s = path;
      s.append(symbol);
      if (openDb(s, symbol, type, tickFlag))
        continue;
//      QString ss = tr("Updating") + " " + symbol;
//      printStatusLogMessage(ss);
        progressBar->setProgress(loop, (int) list.count());
    }

    int lineCount = 0;
    QFileInfo fi(f);
    QString fName = fi.fileName();
    while(stream.atEnd() == 0)
    {
      QString ts = stream.readLine();
      QStringList l = QStringList::split( '\n', substituteSeparator(ts, delim, '\n'), FALSE);

      lineCount++;
      if (l.count() != fieldList.count())
      {
        QString ss = QString().sprintf(
          "%s - %s - %s: %s Number of fields in file (%i) != rule format (%i)",
          fName.latin1(), symbol.latin1(), tr("Line").latin1(),
          QString::number(lineCount).latin1(),  l.count(), fieldList.count()
          );
        printStatusLogMessage(ss);
        continue;
      }

      int fieldLoop;
      bool flag = FALSE;
      Setting r;
      for (fieldLoop = 0; fieldLoop < (int) fieldList.count(); fieldLoop++)
      {
        QString listItem = l[fieldLoop].stripWhiteSpace();
        if (fieldList[fieldLoop].contains("Date:"))
	{
          QDate dt;
          getDate(fieldList[fieldLoop], listItem, r, dt);
          if (! dt.isValid())
	  {
            QString ss = QString().sprintf("%s - %s - %s: %s %s: %s",
              fName.latin1(), symbol.latin1(), tr("Line").latin1(), QString::number(lineCount).latin1(),
              tr("Bad date").latin1(), listItem.latin1()
              );
            printStatusLogMessage(ss);
	    flag = TRUE;
	    break;
	  }

          if (dateRange->isChecked())
          {
            if (dt < sdate->date() || dt > edate->date())
	    {
	      flag = TRUE;
	      break;
	    }
          }
          ts = "Date";
          ts2 = dt.toString("yyyyMMdd");
	  r.setData(ts, ts2);
	  continue;
	}

        if (! fieldList[fieldLoop].compare("Time"))
	{
          getTime(listItem, s);
          if (! s.length())
	  {
            QString ss = QString().sprintf("%s - %s - %s: %s %s: %s",
              fName.latin1(), symbol.latin1(), tr("Line").latin1(), QString::number(lineCount).latin1(),
              tr("Bad time").latin1(), listItem.latin1()
              );
            printStatusLogMessage(ss);
	    flag = TRUE;
	    break;
	  }
          ts = "Time";
	  r.setData(ts, s);
	  continue;
	}

        if (! fieldList[fieldLoop].compare("Symbol"))
	{
	  if (symbolFilter.count())
	  {
	    if (symbolFilter.findIndex(listItem) == -1)
	    {
	      flag = TRUE;
	      break;
	    }
	  }

          ts = "Symbol";
	  r.setData(ts, listItem);
	  continue;
	}

        if (! fieldList[fieldLoop].compare("Name"))
	{
          ts = "Name";
	  r.setData(ts, listItem);
	  continue;
	}

	if (! fieldList[fieldLoop].compare("Open") ||
	    ! fieldList[fieldLoop].compare("High") ||
	    ! fieldList[fieldLoop].compare("Low") ||
	    ! fieldList[fieldLoop].compare("Close"))
	{
          if (setTFloat(listItem, TRUE))
	  {
            QString ss = QString().sprintf("%s - %s - %s: %i %s: %s",
              fName.latin1(), symbol.latin1(), tr("Line").latin1(), lineCount,
              tr("Bad value").latin1(), tr(fieldList[fieldLoop]).latin1()
              );
            printStatusLogMessage(ss);
	    flag = TRUE;
	    break;
	  }
          ts = QString::number(tfloat);
	  r.setData(fieldList[fieldLoop], ts);
	  continue;
	}

	if (! fieldList[fieldLoop].compare("Volume") ||
	    ! fieldList[fieldLoop].compare("OI"))
	{
          if (setTFloat(listItem, FALSE))
	  {
            QString ss = QString().sprintf("%s - %s - %s: %s %s: %s",
              fName.latin1(), symbol.latin1(), tr("Line").latin1(), QString::number(lineCount).latin1(),
              tr("Bad value").latin1(), tr(fieldList[fieldLoop]).latin1()
              );
            printStatusLogMessage(ss);
	    flag = TRUE;
	    break;
	  }
          ts = QString::number(tfloat);
	  r.setData(fieldList[fieldLoop], ts);
	  continue;
	}
      }

      if (flag)
	continue;

      ts = "Date";
      r.getData(ts, s);
      if (! s.length())
	continue;

      ts = "Time";
      r.getData(ts, ts2);
      if (ts2.length())
        s.append(ts2);
      else
        s.append("000000");

      Bar bar;
      if (bar.setDate(s))
      {
        ts = "Date";
        r.getData(ts, ts2);
        QString ss = tr("Bad date") + " " + ts2;
        printStatusLogMessage(ss);
        continue;
      }
      bar.setTickFlag(tickFlag);
      ts = "Open";
      bar.setOpen(r.getDouble(ts));
      ts = "High";
      bar.setHigh(r.getDouble(ts));
      ts = "Low";
      bar.setLow(r.getDouble(ts));
      ts = "Close";
      bar.setClose(r.getDouble(ts));
      ts = "Volume";
      bar.setVolume(r.getDouble(ts));
      ts = "OI";
      bar.setOI(r.getInt(ts));

      DBIndexItem item;

      if (! symbol.length())
      {
        ts = "Symbol";
        QString t;
        r.getData(ts, t);
	s = path;
	s.append(t);
	if (openDb(s, t, type, tickFlag))
	  continue;

        ts = "Name";
	r.getData(ts, s);
	if (s.length())
        {
          chartIndex->getIndexItem(t, item);
          item.setTitle(s);
	  chartIndex->setIndexItem(t, item);
        }

        db.setBar(bar);

        ts = "Symbol";
        r.getData(ts, ts2);
//        QString ss = tr("Updating") + " " + ts2;
//        printStatusLogMessage(ss);
	config.closePlugin(type);

        db.close();

        emit signalWakeup();
      }
      else
      {
        ts = "Name";
	r.getData(ts, s);
	if (s.length())
        {
          chartIndex->getIndexItem(symbol, item);
          item.setTitle(s);
	  chartIndex->setIndexItem(symbol, item);
        }
        db.setBar(bar);

        emit signalWakeup();
      }
    }

    db.close();
    f.close();
  }

  progressBar->setProgress((int) list.count(), (int) list.count());
  downloadComplete();
  if (cancelFlag)
  {
    cancelFlag = FALSE;
    printStatusLogMessage(stringCanceled);
  }
  else {
    QString ss = stringDone + " " + QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss");
    printStatusLogMessage(ss);
  }
  progressBar->reset();
}