i dont know if this is optimized for spot testnet, because i chnaged the base url and stream url my self inside that modules, to "wss://testnet.binance.vision" and "https://testnet.binance.vision/" and then i can get user balances info for my test net account, but i cant place orders in that.
if i place a order it gives a big error, for example
`<ref *2> IncomingMessage {
_readableState: ReadableState {
objectMode: false,
highWaterMark: 16384,
buffer: BufferList { head: null, tail: null, length: 0 },
length: 0,
pipes: [],
flowing: true,
ended: true,
endEmitted: true,
reading: false,
constructed: true,
sync: true,
needReadable: false,
emittedReadable: false,
readableListening: false,
resumeScheduled: false,
errorEmitted: false,
emitClose: true,
autoDestroy: true,
destroyed: false,
errored: null,
closed: false,
closeEmitted: false,
defaultEncoding: 'utf8',
awaitDrainWriters: null,
multiAwaitDrain: false,
readingMore: true,
decoder: null,
encoding: null,
} and i also used this code to get user data in streams but idk if this is working or not function balance_update(data) {
console.log("Balance Update");
for ( let obj of data.B ) {
let { a:asset, f:available, l:onOrder } = obj;
if ( available == "0.00000000" ) continue;
console.log(asset+"\tavailable: "+available+" ("+onOrder+" on order)");
}
}
function execution_update(data) {
let { x:executionType, s:symbol, p:price, q:quantity, S:side, o:orderType, i:orderId, X:orderStatus } = data;
if ( executionType == "NEW" ) {
if ( orderStatus == "REJECTED" ) {
console.log("Order Failed! Reason: "+data.r);
}
console.log(symbol+" "+side+" "+orderType+" ORDER #"+orderId+" ("+orderStatus+")");
console.log("..price: "+price+", quantity: "+quantity);
return;
}
//NEW, CANCELED, REPLACED, REJECTED, TRADE, EXPIRED
console.log(symbol+"\t"+side+" "+executionType+" "+orderType+" ORDER #"+orderId);
}
binance.websockets.userData(balance_update, execution_update);`
i just want this all to work fully on testnet spot
or guide me if ive made any mistakes;
i dont know if this is optimized for spot testnet, because i chnaged the base url and stream url my self inside that modules, to "wss://testnet.binance.vision" and "https://testnet.binance.vision/" and then i can get user balances info for my test net account, but i cant place orders in that. if i place a order it gives a big error, for example `<ref *2> IncomingMessage { _readableState: ReadableState { objectMode: false, highWaterMark: 16384, buffer: BufferList { head: null, tail: null, length: 0 }, length: 0, pipes: [], flowing: true, ended: true, endEmitted: true, reading: false, constructed: true, sync: true, needReadable: false, emittedReadable: false, readableListening: false, resumeScheduled: false, errorEmitted: false, emitClose: true, autoDestroy: true, destroyed: false, errored: null, closed: false, closeEmitted: false, defaultEncoding: 'utf8', awaitDrainWriters: null, multiAwaitDrain: false, readingMore: true, decoder: null, encoding: null,
}, _events: [Object: null prototype] { end: [ [Function: responseOnEnd], [Function (anonymous)] ], close: [ [Function (anonymous)], [Function (anonymous)] ], data: [Function (anonymous)], error: [Function (anonymous)] }, _eventsCount: 4, _maxListeners: undefined, socket: null, httpVersionMajor: 1, httpVersionMinor: 1, httpVersion: '1.1', complete: true, rawHeaders: [ 'Content-Type', 'application/json;charset=UTF-8', 'Content-Length', '52', 'Connection', 'keep-alive', 'Date', 'Sun, 18 Jul 2021 12:00:45 GMT', 'Server', 'nginx', 'x-mbx-uuid', '15d7529f-d6c0-41e7-9f9c-6fb44270edd3', 'x-mbx-used-weight', '1', 'x-mbx-used-weight-1m', '1', 'Strict-Transport-Security', 'max-age=31536000; includeSubdomains', 'X-Frame-Options', 'SAMEORIGIN', 'X-Xss-Protection', '1; mode=block', 'X-Content-Type-Options', 'nosniff', 'Content-Security-Policy', "default-src 'self'", 'X-Content-Security-Policy', "default-src 'self'", 'X-WebKit-CSP', "default-src 'self'", 'Cache-Control', 'no-cache, no-store, must-revalidate', 'Pragma', 'no-cache', 'Expires', '0', 'X-Cache', 'Error from cloudfront', 'Via', '1.1 4a3d45392079538c9aa57c1dba9c7b37.cloudfront.net (CloudFront)', 'X-Amz-Cf-Pop', 'MAA51-C1', 'X-Amz-Cf-Id', 'cBnLRIxQ9aFr5wxdtm1ee9y5-OqLkOmFQfHymeNifk03Pm3Vxp_Wvg==' ], rawTrailers: [], aborted: false, upgrade: false, url: '', method: null, statusCode: 400, statusMessage: 'Bad Request', client: <ref *1> TLSSocket { _tlsOptions: { allowHalfOpen: undefined, pipe: false, secureContext: [SecureContext], isServer: false, requestCert: true, rejectUnauthorized: true, session: undefined, ALPNProtocols: undefined, requestOCSP: undefined, enableTrace: undefined, pskCallback: undefined, highWaterMark: undefined, onread: undefined, signal: undefined }, _secureEstablished: true, _securePending: false, _newSessionPending: false, _controlReleased: true, secureConnecting: false, _SNICallback: null, servername: 'testnet.binance.vision', alpnProtocol: false, authorized: true, authorizationError: null, encrypted: true, _events: [Object: null prototype] { close: [Array], end: [Function: onReadableStreamEnd], newListener: [Function: keylogNewListener], secure: [Function: onConnectSecure], session: [Function (anonymous)], free: [Function: onFree], timeout: [Function: onTimeout], agentRemove: [Function: onRemove] }, _eventsCount: 8, connecting: false, _hadError: false, _parent: null, _host: 'testnet.binance.vision', _readableState: ReadableState { objectMode: false, highWaterMark: 16384, buffer: BufferList { head: null, tail: null, length: 0 }, length: 0, pipes: [], flowing: true, ended: false, endEmitted: false, reading: true, constructed: true, sync: false, needReadable: true, emittedReadable: false, readableListening: false, resumeScheduled: false, errorEmitted: false, emitClose: false, autoDestroy: true, destroyed: false, errored: null, closed: false, closeEmitted: false, defaultEncoding: 'utf8', awaitDrainWriters: null, multiAwaitDrain: false, readingMore: false, decoder: null, encoding: null,
}, _consuming: false, _dumped: false, req: <ref 3> ClientRequest { _events: [Object: null prototype] { response: [Function: bound ], error: [Array], drain: [Function (anonymous)], socket: [Function (anonymous)], timeout: [Function], prefinish: [Function: requestOnPrefinish] }, _eventsCount: 6, _maxListeners: undefined, outputData: [], outputSize: 0, writable: true, destroyed: true, _last: false, chunkedEncoding: false, shouldKeepAlive: true, _defaultKeepAlive: true, useChunkedEncodingByDefault: true, sendDate: false, _removedConnection: false, _removedContLen: false, _removedTE: false, _contentLength: null, _hasBody: true, _trailer: '', finished: true, _headerSent: true, _closed: false, socket: <ref 1> TLSSocket { _tlsOptions: [Object], _secureEstablished: true, _securePending: false, _newSessionPending: false, _controlReleased: true, secureConnecting: false, _SNICallback: null, servername: 'testnet.binance.vision', alpnProtocol: false, authorized: true, authorizationError: null, encrypted: true, _events: [Object: null prototype], _eventsCount: 8, connecting: false, _hadError: false, _parent: null, _host: 'testnet.binance.vision', _readableState: [ReadableState], _maxListeners: undefined, _writableState: [WritableState], allowHalfOpen: false, _sockname: null, _pendingData: null, _pendingEncoding: '', server: undefined, _server: null, ssl: [TLSWrap], _requestCert: true, _rejectUnauthorized: true, parser: null, _httpMessage: [Circular *3], timeout: 0,
}, request: <ref 4> Request { _events: [Object: null prototype] { error: [Array], complete: [Function: bound ], pipe: [Function (anonymous)], data: [Function (anonymous)], end: [Function (anonymous)] }, _eventsCount: 5, _maxListeners: undefined, method: 'POST', family: false, localAddress: false, timeout: 5000, forever: true, qsStringifyOptions: { arrayFormat: 'repeat' }, headers: { 'User-Agent': 'Mozilla/4.0 (compatible; Node Binance API)', 'Content-type': 'application/x-www-form-urlencoded', 'X-MBX-APIKEY': 'j7rU6E7o4GriW2RHq8AwTCWdU6QUNMpSVB32DrZ8oeaUroF9fhl9XGSung8YOam4', 'content-length': 184 }, callback: [Function (anonymous)], readable: true, writable: true, explicitMethod: true, _qs: Querystring { request: [Circular 4], lib: [Object], useQuerystring: undefined, parseOptions: {}, stringifyOptions: [Object] }, _auth: Auth { request: [Circular 4], hasAuth: false, sentAuth: false, bearerToken: null, user: null, pass: null }, _oauth: OAuth { request: [Circular 4], params: null }, _multipart: Multipart { request: [Circular 4], boundary: '566b5b0f-c148-4e61-8e79-50c1044ace29', chunked: false, body: null }, _redirect: Redirect { request: [Circular 4], followRedirect: true, followRedirects: true, followAllRedirects: false, followOriginalHttpMethod: false, allowRedirect: [Function (anonymous)], maxRedirects: 10, redirects: [], redirectsFollowed: 0, removeRefererHeader: false }, _tunnel: Tunnel { request: [Circular *4], proxyHeaderWhiteList: [Array], proxyHeaderExclusiveList: [] }, setHeader: [Function (anonymous)], hasHeader: [Function (anonymous)], getHeader: [Function (anonymous)], removeHeader: [Function (anonymous)], pool: { 'https:': [Agent] }, dests: [], __isRequestRequest: true, _callback: [Function (anonymous)], uri: Url { protocol: 'https:', slashes: true, auth: null, host: 'testnet.binance.vision', port: 443, hostname: 'testnet.binance.vision', hash: null, search: null, query: null, pathname: '/api/v3/order', path: '/api/v3/order', href: 'https://testnet.binance.vision/api/v3/order' }, proxy: null, tunnel: true, setHost: true, originalCookieHeader: undefined, _disableCookies: true, _jar: undefined, port: 443, host: 'testnet.binance.vision', body: 'symbol=BTCUSDT&side=BUY&type=LIMIT&quantity=1&price=1&timeInForce=GTC×tamp=1626609645090&recvWindow=5000&signature=49fcb6ba9fbc2cdd0336dafc11b2c2460b35bf52e0325a32394e3615eb271420', path: '/api/v3/order', httpModule: { Agent: [Function: Agent], globalAgent: [Agent], Server: [Function: Server], createServer: [Function: createServer], get: [Function (anonymous)], request: [Function (anonymous)] }, agentClass: [Function: Agent], agentOptions: { keepAlive: true }, agent: Agent { _events: [Object: null prototype], _eventsCount: 2, _maxListeners: undefined, defaultPort: 443, protocol: 'https:', options: [Object: null prototype], requests: [Object: null prototype] {}, sockets: [Object: null prototype], freeSockets: [Object: null prototype] {}, keepAliveMsecs: 1000, keepAlive: true, maxSockets: Infinity, maxFreeSockets: 256, scheduling: 'lifo', maxTotalSockets: Infinity, totalSocketCount: 3, maxCachedSessions: 100, _sessionCache: [Object],
}, toJSON: [Function: responseToJSON], caseless: Caseless { dict: { 'content-type': 'application/json;charset=UTF-8', 'content-length': '52', connection: 'keep-alive', date: 'Sun, 18 Jul 2021 12:00:45 GMT', server: 'nginx', 'x-mbx-uuid': '15d7529f-d6c0-41e7-9f9c-6fb44270edd3', 'x-mbx-used-weight': '1', 'x-mbx-used-weight-1m': '1', 'strict-transport-security': 'max-age=31536000; includeSubdomains', 'x-frame-options': 'SAMEORIGIN', 'x-xss-protection': '1; mode=block', 'x-content-type-options': 'nosniff', 'content-security-policy': "default-src 'self'", 'x-content-security-policy': "default-src 'self'", 'x-webkit-csp': "default-src 'self'", 'cache-control': 'no-cache, no-store, must-revalidate', pragma: 'no-cache', expires: '0', 'x-cache': 'Error from cloudfront', via: '1.1 4a3d45392079538c9aa57c1dba9c7b37.cloudfront.net (CloudFront)', 'x-amz-cf-pop': 'MAA51-C1', 'x-amz-cf-id': 'cBnLRIxQ9aFr5wxdtm1ee9y5-OqLkOmFQfHymeNifk03Pm3Vxp_Wvg==' } }, body: '{"code":-1013,"msg":"Filter failure: PERCENT_PRICE"}',
},
}
and i also used this code to get user data in streams but idk if this is working or not
function balance_update(data) { console.log("Balance Update"); for ( let obj of data.B ) { let { a:asset, f:available, l:onOrder } = obj; if ( available == "0.00000000" ) continue; console.log(asset+"\tavailable: "+available+" ("+onOrder+" on order)"); } } function execution_update(data) { let { x:executionType, s:symbol, p:price, q:quantity, S:side, o:orderType, i:orderId, X:orderStatus } = data; if ( executionType == "NEW" ) { if ( orderStatus == "REJECTED" ) { console.log("Order Failed! Reason: "+data.r); } console.log(symbol+" "+side+" "+orderType+" ORDER #"+orderId+" ("+orderStatus+")"); console.log("..price: "+price+", quantity: "+quantity); return; } //NEW, CANCELED, REPLACED, REJECTED, TRADE, EXPIRED console.log(symbol+"\t"+side+" "+executionType+" "+orderType+" ORDER #"+orderId); } binance.websockets.userData(balance_update, execution_update);`i just want this all to work fully on testnet spot or guide me if ive made any mistakes;
@jaggedsoft