Join won't modify its child's price once it has joined
This commit is contained in:
1 parent
f8ddaab884
commit
85f42d1e23
2 files changed
+20
-1
No files matched your search
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "lib/orderman/order_factory/IOrderFactory.h"
|
||||
#include "lib/orderman/orders/spreader_orders/spreader/SpreaderUtils.h"
|
||||
#include "lib/os/os.h"
|
||||
#include "lib/utils/PBUtils.h"
|
||||
|
||||
namespace bts {
|
||||
@@ -20,6 +21,7 @@ struct JoinAlgo::PImpl {
|
||||
ChildTemplate *child_template = nullptr;
|
||||
Book book_at_inception;
|
||||
Book last_book;
|
||||
Price joined_price=Price(os::nan());
|
||||
};
|
||||
|
||||
JoinAlgo::JoinAlgo() : me(new PImpl()) {}
|
||||
@@ -80,7 +82,8 @@ void JoinAlgo::do_update(api::orderman::Update const &update) {
|
||||
}
|
||||
|
||||
Update child_update;
|
||||
child_update.set_price(update.price());
|
||||
Price price_to_pass = get_price_to_pass(Price(update.price()));
|
||||
child_update.set_price(price_to_pass.value());
|
||||
child_update.set_quantity(update.quantity());
|
||||
if (update.has_custom()) {
|
||||
update_join_threshold();
|
||||
@@ -146,6 +149,7 @@ void JoinAlgo::try_to_join() {
|
||||
|
||||
// Time to join
|
||||
Update child_update;
|
||||
me->joined_price = Price(my_side_psz.price());
|
||||
child_update.set_price(my_side_psz.price());
|
||||
child_update.set_quantity(algo().quantity().value());
|
||||
algo().update_child(me->child_key, child_update);
|
||||
@@ -161,6 +165,20 @@ void JoinAlgo::try_to_join() {
|
||||
}
|
||||
}
|
||||
|
||||
Price JoinAlgo::get_price_to_pass (Price price) const{
|
||||
Price rv;
|
||||
switch (me->status) {
|
||||
case Status::WAITING_FOR_MD:
|
||||
case Status::WAITING_TO_JOIN:
|
||||
rv = price;
|
||||
break;
|
||||
case Status::JOINED:
|
||||
rv = me->joined_price;
|
||||
break;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
void JoinAlgo::update_join_threshold() {
|
||||
me->min_quantity_to_join = SpreaderUtils::_quantity_threshold(
|
||||
algo().definition().custom_def().join().join_threshold(), algo().quantity());
|
||||
|
||||
@@ -31,6 +31,7 @@ private:
|
||||
void update_join_threshold();
|
||||
bool has_running_child() const;
|
||||
void try_to_join();
|
||||
Price get_price_to_pass (Price price) const;
|
||||
};
|
||||
|
||||
}}
|
||||
Reference in new issue
Block a user