Skip to content

Instantly share code, notes, and snippets.

@Milerius
Created March 24, 2021 16:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Milerius/52e8df6beeb6c4aa3f91abb9cf543e08 to your computer and use it in GitHub Desktop.
Save Milerius/52e8df6beeb6c4aa3f91abb9cf543e08 to your computer and use it in GitHub Desktop.
constexpr const char* g_komodolive_endpoint = "http://95.216.160.96:8080/api/v1";
t_http_client_ptr g_komodolive_client{std::make_unique<t_http_client>(FROM_STD_STR(g_komodolive_endpoint))};
TEST_CASE("generate all coinpaprika possibilities")
{
const auto resp = ::mm2::api::async_process_rpc_get(g_komodolive_client, "tickers", "/ticker").get();
std::string body = TO_STD_STR(resp.extract_string(true).get());
nlohmann::json j_metrics = nlohmann::json::parse(body);
nlohmann::json metrics = nlohmann::json::object();
for (auto&& cur: j_metrics)
{
for (auto&& [key, obj]: cur.items()) { metrics[key] = obj; }
}
std::unordered_set<std::string> visited;
fs::path cfg_path = antara::gaming::core::assets_real_path() / "config" / "0.4.0-coins.json";
std::ifstream ifs(cfg_path.string());
nlohmann::json j;
ifs >> j;
std::unordered_map<std::string, atomic_dex::coin_config> cfg;
auto out = j.get<std::unordered_map<std::string, atomic_dex::coin_config>>();
CHECK_GT(out.size(), 0);
std::ofstream ofs("/tmp/out.txt", std::ios::trunc);
for (auto&& [key, current_cfg]: out)
{
if (current_cfg.coinpaprika_id != "test-coin")
{
for (auto&& [cur_key, sub_current_cfg]: out)
{
if (visited.contains(key + "/" + cur_key) || !metrics.contains(key + "_" + cur_key))
continue;
const auto obj = metrics.at(key + "_" + cur_key);
if (safe_float(obj.at("base_volume").get<std::string>()) > 0 || safe_float(obj.at("quote_volume").get<std::string>()) > 0)
{
if (key != cur_key && sub_current_cfg.coinpaprika_id != "test-coin")
{
ofs << key << "/" << cur_key << std::endl;
}
}
visited.emplace(key + "/" + cur_key);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment