compute_synthetic_book was multiplying leg prices by their qty twice
This is a pre-emptive bug fix, as the method has only been fed synths with leg quantities +/-1.
This commit is contained in:
1 parent
1674486dc0
commit
590ca3892d
2 files changed
+11
-3
No files matched your search
@@ -87,6 +87,9 @@ class IntPrice {
|
||||
_exponent = temp._exponent;
|
||||
return *this;
|
||||
}
|
||||
IntPrice operator -() {
|
||||
return IntPrice(-_mantissa, _exponent);
|
||||
}
|
||||
IntPrice operator * (const IntPrice& other) const {
|
||||
return op(other, [](int64_t m1, int64_t m2) { return m1 * m2; });
|
||||
}
|
||||
|
||||
@@ -116,11 +116,16 @@ void compute_synthetic_book(
|
||||
legs[i].curr_level_qty_used += MDP3Quantity(limiting_factor);
|
||||
auto marginal_cost = md::INT_NAN;
|
||||
for (auto& l : legs) {
|
||||
// The book's prices have already been multiplied by abs(leg_qty);
|
||||
// Subtract the leg's cost if qty is negative, otherwise add it
|
||||
// to the synthetic's marginal cost.
|
||||
auto lcost = l.curr_price();
|
||||
if (l.leg_qty.value() < 0)
|
||||
lcost = -lcost;
|
||||
if (marginal_cost.is_nan())
|
||||
marginal_cost = l.curr_price() * l.leg_qty.value();
|
||||
marginal_cost = lcost;
|
||||
else
|
||||
marginal_cost =
|
||||
marginal_cost + l.curr_price() * l.leg_qty.value();
|
||||
marginal_cost += lcost;
|
||||
}
|
||||
dest.emplace_back(marginal_cost, MDP3Quantity(limiting_factor));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user