Git Product home page Git Product logo

Comments (3)

mussonero avatar mussonero commented on June 14, 2024 1

@baker-Xie,

  1. I did multiple tests using the examples provided, also I have added a high-resolution clock to both C++ and the python code,
    it is practically unnoticeable the difference. 0.04ms~0.06ms
    But still, python gets nice results 👍.
    test

  2. Regarding your question (1) About the sendOrder API
    You need to post-process manually

from binance-cxx-api.

dmikushin avatar dmikushin commented on June 14, 2024

Dear @baker-Xie thank you for your testing! I could imagine the first connection is slower than subsequent ones, due to initialization overhead. A lot of other aspects may be involved, depending on how the actual test is designed. Would it be possible for you to publish and/or attach here your test code for our further analysis?

from binance-cxx-api.

baker-Xie avatar baker-Xie commented on June 14, 2024

Dear @dmikushin , Thanks for you reply. I'll paste my code here.
(1) The first http call of binance-cxx-api is slow of course, but the rest http calls are slow too (800ms)
(2) The python library is python-binance, please use pip install python-binance to install it.

Meanwhile, I have a question
(1) About the sendOrder API
There is quantity and price parameter which is double . But from website, there is minQty and tickSize. So we should guarantee that our price/quantity parameter are multiple to minQty/tickSize. But in your API, price/quantity are double, and I didn't see further post-process about them. So, if I use this API, should I pass a valid price/quantity , or you code will post-process for me?
For example, minQty = 0.01 tickSize = 0.1
if my quantity is 0.015, my price is 1.12, should I just pass quantity=0.015 / price =1.12 to APi, or should I pass quantity = 0.01 and price = 1.1 to API?

c++ test code:

#include <iostream>
#include <json/json.h>
#include <map>
#include <string>
#include <vector>
#include <algorithm>

#include "binance.h"
#include "binance_logger.h"
#include "binance_websocket.h"
#include "sys/time.h"

using namespace binance;

using std::map;
using std::vector;
using std::string;
using std::cout;
using std::endl;

unsigned long long GetTimestamp()
{
    struct timeval temp;
    gettimeofday(&temp, nullptr);
    return temp.tv_sec * 1e6 + temp.tv_usec;
}

int main()
{
    Json::Value result;

    auto _server = new Server;
    auto _market = new Market(*_server);

    auto beginTime = GetTimestamp();
    _market->getDepth(result, "LINKBTC", 5);
    auto endTime = GetTimestamp();
    cout << (endTime-beginTime) << endl;

    beginTime = GetTimestamp();
    _market->getDepth(result, "ETHTUSD", 5);
    endTime = GetTimestamp();
    cout << (endTime-beginTime) << endl;

    beginTime = GetTimestamp();
    _market->getDepth(result, "LINKETH", 5);
    endTime = GetTimestamp();
    cout << (endTime-beginTime) << endl;

    beginTime = GetTimestamp();
    _market->getDepth(result, "IOTABTC", 5);
    endTime = GetTimestamp();
    cout << (endTime-beginTime) << endl;

    beginTime = GetTimestamp();
    _market->getExchangeInfo(result);
    endTime = GetTimestamp();
    cout << (endTime-beginTime) << endl;

    beginTime = GetTimestamp();
    _market->getExchangeInfo(result);
    endTime = GetTimestamp();
    cout << (endTime-beginTime) << endl;
}

Pyhon test code:

from binance.client import Client as Client_Binance
from binance.enums import *
import time

binance_api_key = 'XXX'
binance_api_secret = 'XXX'

clientB = Client_Binance(binance_api_key, binance_api_secret)

beginTime = time.time()
depthB = clientB.get_order_book(symbol="LINKBTC", limit=5)
print(time.time() - beginTime)

beginTime = time.time()
depthB = clientB.get_order_book(symbol="ETHTUSD", limit=5)
print(time.time() - beginTime)

beginTime = time.time()
depthB = clientB.get_order_book(symbol="LINKETH", limit=5)
print(time.time() - beginTime)

beginTime = time.time()
depthB = clientB.get_order_book(symbol="IOTABTC", limit=5)
print(time.time() - beginTime)

beginTime = time.time()
depthB = clientB.get_order_book(symbol="IOTAETH", limit=5)
print(time.time() - beginTime)

from binance-cxx-api.

Related Issues (15)

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.