-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathloadCommand.cpp
More file actions
44 lines (40 loc) · 1.22 KB
/
Copy pathloadCommand.cpp
File metadata and controls
44 lines (40 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Backtesting Engine in C++
//
// (c) 2026 Ryan McCaffery | https://mccaffers.com
// This code is licensed under MIT license (see LICENSE.txt for details)
// ---------------------------------------
#include "loadCommand.hpp"
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
#include "redisLoader.hpp"
int LoadCommand::run(int argc, const char* argv[]) {
if (argc < 3) {
std::cerr << "Usage: " << argv[0] << " load <path> [path...]"
<< std::endl;
return 1;
}
for (int i = 2; i < argc; ++i) {
const std::string path = argv[i];
std::ifstream ifs(path);
if (!ifs) {
std::cerr << "BacktestingEngine: failed to open file: " << path
<< std::endl;
return 1;
}
std::ostringstream buffer;
buffer << ifs.rdbuf();
if (ifs.bad()) {
std::cerr << "BacktestingEngine: failed to read file: " << path
<< std::endl;
return 1;
}
const int rc = RedisLoader::load(buffer.str(), "127.0.0.1", 6379,
"strategy_queue");
if (rc != 0) {
return rc;
}
}
return 0;
}