Skip to content

Commit

Permalink
chore: small clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptochassis committed Oct 24, 2023
1 parent c96709e commit 847f960
Show file tree
Hide file tree
Showing 15 changed files with 46 additions and 29 deletions.
Expand Up @@ -347,7 +347,8 @@ class ExecutionManagementServiceAscendex : public ExecutionManagementService {
auto it1Str = std::string(it1->value.GetString());
auto it2Str = std::string(it2->value.GetString());
if (!it1Str.empty() && !it2Str.empty()) {
element.insert(CCAPI_EM_ORDER_CUMULATIVE_FILLED_PRICE_TIMES_QUANTITY, UtilString::printDoubleScientific(std::stod(it1Str) * std::stod(it2Str)));
element.insert(CCAPI_EM_ORDER_CUMULATIVE_FILLED_PRICE_TIMES_QUANTITY,
Decimal(UtilString::printDoubleScientific(std::stod(it1Str) * std::stod(it2Str))).toString());
}
}
}
Expand Down Expand Up @@ -491,7 +492,7 @@ class ExecutionManagementServiceAscendex : public ExecutionManagementService {
auto it = data.FindMember("ap");
if (it != data.MemberEnd() && !it->value.IsNull()) {
info.insert(CCAPI_EM_ORDER_CUMULATIVE_FILLED_PRICE_TIMES_QUANTITY,
UtilString::printDoubleScientific(std::stod(it->value.GetString()) * std::stod(data["cfq"].GetString())));
Decimal(UtilString::printDoubleScientific(std::stod(it->value.GetString()) * std::stod(data["cfq"].GetString()))).toString());
}
info.insert(CCAPI_EM_BASE_ASSET_QUANTITY_AVAILABLE_FOR_TRADING, data["bab"].GetString());
info.insert(CCAPI_EM_BASE_ASSET_QUANTITY_TOTAL, data["btb"].GetString());
Expand Down
Expand Up @@ -642,7 +642,7 @@ class ExecutionManagementServiceBinanceBase : public ExecutionManagementService
auto it = data.FindMember("ap");
if (it != data.MemberEnd() && !it->value.IsNull()) {
info.insert(CCAPI_EM_ORDER_CUMULATIVE_FILLED_PRICE_TIMES_QUANTITY,
UtilString::printDoubleScientific(std::stod(it->value.GetString()) * std::stod(data["z"].GetString())));
Decimal(UtilString::printDoubleScientific(std::stod(it->value.GetString()) * std::stod(data["z"].GetString()))).toString());
}
}
std::vector<Element> elementList;
Expand Down
Expand Up @@ -221,7 +221,8 @@ class ExecutionManagementServiceBitget : public ExecutionManagementServiceBitget
auto it1Str = std::string(it1->value.GetString());
auto it2Str = std::string(it2->value.GetString());
if (!it1Str.empty() && !it2Str.empty()) {
element.insert(CCAPI_EM_ORDER_CUMULATIVE_FILLED_PRICE_TIMES_QUANTITY, UtilString::printDoubleScientific(std::stod(it1Str) * std::stod(it2Str)));
element.insert(CCAPI_EM_ORDER_CUMULATIVE_FILLED_PRICE_TIMES_QUANTITY,
Decimal(UtilString::printDoubleScientific(std::stod(it1Str) * std::stod(it2Str))).toString());
}
}
}
Expand Down
Expand Up @@ -276,7 +276,8 @@ class ExecutionManagementServiceBitgetFutures : public ExecutionManagementServic
auto it1Str = std::string(it1->value.GetString());
auto it2Str = std::string(it2->value.GetString());
if (!it1Str.empty() && !it2Str.empty()) {
element.insert(CCAPI_EM_ORDER_CUMULATIVE_FILLED_PRICE_TIMES_QUANTITY, UtilString::printDoubleScientific(std::stod(it1Str) * std::stod(it2Str)));
element.insert(CCAPI_EM_ORDER_CUMULATIVE_FILLED_PRICE_TIMES_QUANTITY,
Decimal(UtilString::printDoubleScientific(std::stod(it1Str) * std::stod(it2Str))).toString());
}
}
}
Expand Down
Expand Up @@ -279,8 +279,10 @@ class ExecutionManagementServiceBitmex : public ExecutionManagementService {
auto it1 = x.FindMember("cumQty");
auto it2 = x.FindMember("avgPx");
if (it1 != x.MemberEnd() && it2 != x.MemberEnd()) {
element.insert(CCAPI_EM_ORDER_CUMULATIVE_FILLED_PRICE_TIMES_QUANTITY,
std::to_string(std::stod(it1->value.GetString()) * (it2->value.IsNull() ? 0 : std::stod(it2->value.GetString()))));
element.insert(
CCAPI_EM_ORDER_CUMULATIVE_FILLED_PRICE_TIMES_QUANTITY,
Decimal(UtilString::printDoubleScientific(std::stod(it1->value.GetString()) * (it2->value.IsNull() ? 0 : std::stod(it2->value.GetString()))))
.toString());
}
}
}
Expand Down Expand Up @@ -464,7 +466,7 @@ class ExecutionManagementServiceBitmex : public ExecutionManagementService {
auto it = x.FindMember("avgPx");
if (it != x.MemberEnd() && !it->value.IsNull()) {
info.insert(CCAPI_EM_ORDER_CUMULATIVE_FILLED_PRICE_TIMES_QUANTITY,
std::to_string(std::stod(it->value.GetString()) * std::stod(x["cumQty"].GetString())));
Decimal(UtilString::printDoubleScientific(std::stod(it->value.GetString()) * std::stod(x["cumQty"].GetString()))).toString());
}
std::vector<Element> elementList;
elementList.emplace_back(std::move(info));
Expand Down
Expand Up @@ -358,14 +358,16 @@ class ExecutionManagementServiceCoinbase : public ExecutionManagementService {
element.insert(CCAPI_EM_ORDER_SIDE, makerSide == "buy" ? CCAPI_EM_ORDER_SIDE_SELL : CCAPI_EM_ORDER_SIDE_BUY);
element.insert(CCAPI_IS_MAKER, "0");
element.insert(CCAPI_EM_ORDER_ID, document["taker_order_id"].GetString());
element.insert(CCAPI_EM_ORDER_FEE_QUANTITY,
UtilString::printDoubleScientific(std::stod(priceStr) * std::stod(sizeStr) * std::stod(document["taker_fee_rate"].GetString())));
element.insert(CCAPI_EM_ORDER_FEE_QUANTITY, Decimal(UtilString::printDoubleScientific(std::stod(priceStr) * std::stod(sizeStr) *
std::stod(document["taker_fee_rate"].GetString())))
.toString());
} else if (document.FindMember("maker_user_id") != document.MemberEnd()) {
element.insert(CCAPI_EM_ORDER_SIDE, makerSide == "buy" ? CCAPI_EM_ORDER_SIDE_BUY : CCAPI_EM_ORDER_SIDE_SELL);
element.insert(CCAPI_IS_MAKER, "1");
element.insert(CCAPI_EM_ORDER_ID, document["maker_order_id"].GetString());
element.insert(CCAPI_EM_ORDER_FEE_QUANTITY,
UtilString::printDoubleScientific(std::stod(priceStr) * std::stod(sizeStr) * std::stod(document["maker_fee_rate"].GetString())));
element.insert(CCAPI_EM_ORDER_FEE_QUANTITY, Decimal(UtilString::printDoubleScientific(std::stod(priceStr) * std::stod(sizeStr) *
std::stod(document["maker_fee_rate"].GetString())))
.toString());
}
element.insert(CCAPI_EM_ORDER_INSTRUMENT, instrument);
elementList.emplace_back(std::move(element));
Expand Down
Expand Up @@ -322,8 +322,10 @@ class ExecutionManagementServiceDeribit : public ExecutionManagementService {
auto it1 = x.FindMember("filled_amount");
auto it2 = x.FindMember("average_price");
if (it1 != x.MemberEnd() && it2 != x.MemberEnd()) {
element.insert(CCAPI_EM_ORDER_CUMULATIVE_FILLED_PRICE_TIMES_QUANTITY,
std::to_string(std::stod(it1->value.GetString()) * (it2->value.IsNull() ? 0 : std::stod(it2->value.GetString()))));
element.insert(
CCAPI_EM_ORDER_CUMULATIVE_FILLED_PRICE_TIMES_QUANTITY,
Decimal(UtilString::printDoubleScientific(std::stod(it1->value.GetString()) * (it2->value.IsNull() ? 0 : std::stod(it2->value.GetString()))))
.toString());
}
}
}
Expand Down Expand Up @@ -533,7 +535,9 @@ class ExecutionManagementServiceDeribit : public ExecutionManagementService {
auto it2 = x.FindMember("average_price");
if (it1 != x.MemberEnd() && it2 != x.MemberEnd()) {
info.insert(CCAPI_EM_ORDER_CUMULATIVE_FILLED_PRICE_TIMES_QUANTITY,
std::to_string(std::stod(it1->value.GetString()) * (it2->value.IsNull() ? 0 : std::stod(it2->value.GetString()))));
Decimal(UtilString::printDoubleScientific(std::stod(it1->value.GetString()) *
(it2->value.IsNull() ? 0 : std::stod(it2->value.GetString()))))
.toString());
}
std::vector<Element> elementList;
elementList.emplace_back(std::move(info));
Expand Down
Expand Up @@ -229,7 +229,7 @@ class ExecutionManagementServiceErisx : public ExecutionManagementService {
auto it2 = x.FindMember("avgPrice");
if (it1 != x.MemberEnd() && it2 != x.MemberEnd()) {
element.insert(CCAPI_EM_ORDER_CUMULATIVE_FILLED_PRICE_TIMES_QUANTITY,
std::to_string(std::stod(it1->value.GetString()) * std::stod(it2->value.GetString())));
Decimal(UtilString::printDoubleScientific(std::stod(it1->value.GetString()) * std::stod(it2->value.GetString()))).toString());
}
}
}
Expand Down
Expand Up @@ -74,7 +74,8 @@ class ExecutionManagementServiceGateioPerpetualFutures : public ExecutionManagem
Element element;
element.insert(CCAPI_INSTRUMENT, x["contract"].GetString());
element.insert(CCAPI_EM_POSITION_QUANTITY, x["size"].GetString());
element.insert(CCAPI_EM_POSITION_COST, std::to_string(std::stod(x["entry_price"].GetString()) * std::stod(x["size"].GetString())));
element.insert(CCAPI_EM_POSITION_COST,
Decimal(UtilString::printDoubleScientific(std::stod(x["entry_price"].GetString()) * std::stod(x["size"].GetString()))).toString());
elementList.emplace_back(std::move(element));
}
} break;
Expand Down
Expand Up @@ -257,7 +257,7 @@ class ExecutionManagementServiceGemini : public ExecutionManagementService {
auto it2 = x.FindMember("avg_execution_price");
if (it1 != x.MemberEnd() && it2 != x.MemberEnd()) {
element.insert(CCAPI_EM_ORDER_CUMULATIVE_FILLED_PRICE_TIMES_QUANTITY,
std::to_string(std::stod(it1->value.GetString()) * std::stod(it2->value.GetString())));
Decimal(UtilString::printDoubleScientific(std::stod(it1->value.GetString()) * std::stod(it2->value.GetString()))).toString());
}
}
{
Expand Down Expand Up @@ -436,7 +436,7 @@ class ExecutionManagementServiceGemini : public ExecutionManagementService {
auto it2 = x.FindMember("avg_execution_price");
if (it1 != x.MemberEnd() && it2 != x.MemberEnd()) {
info.insert(CCAPI_EM_ORDER_CUMULATIVE_FILLED_PRICE_TIMES_QUANTITY,
std::to_string(std::stod(it1->value.GetString()) * std::stod(it2->value.GetString())));
Decimal(UtilString::printDoubleScientific(std::stod(it1->value.GetString()) * std::stod(it2->value.GetString()))).toString());
}
}
{
Expand Down
Expand Up @@ -209,8 +209,10 @@ class ExecutionManagementServiceHuobiDerivativesBase : public ExecutionManagemen
auto it1 = x.FindMember("trade_volume");
auto it2 = x.FindMember("trade_avg_price");
if (it1 != x.MemberEnd() && it2 != x.MemberEnd()) {
element.insert(CCAPI_EM_ORDER_CUMULATIVE_FILLED_PRICE_TIMES_QUANTITY,
std::to_string(std::stod(it1->value.GetString()) * (it2->value.IsNull() ? 0 : std::stod(it2->value.GetString()))));
element.insert(
CCAPI_EM_ORDER_CUMULATIVE_FILLED_PRICE_TIMES_QUANTITY,
Decimal(UtilString::printDoubleScientific(std::stod(it1->value.GetString()) * (it2->value.IsNull() ? 0 : std::stod(it2->value.GetString()))))
.toString());
}
}
}
Expand Down Expand Up @@ -353,7 +355,7 @@ class ExecutionManagementServiceHuobiDerivativesBase : public ExecutionManagemen
auto it2 = document.FindMember("trade_avg_price");
if (it1 != document.MemberEnd() && it2 != document.MemberEnd()) {
info.insert(CCAPI_EM_ORDER_CUMULATIVE_FILLED_PRICE_TIMES_QUANTITY,
std::to_string(std::stod(it1->value.GetString()) * std::stod(it2->value.GetString())));
Decimal(UtilString::printDoubleScientific(std::stod(it1->value.GetString()) * std::stod(it2->value.GetString()))).toString());
}
}
for (const auto& x : document["trade"].GetArray()) {
Expand Down
Expand Up @@ -231,7 +231,7 @@ class ExecutionManagementServiceKraken : public ExecutionManagementService {
auto it2 = itr->value.FindMember("price");
if (it1 != itr->value.MemberEnd() && it2 != itr->value.MemberEnd()) {
element.insert(CCAPI_EM_ORDER_CUMULATIVE_FILLED_PRICE_TIMES_QUANTITY,
std::to_string(std::stod(it1->value.GetString()) * std::stod(it2->value.GetString())));
Decimal(UtilString::printDoubleScientific(std::stod(it1->value.GetString()) * std::stod(it2->value.GetString()))).toString());
}
element.insert(CCAPI_EM_ORDER_ID, itr->name.GetString());
elementList.emplace_back(std::move(element));
Expand Down Expand Up @@ -500,8 +500,9 @@ class ExecutionManagementServiceKraken : public ExecutionManagementService {
auto it1 = itr->value.FindMember("vol_exec");
auto it2 = itr->value.FindMember("avg_price");
if (it1 != itr->value.MemberEnd() && it2 != itr->value.MemberEnd()) {
element.insert(CCAPI_EM_ORDER_CUMULATIVE_FILLED_PRICE_TIMES_QUANTITY,
std::to_string(std::stod(it1->value.GetString()) * std::stod(it2->value.GetString())));
element.insert(
CCAPI_EM_ORDER_CUMULATIVE_FILLED_PRICE_TIMES_QUANTITY,
Decimal(UtilString::printDoubleScientific(std::stod(it1->value.GetString()) * std::stod(it2->value.GetString()))).toString());
}
element.insert(CCAPI_EM_ORDER_ID, itr->name.GetString());
elementList.emplace_back(std::move(element));
Expand All @@ -513,7 +514,7 @@ class ExecutionManagementServiceKraken : public ExecutionManagementService {
auto it2 = itr->value.FindMember("avg_price");
if (it1 != itr->value.MemberEnd() && it2 != itr->value.MemberEnd()) {
element.insert(CCAPI_EM_ORDER_CUMULATIVE_FILLED_PRICE_TIMES_QUANTITY,
std::to_string(std::stod(it1->value.GetString()) * std::stod(it2->value.GetString())));
Decimal(UtilString::printDoubleScientific(std::stod(it1->value.GetString()) * std::stod(it2->value.GetString()))).toString());
}
element.insert(CCAPI_EM_ORDER_ID, itr->name.GetString());
elementList.emplace_back(std::move(element));
Expand Down
Expand Up @@ -329,7 +329,8 @@ class ExecutionManagementServiceMexcFutures : public ExecutionManagementService
// auto it1Str = std::string(it1->value.GetString());
// auto it2Str = std::string(it2->value.GetString());
// if (!it1Str.empty() && !it2Str.empty()) {
// element.insert(CCAPI_EM_ORDER_CUMULATIVE_FILLED_PRICE_TIMES_QUANTITY, UtilString::printDoubleScientific(std::stod(it1Str) * std::stod(it2Str)));
// element.insert(CCAPI_EM_ORDER_CUMULATIVE_FILLED_PRICE_TIMES_QUANTITY, Decimal(UtilString::printDoubleScientific(std::stod(it1Str) *
// std::stod(it2Str))).toString());
// }
// }
// }
Expand Down
Expand Up @@ -336,7 +336,8 @@ class ExecutionManagementServiceOkx : public ExecutionManagementService {
auto it1Str = std::string(it1->value.GetString());
auto it2Str = std::string(it2->value.GetString());
if (!it1Str.empty() && !it2Str.empty()) {
element.insert(CCAPI_EM_ORDER_CUMULATIVE_FILLED_PRICE_TIMES_QUANTITY, UtilString::printDoubleScientific(std::stod(it1Str) * std::stod(it2Str)));
element.insert(CCAPI_EM_ORDER_CUMULATIVE_FILLED_PRICE_TIMES_QUANTITY,
Decimal(UtilString::printDoubleScientific(std::stod(it1Str) * std::stod(it2Str))).toString());
}
}
}
Expand Down
Expand Up @@ -282,7 +282,7 @@ class MarketDataServiceKraken : public MarketDataService {
dataPoint.insert({MarketDataMessage::DataFieldType::CLOSE_PRICE, x[5].GetString()});
dataPoint.insert({MarketDataMessage::DataFieldType::VOLUME, x[7].GetString()});
dataPoint.insert(
{MarketDataMessage::DataFieldType::QUOTE_VOLUME, UtilString::printDoubleScientific(std::stod(x[6].GetString()) * std::stod(x[7].GetString()))});
{MarketDataMessage::DataFieldType::QUOTE_VOLUME, Decimal(UtilString::printDoubleScientific(std::stod(x[6].GetString()) * std::stod(x[7].GetString()))}).toString());
marketDataMessage.data[MarketDataMessage::DataType::CANDLESTICK].emplace_back(std::move(dataPoint));
marketDataMessageList.emplace_back(std::move(marketDataMessage));
}
Expand Down

0 comments on commit 847f960

Please sign in to comment.