예제 #1
0
bool CSV::openDb (QString &path, QString &symbol, QString &type, bool tickFlag)
{
  if (db.open(path, chartIndex))
  {
    qDebug("CSV::openDb:can't open chart");
    QString ss("CSV::OpenDb:Could not open db.");
    printStatusLogMessage(ss);
    db.close();
    return TRUE;
  }

  QString s;
  DBIndexItem item;
  chartIndex->getIndexItem(symbol, item);
  item.getSymbol(s);
  if (! s.length())
  {
    if (! type.compare("Futures"))
    {
      db.setType(DbPlugin::Futures1);
      if (db.createNewFutures())
      {
        db.close();
        return TRUE;
      }
    }
    else
    {
      if(db.createNewStock())
      {
        db.close();
        return TRUE;
      }
    }

    item.setSymbol(symbol);
    item.setBarType(tickFlag);
    chartIndex->setIndexItem(symbol, item);
  }

  // verify if this chart can be updated by this plugin
  item.getQuotePlugin(s);
  if (! s.length())
  {
    item.setQuotePlugin(pluginName);
    chartIndex->setIndexItem(symbol, item);
  }
  else
  {
    if (s.compare(pluginName))
    {
      s = symbol + " - skipping update. Source does not match destination.";
      printStatusLogMessage(s);
      db.close();
      return TRUE;
    }
  }

  return FALSE;
}
예제 #2
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;
  }
}