niXman / binapi

Binance API C++ implementation
Apache License 2.0
252 stars 85 forks source link

Got stuck on make #15

Closed ruisg closed 3 years ago

ruisg commented 3 years ago

Hello,

After doing the following commands: sudo apt install -y libssl-dev && git clone https://github.com/niXman/binapi.git && cd binapi/examples/asynchronous && cmake . && make

Everything works fine until it starts the make. Here I get stuck: examples/synchronous-user_data$ make Scanning dependencies of target binapi [ 11%] Building CXX object CMakeFiles/binapi.dir/main.cpp.o [ 22%] Building CXX object CMakeFiles/binapi.dir/home/ubuntu/teste/src/api.cpp.o

Sometimes it even get stuck on [ 11%] line. I don't know what im missing. Can someone please help?

gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0

niXman commented 3 years ago

how many RAM on your linux-device? could you run make in one terminal and some kind of system resource monitor in the other? look at RAM consumption.

ruisg commented 3 years ago

@niXman thanks for the reply. You are right, ram goes to 100%, this was a test VPS.

Just one more question, can you provide an example of a new order post please?

niXman commented 3 years ago

sure:


// ----------------------------------------------------------------------------
//                              Apache License
//                        Version 2.0, January 2004
//                     http://www.apache.org/licenses/
//
// This file is part of binapi(https://github.com/niXman/binapi) project.
//
// Copyright (c) 2019-2021 niXman (github dot nixman dog pm.me). All rights reserved.
// ----------------------------------------------------------------------------

#include <binapi/api.hpp>

#include <boost/asio/io_context.hpp>

#include <iostream>

int main(int argc, char **argv) {
    assert(argc == 3);
    std::string pk = argv[1];
    std::string sk = argv[2];

    boost::asio::io_context ioctx;

    binapi::rest::api api{
        ioctx
        ,"api.binance.com"
        ,"443"
        ,std::move(pk)
        ,std::move(sk)
        ,10000 // recvWindow
    };

    auto res = api.new_order(
         "BTCUSDT"
        ,binapi::e_side::buy
        ,binapi::e_type::market
        ,binapi::e_time::GTC
        ,"some amount"
        ,"some price"
        ,"" // client_order_id: unused
        ,"" // stop_price: unused
        ,"" // iceberg_amount: unused
        ,{} // callback: ignored for blocked way
    );
    if ( !res ) {
        std::cerr << "put order error: " << res.errmsg << std::endl;

        return EXIT_FAILURE;
    }

    std::cout << "put order info: " << res.v << std::endl;

    return EXIT_SUCCESS;
}

but not tested.

niXman commented 3 years ago

so, if you can successfully compile binapi - close the issue please ;)