48# include <gtest/gtest.h>
78 constexpr long long max_age_ms = 1000;
81 constexpr double clear_margin = 1e-9;
90 const Fee fees[] = {{
"0", 0, 1}, {
"1bp", 1, 10000}, {
"0.075%", 75, 100000}, {
"0.1%", 1, 1000}};
91 constexpr size_t fee_075 = 2;
92 constexpr size_t fee_10 = 3;
102 Rational() { mpq_init(q_); }
103 explicit Rational(
const double x) { mpq_init(q_); mpq_set_d(q_, x); }
104 Rational(
const Rational & other) { mpq_init(q_); mpq_set(q_, other.q_); }
105 Rational & operator=(
const Rational & other) { mpq_set(q_, other.q_);
return *
this; }
106 ~Rational() { mpq_clear(q_); }
108 Rational & operator+=(
const Rational & other) { mpq_add(q_, q_, other.q_);
return *
this; }
110 friend Rational
operator-(
const Rational & a,
const Rational & b)
113 mpq_sub(
r.q_, a.q_, b.q_);
117 Rational times(
const size_t factor)
const
120 mpq_set_ui(f.q_,
static_cast<unsigned long>(factor), 1);
122 mpq_mul(
r.q_, q_, f.q_);
126 Rational divided_by(
const size_t divisor)
const
129 mpq_set_ui(d.q_,
static_cast<unsigned long>(divisor), 1);
131 mpq_div(
r.q_, q_, d.q_);
135 friend int compare(
const Rational & a,
const Rational & b) {
return mpq_cmp(a.q_, b.q_); }
136 int sign()
const {
return mpq_sgn(q_); }
137 double to_double()
const {
return mpq_get_d(q_); }
141 bool mean_less(
const Rational & a,
const size_t la,
const Rational & b,
const size_t lb)
143 return compare(a.times(lb), b.times(la)) < 0;
146 bool mean_equal(
const Rational & a,
const size_t la,
const Rational & b,
const size_t lb)
148 return compare(a.times(lb), b.times(la)) == 0;
153 bool within_one_ulp(
const double computed,
const Rational & exact)
156 return exact.sign() == 0;
157 if ((computed < 0.0 ? -1 : 1) != exact.sign())
159 const double up = std::nextafter(computed, std::numeric_limits<double>::infinity());
160 const double down = std::nextafter(computed, -std::numeric_limits<double>::infinity());
161 return compare(Rational(down), exact) <= 0
and compare(exact, Rational(up)) <= 0;
169 const std::set<Graph::Arc *> * hidden =
nullptr;
173 return hidden ==
nullptr or hidden->count(arc) == 0;
182 double weight[A][A] = {};
183 Rational exact[A][A];
184 bool visible[A][A] = {};
186 std::set<Graph::Arc *> hidden;
190 Market(
const Market_Snapshot & snapshot,
const Fee & fee,
const bool fresh_only)
192 for (
int i = 0; i < A; ++i)
195 const double fee_term = -std::log1p(-
static_cast<double>(fee.num) /
static_cast<double>(fee.den));
196 const double ln10 = std::log(10.0);
197 for (
const auto & q :
snapshot.quotes)
200 weight[q.base][q.quote] = -(std::log(
static_cast<double>(q.bid)) - q.exponent * ln10) + fee_term;
201 weight[q.quote][q.base] = -(q.exponent * ln10 - std::log(
static_cast<double>(q.ask))) + fee_term;
202 const bool shown = not fresh_only or (q.age_ms <= max_age_ms
and q.observed != 0);
203 visible[q.base][q.quote] = visible[q.quote][q.base] =
shown;
204 quote[q.base][q.quote] =
quote[q.quote][q.base] = &q;
207 for (
int u = 0; u < A; ++u)
208 for (
int v = 0; v < A; ++v)
211 arc[u][v] = g.
insert_arc(node[u], node[v], weight[u][v]);
212 exact[u][v] = Rational(weight[u][v]);
213 if (not visible[u][v])
214 hidden.insert(arc[u][v]);
225 size_t by_length[A + 1] = {};
226 bool any_within[A + 1] = {};
227 Rational best_total[A + 1];
228 size_t best_length[A + 1] = {};
229 std::vector<int> best_nodes;
232 size_t mean_length = 1;
238 std::vector<int> path;
239 bool on_path[A] = {};
241 const auto record = [&](
const Rational & total)
243 const size_t len = path.size();
246 for (
size_t bound = len; bound <= A; ++bound)
247 if (not o.any_within[bound] or compare(total, o.best_total[bound]) < 0
248 or (compare(total, o.best_total[bound]) == 0
and len < o.best_length[bound]))
250 o.any_within[bound] =
true;
251 o.best_total[bound] = total;
252 o.best_length[bound] = len;
256 if (not o.any or
mean_less(total, len, o.mean_total, o.mean_length))
259 o.mean_total = total;
264 std::function<void(
int,
int,
const Rational &)>
dfs =
265 [&](
const int start,
const int u,
const Rational & total)
267 for (
int v = 0; v < A; ++v)
269 if (v == u or not
m.visible[u][v])
278 if (v < start or on_path[v])
288 for (
int s = 0; s < A; ++s)
292 dfs(s, s, Rational());
303 std::set<Graph::Node *> seen;
308 for (
auto it =
arcs.get_it(); it.has_curr(); it.next_ne())
310 auto * arc = it.get_curr();
311 if (
m.hidden.count(arc) != 0)
313 auto * src =
m.g.get_src_node(arc);
314 if (first ==
nullptr)
316 if (src != current or not seen.insert(src).second)
319 total += Rational(arc->get_info());
328 int exact_profit_sign(
const Market &
m,
const std::vector<int> &
nodes,
const Fee & fee)
330 mpz_t
num, den, scale;
331 mpz_inits(num, den, scale,
nullptr);
334 for (
size_t i = 0; i <
nodes.size(); ++i)
336 const int u =
nodes[i];
339 mpz_ui_pow_ui(scale, 10,
static_cast<unsigned long>(q.
exponent));
342 mpz_mul_si(num, num, q.
bid);
343 mpz_mul(den, den, scale);
347 mpz_mul(num, num, scale);
348 mpz_mul_si(den, den, q.
ask);
350 mpz_mul_si(num, num, fee.den - fee.num);
351 mpz_mul_si(den, den, fee.den);
353 const int order = mpz_cmp(num, den);
354 mpz_clears(num, den, scale,
nullptr);
355 return order > 0 ? 1 : order < 0 ? -1 : 0;
358 std::string describe(
const Market_Snapshot & s,
const Fee & fee,
const bool fresh_only)
360 return std::string(
"snapshot=") + s.
label +
" fee=" + fee.name + (fresh_only ?
" fresh quotes only" :
" every quote");
366 if (
std::string(s.label) == label)
368 ADD_FAILURE() <<
"no snapshot labelled " << label;
374 void check_short(
const Market &
m,
const Oracle & o)
376 for (
size_t bound = 1; bound <= 3; ++bound)
378 SCOPED_TRACE(::testing::Message() <<
"up_to_3 bound=" << bound);
379 const auto r = most_negative_cycle_up_to_3<Graph, Distance, Hide_Set>(
381 ASSERT_EQ(
r.has_cycle, o.any_within[bound]);
386 ASSERT_TRUE(exact_cycle(
m,
r.cycle_arcs, total, length));
387 ASSERT_EQ(length,
r.length);
388 ASSERT_EQ(length, o.best_length[bound]);
389 ASSERT_EQ(compare(total, o.best_total[bound]), 0);
390 ASSERT_TRUE(within_one_ulp(
r.total_cost, total));
391 ASSERT_EQ(
r.is_negative(), total.sign() < 0);
399 void check_bounded(
const Market &
m,
const Oracle & o)
401 for (
const size_t bound : {size_t(3), size_t(4), size_t(6)})
403 SCOPED_TRACE(::testing::Message() <<
"bounded L=" << bound);
404 const auto r = most_negative_cycle_bounded<Graph, Distance, Hide_Set>(
406 ASSERT_EQ(
r.has_cycle, o.any_within[bound]);
411 ASSERT_TRUE(exact_cycle(
m,
r.cycle_arcs, total, length));
412 ASSERT_EQ(length,
r.length);
413 ASSERT_LE(length, bound);
414 ASSERT_TRUE(within_one_ulp(
r.total_cost, total));
415 ASSERT_EQ(
r.is_negative(), total.sign() < 0);
416 ASSERT_GE(compare(total, o.best_total[bound]), 0);
419 ASSERT_GE(
r.optimality_gap, 0.0);
420 ASSERT_LE(compare(total - o.best_total[bound], Rational(
r.optimality_gap)), 0);
423 ASSERT_EQ(compare(total, o.best_total[bound]), 0);
425 if (o.best_total[bound].to_double() < -clear_margin)
427 ASSERT_TRUE(
r.is_negative());
434 void check_disjoint(
const Market &
m,
const Oracle & o)
436 for (
const size_t wanted : {size_t(1), size_t(3)})
438 SCOPED_TRACE(::testing::Message() <<
"find_disjoint wanted=" << wanted);
439 const auto cycles = find_disjoint_negative_cycles<Graph, Distance, Hide_Set>(
440 m.g, wanted, Negative_Cycle_Exclusion::All_Arcs,
Distance(), Hide_Set{&
m.hidden});
441 ASSERT_LE(cycles.size(), wanted);
442 std::set<Graph::Arc *> used;
443 for (
auto it = cycles.get_it(); it.has_curr(); it.next_ne())
445 const auto & item = it.get_curr();
446 const auto arcs = item.cycle.arcs();
449 ASSERT_TRUE(exact_cycle(
m,
arcs, total, length));
450 ASSERT_EQ(length, item.length);
451 ASSERT_LT(total.sign(), 0);
452 ASSERT_TRUE(within_one_ulp(item.total_cost, total));
453 for (
auto ai =
arcs.get_it(); ai.has_curr(); ai.next_ne())
454 ASSERT_TRUE(used.insert(ai.get_curr()).second);
456 if (not o.any_within[A])
458 ASSERT_TRUE(cycles.is_empty());
461 const double best = o.best_total[A].to_double();
462 if (best < -clear_margin)
464 ASSERT_FALSE(cycles.is_empty());
466 else if (best > clear_margin)
468 ASSERT_TRUE(cycles.is_empty());
474 void check_means(
const Market &
m,
const Oracle & o)
476 const auto h = howard_minimum_mean_cycle<Graph, Distance, Hide_Set>(
478 const auto k = karp_minimum_mean_cycle<Graph, Distance, Hide_Set>(
480 ASSERT_EQ(
h.has_cycle, o.any);
481 ASSERT_EQ(
k.has_cycle, o.any);
485 const double mean = o.mean_total.divided_by(o.mean_length).to_double();
488 ASSERT_TRUE(exact_cycle(
m,
h.cycle_arcs, total, length)) <<
"Howard";
489 ASSERT_EQ(length,
h.cycle_length);
490 ASSERT_TRUE(within_one_ulp(
h.cycle_total_cost, total));
491 if (not
h.used_karp
and h.numeric_quality == Cycle_Numeric_Quality::Exact)
493 ASSERT_TRUE(mean_equal(total, length, o.mean_total, o.mean_length)) <<
"Howard is not exact";
495 if (std::fabs(mean) > clear_margin)
497 ASSERT_EQ(
h.minimum_mean < 0, mean < 0) <<
"Howard sign";
500 ASSERT_TRUE(exact_cycle(
m,
k.cycle_arcs, total, length)) <<
"Karp";
501 ASSERT_EQ(length,
k.cycle_length);
502 ASSERT_LE(std::fabs(
static_cast<double>(
k.minimum_mean) - mean), 1e-12) <<
"Karp mean";
503 if (std::fabs(mean) > clear_margin)
505 ASSERT_EQ(
k.minimum_mean < 0, mean < 0) <<
"Karp sign";
511 void check_money(
const Market &
m,
const Oracle & o,
const Fee & fee)
513 if (not o.any_within[A])
515 const double best = o.best_total[A].to_double();
516 const int profit = exact_profit_sign(
m, o.best_nodes, fee);
517 if (best < -clear_margin)
519 ASSERT_EQ(profit, 1) <<
"a negative total must be a profit";
521 else if (best > clear_margin)
523 ASSERT_EQ(profit, -1) <<
"a positive total must be a loss";
528 void check_market(
const Market_Snapshot & s,
const Fee & fee,
const bool fresh_only)
530 SCOPED_TRACE(describe(s, fee, fresh_only));
531 const Market
m(s, fee, fresh_only);
534 if (::testing::Test::HasFatalFailure())
537 if (::testing::Test::HasFatalFailure())
539 check_disjoint(
m, o);
540 if (::testing::Test::HasFatalFailure())
543 if (::testing::Test::HasFatalFailure())
545 check_money(
m, o, fee);
550TEST(NegativeCyclesMarketTest, TheOracleCountsEveryCycleOfTheCompleteMarket)
556 EXPECT_EQ(o.cycles, 409u);
557 EXPECT_EQ(o.by_length[1], 0u);
558 EXPECT_EQ(o.by_length[2], 15u);
559 EXPECT_EQ(o.by_length[3], 40u);
560 EXPECT_EQ(o.by_length[4], 90u);
561 EXPECT_EQ(o.by_length[5], 144u);
562 EXPECT_EQ(o.by_length[6], 120u);
566TEST(NegativeCyclesMarketTest, RealQuotesAgreeWithTheExhaustiveOracle)
572 for (
const auto & fee : fees)
573 for (
const bool fresh_only : {
false,
true})
575 check_market(s, fee, fresh_only);
576 if (::testing::Test::HasFatalFailure())
582TEST(NegativeCyclesMarketTest, ARaisedFeeNeverImprovesTheBestCycle)
587 for (
const bool fresh_only : {
false,
true})
589 SCOPED_TRACE(std::string(
"snapshot=") + s.
label + (fresh_only ?
" fresh" :
" all"));
590 Rational previous[4];
592 for (
const auto & fee : fees)
594 const Market
m(s, fee, fresh_only);
595 for (
size_t bound = 2; bound <= 3; ++bound)
597 const auto r = most_negative_cycle_up_to_3<Graph, Distance, Hide_Set>(
603 ASSERT_TRUE(exact_cycle(
m,
r.cycle_arcs, total, length));
606 ASSERT_GE(compare(total, previous[bound]), 0) <<
"bound " << bound <<
" fee " << fee.name;
608 previous[bound] = total;
616TEST(NegativeCyclesMarketTest, QuietStatesOnlyOfferTheRoundTripThatCostsTwoFees)
622 const std::string label = s.
label;
623 const bool quiet = label.rfind(
"typical-", 0) == 0 or label ==
"first" or label ==
"len3"
624 or label ==
"len5" or label ==
"len6";
627 for (
const size_t f : {fee_075, fee_10})
629 SCOPED_TRACE(describe(s, fees[f],
false));
630 const Market
m(s, fees[f],
false);
632 const double two_fees = 2 * -std::log1p(-
static_cast<double>(fees[f].num) / fees[f].den);
633 ASSERT_TRUE(o.any_within[A]);
634 EXPECT_EQ(o.best_length[A], 2u);
635 const double best = o.best_total[A].to_double();
636 EXPECT_GE(best, two_fees - 1e-12);
637 EXPECT_LE(best, two_fees + 1e-4);
639 const auto r = most_negative_cycle_bounded<Graph, Distance, Hide_Set>(
641 EXPECT_FALSE(
r.is_negative());
642 const auto reported = find_disjoint_negative_cycles<Graph, Distance, Hide_Set>(
643 m.g, 1, Negative_Cycle_Exclusion::All_Arcs,
Distance(), Hide_Set{&
m.hidden});
644 EXPECT_TRUE(reported.is_empty());
650TEST(NegativeCyclesMarketTest, TheFreshBurstReproducesTheEpisodesOfTheDay)
663 {
"burst-1", fee_075, 3, -22.6732e-4}, {
"burst-1", fee_10, 3, -15.1667e-4},
664 {
"burst-2", fee_075, 3, -23.7742e-4}, {
"burst-2", fee_10, 3, -16.2677e-4},
665 {
"burst-3", fee_075, 4, -45.1460e-4}, {
"burst-3", fee_10, 4, -35.1372e-4},
669 SCOPED_TRACE(describe(find_snapshot(e.label), fees[e.fee],
true));
670 const Market
m(find_snapshot(e.label), fees[e.fee],
true);
672 ASSERT_TRUE(o.any_within[A]);
673 EXPECT_EQ(o.best_length[A], e.legs);
674 EXPECT_NEAR(o.best_total[A].to_double(), e.total, 1e-7);
676 const auto found = find_disjoint_negative_cycles<Graph, Distance, Hide_Set>(
677 m.g, 1, Negative_Cycle_Exclusion::All_Arcs,
Distance(), Hide_Set{&
m.hidden});
678 EXPECT_FALSE(found.is_empty());
683TEST(NegativeCyclesMarketTest, TrianglesUnderestimateTheFourLegOpportunityOfTheBurst)
689 const Market
m(find_snapshot(
"burst-3"), fees[fee_075],
true);
691 ASSERT_TRUE(o.any_within[A]);
692 ASSERT_EQ(o.best_length[A], 4u);
694 const auto triangle = most_negative_cycle_up_to_3<Graph, Distance, Hide_Set>(
696 ASSERT_TRUE(triangle.has_cycle);
697 EXPECT_EQ(triangle.length, 3u);
698 EXPECT_TRUE(triangle.is_negative());
699 EXPECT_NEAR(triangle.total_cost, -23.7934e-4, 1e-7);
700 EXPECT_GT(triangle.total_cost, o.best_total[A].to_double() + 1e-3);
702 const auto four = most_negative_cycle_bounded<Graph, Distance, Hide_Set>(
704 ASSERT_TRUE(four.has_cycle);
705 EXPECT_EQ(four.length, 4u);
708 ASSERT_TRUE(exact_cycle(
m, four.cycle_arcs, total, length));
709 EXPECT_EQ(compare(total, o.best_total[A]), 0);
710 EXPECT_LT(four.optimality_gap, 1e-12);
712 const auto six = most_negative_cycle_bounded<Graph, Distance, Hide_Set>(
714 EXPECT_FALSE(six.is_exact);
715 EXPECT_GT(six.optimality_gap, 1e-4);
719TEST(NegativeCyclesMarketTest, StaleQuotesOverstateTheBurstAndFakeTheBiggestProfitOfTheDay)
726 const Market
all(find_snapshot(
"burst-3"), fees[fee_075],
false);
727 const Market fresh(find_snapshot(
"burst-3"), fees[fee_075],
true);
730 ASSERT_TRUE(o_all.any_within[A]);
731 ASSERT_TRUE(o_fresh.any_within[A]);
732 EXPECT_EQ(o_all.best_length[A], 5u);
733 EXPECT_NEAR(o_all.best_total[A].to_double(), -56.6517e-4, 1e-7);
734 EXPECT_LT(compare(o_all.best_total[A], o_fresh.best_total[A]), 0);
736 bool uses_stale_quote =
false;
737 for (
size_t i = 0; i < o_all.best_nodes.size(); ++i)
739 const int u = o_all.best_nodes[i];
740 const int v = o_all.best_nodes[(i + 1) % o_all.best_nodes.size()];
741 uses_stale_quote = uses_stale_quote or not fresh.visible[u][v];
743 EXPECT_TRUE(uses_stale_quote);
746 const Market
all(find_snapshot(
"raw-peak"), fees[fee_075],
false);
747 const Market fresh(find_snapshot(
"raw-peak"), fees[fee_075],
true);
749 ASSERT_TRUE(o_all.any_within[A]);
750 EXPECT_EQ(o_all.best_length[A], 5u);
751 EXPECT_NEAR(o_all.best_total[A].to_double(), -135.175e-4, 1e-6);
752 EXPECT_EQ(exact_profit_sign(
all, o_all.best_nodes, fees[fee_075]), 1);
755 const auto found = find_disjoint_negative_cycles<Graph, Distance, Hide_Set>(
756 fresh.g, 1, Negative_Cycle_Exclusion::All_Arcs,
Distance(), Hide_Set{&fresh.hidden});
757 EXPECT_TRUE(found.is_empty());
761TEST(NegativeCyclesMarketTest, TheRelaxedBoundLeavesAGapOnARealState)
767 const Market
m(find_snapshot(
"bounded-miss"), fees[fee_075],
false);
769 ASSERT_TRUE(o.any_within[A]);
770 EXPECT_EQ(o.best_length[A], 6u);
771 EXPECT_NEAR(o.best_total[A].to_double(), -6.2466e-4, 1e-7);
773 const auto r = most_negative_cycle_bounded<Graph, Distance, Hide_Set>(
775 ASSERT_TRUE(
r.has_cycle);
776 EXPECT_TRUE(
r.is_negative());
777 EXPECT_FALSE(
r.is_exact);
780 ASSERT_TRUE(exact_cycle(
m,
r.cycle_arcs, total, length));
781 EXPECT_GT(compare(total, o.best_total[A]), 0);
782 EXPECT_GE(
r.optimality_gap, (total - o.best_total[A]).to_double());
784 const auto triangle = most_negative_cycle_up_to_3<Graph, Distance, Hide_Set>(
786 ASSERT_TRUE(triangle.has_cycle);
787 EXPECT_NEAR(triangle.total_cost, -5.81819e-4, 1e-7);
791TEST(NegativeCyclesMarketTest, TheNearBreakEvenStateIsAnUnprofitableTriangle)
796 const Market
m(find_snapshot(
"near-zero"), fees[fee_10],
false);
798 ASSERT_TRUE(o.any_within[A]);
799 EXPECT_EQ(o.best_length[A], 3u);
800 EXPECT_GT(o.best_total[A].to_double(), 0.0);
801 EXPECT_LT(o.best_total[A].to_double(), 1e-6);
802 EXPECT_EQ(exact_profit_sign(
m, o.best_nodes, fees[fee_10]), -1);
804 const auto r = most_negative_cycle_bounded<Graph, Distance, Hide_Set>(
806 EXPECT_FALSE(
r.is_negative());
807 const auto found = find_disjoint_negative_cycles<Graph, Distance, Hide_Set>(
808 m.g, 1, Negative_Cycle_Exclusion::All_Arcs,
Distance(), Hide_Set{&
m.hidden});
809 EXPECT_TRUE(found.is_empty());
811 const Market cheaper(find_snapshot(
"near-zero"), fees[fee_075],
false);
812 const auto gain = most_negative_cycle_up_to_3<Graph, Distance, Hide_Set>(
813 cheaper.g, 3,
Distance(), Hide_Set{&cheaper.hidden});
814 EXPECT_TRUE(gain.is_negative());
815 EXPECT_NEAR(gain.total_cost, -7.50313e-4, 1e-7);
Minimum mean cycle by Howard's policy iteration.
Minimum mean cycle in directed graphs (Karp algorithm).
Enumeration of negative cycles and bounded-length most negative cycle in directed graphs.
Default distance accessor for arc weights.
Generic directed graph (digraph) wrapper template.
Doubly-linked list (defined in tpl_dynList.H).
virtual Node * insert_node(Node *node) noexcept
Insertion of a node already allocated.
Arc Arc
The node class type.
Arc * insert_arc(Node *src_node, Node *tgt_node, void *a)
Minimal std::expected-style result type for C++20.
double to_double(const Geom_Number &n)
Convert Geom_Number to double.
DynArray< Graph::Node * > nodes
DynArray< Graph::Arc * > arcs
std::string quote(const std::string &s)
decltype(auto) current(It &it) noexcept(current_is_noexcept< It >)
Current item of an iterator that is positioned on one.
DFSResult< typename Domain::Distance > dfs(Domain &domain, typename Domain::State &state, SearchPath< typename Domain::Move > &path, const typename Domain::Distance g, const typename Domain::Distance threshold, const size_t depth, IDAStarResult< Solution, typename Domain::Distance > &result, OnSolution &on_solution)
Core recursive DFS used by IDA* for a single threshold pass.
bool mean_less(const Acc c1, const size_t l1, const Acc c2, const size_t l2)
Whether the mean c1 / l1 is smaller than c2 / l2.
Main namespace for Aleph-w library functions.
bool all(Container &container, Operation &operation)
Return true if all elements satisfy a predicate.
auto enumerate(const Container &c)
Return pairs of (element, index).
Gen_MultiPolynomial< C, M > operator-(const C &s, const Gen_MultiPolynomial< C, M > &p)
Scalar - polynomial.
and
Check uniqueness with explicit hash + equality functors.
auto mean(const Container &data) -> std::decay_t< decltype(*std::begin(data))>
Compute the arithmetic mean.
const Market_Snapshot snapshots[]
The snapshots, in chronological order.
constexpr int asset_count
Number of assets of the market: BTC, ETH, SOL, BNB, USDT and USDC.
Snapshot snapshot(const Aleph::Adaptive_Huffman_Encoder &encoder)
Reconstruct and validate the tree using public encoder operations.
constexpr bool shown(unsigned long hidden, int i) noexcept
Whether the arc number i is shown by the mask hidden.
int num(Node *p)
The number of a node of a built graph.
Top-of-book quotes of real Binance spot markets, as a fixture for the cycle searches of Negative_Cycl...
Arc of graph implemented with double-linked adjacency lists.
Best bid and ask of one pair, with the price scale of both.
int exponent
Decimal places of the prices.
long long bid
Best bid, in units of 10^-exponent.
long long ask
Best ask, in units of 10^-exponent.
int base
Index of the base asset: what the bid buys and the ask sells.
State of the whole market at one instant.
const char * label
Why it was chosen (see the file documentation).
FooMap m(5, fst_unit_pair_hash, snd_unit_pair_hash)
Generic graph and digraph implementations.