void IndicatorPlugin::loadFile (QString &file, Setting &dict) { QFile f(file); if (! f.open(IO_ReadOnly)) { qDebug("IndicatorPlugin:can't read file %s", file.latin1()); return; } QTextStream stream(&f); while(stream.atEnd() == 0) { QString s = stream.readLine(); s = s.stripWhiteSpace(); if (! s.length()) continue; QStringList l = QStringList::split("=", s, FALSE); if (l.count() < 2) continue; if (l.count() > 2) { QString k = l[0]; s = s.remove(0, k.length() + 1); dict.setData(k, s); } else dict.setData(l[0], l[1]); } f.close(); }
void VerticalLine::getSettings (Setting &set) { QString s = date.toString(dateFormat); set.setData(dateLabel, s); s = color.name(); set.setData(colorLabel, s); set.setData(plotLabel, plot); set.setData(nameLabel, name); set.setData(typeLabel, type); }
void Yahoo::createFundamentalUrls (QString &d) { QString s = "http://finance.yahoo.com/q/ks?s=" + d; Setting *set = new Setting; QString ts = "url"; set->setData(ts, s); ts = "symbol"; set->setData(ts, d); url.append(set); }
void HorizontalLine::getSettings (Setting &set) { QString s = QString::number(value); set.setData(valueLabel, s); s = color.name(); set.setData(colorLabel, s); set.setData(plotLabel, plot); set.setData(nameLabel, name); set.setData(textLabel, text); set.setData(typeLabel, type); }
void CUS::getIndicatorSettings (Setting &dict) { QString ts = "script"; QString ts2 = formulaList.join("|"); dict.setData(ts, ts2); ts = "plugin"; dict.setData(ts, pluginName); ts = "version"; ts2 = QString::number(version); dict.setData(ts, ts2); }
void CSV::getRule (Setting &set) { QString s = ruleDir +"/" + ruleCombo->currentText(); QFile f(s); if (! f.open(QIODevice::ReadOnly)) { qDebug("CSV::getRule:cannot read file."); return; } Q3TextStream stream(&f); while(stream.atEnd() == 0) { s = stream.readLine(); s = s.stripWhiteSpace(); if (! s.length()) continue; QStringList l = QStringList::split("=", s, FALSE); if (l.count() != 2) continue; set.setData(l[0], l[1]); } f.close(); }
void TALIB::getIndicatorSettings (Setting &dict) { QString s; parms.getString(s); dict.parse(s); s = "plugin"; dict.setData(s, pluginName); }
void Yahoo::createQuoteUrls (QString &d) { // multiple quotes: download.finance.yahoo.com/d/quotes.csv?s=IBM+RHAT+SCOX+MSFT+GOLD&f=sl1d1t1c1ohgv // multiple close only: download.finance.yahoo.com/d/quotes.csv?s=IBM+RHAT+SCOX+MSFT+GOLD&f=sl1 // URLPrefix = "http://download.finance.yahoo.com/d/quotes.csv?s="; // URLPostfix = "&f=snl1d1t1c1ohgv&e=.csv"; QString s = "http://download.finance.yahoo.com/d/quotes.csv?s="; s.append(d); s.append("&f=snl1d1t1c1ohgv&e=.csv"); Setting *set = new Setting; QString ts = "url"; set->setData(ts, s); ts = "symbol"; set->setData(ts, d); url.append(set); }
void PP::getIndicatorSettings (Setting &dict) { QString ts = resColor.name(); dict.setData(resColorLabel, ts); ts = supColor.name(); dict.setData(supColorLabel, ts); ts = QString::number(resLineType); dict.setData(resLineTypeLabel, ts); ts = QString::number(supLineType); dict.setData(supLineTypeLabel, ts); dict.setData(resLabelLabel, resLabel); dict.setData(resLabel2Label, resLabel2); dict.setData(resLabel3Label, resLabel3); dict.setData(supLabelLabel, supLabel); dict.setData(supLabel2Label, supLabel2); dict.setData(supLabel3Label, supLabel3); dict.setData(labelLabel, label); dict.setData(pluginLabel, pluginName); }
void SellArrow::getSettings (Setting &set) { QString s = date.toString(dateFormat); set.setData(dateLabel, s); s = QString::number(value); set.setData(valueLabel, s); s = color.name(); set.setData(colorLabel, s); set.setData(identifierLabel, identifier); set.setData(priceLabel, price); set.setData(plotLabel, plot); set.setData(nameLabel, name); set.setData(typeLabel, type); }
void SINWAV::getIndicatorSettings (Setting &dict) { QString ts = colorSin.name(); dict.setData(colorSinLabel, ts); ts = colorLead.name(); dict.setData(colorLeadLabel, ts); dict.setData(labelSinLabel, labelSin); dict.setData(labelLeadLabel, labelLead); ts = QString::number(lineTypeSin); dict.setData(lineTypeSinLabel, ts); ts = QString::number(lineTypeLead); dict.setData(lineTypeLeadLabel, ts); dict.setData(pluginLabel, pluginName); }
void PlotLine::getInfo (int i, Setting &r) { QString s, k; double open, high, low, close; QColor color; bool ff; switch (lineType) { case Bar: case Candle: getData(i, color, open, high, low, close, ff); strip(open, 4, s); k = "O"; r.setData(k, s); strip(high, 4, s); k = "H"; r.setData(k, s); strip(low, 4, s); k = "L"; r.setData(k, s); strip(close, 4, s); k = "C"; r.setData(k, s); break; case PF: getData(i, color, open, high, low, close, ff); strip(high, 4, s); k = "H"; r.setData(k, s); strip(low, 4, s); k = "L"; r.setData(k, s); break; default: strip(getData(i), 4, s); r.setData(label, s); break; } }
void LOWPASS::getIndicatorSettings (Setting &dict) { QString ts = color.name(); dict.setData(colorLabel, ts); ts = QString::number(lineType); dict.setData(lineTypeLabel, ts); dict.setData(labelLabel, label); ts = QString::number(input); dict.setData(inputLabel, ts); dict.setData(pluginLabel, pluginName); ts = QString::number(freq); dict.setData(freqLabel, ts); ts = QString::number(width); dict.setData(widthLabel, ts); }
void Text::getSettings (Setting &set) { QString s = date.toString(dateFormat); set.setData(dateLabel, s); s = QString::number(value); set.setData(valueLabel, s); s = color.name(); set.setData(colorLabel, s); set.setData(plotLabel, plot); set.setData(nameLabel, name); set.setData(labelLabel, label); set.setData(typeLabel, type); s = font.family(); s.append(" "); s.append(QString::number(font.pointSize())); s.append(" "); s.append(QString::number(font.weight())); set.setData(fontLabel, s); }
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; } }
void Yahoo::parseFundamental () { if (! data.length()) return; if (data.contains("no data available")) return; QStringList l = QStringList::split("yfnc_tablehead1", data, FALSE); int loop; Setting fund; for (loop = 1; loop < (int) l.count(); loop++) { QString k = l[loop]; int p = k.find(">", 0, TRUE); if (p == -1) continue; p++; k.remove(0, p); p = k.find("<", 0, TRUE); if (p == -1) continue; k.truncate(p); if (k.contains("&sup")) k.truncate(k.length() - 6); if (k.contains("&")) k.remove(k.find("&", 0, TRUE), 5); k = k.stripWhiteSpace(); if (! k.length()) continue; QString d = l[loop]; p = d.find("yfnc_tabledata1", 0, TRUE); if (p == -1) continue; p = d.find(">", p, TRUE); if (p == -1) continue; p++; d.remove(0, p); p = d.find("<", 0, TRUE); if (p == -1) continue; d.truncate(p); d = d.stripWhiteSpace(); if (! d.length()) continue; fund.setData(k, d); } QString s = dataPath + "/"; QString ts = "symbol"; QString ts2; currentUrl->getData(ts, ts2); QFileInfo fi(ts2); if (fi.extension(FALSE).length()) s.append(fi.extension(FALSE).upper()); else s.append("US"); s.append("/"); s.append(ts2); if (plug.open(s, chartIndex)) { QString ss(tr("Could not open db")); printStatusLogMessage(ss); return; } QString fn = ts2; // verify if this chart can be updated by this plugin DBIndexItem item; chartIndex->getIndexItem(fn, item); item.getSymbol(s); if (! s.length()) { if(plug.createNewStock()) { plug.close(); return; } chartIndex->getIndexItem(fn, item); item.setQuotePlugin(pluginName); item.setSymbol(ts2); QString title = ts2; int p = data.find("yfnc_leftnav1", 0, TRUE); if (p != -1) { p = data.find("b>", p, TRUE); if (p != -1) { p = p + 2; int p2 = data.find("<", p, TRUE); if (p2 != -1) { s = data.mid(p, p2 - p); if (s.length()) title = s; } } } item.setTitle(title); chartIndex->setIndexItem(fn, item); } else { QString s2; item.getTitle(s2); if (! s.compare(s2)) { int p = data.find("yfnc_leftnav1", 0, TRUE); if (p != -1) { p = data.find("b>", p, TRUE); if (p != -1) { p = p + 2; int p2 = data.find("<", p, TRUE); if (p2 != -1) { s = data.mid(p, p2 - p); if (s.length()) { item.setTitle(s); chartIndex->setIndexItem(fn, item); } } } } } } // item.getQuotePlugin(s); // if (s.compare(pluginName)) // { // s = ts2 + " - " + tr("skipping update. Source does not match destination"); // printStatusLogMessage(s); // plug.close(); // return; // } // include date of this update QDate dt = QDate::currentDate(); ts = "updateDate"; ts2 = dt.toString("yyyy-MM-dd"); fund.setData(ts, ts2); fund.getString(ts2); ts = "Fundamentals"; chartIndex->setFundamentals(fn, ts2); plug.close(); emit signalWakeup(); }
void Yahoo::createHistoryUrls (QString &d) { if (sdate->date().daysTo(edate->date()) > 199) { QDate tsdate = sdate->date(); QDate tedate = sdate->date(); while (tsdate <= edate->date()) { tsdate = tedate; tedate = tsdate.addDays(199); if (tedate.dayOfWeek() == 6) tedate = tedate.addDays(-1); else { if (tedate.dayOfWeek() == 7) tedate = tedate.addDays(-2); } if (tedate > edate->date()) tedate = edate->date(); QString s = "http://table.finance.yahoo.com/table.csv?s="; s.append(d); s.append("&a="); s.append(QString::number(tsdate.month() - 1)); s.append("&b="); s.append(tsdate.toString("dd")); s.append("&c="); s.append(tsdate.toString("yyyy")); s.append("&d="); s.append(QString::number(tedate.month() - 1)); s.append("&e="); s.append(tedate.toString("dd")); s.append("&f="); s.append(tedate.toString("yyyy")); s.append("&g=d&ignore=.csv"); Setting *set = new Setting; QString ts = "url"; set->setData(ts, s); ts = "symbol"; set->setData(ts, d); url.append(set); if (tedate == edate->date()) break; } } else { QString s = "http://table.finance.yahoo.com/table.csv?s="; s.append(d); s.append("&a="); s.append(QString::number(sdate->date().month() - 1)); s.append("&b="); s.append(sdate->date().toString("dd")); s.append("&c="); s.append(sdate->date().toString("yyyy")); s.append("&d="); s.append(QString::number(edate->date().month() - 1)); s.append("&e="); s.append(edate->date().toString("dd")); s.append("&f="); s.append(edate->date().toString("yyyy")); s.append("&g=d&ignore=.csv"); Setting *set = new Setting; QString ts = "url"; set->setData(ts, s); ts = "symbol"; set->setData(ts, d); url.append(set); } }
void BARS::getIndicatorSettings (Setting &dict) { QString ts = barUpColor.name(); dict.setData(barUpColorLabel, ts); ts = barDownColor.name(); dict.setData(barDownColorLabel, ts); ts = barNeutralColor.name(); dict.setData(barNeutralColorLabel, ts); ts = candleColor.name(); dict.setData(candleColorLabel, ts); dict.setData(labelLabel, label); dict.setData(methodLabel, method); ts = QString::number(lineType); dict.setData(lineTypeLabel, ts); dict.setData(pluginLabel, pluginName); ts = pfXColor.name(); dict.setData(pfXColorLabel, ts); ts = pfOColor.name(); dict.setData(pfOColorLabel, ts); ts = QString::number(pfReversal); dict.setData(pfReversalLabel, ts); dict.setData(pfMethodLabel, pfMethod); ts = maColor.name(); dict.setData(maColorLabel, ts); ts = QString::number(maLineType); dict.setData(maLineTypeLabel, ts); ts = QString::number(maPeriod); dict.setData(maPeriodLabel, ts); dict.setData(maLabelLabel, maLabel); ts = QString::number(maType); dict.setData(maTypeLabel, ts); ts = QString::number(maInput); dict.setData(maInputLabel, ts); ts = maColor2.name(); dict.setData(maColor2Label, ts); ts = QString::number(maLineType2); dict.setData(maLineType2Label, ts); ts = QString::number(maPeriod2); dict.setData(maPeriod2Label, ts); dict.setData(maLabel2Label, maLabel2); ts = QString::number(maType2); dict.setData(maType2Label, ts); ts = QString::number(maInput2); dict.setData(maInput2Label, ts); ts = maColor3.name(); dict.setData(maColor3Label, ts); ts = QString::number(maLineType3); dict.setData(maLineType3Label, ts); ts = QString::number(maPeriod3); dict.setData(maPeriod3Label, ts); dict.setData(maLabel3Label, maLabel3); ts = QString::number(maType3); dict.setData(maType3Label, ts); ts = QString::number(maInput3); dict.setData(maInput3Label, ts); ts = maColor4.name(); dict.setData(maColor4Label, ts); ts = QString::number(maLineType4); dict.setData(maLineType4Label, ts); ts = QString::number(maPeriod4); dict.setData(maPeriod4Label, ts); dict.setData(maLabel4Label, maLabel4); ts = QString::number(maType4); dict.setData(maType4Label, ts); ts = QString::number(maInput4); dict.setData(maInput4Label, ts); }
void Yahoo::createAutoHistoryUrls (QString &path, QString &d) { if (plug.open(path, chartIndex)) { qDebug("Yahoo::createAutoHistoryUrls:could not open db"); return; } QFileInfo fi(path); QString fn = fi.fileName(); // verify if this chart can be updated by this plugin QString s; DBIndexItem item; chartIndex->getIndexItem(fn, item); item.getQuotePlugin(s); if (! s.length()) { item.setQuotePlugin(pluginName); chartIndex->setIndexItem(fn, item); } // else // { // if (s.compare(pluginName)) // { // qDebug("Yahoo::createAutoHistoryUrls:source not same as destination"); // plug.close(); // return; // } // } QDate edt = QDate::currentDate(); if (edt.dayOfWeek() == 6) edt = edt.addDays(-1); else { if (edt.dayOfWeek() == 7) edt = edt.addDays(-2); } Bar bar; plug.getLastBar(bar); if (bar.getEmptyFlag()) { QDate dt = edt; dt = dt.addDays(-365); s = dt.toString("yyyyMMdd000000"); bar.setDate(s); } QDateTime dt; bar.getDate(dt); if (dt.date() == edt) { // qDebug("Yahoo::createAutoHistoryUrls:barDate == endDate"); plug.close(); return; } s = "http://table.finance.yahoo.com/table.csv?s="; s.append(d); s.append("&a="); s.append(QString::number(dt.date().month() - 1)); s.append("&b="); s.append(dt.toString("dd")); s.append("&c="); s.append(dt.toString("yyyy")); s.append("&d="); s.append(QString::number(edt.month() - 1)); s.append("&e="); s.append(edt.toString("dd")); s.append("&f="); s.append(edt.toString("yyyy")); s.append("&g=d&ignore=.csv"); plug.close(); Setting *set = new Setting; QString ts = "url"; set->setData(ts, s); ts = "symbol"; set->setData(ts, d); url.append(set); }
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(); }
void CSV::getDate (QString &k, QString &d, Setting &r, QDate &date) { QStringList l; QString dateString = d; QString timeString; if (d.contains(" ")) { QStringList l2 = QStringList::split(" ", d, FALSE); dateString = l2[0]; timeString = l2[1]; } while (1) { if (dateString.contains("/")) { l = QStringList::split("/", dateString, FALSE); if (l.count() != 3) return; else dateString = l.join(QString::null); break; } if (dateString.contains("-")) { l = QStringList::split("-", dateString, FALSE); if (l.count() != 3) return; else dateString = l.join(QString::null); break; } if (dateString.contains(".")) { l = QStringList::split(".", dateString, FALSE); if (l.count() != 3) return; else dateString = l.join(QString::null); break; } break; } while (1) { if (! k.compare("Date:YYYYMMDD")) { if (l.count()) date.setYMD(l[0].toInt(), l[1].toInt(), l[2].toInt()); else { if (dateString.length() == 8) date.setYMD(dateString.left(4).toInt(), dateString.mid(4, 2).toInt(), dateString.right(2).toInt()); } break; } if (! k.compare("Date:YYMMDD")) { if (l.count()) date.setYMD(l[0].toInt(), l[1].toInt(), l[2].toInt()); else { if (dateString.length() == 6) date.setYMD(dateString.left(2).toInt(), dateString.mid(2, 2).toInt(), dateString.right(2).toInt()); } break; } if (! k.compare("Date:MMDDYYYY")) { if (l.count()) date.setYMD(l[2].toInt(), l[0].toInt(), l[1].toInt()); else { if (dateString.length() == 8) date.setYMD(dateString.right(4).toInt(), dateString.left(2).toInt(), dateString.mid(2, 2).toInt()); } break; } if (! k.compare("Date:MMDDYY")) { if (l.count()) date.setYMD(l[2].toInt(), l[0].toInt(), l[1].toInt()); else { if (dateString.length() == 6) date.setYMD(dateString.right(2).toInt(), dateString.left(2).toInt(), dateString.mid(2, 2).toInt()); } break; } if (! k.compare("Date:DDMMYYYY")) { if (l.count()) date.setYMD(l[2].toInt(), l[1].toInt(), l[0].toInt()); else { if (dateString.length() == 8) date.setYMD(dateString.right(4).toInt(), dateString.mid(2, 2).toInt(), dateString.left(2).toInt()); } break; } if (! k.compare("Date:MMDDYYYYHHMMSS")) { QString s; getTime(timeString, s); if (s.length()) { QString ts = "Time"; r.setData(ts, s); } else break; if (l.count()) date.setYMD(l[2].toInt(), l[0].toInt(), l[1].toInt()); else { if (dateString.length() == 8) date.setYMD(dateString.right(4).toInt(), dateString.left(2).toInt(), dateString.mid(2, 2).toInt()); } break; } if (! k.compare("Date:YYYYMMDDHHMMSS")) { timeString = d.right(6); dateString = d.left(8); QString s; getTime(timeString, s); if (s.length()) { QString ts = "Time"; r.setData(ts, s); } else break; if (l.count()) date.setYMD(l[0].toInt(), l[1].toInt(), l[2].toInt()); else { if (dateString.length() == 8) date.setYMD(dateString.left(4).toInt(), dateString.mid(4, 2).toInt(), dateString.right(2).toInt()); } break; } break; } }
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); } }
void ExScript::getIndicatorSettings (Setting &dict) { QString ts = color.name(); dict.setData(colorLabel, ts); dict.setData(labelLabel, label); ts = QString::number(lineType); dict.setData(lineTypeLabel, ts); dict.setData(scriptPathLabel, scriptPath); dict.setData(comlineParmsLabel, comlineParms); ts = QString::number(dateFlag); dict.setData(dateLabel, ts); ts = QString::number(openFlag); dict.setData(openLabel, ts); ts = QString::number(highFlag); dict.setData(highLabel, ts); ts = QString::number(lowFlag); dict.setData(lowLabel, ts); ts = QString::number(closeFlag); dict.setData(closeLabel, ts); ts = QString::number(volumeFlag); dict.setData(volumeLabel, ts); ts = QString::number(oiFlag); dict.setData(oiLabel, ts); ts = QString::number(seconds); dict.setData(timeoutLabel, ts); dict.setData(pluginLabel, pluginName); }
PlotLine * SYMBOL::getSYMBOL () { QString s; Config config; config.getData(Config::IndexPath, s); DBIndex index; index.open(s); PlotLine *line = new PlotLine(); DbPlugin db; if (db.open(symbol, &index)) { db.close(); index.close(); return line; } QDateTime date; data->getDate(0, date); QString ts; config.getData(Config::BarLength, ts); db.setBarLength((BarData::BarLength) ts.toInt()); config.getData(Config::Bars, ts); db.setBarRange(ts.toInt()); BarData *recordList = new BarData(symbol); QDateTime dt = QDateTime::currentDateTime(); db.getHistory(recordList, dt); QDict<Setting> dict; dict.setAutoDelete(TRUE); int loop; ts = "Close"; QString ts2; for (loop = 0; loop < (int) recordList->count(); loop++) { Setting *r = new Setting; ts2 = QString::number(recordList->getClose(loop)); r->setData(ts, ts2); recordList->getDate(loop, dt); QString s = dt.toString("yyyyMMddhhmmss"); dict.insert(s, r); } double val = 0; for (loop = 0; loop < (int) data->count(); loop++) { data->getDate(loop, dt); QString s = dt.toString("yyyyMMddhhmmss"); Setting *r2 = dict[s]; if (r2) { val = r2->getDouble(ts); line->append(val); } } delete recordList; db.close(); index.close(); line->setScaleFlag(TRUE); return line; }
void THERM::getIndicatorSettings (Setting &dict) { QString ts = upColor.name(); dict.setData(upColorLabel, ts); ts = downColor.name(); dict.setData(downColorLabel, ts); ts = threshColor.name(); dict.setData(threshColorLabel, ts); dict.setData(labelLabel, label); ts = QString::number(threshold); dict.setData(thresholdLabel, ts); ts = QString::number(smoothing); dict.setData(smoothingLabel, ts); ts = QString::number(smoothType); dict.setData(smoothTypeLabel, ts); ts = maColor.name(); dict.setData(maColorLabel, ts); ts = QString::number(maLineType); dict.setData(maLineTypeLabel, ts); ts = QString::number(maPeriod); dict.setData(maPeriodLabel, ts); dict.setData(maLabelLabel, maLabel); ts = QString::number(maType); dict.setData(maTypeLabel, ts); dict.setData(pluginLabel, pluginName); }