Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,24 @@ int main(int argc, char* argv[]) {
}

for (size_t i = 0; i < runtimes.size(); ++i) {
if (!runtimes[i].adapter->start(runtimes[i].symbols, runtimes[i].books,
runtimes[i].metricsMap, snapshotDepth)) {
fprintf(stderr, "failed to start %s adapter\n", runtimes[i].name.c_str());
constexpr int kMaxStartAttempts = 10;
constexpr int kBackoffCapSec = 300;
int backoffSec = 30;
bool started = false;
for (int attempt = 1; attempt <= kMaxStartAttempts; ++attempt) {
if (runtimes[i].adapter->start(runtimes[i].symbols, runtimes[i].books,
runtimes[i].metricsMap, snapshotDepth)) {
started = true;
break;
}
fprintf(stderr, "failed to start %s adapter (attempt %d/%d), retrying in %ds\n",
runtimes[i].name.c_str(), attempt, kMaxStartAttempts, backoffSec);
std::this_thread::sleep_for(std::chrono::seconds(backoffSec));
backoffSec = std::min(backoffSec * 2, kBackoffCapSec);
}
if (!started) {
fprintf(stderr, "gave up starting %s adapter after %d attempts\n",
runtimes[i].name.c_str(), kMaxStartAttempts);
for (size_t j = 0; j < i; ++j) {
runtimes[j].adapter->stop();
}
Expand Down
4 changes: 2 additions & 2 deletions src/price_ladder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
// dense books (BTC/USDT at $0.01 tick).
//
// Memory: (2 * halfRange + 1) * 8 bytes per ladder.
// Default: ±300 000 ticks = ±$3 000 at $0.01 tick ≈ 4.8 MB per ladder.
// Default: ±5 000 ticks = ±$50 at $0.01 tick ≈ 78 KB per ladder.
class PriceLadder {
public:
static constexpr long long kDefaultTick = 1'000'000LL; // $0.01 in 1e8 units
static constexpr int kDefaultHalfRange = 300'000; // ±$3 000 at default tick
static constexpr int kDefaultHalfRange = 5'000; // ±$50 at default tick

explicit PriceLadder(long long tickSizeArg = kDefaultTick,
int halfRangeArg = kDefaultHalfRange);
Expand Down
6 changes: 6 additions & 0 deletions src/symbol_normalizer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ inline std::optional<std::string> SymbolNormalizer::fromCanonical(
for (char& c : result) {
if (c == '-') c = '/';
}
// Map canonical base currencies back to Kraken legacy tickers.
if (result.starts_with("BTC/")) {
result.replace(0, 3, "XBT");
} else if (result.starts_with("DOGE/")) {
result.replace(0, 4, "XDG");
}
return result;
}

Expand Down
Loading