Skip to content

Commit

Permalink
Merge pull request #2130 from KomodoPlatform/restore_qty
Browse files Browse the repository at this point in the history
restore best order amount values
  • Loading branch information
syl authored Nov 30, 2022
2 parents ba3a975 + 6c4160a commit 65d3a99
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,8 @@ Item
{
orderbook_list.currentIndex = index

selectOrder(isAsk, coin, price, quantity, price_denom,
price_numer, quantity_denom, quantity_numer,
min_volume, base_min_volume, base_max_volume,
selectOrder(isAsk, coin, price, price_denom,
price_numer, min_volume, base_min_volume, base_max_volume,
rel_min_volume, rel_max_volume, base_max_volume_denom,
base_max_volume_numer, uuid)

Expand Down Expand Up @@ -189,7 +188,7 @@ Item
{
anchors.verticalCenter: parent.verticalCenter
width: parent.width * 0.37
text: { new BigNumber(quantity).toFixed(6) }
text: { new BigNumber(rel_max_volume).toFixed(6) }
font.family: DexTypo.fontFamily
font.pixelSize: 12
horizontalAlignment: Text.AlignRight
Expand Down
5 changes: 1 addition & 4 deletions atomic_defi_design/Dex/Exchange/Trade/ProView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,15 @@ RowLayout
property alias bestOrders: bestOrders
property alias placeOrderForm: placeOrderForm

function selectOrder(is_asks, coin, price, quantity, price_denom, price_numer, quantity_denom, quantity_numer, min_volume, base_min_volume, base_max_volume, rel_min_volume, rel_max_volume, base_max_volume_denom, base_max_volume_numer, uuid)
function selectOrder(is_asks, coin, price, price_denom, price_numer, min_volume, base_min_volume, base_max_volume, rel_min_volume, rel_max_volume, base_max_volume_denom, base_max_volume_numer, uuid)
{
setMarketMode(!is_asks ? MarketMode.Sell : MarketMode.Buy)

API.app.trading_pg.preffered_order = {
"coin": coin,
"price": price,
"quantity": quantity,
"price_denom": price_denom,
"price_numer": price_numer,
"quantity_denom": quantity_denom,
"quantity_numer": quantity_numer,
"min_volume": min_volume,
"base_min_volume": base_min_volume,
"base_max_volume": base_max_volume,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ DexListView
{
Layout.preferredWidth: _quantityColumnSize
horizontalAlignment: Text.AlignRight
text_value: parseFloat(General.formatDouble(quantity, General.amountPrecision, true)).toFixed(8)
text_value: parseFloat(General.formatDouble(rel_max_volume, General.amountPrecision, true)).toFixed(8)
font.pixelSize: 14
}

Expand Down
1 change: 0 additions & 1 deletion src/core/atomicdex/api/mm2/orderbook.order.contents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ namespace atomic_dex::mm2
ss << "coin: " << coin << " ";
ss << "address: " << address << " ";
ss << "price: " << price << " ";
ss << "max_volume: " << maxvolume << " ";
ss << "depth_percent: " << depth_percent << " ";
ss << "base_max_volume: " << base_max_volume << " ";
ss << "rel_max_volume: " << rel_max_volume << " ";
Expand Down
2 changes: 1 addition & 1 deletion src/core/atomicdex/api/mm2/orderbook.order.contents.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace atomic_dex::mm2
std::string min_volume;
std::string min_volume_fraction_numer;
std::string min_volume_fraction_denom;
std::string maxvolume;
std::string max_volume;
std::string max_volume_fraction_numer;
std::string max_volume_fraction_denom;
std::string base_min_volume;
Expand Down
22 changes: 11 additions & 11 deletions src/core/atomicdex/api/mm2/rpc.orderbook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace atomic_dex::mm2
cur_asks.min_volume = cur_asks.base_min_volume;
cur_asks.min_volume_fraction_numer = cur_asks.base_min_volume_numer;
cur_asks.min_volume_fraction_denom = cur_asks.base_min_volume_denom;
cur_asks.maxvolume = cur_asks.base_max_volume;
cur_asks.max_volume = cur_asks.base_max_volume;
cur_asks.max_volume_fraction_numer = cur_asks.base_max_volume_numer;
cur_asks.max_volume_fraction_denom = cur_asks.base_max_volume_denom;

Expand All @@ -54,10 +54,10 @@ namespace atomic_dex::mm2
boost::trim_right_if(cur_asks.price, boost::is_any_of("0"));
cur_asks.price = cur_asks.price;
}
cur_asks.maxvolume = atomic_dex::utils::adjust_precision(cur_asks.maxvolume);
t_float_50 total_f = safe_float(cur_asks.price) * safe_float(cur_asks.maxvolume);
cur_asks.max_volume = atomic_dex::utils::adjust_precision(cur_asks.max_volume);
t_float_50 total_f = safe_float(cur_asks.price) * safe_float(cur_asks.max_volume);
cur_asks.total = atomic_dex::utils::adjust_precision(total_f.str());
result_asks_f = result_asks_f + safe_float(cur_asks.maxvolume);
result_asks_f = result_asks_f + safe_float(cur_asks.max_volume);
}
answer.asks_total_volume = result_asks_f.str();

Expand All @@ -67,33 +67,33 @@ namespace atomic_dex::mm2
cur_bids.min_volume = cur_bids.base_min_volume;
cur_bids.min_volume_fraction_numer = cur_bids.base_min_volume_numer;
cur_bids.min_volume_fraction_denom = cur_bids.base_min_volume_denom;
cur_bids.maxvolume = cur_bids.base_max_volume;
cur_bids.max_volume = cur_bids.base_max_volume;
cur_bids.max_volume_fraction_numer = cur_bids.base_max_volume_numer;
cur_bids.max_volume_fraction_denom = cur_bids.base_max_volume_denom;
cur_bids.total = cur_bids.maxvolume;
cur_bids.total = cur_bids.max_volume;

if (cur_bids.price.find('.') != std::string::npos)
{
boost::trim_right_if(cur_bids.price, boost::is_any_of("0"));
cur_bids.price = cur_bids.price;
}
cur_bids.maxvolume = atomic_dex::utils::adjust_precision(cur_bids.maxvolume);
t_float_50 total_f = safe_float(cur_bids.price) * safe_float(cur_bids.maxvolume);
cur_bids.max_volume = atomic_dex::utils::adjust_precision(cur_bids.max_volume);
t_float_50 total_f = safe_float(cur_bids.price) * safe_float(cur_bids.max_volume);
cur_bids.total = atomic_dex::utils::adjust_precision(total_f.str());
result_bids_f = result_bids_f + safe_float(cur_bids.maxvolume);
result_bids_f = result_bids_f + safe_float(cur_bids.max_volume);
}
answer.bids_total_volume = result_bids_f.str();

for (auto&& cur_asks: answer.asks)
{
t_float_50 percent_f = safe_float(cur_asks.maxvolume) / result_asks_f;
t_float_50 percent_f = safe_float(cur_asks.max_volume) / result_asks_f;
cur_asks.depth_percent = atomic_dex::utils::adjust_precision(percent_f.str());
// SPDLOG_INFO("cur_asks: {}", cur_asks.to_string());
}

for (auto&& cur_bids: answer.bids)
{
t_float_50 percent_f = safe_float(cur_bids.maxvolume) / result_bids_f;
t_float_50 percent_f = safe_float(cur_bids.max_volume) / result_bids_f;
cur_bids.depth_percent = atomic_dex::utils::adjust_precision(percent_f.str());
// SPDLOG_INFO("cur_bids: {}", cur_bids.to_string());
}
Expand Down
23 changes: 0 additions & 23 deletions src/core/atomicdex/models/qt.orderbook.model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,6 @@ namespace atomic_dex
return QString::fromStdString(m_model_data.at(index.row()).price_fraction_denom);
case PriceNumerRole:
return QString::fromStdString(m_model_data.at(index.row()).price_fraction_numer);
case QuantityRole:
return QString::fromStdString(m_model_data.at(index.row()).maxvolume);
case TotalRole:
return QString::fromStdString(m_model_data.at(index.row()).total);
case UUIDRole:
Expand All @@ -114,10 +112,6 @@ namespace atomic_dex
return m_model_data.at(index.row()).is_mine;
case PercentDepthRole:
return QString::fromStdString(m_model_data.at(index.row()).depth_percent);
case QuantityDenomRole:
return QString::fromStdString(m_model_data.at(index.row()).max_volume_fraction_denom);
case QuantityNumerRole:
return QString::fromStdString(m_model_data.at(index.row()).max_volume_fraction_numer);
case BaseMinVolumeRole:
return QString::fromStdString(m_model_data.at(index.row()).base_min_volume);
case BaseMinVolumeDenomRole:
Expand Down Expand Up @@ -269,9 +263,6 @@ namespace atomic_dex
case IsMineRole:
order.is_mine = value.toBool();
break;
case QuantityRole:
order.maxvolume = value.toString().toStdString();
break;
case TotalRole:
order.total = value.toString().toStdString();
break;
Expand All @@ -281,12 +272,6 @@ namespace atomic_dex
case PercentDepthRole:
order.depth_percent = value.toString().toStdString();
break;
case QuantityDenomRole:
order.max_volume_fraction_denom = value.toString().toStdString();
break;
case QuantityNumerRole:
order.max_volume_fraction_numer = value.toString().toStdString();
break;
case CoinRole:
order.coin = value.toString().toStdString();
break;
Expand Down Expand Up @@ -352,14 +337,11 @@ namespace atomic_dex
return {
{PriceRole, "price"},
{CoinRole, "coin"},
{QuantityRole, "quantity"},
{TotalRole, "total"},
{UUIDRole, "uuid"},
{IsMineRole, "is_mine"},
{PriceDenomRole, "price_denom"},
{PriceNumerRole, "price_numer"},
{QuantityDenomRole, "quantity_denom"},
{QuantityNumerRole, "quantity_numer"},
{PercentDepthRole, "depth"},
{MinVolumeRole, "min_volume"},
{EnoughFundsToPayMinVolume, "enough_funds_to_pay_min_volume"},
Expand Down Expand Up @@ -461,7 +443,6 @@ namespace atomic_dex
update_value(OrderbookRoles::PriceNumerRole, QString::fromStdString(order.price_fraction_numer), idx, *this);
update_value(OrderbookRoles::PriceDenomRole, QString::fromStdString(order.price_fraction_denom), idx, *this);
update_value(OrderbookRoles::IsMineRole, order.is_mine, idx, *this);
update_value(OrderbookRoles::QuantityRole, QString::fromStdString(order.maxvolume), idx, *this);
update_value(OrderbookRoles::TotalRole, QString::fromStdString(order.total), idx, *this);
update_value(OrderbookRoles::PercentDepthRole, QString::fromStdString(order.depth_percent), idx, *this);
update_value(OrderbookRoles::BaseMinVolumeRole, QString::fromStdString(order.base_min_volume), idx, *this);
Expand All @@ -488,7 +469,6 @@ namespace atomic_dex
OrderbookRoles::PriceNumerRole,
OrderbookRoles::PriceDenomRole,
OrderbookRoles::IsMineRole,
OrderbookRoles::QuantityRole,
OrderbookRoles::TotalRole,
OrderbookRoles::PercentDepthRole,
OrderbookRoles::BaseMinVolumeRole,
Expand Down Expand Up @@ -651,11 +631,8 @@ namespace atomic_dex
const bool is_buy = trading_pg.get_market_mode() == MarketMode::Buy;
out["coin"] = QString::fromStdString(is_buy ? order.rel_coin.value() : order.coin);
out["price"] = QString::fromStdString(order.price);
out["quantity"] = QString::fromStdString(order.maxvolume);
out["price_denom"] = QString::fromStdString(order.price_fraction_denom);
out["price_numer"] = QString::fromStdString(order.price_fraction_numer);
out["quantity_denom"] = QString::fromStdString(order.max_volume_fraction_denom);
out["quantity_numer"] = QString::fromStdString(order.max_volume_fraction_numer);
out["min_volume"] = QString::fromStdString(order.min_volume);
out["base_min_volume"] = QString::fromStdString(order.base_min_volume);
out["base_max_volume"] = QString::fromStdString(order.base_max_volume);
Expand Down
3 changes: 0 additions & 3 deletions src/core/atomicdex/models/qt.orderbook.model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,11 @@ namespace atomic_dex
{
PriceRole = Qt::UserRole + 1, // 257
CoinRole,
QuantityRole,
TotalRole,
UUIDRole,
IsMineRole,
PriceDenomRole,
PriceNumerRole,
QuantityDenomRole,
QuantityNumerRole,
PercentDepthRole,
MinVolumeRole,
EnoughFundsToPayMinVolume,
Expand Down
6 changes: 0 additions & 6 deletions src/core/atomicdex/models/qt.orderbook.proxy.model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ namespace atomic_dex
{
case orderbook_model::PriceRole:
return safe_float(left_data.toString().toStdString()) < safe_float(right_data.toString().toStdString());
case orderbook_model::QuantityRole:
break;
case orderbook_model::TotalRole:
break;
case orderbook_model::UUIDRole:
Expand All @@ -62,10 +60,6 @@ namespace atomic_dex
break;
case orderbook_model::PercentDepthRole:
break;
case orderbook_model::QuantityDenomRole:
break;
case orderbook_model::QuantityNumerRole:
break;
case orderbook_model::CoinRole:
break;
case orderbook_model::MinVolumeRole:
Expand Down
3 changes: 0 additions & 3 deletions src/core/atomicdex/pages/widgets/dex/qt.orderbook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,8 @@ namespace atomic_dex
t_order_contents order = m_best_orders->get_order_content(idx);
out["coin"] = QString::fromStdString(is_buy ? order.rel_coin.value() : order.coin);
out["price"] = QString::fromStdString(order.price);
out["quantity"] = QString::fromStdString(order.maxvolume);
out["price_denom"] = QString::fromStdString(order.price_fraction_denom);
out["price_numer"] = QString::fromStdString(order.price_fraction_numer);
out["quantity_denom"] = QString::fromStdString(order.max_volume_fraction_denom);
out["quantity_numer"] = QString::fromStdString(order.max_volume_fraction_numer);
out["min_volume"] = QString::fromStdString(order.min_volume);
out["base_min_volume"] = QString::fromStdString(order.base_min_volume);
out["base_max_volume"] = QString::fromStdString(order.base_max_volume);
Expand Down

0 comments on commit 65d3a99

Please sign in to comment.