From 637610bcf851d70657c2dcf251d6daed2429a9a5 Mon Sep 17 00:00:00 2001 From: wumu <mayi@mayi.com> Date: 星期三, 26 二月 2025 22:59:54 +0800 Subject: [PATCH] 0226 --- getstocklist.cpp | 475 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 457 insertions(+), 18 deletions(-) diff --git a/getstocklist.cpp b/getstocklist.cpp index d9f0fa0..c1b5066 100644 --- a/getstocklist.cpp +++ b/getstocklist.cpp @@ -7,6 +7,10 @@ #include <QJsonObject> #include <QJsonArray> #include <QLibrary> // 鐢ㄤ簬鍔犺浇dll鍔ㄦ�佸簱鐨勭被 +#include <QDateTime> + + +#pragma execution_character_set("utf-8") GetStockList::GetStockList(QWidget *parent) : QMainWindow(parent), @@ -16,10 +20,14 @@ ui->pushButton_get->hide(); ui->statusbar->hide(); + // 娉ㄥ唽鍏冪被鍨� + qRegisterMetaType<QVector<QVector<QString>>>("QVector<QVector<QString>> &"); // 鏂规2: // 濡傛灉https 璁块棶鐨勬椂鍊欙紝杩樻槸鐖彇澶辫触锛屽彲浠ヤ唬鐮佸姞杞藉姩鎬佸簱鏉ユ敮鎸� // 鍓嶆彁鏉′欢鏄妸2涓猟ll鍔ㄦ�佸簱鎷疯礉鐨勭敓鎴愮洰褰曚腑:libeay32.dll 鍜� ssleay32.dll // 鎷疯礉鍒扮敓鎴愮洰褰曪紝灏卞彲浠ョ洿鎺ュ姞杞� + // 鑻ユ槸msvc 64bit鐨勭紪璇戝櫒锛岄渶瑕佷笅杞藉搴斾綅鏁扮殑dll搴撴潵鎷疯礉鍗冲彲 -- openssl-1.0.2q-x64_86-win64.zip + QLibrary lb("libeay32.dll"); if(lb.load()){ qDebug()<<"load libeay32.dll 鎴愬姛"; @@ -41,7 +49,11 @@ QStringList labels; labels<<"鑲$エ鍚嶅瓧"<<"鑲$エ浠e彿"<<"鎬诲競鍊�(浜�)"<<"娴侀�氬競鍊�(浜�)"<<"娑ㄨ穼骞�(%)"<<"鏀剁洏浠�"<<"鎴愪氦棰�(浜�)"<<"鎴愪氦閲�(鎵�)"<<"鎹㈡墜鐜�(%)"<<"甯傜泩鐜�"; m_model->setHorizontalHeaderLabels(labels); // 璁剧疆妯″瀷鐨勫垪鏍囩鍚� - ui->tableView->setModel(m_model); // 灏嗘ā鍨嬪拰瑙嗗浘鍏宠仈 + m_customModel = new CustomSortProxyModel; + m_customModel->setSourceModel(m_model); // 璁剧疆婧愭ā鍨� + + //ui->tableView->setModel(m_model); // 灏嗘ā鍨嬪拰瑙嗗浘鍏宠仈 + ui->tableView->setModel(m_customModel); // 璁剧疆鑷畾涔夋帓搴忕殑妯″瀷 ui->tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); // 璁剧疆鍐呭鑷�傚簲锛屾媺浼� // 缁欒〃鏍艰鍥炬坊鍔犲彸鍑昏嚜瀹氫箟鑿滃崟 @@ -51,11 +63,19 @@ m_menu = new QMenu(this); QMenu *dateMenu = new QMenu("璁剧疆鍛ㄦ湡"); + QAction *m30Action = dateMenu->addAction("璁剧疆涓�30鍒�"); + QAction *m60Action = dateMenu->addAction("璁剧疆涓�60鍒�"); + QAction *m120Action = dateMenu->addAction("璁剧疆涓�120鍒�"); + QAction *dayAction = dateMenu->addAction("璁剧疆涓烘棩"); QAction *weekAction = dateMenu->addAction("璁剧疆涓哄懆"); QAction *monthAction = dateMenu->addAction("璁剧疆涓烘湀"); QAction *yearAction = dateMenu->addAction("璁剧疆涓哄勾"); m_menu->addMenu(dateMenu); + connect(m30Action,&QAction::triggered,this,[&]{ m_dateType = "30m";}); + connect(m60Action,&QAction::triggered,this,[&]{ m_dateType = "60m";}); + connect(m120Action,&QAction::triggered,this,[&]{ m_dateType = "120m";}); + connect(dayAction,&QAction::triggered,this,[&]{ m_dateType = "day";}); connect(weekAction,&QAction::triggered,this,[&]{ m_dateType = "week";}); // 淇敼鏃ユ湡绫诲瀷 connect(monthAction,&QAction::triggered,this,[&]{ m_dateType = "month";}); connect(yearAction,&QAction::triggered,this,[&]{ m_dateType = "year";}); @@ -76,11 +96,36 @@ connect(pre1000Action,&QAction::triggered,this,[&]{ m_maTestNum = 1000;}); connect(pre5000Action,&QAction::triggered,this,[&]{ m_maTestNum = 5000;}); + QMenu *timerMenu = new QMenu("璁剧疆杞鎵ц绛栫暐"); + QAction *timerMultiResonateAction = timerMenu->addAction("杞澶氱瓥鐣ュ叡鎸�"); + + m_menu->addMenu(timerMenu); + + m_pollMultiTimer = new QTimer(this); + connect(m_pollMultiTimer,SIGNAL(timeout()),this,SLOT(pollMultiSlot())); + + connect(timerMultiResonateAction,&QAction::triggered,this,[&] { + static int cnt=0; + if(cnt % 2 == 0){ + m_pollMultiTimer->start(1000*60); + qDebug()<<"鍚姩杞澶氱瓥鐣ュ叡鎸殑瀹氭椂鍣�"; + }else{ + m_pollMultiTimer->stop(); + qDebug()<<"鍋滄杞澶氱瓥鐣ュ叡鎸瓥鐣�"; + } + }); // 杞澶氱瓥鐣ュ叡鎸� + + QAction *policy = m_menu->addAction("绛栫暐鍒嗘瀽"); QAction *price = m_menu->addAction("鏈�鏂颁环鏍�"); QAction *maPolicy = m_menu->addAction("MA绛栫暐"); QAction *macdPolicy = m_menu->addAction("MACD绛栫暐"); QAction *maTest100 = m_menu->addAction("MA绛栫暐-鍥炴祴"); + QAction *buttomToUpPolicy = m_menu->addAction("搴曢儴鍙嶈浆绛栫暐"); + QAction *multiResonatePolicy = m_menu->addAction("澶氱瓥鐣ュ叡鎸�"); + QAction *multiResonateTest100 = m_menu->addAction("澶氱瓥鐣ュ叡鎸�-鍥炴祴"); + QAction *oneUpCrossFourPolicy = m_menu->addAction("涓�闃崇┛鍥涚嚎绛栫暐"); + QAction *oneUpCrossFourTest100 = m_menu->addAction("涓�闃崇┛鍥涚嚎绛栫暐-鍥炴祴"); @@ -89,7 +134,11 @@ connect(maPolicy,SIGNAL(triggered(bool)),this,SLOT(maPolicySlot())); // MA鍧囩嚎绛栫暐 connect(macdPolicy,SIGNAL(triggered(bool)),this,SLOT(macdPolicySlot())); // MA鍧囩嚎绛栫暐 connect(maTest100,SIGNAL(triggered(bool)),this,SLOT(maTest100Slot())); // MA鍥炴祴鍓�100鍚� - + connect(buttomToUpPolicy,SIGNAL(triggered(bool)),this,SLOT(buttomToUpPolicySlot())); // 搴曢儴鍙嶈浆绛栫暐 + connect(multiResonatePolicy,SIGNAL(triggered(bool)),this,SLOT(multiResonatePolicySlot())); // 澶氱瓥鐣ュ叡鎸� + connect(multiResonateTest100,SIGNAL(triggered(bool)),this,SLOT(multiResonateTest100Slot())); // 澶氱瓥鐣ュ叡鎸洖娴� + connect(oneUpCrossFourPolicy,SIGNAL(triggered(bool)),this,SLOT(oneUpCrossFourSlot())); // 涓�闃崇┛鍥涚嚎绛栫暐 + connect(oneUpCrossFourTest100,SIGNAL(triggered(bool)),this,SLOT(oneUpCrossFourTest100Slot())); // 涓�闃崇┛鍥涚嚎鍥炴祴 // 澶勭悊鏁版嵁鐖彇鐨勬搷浣� @@ -116,18 +165,28 @@ on_pushButton_get_clicked(); // 琛ㄦ牸鍒楁帓搴� - ui->tableView->setSortingEnabled(false); - ui->tableView->horizontalHeader()->setSortIndicatorShown(false); - connect(ui->tableView->horizontalHeader(),&QHeaderView::sortIndicatorChanged,this,[=](int index,Qt::SortOrder order){ - qDebug()<<"sort:"<<index<<order; - m_model->sort(index,order); - ui->tableView->horizontalHeader()->setSortIndicatorShown(true); + ui->tableView->setSortingEnabled(true); +// ui->tableView->setSortingEnabled(false); +// ui->tableView->horizontalHeader()->setSortIndicatorShown(false); +// connect(ui->tableView->horizontalHeader(),&QHeaderView::sortIndicatorChanged,this,[=](int index,Qt::SortOrder order){ +// qDebug()<<"sort:"<<index<<order; +// //m_model->sort(index,order); +// m_customModel->sort(index,order); +// ui->tableView->horizontalHeader()->setSortIndicatorShown(true); - }); +// }); // 瀹氭椂鑾峰彇鑲$エ浠e彿鐨勫畾鏃跺櫒鐩稿叧 m_getCodeTimer = new QTimer(this); connect(m_getCodeTimer,SIGNAL(timeout()),this,SLOT(getCodeSlot())); + + // 鏀寔缂栬緫妗嗙殑妯$硦鍖归厤 + m_completer = new QCompleter(this); + m_completer->setModel(m_customModel); // 鍏宠仈鍖呭惈鎵�鏈夊尮閰嶅唴瀹圭殑妯″瀷鎴栬�呭瓧绗︿覆閾捐〃 + m_completer->setCaseSensitivity(Qt::CaseInsensitive); // 涓嶅尯鍒嗗ぇ灏忓啓 + m_completer->setCompletionMode(QCompleter::PopupCompletion); // 鑷姩鏄剧ず涓嬫媺妗� + m_completer->setFilterMode(Qt::MatchContains); // 鍓嶇紑鍖归厤銆佸寘鍚�佸悗缂� + ui->lineEdit_search->setCompleter(m_completer); // 鍏宠仈鍖归厤鐨勬帶浠� } @@ -188,6 +247,7 @@ rowItems.append(new QStandardItem(symbol)); rowItems.append(new QStandardItem(QString::number(market_capital,'f',2))); rowItems.append(new QStandardItem(QString::number(float_market_capital))); + //rowItems.append(new CustomItem(QString::number(float_market_capital))); QStandardItem *percentItem = new QStandardItem(QString::number(percent)); if(percent > 0){ percentItem->setData(QColor("red"),Qt::DecorationRole); // 娣诲姞涓�涓楗扮殑棰滆壊涓虹孩鑹� @@ -213,6 +273,9 @@ m_model->appendRow(rowItems); } } + + // 鍙戝皠淇″彿 + emit sendCodeNames(m_codeNames); } @@ -341,6 +404,148 @@ macd_buy = 1; oldVolume = volume; } + } + }else if(m_menuIndex == 4){ + // 搴曢儴鍙嶈浆绛栫暐,鎻愬墠鐨勬劅鐭ョ殑鏃堕棿浼氭洿鏃╋紝寰楀埌鏇村ソ鐨勯鍒よ秼鍔� + // qDebug()<<"搴曢儴鍙嶈浆绛栫暐"; + if(i > 0){ + double volume_cur = jArr.at(i).toArray().at(1).toDouble(); + double volume_old = jArr.at(i-1).toArray().at(1).toDouble(); + double volume_rate = volume_cur / volume_old; + if(volume_rate > 2){ + qDebug()<<"搴曢儴鍙嶈浆绛栫暐:閲忚兘姣�"<<volume_rate<<code <<curDateTime<<"浠锋牸:" <<close; + QString info = QString("<font size=8 color=red> %4 搴曢儴鍙嶈浆绛栫暐:閲忚兘 鏃堕棿:%1 浠锋牸:%2 閲忚兘姣斿��=%3 </font>").arg(curDateTime).arg(close).arg(volume_rate).arg(code); + emit sendInfoMess(info); + } + } + + }else if(m_menuIndex == 5){ + // 澶氱瓥鐣ュ叡鎸�:閲忚兘銆丮ACD銆丮A銆丅OLL + + int cnt = 0; + // 閲忚兘 + if(i > 0){ + double volume_cur = jArr.at(i).toArray().at(1).toDouble(); + double volume_old = jArr.at(i-1).toArray().at(1).toDouble(); + double volume_rate = volume_cur / volume_old; + if(volume_rate > 2){ + cnt++; + qDebug()<<"澶氱瓥鐣ュ叡鎸�:閲忚兘姣�"<<volume_rate<<code <<curDateTime<<"浠锋牸:" <<close; + QString info = QString("<font size=8 color=red> %4 澶氱瓥鐣ュ叡鎸�:閲忚兘绛栫暐 鏃堕棿:%1 浠锋牸:%2 閲忚兘姣斿��=%3 鍏辨尟鍊�:%5</font>").arg(curDateTime).arg(close).arg(volume_rate).arg(code).arg(cnt); + emit sendInfoMess(info); + } + } + + // MACD绛栫暐 缁撳悎鎴愪氦閲忔潵鍒ゆ柇浼氭洿濂�:涔板叆鐐规垚浜ら噺缁х画鏀惧ぇ鍒欐寔鏈夛紝缂╁皬鍒欑鍦� + double dea = jArr.at(i).toArray().at(16).toVariant().toDouble(); + double dif = jArr.at(i).toArray().at(17).toVariant().toDouble(); + double macd = jArr.at(i).toArray().at(18).toVariant().toDouble(); + + if(macd_buy == 1 && oldVolume > volume){ + QString info = QString("<font size=8 color=green> %4 MACD 鎴愪氦閲忓垵娆¤椤� 绂诲満1:%1 浠锋牸:%2 MACD=%3 </font>").arg(curDateTime).arg(close).arg(macd).arg(code); + emit sendInfoMess(info); + macd_buy = 0; + oldVolume = 0; + + } + if(i > 0){ + double dea_old = jArr.at(i-1).toArray().at(16).toVariant().toDouble(); + double dif_old = jArr.at(i-1).toArray().at(17).toVariant().toDouble(); + double macd_old = jArr.at(i-1).toArray().at(18).toVariant().toDouble(); + + if(dif_old > dea_old && dif <= dea){ + // 姝诲弶 + qDebug()<<"MACD姝诲弶:"<<curDateTime<<" 浠锋牸:"<<close <<"MACD="<<macd ; + QString info=QString("<font size=8 color=green> %4 MACD姝诲弶:%1 浠锋牸:%2 MACD=%3 </font>").arg(curDateTime).arg(close).arg(macd).arg(code); + emit sendInfoMess(info); + }else if(dif_old < dea_old && dif >= dea){ + // 閲戝弶 + cnt++; + qDebug()<<"MACD閲戝弶:"<<curDateTime<<" 浠锋牸:"<<close <<"MACD="<<macd <<"寤鸿璁板綍褰撳墠閲戝弶MACD鐨勫�硷紝鑻ュ悗闈㈡湁浣庝簬姝ゅ�硷紝鍏虫敞绂诲満鎻愮ず"; + QString info=QString("<font size=9 color=red> %4 MACD閲戝弶:%1 浠锋牸:%2 MACD=%3 鍏辨尟鍊�:%5 </font>").arg(curDateTime).arg(close).arg(macd).arg(code).arg(cnt); + emit sendInfoMess(info); + + macd_buy = 1; + oldVolume = volume; + } + } + + + // MA ma10浜a20 閲戝弶锛宮a10浜a60 姝诲弶 + double ma5 = jArr.at(i).toArray().at(12).toVariant().toDouble(); + double ma10 = jArr.at(i).toArray().at(13).toVariant().toDouble(); + double ma20 = jArr.at(i).toArray().at(14).toVariant().toDouble(); + double ma30 = jArr.at(i).toArray().at(15).toVariant().toDouble(); + //qDebug()<<"MA5-10-20-30"<<ma5<<ma10<<ma20<<ma30; + if(i>0){ + double ma5_old = jArr.at(i-1).toArray().at(12).toVariant().toDouble(); + double ma10_old = jArr.at(i-1).toArray().at(13).toVariant().toDouble(); + double ma20_old = jArr.at(i-1).toArray().at(14).toVariant().toDouble(); + double ma30_old = jArr.at(i-1).toArray().at(15).toVariant().toDouble(); + +// if(ma5_old > ma20_old && ma5 <= ma20){ +// // 姝诲弶 +// qDebug()<<"MA5-20姝诲弶:"<<curDateTime<<" 浠锋牸:"<<close; +// }else if(ma5_old < ma20_old && ma5 >= ma20){ +// // 閲戝弶 +// qDebug()<<"MA5-20閲戝弶:"<<curDateTime<<" 浠锋牸:"<<close; +// } + + if(ma10_old > ma20_old && ma10 <= ma20){ + // 姝诲弶 + qDebug()<<"MA10-20姝诲弶:"<<curDateTime<<" 浠锋牸:"<<close; + if(buy_price == 0) buy_price = close; + double tmp_rate = (close-buy_price)/buy_price; + rate_all += tmp_rate; + + QString info = QString("<font size=8 color=green> %3 %6 MA10-20姝诲弶:%1 浠锋牸:%2 鐩堝埄姣�:%4 鎬荤泩鍒�:%5</font>").arg(curDateTime).arg(close).arg(code) + .arg(QString::number(tmp_rate*100)).arg(QString::number(rate_all*100)).arg(m_codeNames[code]); + emit sendInfoMess(info); + //buy_price = close; // 姝诲弶涔板叆鐨勬儏鍐� + }else if(ma10_old < ma20_old && ma10 >= ma20){ + // 閲戝弶 + cnt++; + buy_price = close; // 閲戝弶涔板叆鐨勬儏鍐� + + qDebug()<<"MA10-20閲戝弶:"<<curDateTime<<" 浠锋牸:"<<close; + QString info = QString("<font size=8 color=red> %3 %4 MA10-20閲戝弶:%1 浠锋牸:%2 鍏辨尟鍊�:%5 </font>").arg(curDateTime).arg(close).arg(code).arg(m_codeNames[code]).arg(cnt); + //.arg(QString::number(tmp_rate*100)).arg(QString::number(rate_all*100)); + emit sendInfoMess(info); + + } + } + + }else if(m_menuIndex == 6){ + // 涓�闃崇┛鍥涚嚎 + + double ma5 = jArr.at(i).toArray().at(12).toVariant().toDouble(); + double ma10 = jArr.at(i).toArray().at(13).toVariant().toDouble(); + double ma20 = jArr.at(i).toArray().at(14).toVariant().toDouble(); + double ma30 = jArr.at(i).toArray().at(15).toVariant().toDouble(); + + double open = jArr.at(i).toArray().at(2).toVariant().toDouble(); + long long market_cap = jArr.at(i).toArray().at(22).toVariant().toLongLong(); + + double volume_rate = 0; + if(i > 0){ // 璁$畻閲忚兘姣� + double volume_cur = jArr.at(i).toArray().at(1).toDouble(); + double volume_old = jArr.at(i-1).toArray().at(1).toDouble(); + volume_rate = volume_cur / volume_old; + } + + if(ma5 >= open && ma10 >= open && ma20 >= open && ma30 >= open + && ma5 <= close && ma10 <= close && ma20 <= close && ma30 <= close){ + qDebug()<<"涓�闃崇┛鍥涚嚎:"<< code <<curDateTime<<" 浠锋牸:"<<close << "閲忚兘姣�:"<<volume_rate; + if(volume_rate > 4){ + QString info = QString("<font size=8 color=blue> %3 %4 涓�闃崇┛鍥涚嚎:%1 浠锋牸:%2 閲忚兘姣�:%5 鍛ㄦ湡:%6 甯傚��:%7浜�</font>").arg(curDateTime).arg(close).arg(code).arg(m_codeNames[code]).arg(volume_rate) + .arg(m_dateType).arg(market_cap/100000000.0); + emit sendInfoMess(info); + }else{ + QString info = QString("<font size=8 color=red> %3 %4 涓�闃崇┛鍥涚嚎:%1 浠锋牸:%2 閲忚兘姣�:%5 鍛ㄦ湡:%6 甯傚��:%7浜�</font>").arg(curDateTime).arg(close).arg(code).arg(m_codeNames[code]).arg(volume_rate) + .arg(m_dateType).arg(market_cap/100000000.0); + emit sendInfoMess(info); + } + } } @@ -533,12 +738,14 @@ if(m_model->rowCount() == 0)return; // 闃叉寮傚父 int row = ui->tableView->currentIndex().row(); // 鍙栧嚭鑿滃崟鎵�鍦ㄧ殑琛屽彿 - QString symbol = m_model->item(row,1)->text(); // 鍙栧綋鍓嶈鎵�鍦ㄧ殑鑲$エ浠e彿 +// QString symbol = m_model->item(row,1)->text(); // 鍙栧綋鍓嶈鎵�鍦ㄧ殑鑲$エ浠e彿 + QString symbol = m_customModel->data(m_customModel->index(row,1)).toString(); qint64 begin = QDateTime::currentMSecsSinceEpoch(); // 鍙栧綋鍓嶆椂闂存埑 m_numsCnt = 30; // 杩欓噷鏄缃幏鍙栧崟涓偂绁ㄧ殑鏁版嵁閲� QString urlStr = QString("https://stock.xueqiu.com/v5/stock/chart/kline.json?symbol=%1&begin=%2&period=week&type=before&count=-%3&indicator=kline").arg(symbol).arg(begin).arg(m_numsCnt); qDebug()<<urlStr; - qDebug()<<"褰撳墠鑲$エ:"<<symbol<<m_model->item(row,0)->text(); +// qDebug()<<"褰撳墠鑲$エ:"<<symbol<<m_model->item(row,0)->text(); + qDebug()<<"褰撳墠鑲$エ:"<<symbol<<m_customModel->data(m_customModel->index(row,0)).toString(); // 涓嬩竴姝ュ氨鏄牴鎹畊rl璇锋眰鍒扮殑鏁版嵁锛岃繘琛屽垎鏋� m_menuIndex = 0; // 绗竴涓彍鍗� m_request.setUrl(QUrl(urlStr)); // 璁剧疆鏂扮殑缃戝潃 @@ -550,7 +757,8 @@ qDebug()<<"鏈�鏂颁环鏍�"; if(m_model->rowCount() == 0)return; int row = ui->tableView->currentIndex().row(); - QString symbol = m_model->item(row,1)->text(); // 鍙栧綋鍓嶈鎵�鍦ㄧ殑鑲$エ浠e彿 +// QString symbol = m_model->item(row,1)->text(); // 鍙栧綋鍓嶈鎵�鍦ㄧ殑鑲$エ浠e彿 + QString symbol = m_customModel->data(m_customModel->index(row,1)).toString(); qint64 begin = QDateTime::currentMSecsSinceEpoch(); // 鍙栧綋鍓嶆椂闂存埑 int numsCnt = 20; QString urlStr = QString("https://stock.xueqiu.com/v5/stock/chart/kline.json?symbol=%1&begin=%2&period=day&type=before&count=-%3&indicator=kline").arg(symbol).arg(begin).arg(numsCnt); @@ -567,12 +775,14 @@ qDebug()<<"鎵цMA绛栫暐"; emit sendInfoMess("<font size=12 color=pink>鎵цMA绛栫暐 </font>"); int curRow = ui->tableView->currentIndex().row(); - QString symbol = m_model->item(curRow,1)->text(); +// QString symbol = m_model->item(curRow,1)->text(); + QString symbol = m_customModel->data(m_customModel->index(curRow,1)).toString(); qint64 begin = QDateTime::currentMSecsSinceEpoch(); // 鍙栧綋鍓嶆椂闂存埑 int numsCnt = 300; QString urlStr = QString("https://stock.xueqiu.com/v5/stock/chart/kline.json?symbol=%1&begin=%2&period=%4&type=before&count=-%3&indicator=kline,ma").arg(symbol).arg(begin).arg(numsCnt).arg(m_dateType); qDebug()<<urlStr; - qDebug()<<"褰撳墠鑲$エ:"<<symbol<<m_model->item(curRow,0)->text(); +// qDebug()<<"褰撳墠鑲$エ:"<<symbol<<m_model->item(curRow,0)->text(); + qDebug()<<"褰撳墠鑲$エ:"<<symbol<<m_customModel->data(m_customModel->index(curRow,0)).toString(); // 涓嬩竴姝ュ氨鏄牴鎹畊rl璇锋眰鍒扮殑鏁版嵁锛岃繘琛屽垎鏋� m_menuIndex = 2; // 绗笁涓彍鍗曢」 m_request.setUrl(QUrl(urlStr)); @@ -582,9 +792,22 @@ void GetStockList::maTest100Slot() { - for(int i=0;i<m_model->rowCount() && i < m_maTestNum;++i){ - ui->tableView->setCurrentIndex(m_model->index(i,0)); // 璁剧疆褰撳墠琛ㄦ牸绱㈠紩锛屼富瑕佹槸涓轰簡璁剧疆琛� +// for(int i=0;i<m_model->rowCount() && i < m_maTestNum;++i){ +// ui->tableView->setCurrentIndex(m_model->index(i,0)); // 璁剧疆褰撳墠琛ㄦ牸绱㈠紩锛屼富瑕佹槸涓轰簡璁剧疆琛� +// maPolicySlot(); // 璋冪敤MA绛栫暐鍘诲洖娴� +// } + + for(int i=0;i<m_customModel->rowCount() && i < m_maTestNum;++i){ + ui->tableView->setCurrentIndex(m_customModel->index(i,0)); // 璁剧疆褰撳墠琛ㄦ牸绱㈠紩锛屼富瑕佹槸涓轰簡璁剧疆琛� maPolicySlot(); // 璋冪敤MA绛栫暐鍘诲洖娴� + } +} + +void GetStockList::multiResonateTest100Slot() +{ + for(int i=0;i<m_customModel->rowCount() && i < m_maTestNum;++i){ + ui->tableView->setCurrentIndex(m_customModel->index(i,0)); // 璁剧疆褰撳墠琛ㄦ牸绱㈠紩锛屼富瑕佹槸涓轰簡璁剧疆琛� + multiResonatePolicySlot(); // 璋冪敤澶氱瓥鐣ュ叡鎸瓥鐣ュ幓鍥炴祴 } } @@ -593,17 +816,101 @@ qDebug()<<"鎵цMACD绛栫暐"; emit sendInfoMess("<font size=12 color=pink>鎵цMACD绛栫暐 </font>"); int curRow = ui->tableView->currentIndex().row(); - QString symbol = m_model->item(curRow,1)->text(); +// QString symbol = m_model->item(curRow,1)->text(); + + QString symbol = m_customModel->data(m_customModel->index(curRow,1)).toString(); qint64 begin = QDateTime::currentMSecsSinceEpoch(); // 鍙栧綋鍓嶆椂闂存埑 int numsCnt = 300; QString urlStr = QString("https://stock.xueqiu.com/v5/stock/chart/kline.json?symbol=%1&begin=%2&period=week&type=before&count=-%3&indicator=kline,macd").arg(symbol).arg(begin).arg(numsCnt); qDebug()<<urlStr; - qDebug()<<"褰撳墠鑲$エ:"<<symbol<<m_model->item(curRow,0)->text(); + qDebug()<<"褰撳墠鑲$エ:"<<symbol<<m_customModel->data(m_customModel->index(curRow,0)).toString(); // 涓嬩竴姝ュ氨鏄牴鎹畊rl璇锋眰鍒扮殑鏁版嵁锛岃繘琛屽垎鏋� m_menuIndex = 3; // 绗洓涓彍鍗曢」 m_request.setUrl(QUrl(urlStr)); m_manager.get(m_request); +} + +void GetStockList::buttomToUpPolicySlot() +{ + /* + 澶嶇洏涔嬪墠鐨勬湀绾跨獊鐮存儏鍐碉紝鏀鹃噺涓婃定锛�5鍊嶅乏鍙筹紝骞朵笖鍦�60鏃ュ潎绾夸笂鍐查珮锛屼笉鍥炶惤锛屽ぇ姒傜巼鍙互缁х画鍐� + 鍏虫敞濂藉啿鐨勫舰鎬侊紝鍔犱笂寰堝ソ鐨勬崲鎵嬬巼80%+锛岀敋鑷�100%+锛岃鏄庡厖鍒嗘崲鎵嬩簡锛岀獊鐮翠細鏇村ソ锛屾湁灏变細璧氬鍊� + 骞朵笖澶氭棩鏌ョ湅锛屾瘮渚嬪�间竴鐩村湪鏀惧ぇ锛岃鏄庡緢闈犺氨锛屽氨鏄湁涓�涓暟鍊兼瘮渚嬬殑鐖崌杩囩▼锛岄偅灏卞彲浠ラ噸浠撲拱鍏ョ瓑鏀剁泭浜嗭紝鍙互缁樺埗涓�鏉℃洸绾挎潵瑙傚療鎯呭喌 + */ + + qDebug()<<"鎵ц搴曢儴鍙嶈浆绛栫暐"; + emit sendInfoMess("<font size=12 color=pink>鎵ц搴曢儴鍙嶈浆绛栫暐 </font>"); + int curRow = ui->tableView->currentIndex().row(); +// QString symbol = m_model->item(curRow,1)->text(); + + QString symbol = m_customModel->data(m_customModel->index(curRow,1)).toString(); + qint64 begin = QDateTime::currentMSecsSinceEpoch(); // 鍙栧綋鍓嶆椂闂存埑 + int numsCnt = 300; + QString urlStr = QString("https://stock.xueqiu.com/v5/stock/chart/kline.json?symbol=%1&begin=%2&period=%4&type=before&count=-%3&indicator=kline,macd").arg(symbol).arg(begin).arg(numsCnt).arg(m_dateType); + qDebug()<<urlStr; + qDebug()<<"褰撳墠鑲$エ:"<<symbol<<m_customModel->data(m_customModel->index(curRow,0)).toString(); + // 涓嬩竴姝ュ氨鏄牴鎹畊rl璇锋眰鍒扮殑鏁版嵁锛岃繘琛屽垎鏋� + m_menuIndex = 4; // 绗簲涓彍鍗曢」 + m_request.setUrl(QUrl(urlStr)); + m_manager.get(m_request); +} + +void GetStockList::multiResonatePolicySlot() +{ + qDebug()<<"澶氱瓥鐣ュ叡鎸�:閲忚兘銆丮ACD銆丮A銆丅OLL"; + emit sendInfoMess("<font size=12 color=pink>鎵ц澶氱瓥鐣ュ叡鎸� </font>"); + int curRow = ui->tableView->currentIndex().row(); +// QString symbol = m_model->item(curRow,1)->text(); + + QString symbol = m_customModel->data(m_customModel->index(curRow,1)).toString(); + qint64 begin = QDateTime::currentMSecsSinceEpoch(); // 鍙栧綋鍓嶆椂闂存埑 + int numsCnt = 200; + QString urlStr = QString("https://stock.xueqiu.com/v5/stock/chart/kline.json?symbol=%1&begin=%2&period=%4&type=before&count=-%3&indicator=kline,macd,ma,boll").arg(symbol).arg(begin).arg(numsCnt).arg(m_dateType); + qDebug()<<urlStr; + qDebug()<<"褰撳墠鑲$エ:"<<symbol<<m_customModel->data(m_customModel->index(curRow,0)).toString(); + // 涓嬩竴姝ュ氨鏄牴鎹畊rl璇锋眰鍒扮殑鏁版嵁锛岃繘琛屽垎鏋� + m_menuIndex = 5; // 绗叚涓彍鍗曢」 + m_request.setUrl(QUrl(urlStr)); + m_manager.get(m_request); +} + +void GetStockList::oneUpCrossFourSlot() +{ + /* 涓�闃崇┛鍥涚嚎 + K绾垮嚭鐜颁簡澶ч槼绾垮苟涓旇疮绌�4鏉″潎绾匡紝璇存槑鍦ㄧ寷娑ㄤ簡锛屽苟涓旈噺鑳戒篃璺熶笂鐨勮瘽锛屽氨璇存槑寮哄姴 + + 鏃銆佸懆K銆佹湀K灏卞緢鏄庢樉銆� + 澶ц秼鍔夸互鍛ㄣ�佹湀涓轰富锛岄�傚悎涓暱绾垮鐞� + --------------------------- + 涔熼潪甯搁�傚悎瓒呯煭绾跨殑澶勭悊锛�30鍒嗐��60鍒嗐��120鍒嗙殑澶х┛闃崇嚎涔熷緢鏄庢樉 + --------------------------- + 灏辨槸寮�鐩樹环鍜屾敹鐩樹环鍖呭惈浜嗕竴涓尯闂达紝杩欎釜鍖洪棿鍐呴兘鎶奙a5 Ma10 Ma20 Ma30缁欏寘浣忎簡锛岃鏄庤Е鍙戜簡涓�闃崇┛鍥涚嚎 + */ + qDebug()<<"涓�闃崇┛鍥涚嚎绛栫暐"; + emit sendInfoMess("<font size=12 color=pink>鎵ц涓�闃崇┛鍥涚嚎绛栫暐 </font>"); + int curRow = ui->tableView->currentIndex().row(); +// QString symbol = m_model->item(curRow,1)->text(); + + QString symbol = m_customModel->data(m_customModel->index(curRow,1)).toString(); + qint64 begin = QDateTime::currentMSecsSinceEpoch(); // 鍙栧綋鍓嶆椂闂存埑 + int numsCnt = 200; + QString urlStr = QString("https://stock.xueqiu.com/v5/stock/chart/kline.json?symbol=%1&begin=%2&period=%4&type=before&count=-%3&indicator=kline,macd,ma,boll,market_capital").arg(symbol).arg(begin).arg(numsCnt).arg(m_dateType); + qDebug()<<urlStr; + qDebug()<<"褰撳墠鑲$エ:"<<symbol<<m_customModel->data(m_customModel->index(curRow,0)).toString(); + // 涓嬩竴姝ュ氨鏄牴鎹畊rl璇锋眰鍒扮殑鏁版嵁锛岃繘琛屽垎鏋� + m_menuIndex = 6; // 绗竷涓彍鍗曢」 + m_request.setUrl(QUrl(urlStr)); + m_manager.get(m_request); + +} + +void GetStockList::oneUpCrossFourTest100Slot() +{ + for(int i=0;i<m_customModel->rowCount() && i < m_maTestNum;++i){ + ui->tableView->setCurrentIndex(m_customModel->index(i,0)); // 璁剧疆褰撳墠琛ㄦ牸绱㈠紩锛屼富瑕佹槸涓轰簡璁剧疆琛� + oneUpCrossFourSlot(); // 璋冪敤涓�闃崇┛鍥涚嚎鍘诲洖娴� + } } void GetStockList::getCodeSlot() @@ -625,6 +932,11 @@ } +void GetStockList::pollMultiSlot() +{ + multiResonateTest100Slot(); // 澶氱瓥鐣ュ叡鎸洖娴� +} + void GetStockList::on_pushButton_industry_clicked() { // 鑾峰彇琛屼笟淇℃伅锛岃兘鎷垮埌 琛屼笟浠g爜鍜屽悕瀛楋紝绠�鍐欑瓑 @@ -633,3 +945,130 @@ m_manager.get(m_request); } + +void GetStockList::getLastClosePrice(QString name) +{ + for(int i=0;i<m_model->rowCount();++i){ + if(m_model->item(i,0)->text() == name){ + QString closePrice = m_model->item(i,5)->text(); + emit sendClosePrice(name,closePrice); + } + } +} + +void GetStockList::on_pushButton_filterCap_clicked() +{ + double begin = ui->lineEdit_beginCap->text().toDouble(); + double end = ui->lineEdit_endCap->text().toDouble(); + int rows = m_customModel->rowCount(); + for(int i=rows - 1;i > 0;--i){ + double allCap = m_customModel->data(m_customModel->index(i,2)).toDouble(); + if( allCap < begin || allCap > end){ + m_customModel->removeRow(i); + } + } +} + +void GetStockList::on_pushButton_search_clicked() +{ + ui->tableView->clearSelection(); + QString condition = ui->lineEdit_search->text(); + for(int i =0;i<m_customModel->rowCount();++i){ + if(m_customModel->data(m_customModel->index(i,0)).toString() == condition + || m_customModel->data(m_customModel->index(i,1)).toString() == condition) + { + //ui->tableView->setCurrentIndex(m_customModel->index(i,0)); + ui->tableView->selectRow(i); + break; + } + } +} + +void GetStockList::on_lineEdit_search_returnPressed() +{ + on_pushButton_search_clicked(); +} + +void GetStockList::showHistoryModelData(QVector<QVector<QString>> &model) // 浠庡巻鍙查偅杈瑰皢鏁版嵁鍙戣繃鏉� +{ + qDebug()<<QDateTime::currentDateTime(); + m_model->setRowCount(0); + for(int i=0;i<model.size();++i){ + //qDebug()<<"i="<<i; + QList<QStandardItem*> items; + m_codeNames[model[i][1]] = model[i][0]; + for(int j=0;j<model.at(0).size();++j){ + items.append(new QStandardItem(model[i][j])); + + if(j==2){ + items.append(new QStandardItem(model[i][j])); + } + if(j==3){ + QStandardItem *percentItem = items.back(); + if(percentItem->text().toDouble() > 0){ + percentItem->setData(QColor("red"),Qt::DecorationRole); // 娣诲姞涓�涓楗扮殑棰滆壊涓虹孩鑹� + percentItem->setData(QColor("red"),Qt::TextColorRole); // 灏嗗瓧浣撻鑹茶缃负绾㈣壊 + items.at(0)->setData(QColor("red"),Qt::TextColorRole); // 灏嗚偂绁ㄥ悕瀛楄缃负绾㈣壊 + } + else if(percentItem->text().toDouble() < 0){ + percentItem->setData(QColor("green"),Qt::BackgroundColorRole); + items.at(0)->setData(QColor("green"),Qt::TextColorRole); + } + } + + } + m_model->appendRow(items); + } + qDebug()<<"鍘嗗彶鍒颁俊鎭祴鍊煎畬鎴� 琛屾暟:"<<m_model->rowCount(); + qDebug()<<QDateTime::currentDateTime(); +} + +void GetStockList::showHistoryModelData(QStandardItemModel *model) +{ + +// qDebug()<<QDateTime::currentDateTime(); +// //ui->tableView->setModel(model); +// QVector<QVector<QString>> vec; +// for(int i=0;i<model->rowCount();++i){ +// //QString row; +// QVector<QString> tmp; + +// m_codeNames[model->item(i,1)->text()] = model->item(i,0)->text(); + +// for(int j=0;j<model->columnCount();++j){ +// //row+=model->item(i,j)->text()+" "; +// tmp.append(model->item(i,j)->text()); +// } +// //qDebug()<<i<<row; +// vec.append(tmp); +// } +// qDebug()<<"vec size:"<<vec.size(); + + qDebug()<<QDateTime::currentDateTime(); + m_model->setRowCount(0); + for(int i=0;i<model->rowCount();++i){ + QList<QStandardItem*> items; + m_codeNames[model->item(i,1)->text()] = model->item(i,0)->text(); + for(int j=0;j<model->columnCount();++j){ + items.append(new QStandardItem(model->item(i,j)->text())); + if(j==2){ + items.append(new QStandardItem(model->item(i,j)->text())); + } + if(j==3){ + QStandardItem *percentItem = items.back(); + if(percentItem->text().toDouble() > 0){ + percentItem->setData(QColor("red"),Qt::DecorationRole); // 娣诲姞涓�涓楗扮殑棰滆壊涓虹孩鑹� + percentItem->setData(QColor("red"),Qt::TextColorRole); // 灏嗗瓧浣撻鑹茶缃负绾㈣壊 + items.at(0)->setData(QColor("red"),Qt::TextColorRole); // 灏嗚偂绁ㄥ悕瀛楄缃负绾㈣壊 + } + else if(percentItem->text().toDouble() < 0){ + percentItem->setData(QColor("green"),Qt::BackgroundColorRole); + items.at(0)->setData(QColor("green"),Qt::TextColorRole); + } + } + } + m_model->appendRow(items); + } + qDebug()<<"鍘嗗彶鍒颁俊鎭祴鍊煎畬鎴� 鏉℃暟:"<<m_model->rowCount(); + qDebug()<<QDateTime::currentDateTime(); +} -- Gitblit v1.8.0