コード例 #1
0
ファイル: TALIB.cpp プロジェクト: botvs/FinancialAnalytics
void TALIB::getIndicatorSettings (Setting &dict)
{
  QString s;
  parms.getString(s);
  dict.parse(s);
  s = "plugin";
  dict.setData(s, pluginName);
}
コード例 #2
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"));
}
コード例 #3
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;
  }
}
コード例 #4
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;
}