Delete parameter added
This commit is contained in:
1 parent
e179f7e5a4
commit
69dcfdb2bd
3 files changed
+16
-2
No files matched your search
@@ -8,6 +8,7 @@
|
||||
#include "lib/orderman/orders/spreader_orders/spreader/SpreaderUtils.h"
|
||||
#include "lib/os/os.h"
|
||||
#include "lib/utils/PBUtils.h"
|
||||
#include <stdint.h>
|
||||
|
||||
namespace bts {
|
||||
namespace orderman {
|
||||
@@ -208,11 +209,15 @@ PyramidAlgo::_convert_params (const CustomOrderDefinition& cod){
|
||||
else
|
||||
return std::make_tuple(rv,false,
|
||||
std::string("Top Spread is not defined"));
|
||||
rv.top_delete = Quantity(r.has_value() ? r.value() : UINT32_MAX);
|
||||
for (size_t i = 0; i < 5; i++){
|
||||
auto idx = std::to_string(i+1);
|
||||
auto b = get_if<uint32_t>(params, "Spread " + idx);
|
||||
if (b.has_value() && b.value() != 0)
|
||||
if (b.has_value() && b.value() != 0){
|
||||
rv.sec_keys.emplace_back(b.value());
|
||||
auto pu = get_if<uint32_t>(params, "Spread " + idx + " Payup");
|
||||
rv.cover_payups.emplace_back(pu.has_value() ? pu.value() : UINT32_MAX);
|
||||
}
|
||||
}
|
||||
if(rv.sec_keys.size() < 3)
|
||||
return std::make_tuple(
|
||||
@@ -302,6 +307,7 @@ bool PyramidAlgo::_working_state_met() const{
|
||||
const auto& ps = l.opp_md()[0];
|
||||
cover_sum += ps.price();
|
||||
}
|
||||
// TODO, check for delete
|
||||
return !os::is_nan(cover_sum) &&
|
||||
((me->side == api::Side::SIDE_BUY &&
|
||||
me->out_price.value() <= cover_sum) ||
|
||||
@@ -379,6 +385,7 @@ void PyramidAlgo::_send_hedges (Quantity filled_qty){
|
||||
if (filled_qty.value() > 0)
|
||||
for (auto& l : me->legs)
|
||||
if(!l.is_top_spread())
|
||||
// check payup
|
||||
l.order_key = _algo().launch_child(
|
||||
*l.order_template,
|
||||
Price(l.opp_md()[0].price()),
|
||||
|
||||
@@ -18,7 +18,8 @@ class PyramidAlgo : public IAlgoOrder {
|
||||
struct PyramidAlgoParams{
|
||||
// first one is the top
|
||||
std::vector<SecurityKey> sec_keys;
|
||||
Quantity del_threshold;
|
||||
Quantity top_delete;
|
||||
std::vector<Quantity> cover_payups;
|
||||
};
|
||||
public:
|
||||
OrderOpResult do_before_launch(IBeforeLaunchAlgoServices &) override;
|
||||
|
||||
@@ -122,11 +122,17 @@ extern "C" void init_pyramid_plugin(bts::SparkServices& srv) {
|
||||
join_desc.set_dynamic_order_type("Pyramid");
|
||||
|
||||
*join_desc.add_param_desc() = param_uint32("Top Spread");
|
||||
*join_desc.add_param_desc() = param_uint32("Delete");
|
||||
*join_desc.add_param_desc() = param_uint32("Spread 1");
|
||||
*join_desc.add_param_desc() = param_uint32("Spread 1 Payup");
|
||||
*join_desc.add_param_desc() = param_uint32("Spread 2");
|
||||
*join_desc.add_param_desc() = param_uint32("Spread 2 Payup");
|
||||
*join_desc.add_param_desc() = param_uint32("Spread 3");
|
||||
*join_desc.add_param_desc() = param_uint32("Spread 3 Payup");
|
||||
*join_desc.add_param_desc() = param_uint32("Spread 4");
|
||||
*join_desc.add_param_desc() = param_uint32("Spread 4 Payup");
|
||||
*join_desc.add_param_desc() = param_uint32("Spread 5");
|
||||
*join_desc.add_param_desc() = param_uint32("Spread 5 Payup");
|
||||
|
||||
srv.register_dynamic_algo_order(join_desc, []() { return std::make_unique<orderman::PyramidAlgo>(); });
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user