Switch from precise to pessimistic(tt) building of synthetic books
This commit is contained in:
1 parent
ca2a6a1e60
commit
97a50faf16
2 files changed
+43
-6
No files matched your search
@@ -100,6 +100,7 @@ struct DepthTraversal {
|
||||
levels[x].size = depth[x].size();
|
||||
}
|
||||
}
|
||||
#ifdef PRECISE_SYNTHETICS
|
||||
double available_size() const {
|
||||
double available = 0.0;
|
||||
auto cur = head;
|
||||
@@ -133,6 +134,38 @@ struct DepthTraversal {
|
||||
}
|
||||
return price/size;
|
||||
}
|
||||
#else
|
||||
double available_size() const {
|
||||
double available = 0.0;
|
||||
auto cur = head;
|
||||
while(cur < levels.size() && available < 1) {
|
||||
available += levels[cur].size / qty;
|
||||
++cur;
|
||||
}
|
||||
return available;
|
||||
}
|
||||
double consume(double size) {
|
||||
bts_assert_d(size <= available_size());
|
||||
double take = size * qty;
|
||||
double price = 0.0;
|
||||
while(take > 0) {
|
||||
if (levels[head].size >= take) {
|
||||
price = levels[head].price * price_mult;
|
||||
levels[head].size -= take;
|
||||
if (levels[head].size <= 0) ++head;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
double available = levels[head].size;
|
||||
price = levels[head].price * price_mult;
|
||||
levels[head].size = 0;
|
||||
++head;
|
||||
take -= available;
|
||||
}
|
||||
}
|
||||
return price;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
void copy_depth(size_t count, api::Side side, const api::ContractSpecification& spec, small_vector<DepthTraversal>& leg_travs, Level* out_price) {
|
||||
|
||||
@@ -193,7 +193,8 @@ TEST_CASE("SyntheticBook+1-2", "[md][synthetic]") {
|
||||
{{100,16}, {110,8}, {120,12}, {130,5}});
|
||||
expect_market(synthetic_handle,
|
||||
{{-10,1}, {-20,7}, {-40,4}, {-70,4}, {-80,2}, {-100,2}},
|
||||
{{20,2}, {40,1}, {50,4}, {70,1}, {80,4}, {90,1}, {100,3}, {110,1}, {120,1}});
|
||||
{{20,2}, {50,5}, {70,1}, {80,4}, {100,4}, {110,1}, {130,1}});
|
||||
//precise {{20,2}, {40,1}, {50,4}, {70,1}, {80,4}, {90,1}, {100,3}, {110,1}, {120,1}});
|
||||
}
|
||||
}
|
||||
TEST_CASE("SyntheticBook+2-2", "[md][synthetic]") {
|
||||
@@ -212,8 +213,10 @@ TEST_CASE("SyntheticBook+2-2", "[md][synthetic]") {
|
||||
{{2003.25, 12}, {2003.5, 3}, {2003.75,5}});
|
||||
|
||||
expect_market(synthetic_handle,
|
||||
{{-6.5,5}, {-7.0,1}, {-7.5,1}, {-8.0,1}, {-8.5,2}},
|
||||
{{-5.50,2}, {-5.25,1}, {-5.00,4}, {-4.75,1}, {-4.5,2}, {-3.00,5}});
|
||||
{{-6.5,5}, {-7.0,1}, {-7.5,1}, {-8.5,3}},
|
||||
//precise {{-6.5,5}, {-7.0,1}, {-7.5,1}, {-8.0,1}, {-8.5,2}},
|
||||
{{-5.50,2}, {-5.00,5}, {-4.5,3}, {-3.00,5}});
|
||||
//precise {{-5.50,2}, {-5.25,1}, {-5.00,4}, {-4.75,1}, {-4.5,2}, {-3.00,5}});
|
||||
}
|
||||
|
||||
|
||||
@@ -262,8 +265,8 @@ TEST_CASE("SPARK-955", "[md][synthetic]") {
|
||||
{{2607.25, 3}, {2607.50, 1}, {2608.25, 9}});
|
||||
expect_market(synthetic_handle,
|
||||
// If we do strict price this is right. If we're pessimistic we get {-4.25,2}
|
||||
{ {-4.00, 1}, {-4.25, 1}, { -5.00, 3}, {-5.25, 3}, {-5.50,1}, {-5.75, 6} },
|
||||
// { {-4.25, 2}, { -5.00, 3}, {-5.25, 3}, {-5.50,1}, {-5.75, 6} },
|
||||
{ {-4.25, 2}, { -5.00, 3}, {-5.25, 3}, {-5.75, 7} },
|
||||
//precise { {-4.00, 1}, {-4.25, 1}, { -5.00, 3}, {-5.25, 3}, {-5.50,1}, {-5.75, 6} },
|
||||
{ {5.00, 3}, {5.25, 1}, {6.00,3}, {6.50,6} });
|
||||
}
|
||||
|
||||
@@ -319,7 +322,8 @@ TEST_CASE("Synthetic_net_change", "[md][synthetic]") {
|
||||
// Validate merge
|
||||
expect_market(synthetic_handle,
|
||||
{{-10,1}, {-20,7}, {-40,4}, {-70,4}, {-80,2}, {-100,2}},
|
||||
{{20,2}, {40,1}, {50,4}, {70,1}, {80,4}, {90,1}, {100,3}, {110,1}, {120,1}});
|
||||
{{20,2}, {50,5}, {70,1}, {80,4}, {100,4}, {110,1}, {130,1}});
|
||||
// precise {{20,2}, {40,1}, {50,4}, {70,1}, {80,4}, {90,1}, {100,3}, {110,1}, {120,1}});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user