Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0282ad6df2 |
No files matched your search
@@ -290,7 +290,7 @@ struct GeneralMarketDataListener::PImpl {
|
||||
// if this is set to true, then the security key passed on in the
|
||||
// on_securities function is used. If this is not set to true, then a new key
|
||||
// is generated
|
||||
const bool use_given_sec_key = false;
|
||||
const bool use_given_sec_key = true;
|
||||
const std::string cc_name_prefix = "cc_security";
|
||||
size_t n_bk_updates = 0;
|
||||
bts::persistence::IDGenerator &id_gen =
|
||||
|
||||
@@ -248,7 +248,7 @@ OrderOpResult AlgoWrapperOrder::on_activate(
|
||||
me->set_price_quantity(p, q);
|
||||
for (auto &ct : me->child_templates)
|
||||
ct->builder.activate(*me->services);
|
||||
if (q.full_value() == 0) {
|
||||
if (q.value() == 0) {
|
||||
ReportStateGuard _(*this);
|
||||
terminate(ORDER_STATUS_COMPLETED);
|
||||
} else if (is_attaching())
|
||||
@@ -292,11 +292,8 @@ OrderOpResult AlgoWrapperOrder::on_update(Update const &update) {
|
||||
}
|
||||
case Status::WORKING: {
|
||||
ReportStateGuard _(*this);
|
||||
const double frac_qty = update.has_fractional_quantity()
|
||||
? update.fractional_quantity().fraction()
|
||||
: 0;
|
||||
me->set_price_quantity(
|
||||
Price(update.price()), Quantity(update.quantity(), frac_qty));
|
||||
Price(update.price()), Quantity(update.quantity()));
|
||||
if (update.has_custom()) {
|
||||
*me->definition.mutable_custom_def() = update.custom();
|
||||
me->services->report_definition(me->definition);
|
||||
@@ -316,7 +313,6 @@ OrderOpResult AlgoWrapperOrder::on_update(Price p, Quantity q) {
|
||||
Update up;
|
||||
up.set_price(p.value());
|
||||
up.set_quantity(q.value());
|
||||
up.mutable_fractional_quantity()->set_fraction(q.fractional_part());
|
||||
return on_update(up);
|
||||
}
|
||||
|
||||
@@ -400,17 +396,11 @@ std::vector<api::Security const *> AlgoWrapperOrder::known_securities() const {
|
||||
Price AlgoWrapperOrder::price() const { return Price(me->state().price()); }
|
||||
|
||||
Quantity AlgoWrapperOrder::quantity() const {
|
||||
const auto &s = me->state();
|
||||
return s.has_fractional_quantity()
|
||||
? Quantity{s.quantity(), s.fractional_quantity().fraction()}
|
||||
: Quantity{s.quantity()};
|
||||
return Quantity(me->state().quantity());
|
||||
}
|
||||
|
||||
Quantity AlgoWrapperOrder::total_fills() const {
|
||||
const auto &s = me->state();
|
||||
return s.has_fractional_filled_quantity()
|
||||
? Quantity{s.filled_quantity(), s.fractional_filled_quantity().fraction()}
|
||||
: Quantity{s.filled_quantity()};
|
||||
return Quantity(me->state().filled_quantity());
|
||||
}
|
||||
|
||||
bool AlgoWrapperOrder::is_shutting_down() const {
|
||||
|
||||
@@ -46,7 +46,7 @@ OrderOpResult IcebergAlgo::do_before_launch(IBeforeLaunchAlgoServices &serv) {
|
||||
"Show quantity must be greater than 0"};
|
||||
|
||||
me->pause_between_orders_ms = iceberg.pause_between_orders_ms();
|
||||
me->show_quantity = CQuantity::create_new(iceberg.show_quantity());
|
||||
me->show_quantity = Quantity((uint32_t)iceberg.show_quantity());
|
||||
|
||||
// Create a child template so we can quickly launch our child when
|
||||
// the time comes.
|
||||
@@ -91,11 +91,7 @@ void IcebergAlgo::do_update(api::orderman::Update const &update) {
|
||||
return;
|
||||
}
|
||||
|
||||
const double frac_qty = update.has_fractional_quantity()
|
||||
? update.fractional_quantity().fraction()
|
||||
: 0;
|
||||
const Quantity new_qty{update.quantity(), frac_qty};
|
||||
if (new_qty < algo().total_fills()) {
|
||||
if (update.quantity() < algo().total_fills().value()) {
|
||||
algo().complete();
|
||||
return;
|
||||
}
|
||||
@@ -112,7 +108,7 @@ void IcebergAlgo::do_update(api::orderman::Update const &update) {
|
||||
return;
|
||||
}
|
||||
|
||||
me->show_quantity = CQuantity::create_new(iceberg_update.show_quantity());
|
||||
me->show_quantity = Quantity((uint32_t)iceberg_update.show_quantity());
|
||||
bool had_timer = me->pause_between_orders_ms > 0;
|
||||
bool should_have_timer = iceberg_update.pause_between_orders_ms() > 0;
|
||||
|
||||
@@ -126,10 +122,7 @@ void IcebergAlgo::do_update(api::orderman::Update const &update) {
|
||||
init_child_template(algo(), iceberg_update.child());
|
||||
}
|
||||
}
|
||||
const auto rem_qty = remaining_quantity();
|
||||
child_update.set_quantity(rem_qty.value());
|
||||
child_update.mutable_fractional_quantity()->set_fraction(
|
||||
rem_qty.fractional_part());
|
||||
child_update.set_quantity(remaining_quantity().value());
|
||||
if (me->status == Status::WORKING)
|
||||
algo().update_child(me->child_key, child_update);
|
||||
}
|
||||
@@ -137,9 +130,10 @@ void IcebergAlgo::do_update(api::orderman::Update const &update) {
|
||||
void IcebergAlgo::on_child_change(OrderKey k, ChildState const &st) {
|
||||
if (k == me->child_key) {
|
||||
algo().update_fill_state(
|
||||
algo().total_fills() + st.last_fills, st.last_price);
|
||||
Quantity(algo().total_fills().value() + st.last_fills.value()),
|
||||
st.last_price);
|
||||
|
||||
if (algo().total_fills() >= algo().quantity()) {
|
||||
if (algo().total_fills().value() >= algo().quantity().value()) {
|
||||
algo().complete();
|
||||
return;
|
||||
}
|
||||
@@ -170,7 +164,7 @@ void IcebergAlgo::on_timer() {
|
||||
|
||||
void IcebergAlgo::send_next_order() {
|
||||
bts_assert(me->status == Status::WORKING);
|
||||
bts_assert(algo().quantity() > algo().total_fills());
|
||||
bts_assert(algo().quantity().value() > algo().total_fills().value());
|
||||
|
||||
me->child_key = algo().launch_child(
|
||||
*me->child_template, algo().price(), remaining_quantity());
|
||||
@@ -178,8 +172,9 @@ void IcebergAlgo::send_next_order() {
|
||||
LOG(OrderMan, Info,
|
||||
"Iceberg order {} creating new child order {} with size "
|
||||
"{} price {}. Filled {} so far out of {}",
|
||||
algo().order_key(), me->child_key, remaining_quantity(), algo().price(),
|
||||
algo().total_fills(), algo().quantity());
|
||||
algo().order_key().value(), me->child_key.value(),
|
||||
remaining_quantity().value(), algo().price().value(),
|
||||
algo().total_fills().value(), algo().quantity().value());
|
||||
}
|
||||
|
||||
void orderman::IcebergAlgo::init_child_template(
|
||||
@@ -191,9 +186,9 @@ void orderman::IcebergAlgo::init_child_template(
|
||||
}
|
||||
|
||||
Quantity IcebergAlgo::remaining_quantity() const {
|
||||
bts_assert(algo().quantity() > algo().total_fills());
|
||||
auto remaining = algo().quantity() - algo().total_fills();
|
||||
return std::min(remaining, me->show_quantity);
|
||||
bts_assert(algo().quantity().value() > algo().total_fills().value());
|
||||
auto remaining = algo().quantity().value() - algo().total_fills().value();
|
||||
return Quantity(std::min(remaining, me->show_quantity.value()));
|
||||
}
|
||||
|
||||
} // namespace orderman
|
||||
|
||||
Reference in new issue
Block a user