| | |
| | | ui->tableView_2->setModel(m_modelResult); |
| | | |
| | | QStringList labels; |
| | | labels<<"股票名字"<<"市值"<<"收盘价"<<"涨跌幅"<<"排名"<<"交易时间"<<"排名变化"; |
| | | labels<<"股票名字"<<"市值"<<"收盘价"<<"涨跌幅"<<"排名"<<"交易时间"<<"排名变化"<<"底部反转时间"<<"一阳穿四线时间"; |
| | | m_model->setHorizontalHeaderLabels(labels); |
| | | m_modelResult->setHorizontalHeaderLabels(labels); |
| | | } |
| | |
| | | |
| | | 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); |
| | |
| | | // 第二次查询应该从缓存获取 |
| | | 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()))); |
| | | |
| | | } |
| | | |
| | | // 滑动窗口计算排名变化 |
| | |
| | | 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(); |
| | |
| | | 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){ |
| | |
| | | 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; |
| | | } |
| | | } |
| | | |