From 69fc6911e8c09e2a34640da642874eab0c8a2256 Mon Sep 17 00:00:00 2001 From: wumu <mayi@mayi.com> Date: 星期五, 24 一月 2025 22:28:20 +0800 Subject: [PATCH] 0124 --- regularinvestment.ui | 166 +++++++++++++++++++++++---- regularinvestment.h | 7 + getstocklist.cpp | 49 +++++++ getstocklist.h | 10 + regularinvestment.cpp | 51 ++++++++ getstocklist.ui | 41 ++++++ 6 files changed, 294 insertions(+), 30 deletions(-) diff --git a/getstocklist.cpp b/getstocklist.cpp index a0b32c2..61776ef 100644 --- a/getstocklist.cpp +++ b/getstocklist.cpp @@ -172,6 +172,14 @@ 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::MatchStartsWith); // 鍓嶇紑鍖归厤 + ui->lineEdit_search->setCompleter(m_completer); // 鍏宠仈鍖归厤鐨勬帶浠� + } GetStockList::~GetStockList() @@ -395,6 +403,8 @@ 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); } } @@ -503,6 +513,7 @@ 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){ // 璁$畻閲忚兘姣� @@ -514,7 +525,8 @@ if(ma5 >= open && ma10 >= open && ma20 >= open && ma30 >= open && ma5 <= close && ma10 <= close && ma20 <= close && ma30 <= close){ qDebug()<<"涓�闃崇┛鍥涚嚎:"<< code <<curDateTime<<" 浠锋牸:"<<close << "閲忚兘姣�:"<<volume_rate; - QString info = QString("<font size=8 color=red> %3 %4 涓�闃崇┛鍥涚嚎:%1 浠锋牸:%2 閲忚兘姣�:%5 鍛ㄦ湡:%6 </font>").arg(curDateTime).arg(close).arg(code).arg(m_codeNames[code]).arg(volume_rate).arg(m_dateType); + 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); } } @@ -810,7 +822,7 @@ */ qDebug()<<"鎵ц搴曢儴鍙嶈浆绛栫暐"; - emit sendInfoMess("<font size=12 color=pink>鎵цMACD绛栫暐 </font>"); + emit sendInfoMess("<font size=12 color=pink>鎵ц搴曢儴鍙嶈浆绛栫暐 </font>"); int curRow = ui->tableView->currentIndex().row(); // QString symbol = m_model->item(curRow,1)->text(); @@ -865,7 +877,7 @@ 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); + 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璇锋眰鍒扮殑鏁版嵁锛岃繘琛屽垎鏋� @@ -925,3 +937,34 @@ } } } + +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() +{ + 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)); + break; + } + } +} + +void GetStockList::on_lineEdit_search_returnPressed() +{ + on_pushButton_search_clicked(); +} diff --git a/getstocklist.h b/getstocklist.h index 25ba614..59e642a 100644 --- a/getstocklist.h +++ b/getstocklist.h @@ -11,6 +11,7 @@ #include <QLineSeries> // 鎶樼嚎绫� #include <QSplineSeries> // 鏇茬嚎绫� #include <QTimer> +#include <QCompleter> // 鐢ㄤ簬妯$硦鍖归厤 #include "customitem.h" #include "customsortproxymodel.h" @@ -69,6 +70,12 @@ void getLastClosePrice(QString name); // 閫氳繃鍚嶅瓧鑾峰彇鑲$エ浠锋牸妲� + void on_pushButton_filterCap_clicked(); + + void on_pushButton_search_clicked(); + + void on_lineEdit_search_returnPressed(); + private: Ui::GetStockList *ui; // 杩�2涓敤浜庣埇鍙栨暟鎹殑 @@ -95,6 +102,9 @@ QTimer *m_pollMultiTimer; // 杞澶氱瓥鐣ュ畾鏃跺櫒 + QCompleter *m_completer; // 鏀寔妯$硦鍖归厤 + + }; #endif // GETSTOCKLIST_H diff --git a/getstocklist.ui b/getstocklist.ui index cec3bef..c5e9596 100644 --- a/getstocklist.ui +++ b/getstocklist.ui @@ -25,6 +25,47 @@ </widget> </item> <item> + <widget class="QLineEdit" name="lineEdit_search"> + <property name="placeholderText"> + <string>璇疯緭鍏ヨ偂绁ㄥ悕瀛�</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="pushButton_search"> + <property name="text"> + <string>鏌ユ壘</string> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="label"> + <property name="text"> + <string>甯傚��(浜�):</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="lineEdit_beginCap"/> + </item> + <item> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>鍒�</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="lineEdit_endCap"/> + </item> + <item> + <widget class="QPushButton" name="pushButton_filterCap"> + <property name="text"> + <string>杩囨护甯傚��</string> + </property> + </widget> + </item> + <item> <widget class="QPushButton" name="pushButton_industry"> <property name="text"> <string>鑾峰彇琛屼笟瀵瑰簲鑲$エ</string> diff --git a/regularinvestment.cpp b/regularinvestment.cpp index dc02488..2d7a501 100644 --- a/regularinvestment.cpp +++ b/regularinvestment.cpp @@ -21,6 +21,7 @@ m_nameCodes["涓浗绁炲崕"]= "SH601088"; m_nameCodes["涓浗鐢典俊"]= "SH601728"; m_nameCodes["涓浗绉诲姩"]= "SH600941"; + m_nameCodes["宸ュ晢閾惰"]= "SH601398"; // 澶勭悊鏁版嵁鐖彇鐨勬搷浣� @@ -48,12 +49,19 @@ // 鍘昏姹傞椤� m_manager.get(m_request); - // 澶勭悊妯″瀷 + // 澶勭悊妯″瀷 鍥炴祴 m_model = new QStandardItemModel(0,7,this); ui->tableView->setModel(m_model); QStringList labels; labels<<"鏃堕棿"<<"涔板叆浠锋牸"<<"鏁伴噺(鎵�)"<<"鎵�闇�閲戦(鍏�)"<<"鏈�鏂颁环鏍�"<<"鐩堜簭姣�"<<"鐩堜簭閲戦"; m_model->setHorizontalHeaderLabels(labels); + + // 瀹氭姇涔板叆 + m_modelBuy = new QStandardItemModel(0,9,this); + ui->tableView_buyRecord->setModel(m_modelBuy); + QStringList buyLabels; + buyLabels<<"鐢宠鏃堕棿"<<"鐢宠浠锋牸(鍏�)"<<"鎴愪氦鏃堕棿"<<"鎴愪氦浠锋牸(鍏�)"<<"璐拱鏁伴噺(鎵�)"<<"鎵�闇�閲戦(鍏�)"<<"鏈�鏂颁环鏍�(鍏�)"<<"鐩堜簭姣�"<<"鐩堜簭閲戦(鍏�)"; + m_modelBuy->setHorizontalHeaderLabels(buyLabels); } @@ -66,9 +74,14 @@ void RegularInvestment::showClosePrice(QString name, QString closePrice) { qDebug()<<name<<closePrice; - ui->label_closePrice->setText(closePrice); + if(ui->comboBox->currentText() == name){ + ui->label_closePrice->setText(closePrice); + on_lineEdit_2_returnPressed(); // 鍒锋柊鎬讳环 + }else if(ui->comboBox_3->currentText() == name){ + ui->label_closePrice_2->setText(closePrice); + on_lineEdit_buyNum_returnPressed(); // 鍒锋柊鎬讳环 + } - on_lineEdit_2_returnPressed(); // 鍒锋柊鎬讳环 } void RegularInvestment::on_comboBox_currentIndexChanged(const QString &arg1) @@ -203,3 +216,35 @@ ui->label_winAll->setText(QString::number(allWin)); ui->label_allRate->setText(QString::number((allWin/allBuy)*100)); } + +void RegularInvestment::on_comboBox_3_currentIndexChanged(const QString &arg1) +{ + qDebug()<<"寮�濮嬪畾鎶曞綋鍓嶈偂绁ㄤ负:"<<arg1; + emit getClosePriceSignal(arg1); +} + +void RegularInvestment::on_lineEdit_buyNum_returnPressed() +{ + qDebug()<<ui->lineEdit_buyNum->text(); + double price = ui->lineEdit_buyNum->text().toInt()* 100 * ui->label_closePrice_2->text().toDouble(); + ui->lineEdit_money->setText(QString::number(price)); +} + +void RegularInvestment::on_pushButton_buy_clicked() +{ + QString applyTime = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss"); + QString name = ui->comboBox_3->currentText(); + QString code = m_nameCodes[name]; + QString numStr = ui->lineEdit_buyNum->text(); + QString applyPrice = ui->label_closePrice_2->text(); + double needMoney = numStr.toInt() * applyPrice.toDouble()*100; + + int rowCnt = m_modelBuy->rowCount(); + m_modelBuy->setRowCount(rowCnt+1); + + m_modelBuy->setItem(rowCnt,0,new QStandardItem(applyTime)); + m_modelBuy->setItem(rowCnt,1,new QStandardItem(applyPrice)); + m_modelBuy->setItem(rowCnt,4,new QStandardItem(numStr)); + m_modelBuy->setItem(rowCnt,5,new QStandardItem(QString::number(needMoney))); + +} diff --git a/regularinvestment.h b/regularinvestment.h index 2b8b1e6..3480e7a 100644 --- a/regularinvestment.h +++ b/regularinvestment.h @@ -36,10 +36,17 @@ void on_pushButton_sum_clicked(); + void on_comboBox_3_currentIndexChanged(const QString &arg1); + + void on_lineEdit_buyNum_returnPressed(); + + void on_pushButton_buy_clicked(); + private: Ui::RegularInvestment *ui; QStandardItemModel *m_model; + QStandardItemModel *m_modelBuy; QMap<QString,QString> m_nameCodes; // 鑲$エ鍚嶅瓧鍙婁唬鍙� diff --git a/regularinvestment.ui b/regularinvestment.ui index a186af7..146eb1d 100644 --- a/regularinvestment.ui +++ b/regularinvestment.ui @@ -18,7 +18,7 @@ <item row="0" column="0"> <widget class="QTabWidget" name="tabWidget"> <property name="currentIndex"> - <number>0</number> + <number>1</number> </property> <widget class="QWidget" name="tab"> <attribute name="title"> @@ -63,6 +63,11 @@ <item> <property name="text"> <string>涓浗绉诲姩</string> + </property> + </item> + <item> + <property name="text"> + <string>宸ュ晢閾惰</string> </property> </item> </widget> @@ -231,29 +236,142 @@ <attribute name="title"> <string>寮�濮嬪畾鎶�</string> </attribute> - <widget class="QGroupBox" name="groupBox_2"> - <property name="geometry"> - <rect> - <x>20</x> - <y>30</y> - <width>801</width> - <height>111</height> - </rect> - </property> - <property name="title"> - <string>瀹氭姇涔板叆</string> - </property> - </widget> - <widget class="QTableView" name="tableView_2"> - <property name="geometry"> - <rect> - <x>20</x> - <y>160</y> - <width>801</width> - <height>391</height> - </rect> - </property> - </widget> + <layout class="QGridLayout" name="gridLayout_5"> + <item row="0" column="0"> + <widget class="QGroupBox" name="groupBox_2"> + <property name="title"> + <string>瀹氭姇涔板叆</string> + </property> + <layout class="QGridLayout" name="gridLayout_4"> + <item row="0" column="0"> + <layout class="QHBoxLayout" name="horizontalLayout_4"> + <item> + <widget class="QLabel" name="label_8"> + <property name="text"> + <string>涓偂</string> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="comboBox_3"> + <property name="editable"> + <bool>true</bool> + </property> + <item> + <property name="text"> + <string>闀挎睙鐢靛姏</string> + </property> + </item> + <item> + <property name="text"> + <string>涓浗绁炲崕</string> + </property> + </item> + <item> + <property name="text"> + <string>涓浗鐢典俊</string> + </property> + </item> + <item> + <property name="text"> + <string>涓浗绉诲姩</string> + </property> + </item> + <item> + <property name="text"> + <string>宸ュ晢閾惰</string> + </property> + </item> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QLabel" name="label_13"> + <property name="text"> + <string>鏈�鏂颁环(鍏�)</string> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="label_closePrice_2"> + <property name="text"> + <string>0</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_3"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item row="0" column="1"> + <widget class="QPushButton" name="pushButton_buy"> + <property name="text"> + <string>鐢宠涔板叆</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <layout class="QHBoxLayout" name="horizontalLayout_5"> + <item> + <widget class="QLabel" name="label_11"> + <property name="text"> + <string>瀹氭姇閲戦[鍏僝</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="lineEdit_money"/> + </item> + </layout> + </item> + <item row="2" column="0"> + <layout class="QHBoxLayout" name="horizontalLayout_6"> + <item> + <widget class="QLabel" name="label_12"> + <property name="text"> + <string>瀹氭姇浠芥暟[鎵媇</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="lineEdit_buyNum"> + <property name="text"> + <string>1</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + </item> + <item row="1" column="0"> + <widget class="QTableView" name="tableView_buyRecord"/> + </item> + </layout> </widget> </widget> </item> -- Gitblit v1.8.0