Skip to content

Commit c6d98df

Browse files
committed
apply order_type to rpc req body
1 parent 8c2f797 commit c6d98df

File tree

11 files changed

+73
-46
lines changed

11 files changed

+73
-46
lines changed

atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/OrderForm.qml

+31
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import App 1.0
99
import Dex.Themes 1.0 as Dex
1010
import Dex.Components 1.0 as Dex
1111
import AtomicDEX.TradingError 1.0
12+
import AtomicDEX.MarketMode 1.0 as Dex
1213

1314
ColumnLayout
1415
{
@@ -61,6 +62,36 @@ ColumnLayout
6162
function onBackend_volumeChanged() { input_volume.text = exchange_trade.backend_volume; }
6263
}
6364

65+
// Market mode selector
66+
RowLayout
67+
{
68+
Layout.topMargin: 2
69+
Layout.bottomMargin: 2
70+
Layout.alignment: Qt.AlignHCenter
71+
Layout.preferredWidth: parent.width
72+
height: 28
73+
74+
MarketModeSelector
75+
{
76+
Layout.alignment: Qt.AlignLeft
77+
Layout.preferredWidth: 125
78+
Layout.preferredHeight: 28
79+
marketMode: Dex.MarketMode.Buy
80+
ticker: atomic_qt_utilities.retrieve_main_ticker(left_ticker)
81+
}
82+
83+
Item { Layout.fillWidth: true }
84+
85+
MarketModeSelector
86+
{
87+
marketMode: Dex.MarketMode.Sell
88+
Layout.alignment: Qt.AlignRight
89+
Layout.preferredWidth: 125
90+
Layout.preferredHeight: 28
91+
ticker: atomic_qt_utilities.retrieve_main_ticker(left_ticker)
92+
}
93+
}
94+
6495
Item
6596
{
6697
Layout.preferredWidth: parent.width

atomic_defi_design/Dex/Exchange/ProView/TradingInfo/Main.qml

-34
Original file line numberDiff line numberDiff line change
@@ -86,40 +86,6 @@ ColumnLayout
8686
Layout.rightMargin: 8
8787
}
8888

89-
// Market mode selector
90-
RowLayout
91-
{
92-
Layout.topMargin: 2
93-
Layout.bottomMargin: 2
94-
Layout.alignment: Qt.AlignHCenter
95-
Layout.preferredWidth: 435
96-
height: 28
97-
98-
Item { Layout.fillWidth: true }
99-
MarketModeSelector
100-
{
101-
Layout.alignment: Qt.AlignLeft
102-
Layout.preferredWidth: 150
103-
Layout.preferredHeight: 28
104-
marketMode: MarketMode.Buy
105-
ticker: atomic_qt_utilities.retrieve_main_ticker(left_ticker)
106-
}
107-
108-
Item { Layout.fillWidth: true }
109-
110-
Item { Layout.fillWidth: true }
111-
112-
MarketModeSelector
113-
{
114-
Layout.alignment: Qt.AlignRight
115-
Layout.preferredWidth: 150
116-
Layout.preferredHeight: 28
117-
ticker: atomic_qt_utilities.retrieve_main_ticker(left_ticker)
118-
}
119-
Item { Layout.fillWidth: true }
120-
}
121-
122-
12389
// Chart
12490
Chart
12591
{

atomic_defi_design/Dex/Exchange/Trade/ConfirmTradeModal.qml

+3-2
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ MultipageModal
264264
boxHeight: 20
265265
checked: true
266266
height: 40
267-
text: qsTr("Good until canceled (order will remain on orderbook until filled or canceled)")
267+
text: qsTr("Good until cancelled (order will remain on orderbook until filled or cancelled)")
268268
}
269269

270270
DefaultCheckBox
@@ -450,7 +450,8 @@ MultipageModal
450450
trade({ enable_custom_config: enable_custom_config.checked,
451451
is_dpow_configurable: config_section.is_dpow_configurable,
452452
enable_dpow_confs: enable_dpow_confs.checked,
453-
required_confirmation_count: required_confirmation_count.value, },
453+
required_confirmation_count: required_confirmation_count.value,
454+
good_until_canceled: _goodUntilCanceledCheckbox.checked},
454455
config_section.default_config)
455456
API.app.trading_pg.reset_fees()
456457
}

atomic_defi_design/Dex/Exchange/Trade/SimpleView/OrderRemovedModal.qml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ MultipageModal
1717
Layout.fillWidth: true
1818

1919
wrapMode: Text.WordWrap
20-
text: qsTr("The selected order does not exist anymore, it might have been matched or canceled, and no order with a better price is available.\nPlease select a new order.")
20+
text: qsTr("The selected order does not exist anymore, it might have been matched or cancelled, and no order with a better price is available.\nPlease select a new order.")
2121
}
2222

2323
footer:

atomic_defi_design/Dex/Exchange/Trade/Trade.qml

+2-2
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,9 @@ Item
144144
}
145145

146146
if (sell_mode)
147-
API.app.trading_pg.place_sell_order(nota, confs)
147+
API.app.trading_pg.place_sell_order(nota, confs, options.good_until_canceled)
148148
else
149-
API.app.trading_pg.place_buy_order(nota, confs)
149+
API.app.trading_pg.place_buy_order(nota, confs, options.good_until_canceled)
150150

151151
orderPlaced()
152152
}

src/core/atomicdex/api/mm2/rpc_v1/rpc.buy.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
******************************************************************************/
1616

1717
//! Deps
18-
#include <nlohmann/json.hpp>
1918
#include <spdlog/spdlog.h>
2019

2120
//! Project Headers
@@ -75,5 +74,9 @@ namespace atomic_dex::mm2
7574
{
7675
SPDLOG_INFO("The order is not picked from orderbook we create it from volume = {}, price = {}", j.at("volume").dump(4), request.price);
7776
}
77+
if (request.order_type.has_value())
78+
{
79+
j["order_type"] = request.order_type.value();
80+
}
7881
}
7982
} // namespace atomic_dex::mm2

src/core/atomicdex/api/mm2/rpc_v1/rpc.buy.hpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include <string>
2222

2323
//! Deps
24-
#include <nlohmann/json_fwd.hpp>
24+
#include <nlohmann/json.hpp>
2525

2626
//! Project Header
2727
#include <atomicdex/api/mm2/trading.order.contents.hpp>
@@ -43,7 +43,9 @@ namespace atomic_dex::mm2
4343
bool selected_order_use_input_volume{false};
4444
std::optional<bool> base_nota{std::nullopt};
4545
std::optional<std::size_t> base_confs{std::nullopt};
46+
// bool is_max;
4647
std::optional<std::string> min_volume{std::nullopt};
48+
std::optional<nlohmann::json> order_type;
4749
};
4850

4951
void to_json(nlohmann::json& j, const buy_request& request);

src/core/atomicdex/api/mm2/rpc_v1/rpc.sell.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
******************************************************************************/
1616

1717
//! Deps
18-
#include <nlohmann/json.hpp>
1918
#include <spdlog/spdlog.h>
2019

2120
//! Project Headers

src/core/atomicdex/pages/qt.trading.page.cpp

+27-2
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ namespace atomic_dex
138138
}
139139

140140
void
141-
trading_page::place_buy_order(const QString& base_nota, const QString& base_confs)
141+
trading_page::place_buy_order(const QString& base_nota, const QString& base_confs, const QString& good_until_canceled)
142142
{
143143
this->set_buy_sell_rpc_busy(true);
144144
this->set_buy_sell_last_rpc_data(QJsonObject{{}});
@@ -178,6 +178,19 @@ namespace atomic_dex
178178
.base_confs = base_confs.isEmpty() ? std::optional<std::size_t>{std::nullopt} : base_confs.toUInt(),
179179
.min_volume = (rel_min_volume_f <= rel_min_trade) ? std::optional<std::string>{std::nullopt} : get_min_trade_vol().toStdString()};
180180

181+
if (good_until_canceled == "true")
182+
{
183+
SPDLOG_DEBUG("Good until cancelled order");
184+
req.order_type = nlohmann::json::object();
185+
req.order_type.value()["type"] = "GoodTillCancelled";
186+
}
187+
else
188+
{
189+
SPDLOG_DEBUG("Fill or kill order");
190+
req.order_type = nlohmann::json::object();
191+
req.order_type.value()["type"] = "FillOrKill";
192+
}
193+
181194
if (is_selected_min_max || is_selected_order)
182195
{
183196
req.min_volume = std::optional<std::string>{std::nullopt};
@@ -269,7 +282,7 @@ namespace atomic_dex
269282
}
270283

271284
void
272-
trading_page::place_sell_order(const QString& rel_nota, const QString& rel_confs)
285+
trading_page::place_sell_order(const QString& rel_nota, const QString& rel_confs, const QString& good_until_canceled)
273286
{
274287
this->set_buy_sell_rpc_busy(true);
275288
this->set_buy_sell_last_rpc_data(QJsonObject{{}});
@@ -312,6 +325,18 @@ namespace atomic_dex
312325
req.order_type.value()["type"] = "FillOrKill";
313326
req.min_volume = std::optional<std::string>{std::nullopt};
314327
}
328+
else if (good_until_canceled == "true")
329+
{
330+
SPDLOG_DEBUG("Good until cancelled order");
331+
req.order_type = nlohmann::json::object();
332+
req.order_type.value()["type"] = "GoodTillCancelled";
333+
}
334+
else
335+
{
336+
SPDLOG_DEBUG("Fill or kill order");
337+
req.order_type = nlohmann::json::object();
338+
req.order_type.value()["type"] = "FillOrKill";
339+
}
315340

316341
if (is_selected_min_max)
317342
{

src/core/atomicdex/pages/qt.trading.page.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ namespace atomic_dex
161161
Q_INVOKABLE bool set_pair(bool is_left_side, const QString& changed_ticker);
162162
Q_INVOKABLE void set_current_orderbook(const QString& base, const QString& rel); ///< market_selector (called and selecting another coin)
163163

164-
Q_INVOKABLE void place_buy_order(const QString& base_nota = "", const QString& base_confs = "");
165-
Q_INVOKABLE void place_sell_order(const QString& rel_nota = "", const QString& rel_confs = "");
164+
Q_INVOKABLE void place_buy_order(const QString& base_nota = "", const QString& base_confs = "", const QString& good_until_canceled = "");
165+
Q_INVOKABLE void place_sell_order(const QString& rel_nota = "", const QString& rel_confs = "", const QString& good_until_canceled = "");
166166

167167
Q_INVOKABLE void reset_order();
168168

0 commit comments

Comments
 (0)