sammchardy / python-binance

Binance Exchange API python implementation for automated trading
https://python-binance.readthedocs.io/en/latest/
MIT License
5.97k stars 2.19k forks source link

Binance Server Location #189

Closed kinseyreeves closed 6 years ago

kinseyreeves commented 6 years ago

Not exactly an issue, but was wondering if anybody had figured out the location of binance trading servers? I see that they have a bunch of different end points. Thinking of renting a server but need to know the location for the best speeds as my orders keep getting beaten. If anybody could share any info on their server setup / where it is that would be great. I've had a look and different info suggests either korea or japan. Thanks

ronenkag commented 6 years ago

I have the same problem, trying to figure out where to rent the VPS for my Binance bot... Have you found it out? Wrote to Binance support, still no response.

kinseyreeves commented 6 years ago

I believe it's hosted in tokyo, atleast thats where I've rented my server. However I still suffer from slippage with my program having ~2ms turnaround from receiving websocket data to the trade. So any help would be great. A traceroute and the generic server location sites gave me aws tokyo using api.binance.com

ronenkag commented 6 years ago

Wow! 2ms it's not much at all! Could you tell me where do you rent your VPS? and how good it is?

Thanks!

http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail Virus-free. www.avg.com http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Sat, Mar 3, 2018 at 10:26 AM, kinsey1313 notifications@github.com wrote:

I believe it's hosted in tokyo, atleast thats where I've rented my server. However I still suffer from slippage with my program having ~2ms turnaround from receiving websocket data to the trade. So any help would be great. A traceroute and the generic server location sites gave me aws tokyo using api.binance.com

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/sammchardy/python-binance/issues/189#issuecomment-370130292, or mute the thread https://github.com/notifications/unsubscribe-auth/AFV_faMfgbIT9X8-AVIl3lvJRNlF5ffAks5talPJgaJpZM4SJiFU .

kinseyreeves commented 6 years ago

No thats the time my program takes to calculate what to trade. The time it takes for me to receive server data is about 200ms... 👎 from Melbourne Australia and there is not a considerable change using japan aws hosted in Tokyo.

idaWHALE commented 6 years ago

there is also us.binance.com which is in New Jersey

kinseyreeves commented 6 years ago

Is this the actual trading server however? I'm not sure of the binance server structure but I'd imagine its a single location that handles the trading. Someone please correct me if I'm wrong! If you're from the US, have you pinged this server and gotten a decent response time?

idaWHALE commented 6 years ago

This subdomain seems to be separate, at least is my experience. Several weeks ago when trading was inaccessible, the US subdomain was the first to come back up followed by the main.

sammchardy commented 6 years ago

General consensus is that they are located on AWS in the Tokyo zone.

Do not use anything other than the api.binance.com domain for accessing the API as domains like us.binance.com is only for website access and has different restrictions.

snapo commented 5 years ago

XXXX.ap-northeast-1.compute.amazonaws.com

jonatasfreitasv commented 3 years ago

I tested with Vaultr (https://www.vultr.com/?ref=8732615-6G) 100USD free.

In Tokyo region with < 2ms ping.

kimchirichie commented 3 years ago

tokyo for sure.

gilmotta commented 3 years ago

Tokyo

patrickdugan commented 3 years ago

Tokyo though?

wsgomes commented 3 years ago

Binance is experiencing an issue now... they officially said it is an issue on AWS... I just checked it in status.aws.amazon.com and the only issue displayed there is in Tokyo. I just can´t believe such a rich company running a trading service does not have redundancy.

OtenMoten commented 3 years ago

I tested with Vaultr (https://www.vultr.com/?ref=8732615-6G) 100USD free.

In Tokyo region with < 2ms ping.

I used your link, thanks for sharing bro.

mrzibbert commented 3 years ago

I use for trading, more than a year, low price and beautiful ping with Binance. https://ahost.eu/vds-windows/japan

mantiyeah commented 3 years ago

I use for trading, more than a year, low price and beautiful ping with Binance. https://ahost.eu/vds-windows/japan

Sorry to ask. But I imagine that this would be useful mostly for an automatic bot right?

If you want to manually do scalping, I imagine that the best would be to live in Tokyo.

kasper747 commented 3 years ago

Thank you guys for your insight! I used your ideas and did some extensive testing. It looks like they have local servers in Tokyo and New Jersey. So basically some of you, who are from American can probably use the servers in New Jersey to have also low ping to your own system. I am in Europe myself, and using this solution was day and night. As you see the Europe has the highest ping from them all.

So you can get as low as 10ms including already the calculation from the server. It's not just ping.

time for price request Using this server provider: https://www.vultr.com/?ref=8815565-6G. You get 100$ credits with them. Much simplier to use than AWS, that I usually use.

mrzibbert commented 3 years ago

I use for trading, more than a year, low price and beautiful ping with Binance. https://ahost.eu/vds-windows/japan

Sorry to ask. But I imagine that this would be useful mostly for an automatic bot right?

If you want to manually do scalping, I imagine that the best would be to live in Tokyo.

True basically I use bots, but I myself personally use it for short positions, as the delay is very minimal I get big Profit. Better or live in Tokyo or have your own broker in Tokyo xD. Do not be fooled by discounts :) You will lose more in support, if something goes wrong.

chmickz commented 3 years ago

since I'm looking also for server location. I did this : ping api.binance.com from singapour cloud , time is 17ms from san fransisco cloud time is 1 ms .

So my guess is than the server responding for url api.binance.com are somewhere in the USA

mantiyeah commented 3 years ago

Thank you guys for your insight! I used your ideas and did some extensive testing. It looks like they have local servers in Tokyo and New Jersey. So basically some of you, who are from American can probably use the servers in New Jersey to have also low ping to your own system. I am in Europe myself, and using this solution was day and night. As you see the Europe has the highest ping from them all.

So you can get as low as 10ms including already the calculation from the server. It's not just ping.

  • Tokyo - 0.01s*
  • Seul - 0.042s*
  • New Jersey - 0.01s*
  • Los Angeles - 0.125s*
  • Frankfurt - 0.245s*
  • London - 0.24s*
  • Singapore - 0.095s*
  • Sydney - 0.126s*

time for price request Using this server provider: https://www.vultr.com/?ref=8815565-6G. You get 100$ credits with them. Much simplier to use than AWS, that I usually use.

Are se sure that those are for the server which use the prices?

I know that new jersey has servers for the us web, but not sure if the price u get from the servers in tokyo is the same thing

chmickz commented 3 years ago

since I'm looking also for server location. I did this : ping api.binance.com from singapour cloud , time is 17ms from san fransisco cloud time is 1 ms .

So my guess is than the server responding for url api.binance.com are somewhere in the USA

i forgot to say , this test was made on a digital ocean virtual machine. I use them because they are very reliable (one downtime in 1 years) and they are cheap (less than 5$ a month for a single cpu machine with 25go and 1go ram, and 1To network transfer ).

So far it's enough to run my bot (even with some tensorflow computation) . Here is the link just i case : https://m.do.co/c/a6e619c6428a

kasper747 commented 3 years ago

Thank you guys for your insight! I used your ideas and did some extensive testing. It looks like they have local servers in Tokyo and New Jersey. So basically some of you, who are from American can probably use the servers in New Jersey to have also low ping to your own system. I am in Europe myself, and using this solution was day and night. As you see the Europe has the highest ping from them all. So you can get as low as 10ms including already the calculation from the server. It's not just ping.

  • Tokyo - 0.01s*
  • Seul - 0.042s*
  • New Jersey - 0.01s*
  • Los Angeles - 0.125s*
  • Frankfurt - 0.245s*
  • London - 0.24s*
  • Singapore - 0.095s*
  • Sydney - 0.126s*

time for price request Using this server provider: https://www.vultr.com/?ref=8815565-6G. You get 100$ credits with them. Much simplier to use than AWS, that I usually use.

Are se sure that those are for the server which use the prices?

I know that new jersey has servers for the us web, but not sure if the price u get from the servers in tokyo is the same thing

The way how I was doing the test, I opened the vultr.com service multiple server in different locations. And then run on them the same script to request prices. I have not changed the native API-Url that is in this python-module. So I was not requesting data from binance.us, as I am a customer on binance.com. I am not sure if it's technically two different servers. But maybe for that reason they have a low ping in US East Coast, because they need to have there a location for legal reasons. So they server other customers also.

so I am sure I was getting the same prices, because I was using the same URL, just the location of MY server was in New Jersey.

kasper747 commented 3 years ago

i forgot to say , this test was made on a digital ocean virtual machine. I use them because they are very reliable (one downtime in 1 years) and they are cheap (less than 5$ a month for a single cpu machine with 25go and 1go ram, and 1To network transfer ).

So far it's enough to run my bot (even with some tensorflow computation) . Here is the link just i case : https://m.do.co/c/a6e619c6428a

I personally found, that 1 CPU might be quite degerious because some time just one process can grid-lock the machine, and than you need to restart it.

hps314 commented 3 years ago

Thank you guys for your insight! I used your ideas and did some extensive testing. It looks like they have local servers in Tokyo and New Jersey. So basically some of you, who are from American can probably use the servers in New Jersey to have also low ping to your own system. I am in Europe myself, and using this solution was day and night. As you see the Europe has the highest ping from them all.

So you can get as low as 10ms including already the calculation from the server. It's not just ping.

  • Tokyo - 0.01s*
  • Seul - 0.042s*
  • New Jersey - 0.01s*
  • Los Angeles - 0.125s*
  • Frankfurt - 0.245s*
  • London - 0.24s*
  • Singapore - 0.095s*
  • Sydney - 0.126s*

time for price request Using this server provider: https://www.vultr.com/?ref=8815565-6G. You get 100$ credits with them. Much simplier to use than AWS, that I usually use.

Hello @kasper747 I bought a VPS Vultr Tokyo 1024 MB Cloud Compute 1CPU 25 GB SSD I got time for price request - 0.023s * How to get 0.01s? Must be faster VPS? 2 CPU?

C-Rules commented 3 years ago

Thank you guys for your insight! I used your ideas and did some extensive testing. It looks like they have local servers in Tokyo and New Jersey. So basically some of you, who are from American can probably use the servers in New Jersey to have also low ping to your own system. I am in Europe myself, and using this solution was day and night. As you see the Europe has the highest ping from them all. So you can get as low as 10ms including already the calculation from the server. It's not just ping.

  • Tokyo - 0.01s*
  • Seul - 0.042s*
  • New Jersey - 0.01s*
  • Los Angeles - 0.125s*
  • Frankfurt - 0.245s*
  • London - 0.24s*
  • Singapore - 0.095s*
  • Sydney - 0.126s*

time for price request Using this server provider: https://www.vultr.com/?ref=8815565-6G. You get 100$ credits with them. Much simplier to use than AWS, that I usually use.

Hello @kasper747 I bought a VPS Vultr Tokyo 1024 MB Cloud Compute 1CPU 25 GB SSD I got time for price request - 0.023s * How to get 0.01s? Must be faster VPS? 2 CPU?

I have been using vps from https://www.vpsserver.com/?affcode=3fb1efc10231 at tokyo with pings less than 2ms to api.binance.com around 1.5ms. you can charge with crypto if you want and can use their trial to simply check the time before buying the vps. You should note that there is some time related to opening socket and ssl/tls related data. So to get better results first open the socket and keep it open only send request and measure time from sending request on already established connection and response to get a better time.

kasper747 commented 3 years ago

Thank you guys for your insight! I used your ideas and did some extensive testing. It looks like they have local servers in Tokyo and New Jersey. So basically some of you, who are from American can probably use the servers in New Jersey to have also low ping to your own system. I am in Europe myself, and using this solution was day and night. As you see the Europe has the highest ping from them all. So you can get as low as 10ms including already the calculation from the server. It's not just ping.

  • Tokyo - 0.01s*
  • Seul - 0.042s*
  • New Jersey - 0.01s*
  • Los Angeles - 0.125s*
  • Frankfurt - 0.245s*
  • London - 0.24s*
  • Singapore - 0.095s*
  • Sydney - 0.126s*

time for price request Using this server provider: https://www.vultr.com/?ref=8815565-6G. You get 100$ credits with them. Much simplier to use than AWS, that I usually use.

Hello @kasper747 I bought a VPS Vultr Tokyo 1024 MB Cloud Compute 1CPU 25 GB SSD I got time for price request - 0.023s * How to get 0.01s? Must be faster VPS? 2 CPU?

I would always advise to use at least 2 CPUs. Because if you use only one your instance can easelly friezze from one process and than you need to restart the whole instance - too much risk for critical services. In my test I used an isntance with two CPUs, nothing else. Maybe it is connected with opening and closing sockets. How many times have you repeated the test?

@C-Rules 2ms is just a ping. Requesting a service might take longer. Definitly, I was counting while socket was already opened and the requests were triggered from the server itself, not from my side.

In my experience I have not seen any difference in latency between VPS and virtual instances. As far I know a dedicated server is simply more stable in regards of avalble resources.

But it might make sense to test out difference service providers in Tokyio to find the one with better latency to binance if one want to go faster.

hps314 commented 3 years ago

Thank you guys for your insight! I used your ideas and did some extensive testing. It looks like they have local servers in Tokyo and New Jersey. So basically some of you, who are from American can probably use the servers in New Jersey to have also low ping to your own system. I am in Europe myself, and using this solution was day and night. As you see the Europe has the highest ping from them all. So you can get as low as 10ms including already the calculation from the server. It's not just ping.

  • Tokyo - 0.01s*
  • Seul - 0.042s*
  • New Jersey - 0.01s*
  • Los Angeles - 0.125s*
  • Frankfurt - 0.245s*
  • London - 0.24s*
  • Singapore - 0.095s*
  • Sydney - 0.126s*

time for price request Using this server provider: https://www.vultr.com/?ref=8815565-6G. You get 100$ credits with them. Much simplier to use than AWS, that I usually use.

Hello @kasper747 I bought a VPS Vultr Tokyo 1024 MB Cloud Compute 1CPU 25 GB SSD I got time for price request - 0.023s * How to get 0.01s? Must be faster VPS? 2 CPU?

I would always advise to use at least 2 CPUs. Because if you use only one your instance can easelly friezze from one process and than you need to restart the whole instance - too much risk for critical services. In my test I used an isntance with two CPUs, nothing else. Maybe it is connected with opening and closing sockets. How many times have you repeated the test?

@C-Rules 2ms is just a ping. Requesting a service might take longer. Definitly, I was counting while socket was already opened and the requests were triggered from the server itself, not from my side.

In my experience I have not seen any difference in latency between VPS and virtual instances. As far I know a dedicated server is simply more stable in regards of avalble resources.

But it might make sense to test out difference service providers in Tokyio to find the one with better latency to binance if one want to go faster.

@kasper747 I have a ping of 1.4ms. It takes about 23ms to get the price via API or buy and sell orders. You managed to get 10 milliseconds - so you want to. Will try on 2 CPUs. I have a program in php. Maybe that's why...

kasper747 commented 3 years ago

@hps314 How were you using Php? I was testing it with one python script. I mean this library is in python

hps314 commented 3 years ago

@hps314 How were you using Php? I was testing it with one python script. I mean this library is in python

@kasper747 I have all the code in php. I download prices and execute orders in php. https://github.com/jaggedsoft/php-binance-api

chmickz commented 3 years ago

hello all, I made this small script in python3 , in order to make some reliable test . Please feel free to use it to make your own test.

#!/usr/bin/env python3
from time import time, sleep
from binance.client import Client
loop=10
ROKEY = 'your_key_here'
ROKEYSEC = 'your_secret_here'
total_delai = 0
bclient = Client(api_key=ROKEY,api_secret=ROKEYSEC)
for i in range(loop):
    s = time()
    r = bclient.get_avg_price(symbol='BTCUSDT')
    delai = time()-s
    print('loop number {} delai {} result {}'.format(i,delai, r))
    total_delai +=delai
    sleep(2)

print('average delay {}'.format(total_delai/loop))

I made my test on a digital ocean cloud machine in san fransisco. DO is cheap, easy to manipulate and to migrate machine . a trick to pay less is to use switzerland for VAT. (here is the ref link https://m.do.co/c/a6e619c6428a )
here is a billing example from my account for one month of a single cpu droplet

Final Invoice for January billing period

Issued on February 1, 2021 Product usage charges $5.00 Droplets $5.00 Subtotal $5.00 Tax - VAT France (20.00%) $1.00 Total $6.00

AND THE RESULTS ARE : for san fransico : loop number 0 delai 0.11401081085205078 result {'mins': 5, 'price': '57601.68212838'} loop number 1 delai 0.11512947082519531 result {'mins': 5, 'price': '57600.82330593'} loop number 2 delai 0.1240854263305664 result {'mins': 5, 'price': '57599.76693144'} loop number 3 delai 0.11418557167053223 result {'mins': 5, 'price': '57598.65621511'} loop number 4 delai 0.12267851829528809 result {'mins': 5, 'price': '57595.97103323'} loop number 5 delai 0.12673449516296387 result {'mins': 5, 'price': '57595.04113173'} loop number 6 delai 0.11628222465515137 result {'mins': 5, 'price': '57593.85896357'} loop number 7 delai 0.3298838138580322 result {'mins': 5, 'price': '57590.86031280'} loop number 8 delai 0.11496281623840332 result {'mins': 5, 'price': '57586.98004146'} loop number 9 delai 0.11507511138916016 result {'mins': 5, 'price': '57586.34099463'} average delay 0.13930282592773438

from my personal computer in France (optic fiber line)

loop number 0 delai 0.23161005973815918 result {'mins': 5, 'price': '57473.98379488'} loop number 1 delai 0.23066449165344238 result {'mins': 5, 'price': '57473.43746742'} loop number 2 delai 0.23328661918640137 result {'mins': 5, 'price': '57472.88959753'} loop number 3 delai 0.23072385787963867 result {'mins': 5, 'price': '57458.06634297'} loop number 4 delai 0.23455023765563965 result {'mins': 5, 'price': '57456.40777730'} loop number 5 delai 0.2302262783050537 result {'mins': 5, 'price': '57454.75135576'} loop number 6 delai 0.23994970321655273 result {'mins': 5, 'price': '57451.64674543'} loop number 7 delai 0.23225021362304688 result {'mins': 5, 'price': '57445.75241252'} loop number 8 delai 0.2384181022644043 result {'mins': 5, 'price': '57444.58485420'} loop number 9 delai 0.23217058181762695 result {'mins': 5, 'price': '57442.35732907'} average delay 0.23338501453399657

camel113 commented 3 years ago

I made some ping test with Heroku servers in Europe and United States and I get approx the same response time. url: https://api.binance.com/api/v3/ping response time ~ 220ms I'm wondering how you managed to have such a good response time with your US servers @kasper747 and @chmickz

chmickz commented 3 years ago

I made some ping test with Heroku servers in Europe and United States and I get approx the same response time. url: https://api.binance.com/api/v3/ping response time ~ 220ms I'm wondering how you managed to have such a good response time with your US servers @kasper747 and @chmickz

How did you test : using unix ping command ( like ping https://api.binance.com/api/v3/ping ) or using python code ??

camel113 commented 3 years ago

No, actually I'm using NodeJS and I am making http requests with a lib called axios. So basically, the 220ms is the average answer time to the http GET request I make to https://api.binance.com/api/v3/ping. I was thinking the answer time issue would be common between Python and Node.

chmickz commented 3 years ago

No, actually I'm using NodeJS and I am making http requests with a lib called axios. So basically, the 220ms is the average answer time to the http GET request I make to https://api.binance.com/api/v3/ping. I was thinking the answer time issue would be common between Python and Node.

to compare you should make the test with a simple ping command , and/or use the code I copy paste. (I'm not familiar with node js) .

benbonnet commented 3 years ago

latency does not have anything to do with the language you're using, or the instance running your code. a ping is a ping

or please; someone experienced enough tell me why exactly i'd be wrong to think that

chmickz commented 3 years ago

euuh , actually there is a bit of difference between a ping command like : ping api.binance.com and the code I posted earlier which measure the average time needed to get the price of the crypto from the api ( more layers to go through)

As I said earlier that's why I choose D.O. (check this : https://m.do.co/c/a6e619c6428a )

@camel113 if you run a linux machine you could run my code without to much difficulties

On Wed, 2021-04-28 at 16:55 -0700, Ben wrote:

latency does not have anything to do with the language you're using, or the instance running your code. a ping is a ping

or please; someone experienced enough tell me why exactly i'd be wrong to think that

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

benbonnet commented 3 years ago

i mean by that; the cpu of your instance does not matter. as the code running on it

of course the instance location matters; but thats the very sigle point of differenciation for response time (imho)

that is; we still dont know for sure where is the best location. tokyo for api.binance.COM, and new jersey for api.binance.US ?

chmickz commented 3 years ago

i mean by that; the cpu of your instance does not matter. as the code running on it

of course the instance location matters; but thats the very sigle point of differenciation for response time (imho)

that is; we still dont know for sure where is the best location. tokyo for api.binance.COM, and new jersey for api.binance.US ?

I agree : to run a simple python script (or even a more complex but well coded bot) or to test a simple unix ping ,a single CPU hosted server is enough. Only relative location between client and servers matters . BUT also the type of network, meaning if your client is hosted by the same company as the server , and in the same location , you get a lower latency (less layers/nodes to go through). I may be stating the obvious , but I think maybe it's why I have such low response time .

I'm customer at binance.com and not binance.us . I use to have my bot in singapour , but since I moved it to San fransisco , latency is much lower .(That's what i like in DO . you can move a complete server very esealy )

Of course you don't have to take my word for it : Here's a link that get you 100$ free credit to make some test : https://m.do.co/c/a6e619c6428a

enjoy

benbonnet commented 3 years ago

@chmickz was just reading through, some comments made me think the point had to be narrowed a bit.

It boils down to server location + provider network (you're right on that one!)

am getting started algo'ing around; typical use case to benefit of a lower latency ? i assume no one is practicing hft; so i wonder

chmickz commented 3 years ago

ok all. Just to had new data to this interesting discussion (which looks more and more like a treasure hunt :-) I created a new droplet in new york (you can use this https://m.do.co/c/a6e619c6428a if you want to do your own test)

using the python test program (see previous posts) here is what I have :

(test) root@dropletNY:~/bin/binance_lib# ./pingtest.py loop number 0 delai 0.3083667755126953 result {'mins': 5, 'price': '48723.91529583'} loop number 1 delai 0.310100793838501 result {'mins': 5, 'price': '48721.94350965'} loop number 2 delai 0.3084251880645752 result {'mins': 5, 'price': '48723.95385193'} loop number 3 delai 0.309833288192749 result {'mins': 5, 'price': '48723.48269051'} loop number 4 delai 0.30910825729370117 result {'mins': 5, 'price': '48722.67800612'} loop number 5 delai 0.31095337867736816 result {'mins': 5, 'price': '48720.10171416'} loop number 6 delai 0.30765247344970703 result {'mins': 5, 'price': '48715.35264176'} loop number 7 delai 0.30716800689697266 result {'mins': 5, 'price': '48713.76794342'} loop number 8 delai 0.3072671890258789 result {'mins': 5, 'price': '48711.66785377'} loop number 9 delai 0.3086214065551758 result {'mins': 5, 'price': '48706.54571931'} average delay 0.3087496757507324

My personal opinion is than server behind api.binance.com are located in an amazon cloud somewhere on the west coast of the US .

cfytrok commented 3 years ago

Using AWS availability zone C hosted in Tokyo I get round-trip time (RTT) about 6-8 ms for placing spot orders. Time is measured after connection established. But RTT dramatically increases to 60-70 ms, when I place margin order. Does anyone have lower RTT for margin api?

kanish-111 commented 3 years ago

no i guess now its located in sydney, in vultr, schoose sydney server and check the ping, its less than 0.5ms. even u get less than .5ms in - london, silicon valley, seatle, miami,los angeles, sydney and dallas

OtenMoten commented 3 years ago

no i guess now its located in sydney, in vultr, schoose sydney server and check the ping, its less than 0.5ms. even u get less than .5ms in - london, silicon valley, seatle, miami,los angeles, sydney and dallas

This is not correct. They are based in Tokyo.

kanish-111 commented 3 years ago

no i guess now its located in sydney, in vultr, schoose sydney server and check the ping, its less than 0.5ms. even u get less than .5ms in - london, silicon valley, seatle, miami,los angeles, sydney and dallas

This is not correct. They are based in Tokyo.

ik, but u can check their ping from sydney, its like 0.1ms to 0.4ms

`$ping -c 4 -w15 api.binance.com PING d3h36i1mno13q3.cloudfront.net (52.84.150.66) 56(84) bytes of data. 64 bytes from 52.84.150.66 (52.84.150.66): icmp_seq=1 ttl=246 time=0.194 ms 64 bytes from 52.84.150.66 (52.84.150.66): icmp_seq=2 ttl=246 time=0.187 ms 64 bytes from 52.84.150.66 (52.84.150.66): icmp_seq=3 ttl=246 time=0.221 ms 64 bytes from 52.84.150.66 (52.84.150.66): icmp_seq=4 ttl=246 time=0.255 ms

--- d3h36i1mno13q3.cloudfront.net ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 63ms rtt min/avg/max/mdev = 0.187/0.214/0.255/0.028 ms`

chmickz commented 3 years ago

I assume the goal of this discussion is to know where is the best place to host a trading bot.and because we are on a python discussion thread , that's also why i use the program below in python , because I thinks it's a reliable way to mesure what I call real latency (time for a real request or order emission plus received the answer) PLEASE : if we want to compare real latency measurement , could you please use the same program ? if you want to run the test for free here is the ref link : https://m.do.co/c/a6e619c6428ait gives 100$ for 60 days , so it's long enough to create a ubuntu droplet (the most basic one is enough)before to run the program don't forget the pip install python-binance also a basic Read only key is enough for the test so you don't need to bind it to a specific IP (this way Once it's done you can create a snapshot of the virtual machine and move it to another region ,to re-run the test)

Then, post back the location and the result in this threas so we can all see

!/usr/bin/env python3

from time import time, sleep from binance.client import Client loop=10 ROKEY = 'your_key_here' ROKEYSEC = 'your_secret_here' total_delai = 0 bclient = Client(api_key=ROKEY,api_secret=ROKEYSEC) for i in range(loop): s = time() r = bclient.get_avg_price(symbol='BTCUSDT') delai = time()-s print('loop number {} delai {} result {}'.format(i,delai, r)) total_delai +=delai sleep(2)

print('average delay {}'.format(total_delai/loop))

For example :SOUTH OF FRANCE (OPTIC FIBER LINE): loop number 0 delai 0.24149465560913086 result {'mins': 5, 'price': '31689.15935433'}loop number 1 delai 0.24032807350158691 result {'mins': 5, 'price': '31689.33901065'}loop number 2 delai 0.23905301094055176 result {'mins': 5, 'price': '31689.35393683'}loop number 3 delai 0.2390737533569336 result {'mins': 5, 'price': '31689.38876046'}loop number 4 delai 0.2391524314880371 result {'mins': 5, 'price': '31689.44174132'}loop number 5 delai 0.24004459381103516 result {'mins': 5, 'price': '31689.49166099'}loop number 6 delai 0.2395162582397461 result {'mins': 5, 'price': '31689.49487364'}loop number 7 delai 0.2380661964416504 result {'mins': 5, 'price': '31689.50929057'}loop number 8 delai 0.24039006233215332 result {'mins': 5, 'price': '31689.53699036'}loop number 9 delai 0.24082565307617188 result {'mins': 5, 'price': '31689.59989352'}

average delay 0.2397944688796997

In a VM in SAN FRANSISCO : loop number 0 delai 0.11460614204406738 result {'mins': 5, 'price': '31681.29746134'}loop number 1 delai 0.11735296249389648 result {'mins': 5, 'price': '31681.22987750'}loop number 2 delai 0.11466622352600098 result {'mins': 5, 'price': '31681.20947401'}loop number 3 delai 0.11315298080444336 result {'mins': 5, 'price': '31681.05153953'}loop number 4 delai 0.1152491569519043 result {'mins': 5, 'price': '31680.99514756'}loop number 5 delai 0.11497783660888672 result {'mins': 5, 'price': '31680.96383841'}loop number 6 delai 0.12164473533630371 result {'mins': 5, 'price': '31680.84188431'}loop number 7 delai 0.11379075050354004 result {'mins': 5, 'price': '31680.18035093'}loop number 8 delai 0.1136474609375 result {'mins': 5, 'price': '31680.14936041'}loop number 9 delai 0.1145486831665039 result {'mins': 5, 'price': '31679.91846726'}

average delay 0.11536369323730469

On Mon, 2021-05-03 at 08:42 -0700, Ben wrote:

@chmickz was just reading through, some comments made me think the point had to be narrowed a bit. It boils down to server location + provider network (you're right on that one!)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

kasper747 commented 3 years ago

no i guess now its located in sydney, in vultr, schoose sydney server and check the ping, its less than 0.5ms. even u get less than .5ms in - london, silicon valley, seatle, miami,los angeles, sydney and dallas

This is not correct. They are based in Tokyo.

ik, but u can check their ping from sydney, its like 0.1ms to 0.4ms

`$ping -c 4 -w15 api.binance.com PING d3h36i1mno13q3.cloudfront.net (52.84.150.66) 56(84) bytes of data. 64 bytes from 52.84.150.66 (52.84.150.66): icmp_seq=1 ttl=246 time=0.194 ms 64 bytes from 52.84.150.66 (52.84.150.66): icmp_seq=2 ttl=246 time=0.187 ms 64 bytes from 52.84.150.66 (52.84.150.66): icmp_seq=3 ttl=246 time=0.221 ms 64 bytes from 52.84.150.66 (52.84.150.66): icmp_seq=4 ttl=246 time=0.255 ms

--- d3h36i1mno13q3.cloudfront.net ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 63ms rtt min/avg/max/mdev = 0.187/0.214/0.255/0.028 ms`

Dear Sir, pinging, is not the same as running a query. Who know where your ping goes. maybe it's just a name server. You are better advised to use the proposual from @chmickz . his example seems good. Although I use active action for testing, like placing an order. Because with price there might be some cashing or buffering. But sending just a ping is not really useful.

I tested quite a lot of locations. And it seems they have two servers. One in New York and one in Tokio.

kasper747 commented 3 years ago

I made some ping test with Heroku servers in Europe and United States and I get approx the same response time. url: https://api.binance.com/api/v3/ping response time ~ 220ms I'm wondering how you managed to have such a good response time with your US servers @kasper747 and @chmickz

US is a very big country, one of the biggest. Basically it's a continent, North America. So you need to test for each city. Looking at the ping one of their servers is in New York.

kanish-111 commented 3 years ago

no i guess now its located in sydney, in vultr, schoose sydney server and check the ping, its less than 0.5ms. even u get less than .5ms in - london, silicon valley, seatle, miami,los angeles, sydney and dallas

This is not correct. They are based in Tokyo.

ik, but u can check their ping from sydney, its like 0.1ms to 0.4ms $ping -c 4 -w15 api.binance.com PING d3h36i1mno13q3.cloudfront.net (52.84.150.66) 56(84) bytes of data. 64 bytes from 52.84.150.66 (52.84.150.66): icmp_seq=1 ttl=246 time=0.194 ms 64 bytes from 52.84.150.66 (52.84.150.66): icmp_seq=2 ttl=246 time=0.187 ms 64 bytes from 52.84.150.66 (52.84.150.66): icmp_seq=3 ttl=246 time=0.221 ms 64 bytes from 52.84.150.66 (52.84.150.66): icmp_seq=4 ttl=246 time=0.255 ms --- d3h36i1mno13q3.cloudfront.net ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 63ms rtt min/avg/max/mdev = 0.187/0.214/0.255/0.028 ms

Dear Sir, pinging, is not the same as running a query. Who know where your ping goes. maybe it's just a name server. You are better advised to use the proposual from @chmickz . his example seems good. Although I use active action for testing, like placing an order. Because with price there might be some cashing or buffering. But sending just a ping is not really useful.

I tested quite a lot of locations. And it seems they have two servers. One in New York and one in Tokio.

ok then so im gonna use vultr, so u are suggesting me to use tokyo, ok then ill opt for that, but when i checked ping from tokyo it was around 1-1.4ms while sydney was 0.2-0.4, so that wont be a problem right?? and now from vultr(tokyo) the ping is around 150-200ms, does this affect the performance or its just all endpoints works fine?? apart from that a quick question, any guess on the avg time for placing a market order?? i mean how long it takes to fill an order from sending the api for a market suppose to have huge volume like btcusdt.

chmickz commented 3 years ago

@kanish-111 adding my 2 cents to this discussion . Using a create order to measure the ping gives three problems in my opinion:

first the api key which has to be read write and if you want to test from different vm , should not be bound to a specific ip (so it's a security problem) second the timing is gonna be dependent of the time the order take to be filled . third , due to trading fee it's gonna cost money .

That's why in my script I use r = bclient.get_avg_price(symbol='BTCUSDT') and I gave the free ref link https://m.do.co/c/a6e619c6428a

This way the data queried is dynamic and the test does not cost anything .

@kasper747 the test I made from san fransisco is inside a VM inside a cloud. It is reasonnable to assume such infastructure has a very good connection to internet back bone or a dedicated link to the other side of the country .