Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added a 'localAddress' option to specify which IP is to be used for r… #356

Closed
wants to merge 1 commit into from

Conversation

DoobleD
Copy link

@DoobleD DoobleD commented Sep 10, 2019

I added a 'localAddress' option to specify which IP is to be used for requests to Binance API (allows the use of multi IP on a single server).

Usage :

const binance = require('node-binance-api')().options({
  localAddress: '94.23.25.209',
  APIKEY: '<key>',
  APISECRET: '<secret>',
  useServerTime: true // If you get timestamp errors, synchronize to server time at startup
});

All requests will then use the IP given by localAddress ('94.23.25.209' in the example above). You can then run say 10 bots on a single server, with 10 different IPs.

Why do that? Because Binance has API usage limits for IPs. Use several IPs thus allows to trade more, or to run different strategies and bots simultaneously with each one having the full usage limits for its IP. See https://www.binance.com/en/support/articles/360004492232

Of course you need to own the IPs you specify in the 'localAddress' parameter and have them configured on your server.

Works well on my server.

…equests to Binance API (allows the use of multi IP on a single server)
@TravisBuddy
Copy link

Hey @DoobleD,
Something went wrong with the build.

TravisCI finished with status errored, which means the build failed because of something unrelated to the tests, such as a problem with a dependency or the build process itself.

View build log

TravisBuddy Request Identifier: 8f756530-d3ce-11e9-9a2a-b93990a2c4d9

@jaggedsoft
Copy link
Collaborator

Thank you very much for your contribution, friend. Are you aware if this works on ipv6 addresses?

@DoobleD
Copy link
Author

DoobleD commented Sep 10, 2019 via email

@DoobleD
Copy link
Author

DoobleD commented Sep 10, 2019

Also I realize the line localAddress: Binance.options.localAddress should probably also be added in reqObjPost, between lines 138 and 139.

It seems I was using an older version of node-binance-api (0.8.5) which didn't have that reqObjPost variable.

@jaggedsoft
Copy link
Collaborator

Forgot about this until now, very sorry but I appreciate your hard work!
8feb271

for promiseRequest it might be easier to switch to umi-request otherwise we have to define a custom Agent

@jaggedsoft jaggedsoft closed this Oct 20, 2020
@jaggedsoft
Copy link
Collaborator

better late than never I guess 😏 finally got to take advantage of the issue I filed 4 years ago
cheers

@w4l73r
Copy link

w4l73r commented May 4, 2021

Hi
In order to allow this option to be used everywhere (especially on the futures api), you need to add localAddress: Binance.options.localAddress, to the promiseRequest function (line 540)
Can you please provide a patch ?

@mhdmirel
Copy link

this does not work. How do I run

const binance = require('node-binance-api')().options({
  localAddress: '94.23.25.209',
  APIKEY: '<key>',
  APISECRET: '<secret>',
  useServerTime: true // If you get timestamp errors, synchronize to server time at startup
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants