Skip to main content

C++ SDK Getting Started

The CloudQuant Data Liberator C++ SDK uses Apache Arrow for high-performance data streaming with a generator-based iteration pattern.

Required Security Files

Place the following files from your Downloads ZIP in your working directory:
  • liberator.pfx — Security certificate
  • liberator.json — Contains your Username and Token

Type Reference

The SDK uses std::variant types for flexible argument and return handling:
using Arg = std::variant<std::monostate,
                         bool,
                         int64_t,
                         double,
                         std::string,
                         std::vector<std::string>,
                         std::ostream*>;

using Func = std::function<std::variant<std::monostate,
                 std::shared_ptr<rapidjson::Document>,
                 std::shared_ptr<arrow::RecordBatch>>()>;

using Result = std::variant<std::shared_ptr<rapidjson::Document>, Func>;

Quick Start

Query with get_table

The simplest approach converts results directly into an Arrow Table:
Liberator liberator;

auto table = liberator.get_table(liberator.query({
    {"symbols", std::vector<std::string>{"AAPL", "GOOGL"}},
    {"name", "daily_bars"s},
}));

(void)arrow::PrettyPrint(*table, arrow::PrettyPrintOptions(0, 1), &std::cout);

Query with Generator Pattern

For streaming or large results, use the generator pattern to iterate through record batches:
Liberator liberator;
Liberator::Result ptr;

ptr = liberator.query({
    {"symbols", std::vector<std::string>{"AAPL", "GOOGL"}},
    {"name", "daily_bars"s}
});

auto generator = *std::get_if<Liberator::Func>(&ptr);

for (auto res = generator(); res.index(); res = generator())
{
    auto batch = *std::get_if<2>(&res);
    (void)arrow::PrettyPrint(*batch, arrow::PrettyPrintOptions(0, 1),
        &std::cout);
}