jaggedsoft / node-binance-api

Node Binance API is an asynchronous node.js library for the Binance API designed to be easy to use.
MIT License
1.57k stars 767 forks source link

Is it possible to send test / simulation orders? #674

Open ThallyssonKlein opened 3 years ago

ThallyssonKlein commented 3 years ago

I would like to know if it is possible to test the sending of orders simulated, without using real money initially.

emansammut commented 3 years ago

Yes you can by setting up an apikey and secret key on https://testnet.binance.vision/ But please note that the liquidity is very low on the testnet in which it wouldn't be as realastic but to setup the config to work with testnet, you would need to point your trades to the testnet using this package by setting up the config similar to below:

const binance = new Binance().options({
            APIKEY: '',
            APISECRET: '',
            adjustForTimeDifference: true,
            urls: {
                base: "https://testnet.binance.vision/api/"
            }
});
ThallyssonKlein commented 3 years ago

Why does the return of orders become an empty object using testnet?

emansammut commented 3 years ago

if you're using test: true in the config it will return an empty object, however if you use testnet account without test:true, it will try to fill the order but as mentioned liquidity on testnet is very low and will give a false perception to reality. I would first try without test:true, to make sure you get the response that you you need and handle accordingly in case of any errors. After that use test:true, to simulate orders as expected and try to remove any further errors regarding minNotional, qty filters etc. That's how I progressed before moving to the live account.

gurachan commented 3 years ago

Yes you can by setting up an apikey and secret key on https://testnet.binance.vision/ But please note that the liquidity is very low on the testnet in which it wouldn't be as realastic but to setup the config to work with testnet, you would need to point your trades to the testnet using this package by setting up the config similar to below:

const binance = new Binance().options({
            APIKEY: '',
            APISECRET: '',
            adjustForTimeDifference: true,
            urls: {
                base: "https://testnet.binance.vision/api/"
            }
});

I followed this and the candles data from ethusdt@kline_15m is so different xD and it looks like a bugged result.

i have mine setup like this

const binance = new Binance().options({
    APIKEY: Account.APIKEY,
    APISECRET: Account.APISECRET,
})

..

then it will bug if i try to do this

const binance = new Binance().options({
    APIKEY: Account.TESTKEY,
    APISECRET: Account.TESTSECRET,
    adjustForTimeDifference: true,
    urls: {
         base: "https://testnet.binance.vision/api/"
    }
})

even if i overdo it like this

const binance = new Binance().options({
    APIKEY: Account.TESTKEY,
    APISECRET: Account.TESTSECRET,
    adjustForTimeDifference: true,
    urls: {
         base: "https://testnet.binance.vision/api/",
         combineStream: 'wss://testnet.binance.vision/stream?streams=',
         stream: 'wss://testnet.binance.vision/ws/'
    }
})

they will endup like this

image

the expected result is

image

i just wanna do paper trading :(

kanish-111 commented 3 years ago

even i want to place a order in this, but it shows a error when using testnet i used this let base = 'https://testnet.binance.vision/api/'; let wapi = 'https://testnet.binance.vision/wapi/'; let sapi = 'https://testnet.binance.vision/sapi/';