wumu
2025-09-01 0ec4f3ed2e2584bebb1fb0cc92a039f59fcfa529
250901
4个文件已修改
81 ■■■■■ 已修改文件
analysisbyrediscache.cpp 57 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
analysisbyrediscache.ui 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
clientmainwindow.ui 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
separateanalysis.cpp 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
analysisbyrediscache.cpp
@@ -31,7 +31,7 @@
    ui->tableView_2->setModel(m_modelResult);
    QStringList labels;
    labels<<"股票名字"<<"市值"<<"收盘价"<<"涨跌幅"<<"排名"<<"交易时间"<<"排名变化";
    labels<<"股票名字"<<"市值"<<"收盘价"<<"涨跌幅"<<"排名"<<"交易时间"<<"排名变化"<<"底部反转时间"<<"一阳穿四线时间";
    m_model->setHorizontalHeaderLabels(labels);
    m_modelResult->setHorizontalHeaderLabels(labels);
}
@@ -43,6 +43,7 @@
void AnalysisByRedisCache::on_pushButton_loadDataSQLRedis_clicked()
{
    ui->label_load->setText("缓存加载中...");
    QString begin_date = ui->dateEdit->text();
    QString limit_str = ui->comboBox->currentText();
    QString sql = QString("select * from stock_day_info where time_trade > '%1' limit %2;").arg(begin_date).arg(limit_str);
@@ -58,8 +59,11 @@
    // 第二次查询应该从缓存获取
    timer.restart();
    result = m_dbCache.query(sql);
    qDebug() << "Cached query executed in" << timer.elapsed() << "ms";
    qint64 resTime = timer.elapsed();
    qDebug() << "Cached query executed in" << resTime << "ms";
    m_result = result;
    ui->label_load->setText(QString("缓存加载%2条,耗时%1ms").arg(QString::number(resTime)).arg(QString::number(result.size())));
}
// 滑动窗口计算排名变化
@@ -104,6 +108,9 @@
    int rank_val = 0;
    int cnt = 0;
    int bigFlag = false;
    int bigRankUp = false; // 突然从很低的排名上升到大排名
    bool big_3000 = false;
    bool big_2000 = false;
    for(auto it:m_result){
        if(it["name"].toString() == name){
//            qDebug()<<it["name"].toString()<<it["close"].toString()<<it["amount_rank"].toString()<<it["time_trade"].toString();
@@ -133,13 +140,40 @@
            if(rank_val != 0){
                double rank_rate = 1 - (amount_rank.toDouble()/rank_val);
                //items.append(new QStandardItem(QString::number(rank_rate)));
                rank_val = amount_rank.toInt();
                QStandardItem * amount_rank_item = new QStandardItem(QString::number(rank_rate));
                if(rank_rate > 0.9){
                    amount_rank_item->setData(QColor("red"),Qt::BackgroundColorRole);
                    bigFlag = true;
                }
                if(rank_rate > 0.7 && rank_val >= 1000 && amount_rank.toInt() < 1000){
                    bigRankUp = true;
                    bigFlag = true;
                    if(rank_rate > 0.9){
                        // 紫色
                        amount_rank_item->setData(QColor(170, 85, 255),Qt::BackgroundColorRole);
                    }else{
                        // 粉色
                        amount_rank_item->setData(QColor("pink"),Qt::BackgroundColorRole);
                    }
                    if(rank_val >= 3000){
                        amount_rank_item->setData(QColor(85,170,255),Qt::BackgroundColorRole);
                        big_3000 = true;
                    }
                    else if(rank_val >= 2000){
                        amount_rank_item->setData(QColor(85,255,255),Qt::BackgroundColorRole);
                        big_2000 = true;
                    }
                }
                items.append(amount_rank_item);
                rank_val = amount_rank.toInt(); // 到后面再赋值
            }
            if(rank_val == 0 && amount_rank.toInt() != 0){
@@ -153,10 +187,27 @@
                    items_2.append(new QStandardItem(items.at(i)->text()));
                    if(i==6 && items.at(i)->text().toDouble() > 0.95){
                        items_2.back()->setData(QColor("red"),Qt::BackgroundColorRole);
                    }else if(i==6 && bigRankUp){
                        if(items.at(i)->text().toDouble() > 0.9){
                            items_2.back()->setData(QColor(170, 85, 255),Qt::BackgroundColorRole);
                        }else{
                            items_2.back()->setData(QColor("pink"),Qt::BackgroundColorRole);
                        }
                        if(big_3000){
                            items_2.back()->setData(QColor(85,170,255),Qt::BackgroundColorRole);
                        }
                        if(big_2000){
                            items_2.back()->setData(QColor(85,255,255),Qt::BackgroundColorRole);
                        }
                    }
                }
                m_modelResult->appendRow(items_2);
                bigFlag = false;
                bigRankUp = false;
                big_3000 = false;
                big_2000 = false;
            }
        }
analysisbyrediscache.ui
@@ -82,6 +82,13 @@
       </widget>
      </item>
      <item>
       <widget class="QLabel" name="label_load">
        <property name="text">
         <string>缓存未加载</string>
        </property>
       </widget>
      </item>
      <item>
       <spacer name="horizontalSpacer">
        <property name="orientation">
         <enum>Qt::Horizontal</enum>
clientmainwindow.ui
@@ -18,7 +18,7 @@
    <item row="0" column="0">
     <widget class="QTabWidget" name="tabWidget">
      <property name="currentIndex">
       <number>1</number>
       <number>0</number>
      </property>
      <widget class="QWidget" name="tab">
       <attribute name="title">
separateanalysis.cpp
@@ -142,12 +142,25 @@
            if(rank_val != 0){
                double rank_rate = 1 - (amount_rank.toDouble()/rank_val);
                //items.append(new QStandardItem(QString::number(rank_rate)));
                rank_val = amount_rank.toInt();
                QStandardItem * amount_rank_item = new QStandardItem(QString::number(rank_rate));
                if(rank_rate > 0.9){
                    amount_rank_item->setData(QColor("red"),Qt::BackgroundColorRole);
                }
                if(rank_rate > 0.7 && rank_val >= 1000 && amount_rank.toInt() < 1000){
                    if(rank_rate > 0.9){
                        // 紫色
                        amount_rank_item->setData(QColor(170, 85, 255),Qt::BackgroundColorRole);
                    }else{
                        // 粉色
                        amount_rank_item->setData(QColor("pink"),Qt::BackgroundColorRole);
                    }
                }
                items.append(amount_rank_item);
                rank_val = amount_rank.toInt(); // 刷新排名
            }
            if(rank_val == 0 && amount_rank.toInt() != 0){