// backend/cpp_engine/fast_chart_generator.cpp // High Performance C++ Retrospective Chart & Dual Mode Engine for Quant.ai // Execution Time: < 3ms #include #include #include #include #include #include using namespace std; string readFile(const string& filePath) { ifstream f(filePath); if (!f.is_open()) return ""; stringstream ss; ss << f.rdbuf(); return ss.str(); } int main(int argc, char* argv[]) { auto t0 = chrono::high_resolution_clock::now(); string today_str = "2026-08-26"; if (argc > 1 && string(argv[1]).length() == 10) { today_str = argv[1]; } string basePath = "./backend/"; if (!ifstream("./backend/watchlist.json").is_open()) { basePath = "./"; } string tradeHistFile = basePath + "trade_history.json"; string realTradesJson = readFile(tradeHistFile); if (realTradesJson.empty()) realTradesJson = "{\"trade_history\":[]}"; stringstream html; html << "\n" << "\n" << "\n" << " \n" << " \n" << " Quant.ai - 双模式对比与历史 K 线复盘看板\n" << " \n" << " \n" << "\n" << "\n" << "
\n" << "
\n" << "
Quant.ai | 双模式对比与历史 K 线复盘 ⚡ C++ 毫秒级引擎
\n" << "
对比模式:实盘成交流水 vs 新升级 ML 策略仿真回测
\n" << "
\n" << "
\n" << " 📅 切换历史交易日:\n" << " \n" << "
\n" << "
\n" << "
\n" << " \n" << " \n" << "
\n" << "
\n" << "
\n" << "
\n" << " \n" << " \n" << " \n" << " \n" << "
\n" << "
\n" << "
\n" << "
\n" << "
\n" << "
\n" << "

📋 买卖位置与持仓明细

\n" << " \n" << " \n" << " \n" << " \n" << " \n" << " \n" << " \n" << " \n" << " \n" << " \n" << " \n" << " \n" << " \n" << " \n" << " \n" << " \n" << " \n" << " \n" << "
股票方向买入/做空时间入场价平仓时间平仓价持仓时长成交股数名义金额净盈亏 ($)收益率 (%)离场原因
\n" << "
\n" << " \n" << "\n" << "\n"; string outputPath = basePath + "data/charts/trade_comparison_dashboard.html"; ofstream outFile(outputPath); if (outFile.is_open()) { outFile << html.str(); outFile.close(); } auto t1 = chrono::high_resolution_clock::now(); auto elapsed = chrono::duration_cast(t1 - t0).count(); cout << "✅ [C++ Engine] Successfully generated Dual-Mode K-line dashboard in " << elapsed / 1000.0 << " ms!" << endl; return 0; }