Git Product home page Git Product logo

binance-cxx-api's Introduction

⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⠁⠀⠉⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣿⣿⠟⠁⠀⠀⣀⠀⠀⠈⠻⣿⣿⣿⣿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣿⣅⠀⠀⣠⣾⣿⣷⣄⠀⢀⣼⣿⣿⣿⣿⣿⣿⣿
⣿⣿⣿⣿⠟⠉⠻⢿⣷⣾⡿⠛⠉⠻⣿⣷⣿⡿⠋⠈⠻⣿⣿⣿⣿
⣿⣿⣿⣿⣦⣀⣴⣿⡿⢿⣿⣦⣀⣴⣿⡿⢿⣷⣦⣀⣴⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣿⡋⠀⠀⠙⢿⣿⡿⠋⠀⠀⢹⣿⣿⣿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣿⣿⣦⡀⠀⠀⠉⠀⠀⣀⣴⣿⣿⣿⣿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿

Binance C++ API

Library for accessing Binance Bincoin Exchange using web sockets and JSON.

This version is derived from https://github.com/binance-exchange/binacpp with slight fixes:

  • Corrected endless recursion in BinaCPP::to_string
  • Commented out flags no longer supported by modern versions of web sockets
  • CMake build system
  • Refactored entire API
  • Maintaining thread safety

Prerequisites

sudo apt-get install cmake g++

Building

git clone --recurse-submodules https://github.com/dmikushin/binance-cxx-api.git
cd binance-cxx-api
mkdir build
cd build/
cmake ..
make
./example

binance-cxx-api's People

Contributors

akildemir avatar dmikushin avatar lekensteyn avatar mussonero avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

binance-cxx-api's Issues

Running example.cpp causes segmentation fault after PR #13

Hello,

Since I updated the changes after #13, I get a segmentation fault when running example.cpp. I narrowed down the cause to line 78: Websocket::enter_event_loop();
Had 0 problems before, so I'm positive it's since last update. Sometimes it happens instantly, sometimes it takes longer (10-20 seconds). So I'm guessing it happens in the do-while loop.

OS info:
System Version: macOS 10.14.6 (18G103)
Kernel Version: Darwin 18.7.0

Thank you for your time

subscribe multiple streams limits?

image
I noticed that multiple streams are subscribed in the above way, not the combined streams. will this hit the limits of 10 incoming messages per second.
image

Certificate error?

I get following error while trying to run the example:

[2019/04/01 20:23:07:5422] NOTICE: lws_protocol_init
[2019/04/01 20:23:07:8858] ERR: SSL connect error 337047686: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed
2019-04-01 20:23:07 885877 :binance::Websocket::event_cb LWS_CALLBACK_CLIENT_CONNECTION_ERROR

Any idea?

multiple streams

hi, is it possible to subscribe and parse different streams at the same time ? if so, can you provide with an example if possible ? Also, do you think it's safe to multi-thread ? My aim is to open one many streams per symbol and pipe the data through a local socket to another module. Thanks !

stepSize code

Hi Dmikushin.
Thanks for your project.
I would like to know if you have the c++ code for place a new order using Lotsize , I have seen your function binance::Market::getLotSize, but I wold like to know if you have the implementation using this function + Rules of StepSize ?

Thanks for your help.
Best Regards Maria.

osx compilation issue

Hi,
almost got it compiled on osx 10.13.6.

  • osx does not have HOST_NAME_MAX in limits.h (dont know where it is, just set it to 512 locally)
  • osx does not have a pthread_self() that returns int (it returns a struct) (binance_websocket.cpp line 63). This can be fixed using this code snippet in the same place:

uint64_t tid;
pthread_threadid_np(NULL, &tid);
return tid;

then code compiles. There seems to be a problem with jsoncpp though. cause the last stepp in compiling libbinacpp.so gives me this error:
/usr/local/Cellar/gcc/9.2.0_2/bin/g++-9 -fPIC -shared -lcurl -lwebsockets -ljsoncpp binance.cpp *.o -o libbinacpp.so -lcrypto -L /usr/local/Cellar/[email protected]/1.1.1d/lib/ -L/usr/local/lib -ljsoncp

"Json::Reader::parse(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, Json::Value&, bool)", referenced from:
binance::Account::getInfo(Json::Value&, long) in binance_account.o
binance::Account::getTrades(Json::Value&, char const*, int) in binance_account.o
binance::Account::getTradesSigned(Json::Value&, char const*, long, long, int) in binance_account.o
binance::Account::getHistoricalTrades(Json::Value&, char const*, long, int) in binance_account.o
binance::Account::getOpenOrders(Json::Value&, long) in binance_account.o
binance::Account::getOpenOrders(Json::Value&, char const*, long) in binance_account.o
binance::Account::getAllOrders(Json::Value&, char const*, long, int, long) in binance_account.o
...
"Json::Value::getMemberNamesabi:cxx11 const", referenced from:
binance::Account::getInfo(Json::Value&, long) in binance_account.o
binance::Account::getTrades(Json::Value&, char const*, int) in binance_account.o
binance::Account::getTradesSigned(Json::Value&, char const*, long, long, int) in binance_account.o
binance::Account::getHistoricalTrades(Json::Value&, char const*, long, int) in binance_account.o
binance::Account::getOpenOrders(Json::Value&, long) in binance_account.o
binance::Account::getOpenOrders(Json::Value&, char const*, long) in binance_account.o
binance::Account::getAllOrders(Json::Value&, char const*, long, int, long) in binance_account.o
...
"Json::Value::asStringabi:cxx11 const", referenced from:
binance::Account::getInfo(Json::Value&, long) in binance_account.o
binance::Account::getTrades(Json::Value&, char const*, int) in binance_account.o
binance::Account::getTradesSigned(Json::Value&, char const*, long, long, int) in binance_account.o
binance::Account::getHistoricalTrades(Json::Value&, char const*, long, int) in binance_account.o
binance::Account::getOpenOrders(Json::Value&, long) in binance_account.o
binance::Account::getOpenOrders(Json::Value&, char const*, long) in binance_account.o
binance::Account::getAllOrders(Json::Value&, char const*, long, int, long) in binance_account.o
...

if i remove -ljsoncpp there are tons of errors, so it clearly finds jsoncpp. I have no idea what the issue is. Any help appreciated.
(compiles fine on linux ! thanks for the effort)

Send a market order issue

Hi guys,

i have an issue with placing a market order. Especially with the timeforce.
I get this message when trying to : "Parameter 'timeInForce' sent when not required."

Do you know how can i fix it ?
thanks

Accessing futures websocket data stream

Currently we have access to spot data which is available at 'stream.binance.com'. Can we access futures data also which is available at fstream.binance.com? Simply changing BINANCE_WS_HOST to fstream.binance.com doesn't work. Has anyone else tried accessing futures data using binance-cxx-api?

slow http performance

Hello
I tested this library and python one
When call the same restful API , this library costs 800ms and python library only cost 300ms . Is there any way to imporve the performance? Is the problem with keep alive?
Thanks

wsi-timeout scheduling validity check

I have a strange issue here, almost after 24 hours of running my program using

Websocket::enter_event_loop()

I do not receive any more "wsi scheduling validity check" in program syslogs.
Therefore the program does not get any update from Binance ticker which I set-up.
I was wondering if anyone else has this kind of behavior.

Websocket error: lws_ssl_client_connect1

Hello,

I compiled everything and can use the REST functions without issues, but I'm struggling to find a solution to getting the websocket examples to work.

Without changing the original code, the connection fails with lws_ssl_client_connect1.
If I add LCCSCF_ALLOW_INSECURE, there are no errors, but no data is received.

Any ideas on how can I debug/fix it?

mbedcrypto error not built by this project

Hello,

When following the installation instructions of this library, executing the cmd "cmake .." in the build directory causes the following error:

CMake Error at CMakeLists.txt:31 (target_link_libraries):
Cannot specify link libraries for target "mbedcrypto::mbedcrypto" which is
not built by this project.

Do I need to install mbedcrypto separately, and if so wich one? Because there are multiple mbedcrypto git repos.
(Thank you for your time)

ubuntu Segmentation fault

I am getting Segmentation Fault, just by executing "account.getInfo(json_result, recvWindow)"

Program received signal SIGSEGV, Segmentation fault.
0x00007fbf4151abd6 in mbedtls_sha256_finish_ret (ctx=0x55658cd7faf0, output=0x2af8 <error: Cannot access memory at address 0x2af8>) at /opt/binance-cxx-api/ThirdParty/mbedtls/crypto/library/sha256.c:386
386 PUT_UINT32_BE( ctx->state[0], output, 0 );

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.