andresilvasantos / bitprophet

Node crypto trading platform for Binance exchange.
MIT License
229 stars 74 forks source link

Adding support to Binance Margin trading #51

Open tchit opened 4 years ago

tchit commented 4 years ago

Hi,

I'd like to add support to Binance Margin accounts only to get notified of trades, but I'm not sure what I have to change. This has been implemented in node-binance-api: https://github.com/jaggedsoft/node-binance-api/blob/master/README.md

Thanks!

ghost commented 4 years ago

Hi, alternative would be to update the packages.

1- Update dependencies package.json "dependencies": { "node-binance-api": "^0.10.3", "node-telegram-bot-api": "^0.40.0", }

2-Update bitprophet.js on line 11 remove const binance = require("node-binance-api") on the start line 260 remove binance.options({ "APIKEY": vars.options.binance.key, "APISECRET": vars.options.binance.secret, useServerTime: true, reconnect: false })
and add binance = exchUtils.init()

3-Update exchange_utils.js on line 2 remove const binance = require("node-binance-api") and add const Binance = require("node-binance-api") const binance = new Binance() add new method init: function() { binance.options({ "APIKEY": vars.options.binance.key, "APISECRET": vars.options.binance.secret, useServerTime: true, reconnect: false }) return binance }

it worked for me.

Thanks!

tchit commented 4 years ago

Thank you so much for helping! I tried those changes but I get this error: SyntaxError: Unexpected token 'const' I guess it's because I'm not a coder and I didn't update exchange_utils.js correctly to add the new method.. Would you mind sharing the file? Again, thanks a lot :)

ghost commented 4 years ago

sorry a detail was missing, follows the two points of changes.....

after that, you will have to add the margin methods

exchange_utils.js

image

bitprophet.js

image

image

tchit commented 4 years ago

Thanks @asokimoto I can’t wait to try this. When you say « after that, you will have to add the margin methods you need », do you mean changing the commands in exchange_utils? Like binance.mgOrderstatus instead of binance.orderstatus? Or maybe using binance.websockets.userMarginData(margin_balance_update, margin_execution_update); ?

Sorry, I’m feeling so dumb right now, I feel like I really don’t have sufficient knowledge to even ask this kind of stuff on Github. I will understand if you find this annoying! Thanks for your help anyway :)

ghost commented 4 years ago

exactly, you will need to adapt the parameters in each method call. Need to know how the binance api works :(

See the difference between calls https://github.com/binance-exchange/binance-official-api-docs/blob/master/margin-api.md#margin-account-new-order-trade

https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#new-order--trade

elefterian commented 3 years ago

Thanks @asokimoto I can’t wait to try this. When you say « after that, you will have to add the margin methods you need », do you mean changing the commands in exchange_utils? Like binance.mgOrderstatus instead of binance.orderstatus? Or maybe using binance.websockets.userMarginData(margin_balance_update, margin_execution_update); ?

Sorry, I’m feeling so dumb right now, I feel like I really don’t have sufficient knowledge to even ask this kind of stuff on Github. I will understand if you find this annoying! Thanks for your help anyway :)

hey @tchit did you manage this or found another solution for margin trade? share please thanks a lot