bitcoinvsalts / node-binance-trader

💰 Cryptocurrency Trading Strategy & Portfolio Management Development Framework for Binance. 🤖
https://bitcoinvsalts.com
MIT License
1.17k stars 380 forks source link

PAIR UNKNOWN on every buy - USDT strategy support #97

Closed realflash closed 3 years ago

realflash commented 3 years ago

Running the trader locally to establish everything is working before running in Docker. Version is current master. Every time a buy signal is received the message PAIR UNKNOWN is emitted:

DENTUSDT  ===> BUY 0.00578750 0.01
PAIR UNKNOWN DENTUSDT

Looking at the code I can see the conditional that is failing is line 119 in trader.js:

            if (minimums[alt + "BTC"] && minimums[alt + "BTC"].minQty) {

At startup, the exchange info does seem to be retrieved successfully:

> node-binance-trader@0.3.1 trader /home/user/localdev/node-binance-trader
> node ./src/trader.js

NBT auto trader running.
Auto Trader connected.
NBT Message: Welcome user to the NBT Auto Trading Hub v.0.2.2
NBT HUB => user strategies + trading setup updated
Exchange Minimums: [ 'ETHBTC',
  'LTCBTC',
  'BNBBTC',
  'NEOBTC',
<snip>
  'BNBUSDT',
  'VENBNB',
  ... 1260 more items ]
Open Trades #: 0
Open Trades: {}

So I can see that the minimums variable has been populated there. I added a debug line just before the failing conditional:

            console.log(minimums[alt + "BTC"]);
            if (minimums[alt + "BTC"] && minimums[alt + "BTC"].minQty) {

and now I get:

DENTUSDT  ===> BUY 0.00578750 0.01
undefined
PAIR UNKNOWN DENTUSDT

so it seems the minimums variable is no longer defined. Node is version active LTS, fermium 14.6.0. The same thing happens if I build the Dockerfile provided and run that. Please could you help me diagnose further.

realflash commented 3 years ago

I've added some more logging; it appears the variable minimums is defined, it's the key for the pair that is returning undefined. The minimums variable does contain the key being requested, and that has a minQty subkey which is also defined.

realflash commented 3 years ago

I think this is due to me following https://bitcoinvsaltcoins.com/strategy/608, which is really tethervsaltcoins. Because the code does this:

const alt = signal.pair.replace("BTC", "")
if (minimums[alt + "BTC"] && minimums[alt + "BTC"].minQty) {

(ie remove BTC from the pair and then add it back in everywhere), the instruction to buy fails as it ends up looking for the pair DENTUSDTBTC. I'm assuming this separation of the alt name and the base coin is done largely so that the alt variable can be used in log messages, and that the person who published them is running modified code.

I've looked at all the public forks and I don't see one supporting this strategy. Is there one I can pull from somewhere?

dargmuesli commented 3 years ago

Hey there, yes, currently the code is aligned so that only BTC-based trades are supported. Besides BVA's philosophy, this is an unneeded constraint. In case you found zen's (@balance80) fork, you might have missed this specific branch: https://github.com/balance80/node-binance-trader/tree/feat/multiple-basecoins Try that one and please report success as well as issues, so that we can merge it here :)

realflash commented 3 years ago

Thanks, I will try that out once I have figured out #101 .

realflash commented 3 years ago

We could probably close this issue, now that the error and cause are logged here for others to search.

nithi2023 commented 3 years ago

I tried @balance80's multiple basecoins. but qty is zero and I received this from binance

ERROR 7991117 marketBuy GTOUSDT 0 {"code":-1013,"msg":"Invalid quantity."} Error in queue {"code":-1013,"msg":"Invalid quantity."}