예제 #1
0
void HorizontalLine::setSettings (Setting &set)
{
  QString s;
  value = set.getDouble(valueLabel);
  set.getData(colorLabel, s);
  color.setNamedColor(s);
  set.getData(plotLabel, plot);
  set.getData(nameLabel, name);
  set.getData(textLabel, text);
}
예제 #2
0
void VerticalLine::setSettings (Setting &set)
{
  QString s;
  set.getData(dateLabel, s);
  Bar bar;
  bar.setDate(s);
  bar.getDate(date);
  set.getData(colorLabel, s);
  color.setNamedColor(s);
  set.getData(plotLabel, plot);
  set.getData(nameLabel, name);
}
예제 #3
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();
}
예제 #4
0
void StocksDialog::createFundamentalsPage ()
{
    QWidget *w = new QWidget(this);

    Q3VBoxLayout *vbox = new Q3VBoxLayout(w);
    vbox->setMargin(5);
    vbox->setSpacing(5);

    Setting fund;
    QString s, s2;
    index->getFundamentals(symbol, s2);
    fund.parse(s2);

    s = tr("Fundamentals: last updated ");
    s2 = "updateDate";
    QString s3;
    fund.getData(s2, s3);
    s.append(s3);
    fund.remove(s2);
    QStringList key;
    fund.getKeyList(key);
    key.sort();

    vbox->addSpacing(10);
    QLabel *label = new QLabel(s, w);
    vbox->addWidget(label);

    fundView = new Q3ListView(w);
    fundView->addColumn(tr("Description"));
    fundView->addColumn(tr("Value"));
    vbox->addWidget(fundView);

    int loop;
    for (loop = 0; loop < (int) key.count(); loop++)
    {
        fund.getData(key[loop], s);
        new Q3ListViewItem(fundView, key[loop], s);
    }

    if (! key.count())
        new Q3ListViewItem(fundView, tr("No data available."));

    addTab(w, tr("Fundamentals"));
}
예제 #5
0
void Text::setSettings (Setting &set)
{
  QString s;
  set.getData(dateLabel, s);
  Bar bar;
  bar.setDate(s);
  bar.getDate(date);
  value = set.getDouble(valueLabel);
  set.getData(colorLabel, s);
  color.setNamedColor(s);
  set.getData(plotLabel, plot);
  set.getData(nameLabel, name);
  set.getData(labelLabel, label);
  
  set.getData(fontLabel, s);
  QStringList l = QStringList::split(" ", s, FALSE);
  if (l.count())
    font = QFont(l[0], l[1].toInt(), l[2].toInt());
}
예제 #6
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();
}
예제 #7
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();
}
예제 #8
0
void SellArrow::setSettings (Setting &set)
{
  QString s;
  set.getData(dateLabel, s);
  Bar bar;
  bar.setDate(s);
  bar.getDate(date);
  value = set.getDouble(valueLabel);
  set.getData(colorLabel, s);
  color.setNamedColor(s);
  set.getData(plotLabel, plot);
  set.getData(identifierLabel, identifier);
  set.getData(priceLabel, price);
  set.getData(nameLabel, name);
}
예제 #9
0
void IndicatorPlugin::saveFile (QString &file, Setting &dict)
{
  QFile f(file);
  if (! f.open(IO_WriteOnly))
  {
    qDebug("IndicatorPlugin:can't save file %s", file.latin1());
    return;
  }
  QTextStream stream(&f);
  
  QStringList key;
  dict.getKeyList(key);
  
  int loop;
  QString s;
  for(loop = 0; loop < (int) key.count(); loop++)
  {
    dict.getData(key[loop], s);
    stream << key[loop] << "=" << s << "\n";
  }
  
  f.close();
}
예제 #10
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);
}
예제 #11
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;
}
예제 #12
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();
}
예제 #13
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();
}
예제 #14
0
void NYBOT::parse ()
{
  if (cancelFlag)
    return;
  
  QFile f(file);
  if (! f.open(IO_ReadOnly))
    return;
  QTextStream stream(&f);
    
  QString ts = stream.readLine();
  QString s;
  stripJunk(ts, s);
  QStringList keys = QStringList::split(",", s, FALSE);

  while(stream.atEnd() == 0)
  {
    ts = stream.readLine();
    stripJunk(ts, s);

    QStringList l = QStringList::split(",", s, FALSE);

    if (l.count() != keys.count())
      continue;

    Setting data;
    int loop2;
    for (loop2 = 0; loop2 < (int) keys.count(); loop2++)
      data.setData(keys[loop2], l[loop2]);

    // symbol
    QString symbol;
    QString ts = "commoditySymbol";
    data.getData(ts, symbol);
    symbol = symbol.stripWhiteSpace();
    if (symbol.length() == 0)
      continue;

    if (! symbol.compare("CC") || ! symbol.compare("CR") || ! symbol.compare("CT") ||
        ! symbol.compare("DX") || ! symbol.compare("KC") || ! symbol.compare("OJ") ||
	! symbol.compare("SB") || ! symbol.compare("YX"))
    {
    }
    else
      continue;

    // date
    QString date;
    ts = "tradeDate";
    data.getData(ts, date);
    date.append("000000");

    Bar bar;
    if (bar.setDate(date))
    {
      QString ss = tr("Bad date") + " " + date;
      printStatusLogMessage(ss);
      continue;
    }

    ts = "dailyOpenPrice1";
    data.getData(ts, s);
    if (s.toFloat() == 0)
    {
      ts = "dailyOpenPrice2";
      data.getData(ts, s);
    }
    if (setTFloat(s, FALSE))
      continue;
    else
      bar.setOpen(tfloat);

    ts = "dailyHigh";
    data.getData(ts, s);
    if (setTFloat(s, FALSE))
      continue;
    else
      bar.setHigh(tfloat);

    ts = "dailyLow";
    data.getData(ts, s);
    if (setTFloat(s, FALSE))
      continue;
    else
      bar.setLow(tfloat);

    ts = "settlementPrice";
    data.getData(ts, s);
    if (setTFloat(s, FALSE))
      continue;
    else
      bar.setClose(tfloat);

    ts = "tradeVolume";
    data.getData(ts, s);
    if (setTFloat(s, FALSE))
      continue;
    else
      bar.setVolume(tfloat);

    ts = "openInterest";
    data.getData(ts, s);
    if (setTFloat(s, FALSE))
      continue;
    else
      bar.setOI((int) tfloat);

    if (symbol.compare("CC"))
    {
      bar.setOpen(bar.getOpen() / 100);
      bar.setHigh(bar.getHigh() / 100);
      bar.setLow(bar.getLow() / 100);
      bar.setClose(bar.getClose() / 100);
    }

    if (bar.verify())
      continue;

    //futures month
    ts = "contractMonth";
    data.getData(ts, s);
    QString year = s.left(4);
    QString month = s.right(2);
    QString fmonth;

    switch (month.toInt())
    {
      case 1:
        fmonth = "F";
        break;
      case 2:
        fmonth = "G";
        break;
      case 3:
        fmonth = "H";
        break;
      case 4:
        fmonth = "J";
        break;
      case 5:
        fmonth = "K";
        break;
      case 6:
        fmonth = "M";
        break;
      case 7:
        fmonth = "N";
        break;
      case 8:
        fmonth = "Q";
        break;
      case 9:
        fmonth = "U";
        break;
      case 10:
        fmonth = "V";
        break;
      case 11:
        fmonth = "X";
        break;
      case 12:
        fmonth = "Z";
        break;
      default:
        break;
    }

    if (fd.setSymbol(symbol))
      continue;

    if (year.length())
    {
      symbol.append(year);

      if (fmonth.length())
        symbol.append(fmonth);
      else
        continue;
    }
    else
      continue;

    s = "Futures/";
    QString s2;
    fd.getExchange(s2);
    s.append(s2 + "/");
    fd.getSymbol(s2);
    s.append(s2);
    QString path;
    createDirectory(s, path);
    if (! path.length())
    {
      QString ss(tr("Unable to create futures directory"));
      printStatusLogMessage(ss);
      return;
    }
	
    s = path + "/" + symbol;
    if (plug.open(s, chartIndex))
    {
      QString ss(tr("Could not open db"));
      printStatusLogMessage(ss);
      return;
    }

    DBIndexItem item;
    chartIndex->getIndexItem(symbol, item);
    item.getSymbol(s);
    if (! s.length())
    {
      if (plug.createNewFutures())
        return;

      chartIndex->getIndexItem(symbol, item);

      s = QString::number(Exchange::NYBOT);
      item.setExchange(s);

      item.setQuotePlugin(pluginName);

      chartIndex->setIndexItem(symbol, item);
    }

    plug.setBar(bar);
		 
    plug.close();

    emit signalWakeup();
  }

  f.close();

  downloadComplete();
  if (cancelFlag)
  {
    cancelFlag = FALSE;
    QString ss(tr("Update cancelled"));
    printStatusLogMessage(ss);
  }
  else
  {
    QString ss(tr("Done"));
    printStatusLogMessage(ss);
  }
}
예제 #15
0
void UpgradeMessage::saveHeaderData (DbPlugin &db, QString &k, QString &d, QString &sym, DBIndexItem &item)
{
  // is this a co key?
  bool ok = FALSE;
  double t = k.toDouble(&ok);
  if (ok)
  {
    if (t < 10000)
    {
      // its a chart object
      Setting t;
      t.parse(d);
      QString s = "Plugin";
      QString s2;
      t.getData(s,s2);
      if (s2.length())
      {
        t.remove(s);
        s = "Type";
        t.setData(s, s2);
      }

      s = "Plot";
      t.getData(s, s2);
      if (! s2.compare("Main Plot"))
      {
        s2 = "Bars";
        t.setData(s, s2);
      }
      else
        return;

      index.setChartObject(sym, k, t);
      return;
    }
  }

  if (! k.compare("Type"))
  {
    item.setType(d);
    return;
  }

  if (! k.compare("FuturesType"))
  {
    item.setFuturesType(d);
    return;
  }

  if (! k.compare("FuturesMonth"))
  {
    item.setFuturesMonth(d);
    return;
  }

  if (! k.compare("BarType"))
  {
    item.setBarType(d);
    return;
  }

  if (! k.compare("Fundamentals"))
  {
    index.setFundamentals(sym, d);
    return;
  }

  if (! k.compare("LocalIndicators"))
  {
    index.addIndicator(sym, d);
    return;
  }

  if (! k.compare("QuotePlugin"))
  {
    item.setQuotePlugin(d);
    return;
  }

  if (! k.compare("Symbol"))
  {
    item.setSymbol(d);
    return;
  }

  if (! k.compare("Title"))
  {
    item.setTitle(d);
    return;
  }

  if (! k.compare("Path"))
  {
    item.setPath(d);
    return;
  }

  if (! k.compare("SpreadFirstSymbol"))
  {
    int t = d.find("/data0/", 0, TRUE);
    d.replace(t + 5, 1, "1");
    QString ts = "FirstSymbol";
    db.setData(ts, d);
    return;
  }

  if (! k.compare("SpreadSecondSymbol"))
  {
    int t = d.find("/data0/", 0, TRUE);
    d.replace(t + 5, 1, "1");
    QString ts = "SecondSymbol";
    db.setData(ts, d);
    return;
  }

  if (! k.compare("IndexList"))
  {
    while (1)
    {
      int t = d.find("/data0/", 0, TRUE);
      if (t == -1)
        break;
      else
        d.replace(t + 5, 1, "1");
    }
    QString ts = "List";
    db.setData(ts, d);
    return;
  }

  if (! k.compare("CCAdjustment"))
  {
    QString ts = "Adjustment";
    db.setData(ts, d);
    return;
  }
}
예제 #16
0
void StocksDialog::split ()
{
    int rc = QMessageBox::warning(this,
                                  tr("Warning"),
                                  tr("Are you sure to split this stock?"),
                                  QMessageBox::Yes,
                                  QMessageBox::No,
                                  QMessageBox::NoButton);

    if (rc == QMessageBox::No)
        return;

    QDate dt = splitDate->date();

    // verify if split date < first bar
    Bar bar;
    db->getFirstBar(bar);
    if (! bar.getEmptyFlag())
    {
        QDateTime td;
        bar.getDate(td);
        if (dt < td.date())
        {
            QMessageBox::information(this, tr("Qtstalker: Error"), tr("Invalid split date."));
            return;
        }
    }

    // verify if split date > last bar
    Bar bar2;
    db->getLastBar(bar2);
    if (! bar.getEmptyFlag())
    {
        QDateTime td;
        bar2.getDate(td);
        if (dt > td.date())
        {
            QMessageBox::information(this, tr("Qtstalker: Error"), tr("Invalid split date."));
            return;
        }
    }

    // verify if the ratio format is correct ?:?
    QStringList l = QStringList::split(":", splitRatio->text(), FALSE);
    if (l.count() != 2)
    {
        QMessageBox::information(this, tr("Qtstalker: Error"), tr("Invalid split ratio format.\neg. 2:1"));
        return;
    }

    double plyer = l[1].toDouble() / l[0].toDouble();
    double volplyer = l[0].toDouble() / l[1].toDouble();

    QString s;
    db->getSymbol(s);
    BarData *bars = new BarData(s);
    db->getAllBars(bars);

    int loop;
    for (loop = 0; loop < bars->count(); loop++)
    {
        Bar bar;
        bars->getBar(loop, bar);

        QDateTime td;
        bar.getDate(td);
        if (td.date() < dt)
        {
            bar.setOpen(bar.getOpen() * plyer);
            bar.setHigh(bar.getHigh() * plyer);
            bar.setLow(bar.getLow() * plyer);
            bar.setClose(bar.getClose() * plyer);
            bar.setVolume(bar.getVolume() * volplyer);
            db->setBar(bar);
        }
    }

    delete bars;

    // adjust any chart objects
    QDateTime adt(dt, QTime(0,0,0,0));
    QString fn;
    db->getIndexKey(fn);
    index->getChartObjects(fn, l);
    for (loop = 0; loop < (int) l.count(); loop++)
    {
        Setting set;
        set.parse(l[loop]);
        COBase tco;
        COBase *co = tco.getCO(set);
        if (! co)
            continue;

        co->adjustForSplit(adt, plyer);

        set.clear();
        co->getSettings(set);
        s = "Name";
        QString s2;
        set.getData(s, s2);
        index->setChartObject(fn, s2, set);
    }

    QMessageBox::information(this, tr("Qtstalker: Split Complete"), tr("Split complete."));

    reloadFlag = TRUE;
}
예제 #17
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;
}
예제 #18
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();
}