(opt = {}, callback = false)
| 92 | if (options) setOptions(options); |
| 93 | |
| 94 | function setOptions(opt = {}, callback = false) { |
| 95 | if (typeof opt === 'string') { // Pass json config filename |
| 96 | Binance.options = JSON.parse(file.readFileSync(opt)); |
| 97 | } else Binance.options = opt; |
| 98 | if (typeof Binance.options.recvWindow === 'undefined') Binance.options.recvWindow = default_options.recvWindow; |
| 99 | if (typeof Binance.options.useServerTime === 'undefined') Binance.options.useServerTime = default_options.useServerTime; |
| 100 | if (typeof Binance.options.reconnect === 'undefined') Binance.options.reconnect = default_options.reconnect; |
| 101 | if (typeof Binance.options.test === 'undefined') Binance.options.test = default_options.test; |
| 102 | if (typeof Binance.options.hedgeMode === 'undefined') Binance.options.hedgeMode = default_options.hedgeMode; |
| 103 | if (typeof Binance.options.log === 'undefined') Binance.options.log = default_options.log; |
| 104 | if (typeof Binance.options.verbose === 'undefined') Binance.options.verbose = default_options.verbose; |
| 105 | if (typeof Binance.options.keepAlive === 'undefined') Binance.options.keepAlive = default_options.keepAlive; |
| 106 | if (typeof Binance.options.localAddress === 'undefined') Binance.options.localAddress = default_options.localAddress; |
| 107 | if (typeof Binance.options.family === 'undefined') Binance.options.family = default_options.family; |
| 108 | if (typeof Binance.options.urls !== 'undefined') { |
| 109 | const { urls } = Binance.options; |
| 110 | if (typeof urls.base === 'string') base = urls.base; |
| 111 | if (typeof urls.wapi === 'string') wapi = urls.wapi; |
| 112 | if (typeof urls.sapi === 'string') sapi = urls.sapi; |
| 113 | if (typeof urls.fapi === 'string') fapi = urls.fapi; |
| 114 | if (typeof urls.fapiTest === 'string') fapiTest = urls.fapiTest; |
| 115 | if (typeof urls.stream === 'string') stream = urls.stream; |
| 116 | if (typeof urls.combineStream === 'string') combineStream = urls.combineStream; |
| 117 | if (typeof urls.fstream === 'string') fstream = urls.fstream; |
| 118 | if (typeof urls.fstreamSingle === 'string') fstreamSingle = urls.fstreamSingle; |
| 119 | if (typeof urls.fstreamTest === 'string') fstreamTest = urls.fstreamTest; |
| 120 | if (typeof urls.fstreamSingleTest === 'string') fstreamSingleTest = urls.fstreamSingleTest; |
| 121 | if (typeof urls.dstream === 'string') dstream = urls.dstream; |
| 122 | if (typeof urls.dstreamSingle === 'string') dstreamSingle = urls.dstreamSingle; |
| 123 | if (typeof urls.dstreamTest === 'string') dstreamTest = urls.dstreamTest; |
| 124 | if (typeof urls.dstreamSingleTest === 'string') dstreamSingleTest = urls.dstreamSingleTest; |
| 125 | } |
| 126 | if (Binance.options.useServerTime) { |
| 127 | publicRequest(getSpotUrl() + 'v3/time', {}, function (error, response) { |
| 128 | Binance.info.timeOffset = response.serverTime - new Date().getTime(); |
| 129 | //Binance.options.log("server time set: ", response.serverTime, Binance.info.timeOffset); |
| 130 | if (callback) callback(); |
| 131 | }); |
| 132 | } else if (callback) callback(); |
| 133 | return this; |
| 134 | } |
| 135 | |
| 136 | const getSpotUrl = () => { |
| 137 | if (Binance.options.test) return baseTest; |
no test coverage detected