Skip to content

Commit

Permalink
Kucoin - check prices of ticker because they are sometimes invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
sjanel committed Oct 25, 2023
1 parent 9fa20fe commit 8315c0b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/api/exchanges/src/kucoinpublicapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,23 @@ MarketOrderBookMap KucoinPublic::AllOrderBooksFunc::operator()(int depth) {
for (const json& tickerDetails : data["ticker"]) {
Market mk(tickerDetails["symbol"].get<std::string_view>(), '-');
if (!markets.contains(mk)) {
log::trace("Market {} is not present", mk);
log::debug("Market {} is not present", mk);
continue;
}
MonetaryAmount askPri(tickerDetails["sell"].get<std::string_view>(), mk.quote());
if (askPri == 0) {
log::debug("Discarding {} because of invalid ask price {}", mk, askPri);
continue;
}
MonetaryAmount bidPri(tickerDetails["buy"].get<std::string_view>(), mk.quote());
if (bidPri == 0) {
log::debug("Discarding {} because of invalid bid price {}", mk, bidPri);
continue;
}
// There is no volume in the response, we need to emulate it, based on the 24h volume
MonetaryAmount dayVolume(tickerDetails["vol"].get<std::string_view>(), mk.base());
if (dayVolume == 0) {
log::trace("No volume for {}", mk);
log::debug("Discarding {} because of invalid volume {}", mk, dayVolume);
continue;
}
const MarketsFunc::MarketInfo& marketInfo = marketInfoMap.find(mk)->second;
Expand Down

0 comments on commit 8315c0b

Please sign in to comment.