ccxt 4.2.29 → 4.2.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -6
- package/dist/ccxt.browser.js +2196 -601
- package/dist/ccxt.browser.min.js +7 -7
- package/dist/cjs/ccxt.js +3 -1
- package/dist/cjs/src/ascendex.js +5 -5
- package/dist/cjs/src/base/Exchange.js +33 -25
- package/dist/cjs/src/base/errors.js +3 -3
- package/dist/cjs/src/base/functions/type.js +12 -0
- package/dist/cjs/src/bigone.js +2 -2
- package/dist/cjs/src/binance.js +897 -218
- package/dist/cjs/src/bingx.js +1 -1
- package/dist/cjs/src/bitfinex.js +1 -1
- package/dist/cjs/src/bitfinex2.js +457 -93
- package/dist/cjs/src/bitforex.js +3 -0
- package/dist/cjs/src/bitget.js +8 -4
- package/dist/cjs/src/bitmart.js +3 -3
- package/dist/cjs/src/bitmex.js +4 -4
- package/dist/cjs/src/bitrue.js +1 -1
- package/dist/cjs/src/bitso.js +1 -1
- package/dist/cjs/src/bitteam.js +2 -2
- package/dist/cjs/src/btcalpha.js +1 -1
- package/dist/cjs/src/bybit.js +3 -3
- package/dist/cjs/src/coinbase.js +22 -5
- package/dist/cjs/src/coincheck.js +1 -1
- package/dist/cjs/src/coinex.js +2 -2
- package/dist/cjs/src/coinlist.js +1 -1
- package/dist/cjs/src/coinmate.js +1 -1
- package/dist/cjs/src/coinmetro.js +2 -2
- package/dist/cjs/src/coinsph.js +1 -1
- package/dist/cjs/src/cryptocom.js +3 -3
- package/dist/cjs/src/deribit.js +1 -0
- package/dist/cjs/src/digifinex.js +6 -4
- package/dist/cjs/src/exmo.js +2 -2
- package/dist/cjs/src/gate.js +5 -5
- package/dist/cjs/src/gemini.js +3 -3
- package/dist/cjs/src/hitbtc.js +14 -20
- package/dist/cjs/src/hollaex.js +2 -2
- package/dist/cjs/src/htx.js +6 -6
- package/dist/cjs/src/huobijp.js +1 -1
- package/dist/cjs/src/kraken.js +3 -1
- package/dist/cjs/src/krakenfutures.js +4 -1
- package/dist/cjs/src/kucoin.js +17 -17
- package/dist/cjs/src/kucoinfutures.js +3 -3
- package/dist/cjs/src/lbank.js +28 -27
- package/dist/cjs/src/mexc.js +7 -7
- package/dist/cjs/src/novadax.js +1 -1
- package/dist/cjs/src/okcoin.js +2 -2
- package/dist/cjs/src/okx.js +23 -8
- package/dist/cjs/src/p2b.js +1 -0
- package/dist/cjs/src/phemex.js +3 -3
- package/dist/cjs/src/poloniexfutures.js +6 -3
- package/dist/cjs/src/pro/alpaca.js +1 -1
- package/dist/cjs/src/pro/binance.js +4 -4
- package/dist/cjs/src/pro/bitget.js +1 -1
- package/dist/cjs/src/pro/bitmart.js +1 -1
- package/dist/cjs/src/pro/bitmex.js +49 -6
- package/dist/cjs/src/pro/bitvavo.js +1 -1
- package/dist/cjs/src/pro/bybit.js +2 -2
- package/dist/cjs/src/pro/cex.js +2 -2
- package/dist/cjs/src/pro/independentreserve.js +1 -1
- package/dist/cjs/src/pro/okx.js +1 -1
- package/dist/cjs/src/pro/onetrading.js +2 -2
- package/dist/cjs/src/pro/p2b.js +432 -0
- package/dist/cjs/src/pro/probit.js +5 -5
- package/dist/cjs/src/pro/whitebit.js +1 -1
- package/dist/cjs/src/probit.js +1 -1
- package/dist/cjs/src/timex.js +2 -2
- package/dist/cjs/src/tokocrypto.js +3 -3
- package/dist/cjs/src/wavesexchange.js +2 -2
- package/dist/cjs/src/whitebit.js +3 -3
- package/dist/cjs/src/woo.js +3 -3
- package/dist/cjs/src/yobit.js +1 -1
- package/dist/cjs/src/zaif.js +1 -1
- package/dist/cjs/src/zonda.js +3 -3
- package/js/ccxt.d.ts +4 -1
- package/js/ccxt.js +3 -1
- package/js/src/abstract/bybit.d.ts +2 -2
- package/js/src/abstract/coinbase.d.ts +10 -0
- package/js/src/abstract/okx.d.ts +12 -1
- package/js/src/ascendex.js +5 -5
- package/js/src/base/Exchange.d.ts +2 -2
- package/js/src/base/Exchange.js +33 -25
- package/js/src/base/errorHierarchy.d.ts +7 -6
- package/js/src/base/errorHierarchy.js +7 -6
- package/js/src/base/errors.d.ts +3 -3
- package/js/src/base/errors.js +3 -3
- package/js/src/base/functions/type.js +12 -0
- package/js/src/bigone.js +2 -2
- package/js/src/binance.d.ts +1 -0
- package/js/src/binance.js +898 -219
- package/js/src/bingx.js +1 -1
- package/js/src/bitfinex.js +1 -1
- package/js/src/bitfinex2.d.ts +6 -1
- package/js/src/bitfinex2.js +457 -93
- package/js/src/bitforex.js +3 -0
- package/js/src/bitget.js +8 -4
- package/js/src/bitmart.js +3 -3
- package/js/src/bitmex.js +4 -4
- package/js/src/bitrue.js +1 -1
- package/js/src/bitso.d.ts +1 -1
- package/js/src/bitso.js +1 -1
- package/js/src/bitteam.js +2 -2
- package/js/src/btcalpha.js +1 -1
- package/js/src/bybit.js +3 -3
- package/js/src/coinbase.js +22 -5
- package/js/src/coincheck.js +1 -1
- package/js/src/coinex.js +2 -2
- package/js/src/coinlist.js +1 -1
- package/js/src/coinmate.js +1 -1
- package/js/src/coinmetro.d.ts +1 -1
- package/js/src/coinmetro.js +2 -2
- package/js/src/coinsph.js +1 -1
- package/js/src/cryptocom.js +3 -3
- package/js/src/deribit.js +1 -0
- package/js/src/digifinex.js +6 -4
- package/js/src/exmo.js +2 -2
- package/js/src/gate.js +5 -5
- package/js/src/gemini.d.ts +1 -1
- package/js/src/gemini.js +3 -3
- package/js/src/hitbtc.js +14 -20
- package/js/src/hollaex.js +2 -2
- package/js/src/htx.js +6 -6
- package/js/src/huobijp.js +1 -1
- package/js/src/kraken.js +3 -1
- package/js/src/krakenfutures.js +4 -1
- package/js/src/kucoin.js +17 -17
- package/js/src/kucoinfutures.js +3 -3
- package/js/src/lbank.d.ts +1 -1
- package/js/src/lbank.js +28 -27
- package/js/src/mexc.js +7 -7
- package/js/src/novadax.js +1 -1
- package/js/src/okcoin.js +2 -2
- package/js/src/okx.js +23 -8
- package/js/src/p2b.js +1 -0
- package/js/src/phemex.js +3 -3
- package/js/src/poloniexfutures.js +6 -3
- package/js/src/pro/alpaca.js +1 -1
- package/js/src/pro/binance.js +4 -4
- package/js/src/pro/bitget.js +1 -1
- package/js/src/pro/bitmart.js +1 -1
- package/js/src/pro/bitmex.d.ts +2 -1
- package/js/src/pro/bitmex.js +49 -6
- package/js/src/pro/bitvavo.js +1 -1
- package/js/src/pro/bybit.js +2 -2
- package/js/src/pro/cex.js +2 -2
- package/js/src/pro/independentreserve.js +1 -1
- package/js/src/pro/okx.js +1 -1
- package/js/src/pro/onetrading.js +2 -2
- package/js/src/pro/p2b.d.ts +23 -0
- package/js/src/pro/p2b.js +433 -0
- package/js/src/pro/probit.js +5 -5
- package/js/src/pro/whitebit.js +1 -1
- package/js/src/probit.js +1 -1
- package/js/src/timex.js +2 -2
- package/js/src/tokocrypto.js +3 -3
- package/js/src/wavesexchange.js +2 -2
- package/js/src/whitebit.js +3 -3
- package/js/src/woo.js +3 -3
- package/js/src/yobit.js +1 -1
- package/js/src/zaif.js +1 -1
- package/js/src/zonda.d.ts +1 -1
- package/js/src/zonda.js +3 -3
- package/package.json +1 -1
- package/skip-tests.json +3 -10
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var p2b$1 = require('../p2b.js');
|
|
4
|
+
var errors = require('../base/errors.js');
|
|
5
|
+
var Cache = require('../base/ws/Cache.js');
|
|
6
|
+
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
class p2b extends p2b$1 {
|
|
10
|
+
describe() {
|
|
11
|
+
return this.deepExtend(super.describe(), {
|
|
12
|
+
'has': {
|
|
13
|
+
'ws': true,
|
|
14
|
+
'cancelAllOrdersWs': false,
|
|
15
|
+
'cancelOrdersWs': false,
|
|
16
|
+
'cancelOrderWs': false,
|
|
17
|
+
'createOrderWs': false,
|
|
18
|
+
'editOrderWs': false,
|
|
19
|
+
'fetchBalanceWs': false,
|
|
20
|
+
'fetchOpenOrdersWs': false,
|
|
21
|
+
'fetchOrderWs': false,
|
|
22
|
+
'fetchTradesWs': false,
|
|
23
|
+
'watchBalance': false,
|
|
24
|
+
'watchMyTrades': false,
|
|
25
|
+
'watchOHLCV': true,
|
|
26
|
+
'watchOrderBook': true,
|
|
27
|
+
'watchOrders': false,
|
|
28
|
+
// 'watchStatus': true,
|
|
29
|
+
'watchTicker': true,
|
|
30
|
+
'watchTickers': false,
|
|
31
|
+
'watchTrades': true,
|
|
32
|
+
},
|
|
33
|
+
'urls': {
|
|
34
|
+
'api': {
|
|
35
|
+
'ws': 'wss://apiws.p2pb2b.com/',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
'options': {
|
|
39
|
+
'OHLCVLimit': 1000,
|
|
40
|
+
'tradesLimit': 1000,
|
|
41
|
+
'timeframes': {
|
|
42
|
+
'15m': 900,
|
|
43
|
+
'30m': 1800,
|
|
44
|
+
'1h': 3600,
|
|
45
|
+
'1d': 86400,
|
|
46
|
+
},
|
|
47
|
+
'watchTicker': {
|
|
48
|
+
'name': 'state', // or 'price'
|
|
49
|
+
},
|
|
50
|
+
'watchTickers': {
|
|
51
|
+
'name': 'state', // or 'price'
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
'streaming': {
|
|
55
|
+
'ping': this.ping,
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
async subscribe(name, messageHash, request, params = {}) {
|
|
60
|
+
/**
|
|
61
|
+
* @ignore
|
|
62
|
+
* @method
|
|
63
|
+
* @description Connects to a websocket channel
|
|
64
|
+
* @param {string} name name of the channel
|
|
65
|
+
* @param {string} messageHash string to look up in handler
|
|
66
|
+
* @param {string[]|float[]} request endpoint parameters
|
|
67
|
+
* @param {object} [params] extra parameters specific to the p2b api
|
|
68
|
+
* @returns {object} data from the websocket stream
|
|
69
|
+
*/
|
|
70
|
+
const url = this.urls['api']['ws'];
|
|
71
|
+
const subscribe = {
|
|
72
|
+
'method': name,
|
|
73
|
+
'params': request,
|
|
74
|
+
'id': this.milliseconds(),
|
|
75
|
+
};
|
|
76
|
+
const query = this.extend(subscribe, params);
|
|
77
|
+
return await this.watch(url, messageHash, query, messageHash);
|
|
78
|
+
}
|
|
79
|
+
async watchOHLCV(symbol, timeframe = '15m', since = undefined, limit = undefined, params = {}) {
|
|
80
|
+
/**
|
|
81
|
+
* @method
|
|
82
|
+
* @name p2b#watchOHLCV
|
|
83
|
+
* @description watches historical candlestick data containing the open, high, low, and close price, and the volume of a market. Can only subscribe to one timeframe at a time for each symbol
|
|
84
|
+
* @see https://github.com/P2B-team/P2B-WSS-Public/blob/main/wss_documentation.md#kline-candlestick
|
|
85
|
+
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
86
|
+
* @param {string} timeframe 15m, 30m, 1h or 1d
|
|
87
|
+
* @param {int} [since] timestamp in ms of the earliest candle to fetch
|
|
88
|
+
* @param {int} [limit] the maximum amount of candles to fetch
|
|
89
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
90
|
+
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
91
|
+
*/
|
|
92
|
+
await this.loadMarkets();
|
|
93
|
+
const timeframes = this.safeValue(this.options, 'timeframes', {});
|
|
94
|
+
const channel = this.safeInteger(timeframes, timeframe);
|
|
95
|
+
if (channel === undefined) {
|
|
96
|
+
throw new errors.BadRequest(this.id + ' watchOHLCV cannot take a timeframe of ' + timeframe);
|
|
97
|
+
}
|
|
98
|
+
const market = this.market(symbol);
|
|
99
|
+
const request = [
|
|
100
|
+
market['id'],
|
|
101
|
+
channel,
|
|
102
|
+
];
|
|
103
|
+
const messageHash = 'kline::' + market['symbol'];
|
|
104
|
+
const ohlcv = await this.subscribe('kline.subscribe', messageHash, request, params);
|
|
105
|
+
if (this.newUpdates) {
|
|
106
|
+
limit = ohlcv.getLimit(symbol, limit);
|
|
107
|
+
}
|
|
108
|
+
return this.filterBySinceLimit(ohlcv, since, limit, 0, true);
|
|
109
|
+
}
|
|
110
|
+
async watchTicker(symbol, params = {}) {
|
|
111
|
+
/**
|
|
112
|
+
* @method
|
|
113
|
+
* @name p2b#watchTicker
|
|
114
|
+
* @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
115
|
+
* @see https://github.com/P2B-team/P2B-WSS-Public/blob/main/wss_documentation.md#last-price
|
|
116
|
+
* @see https://github.com/P2B-team/P2B-WSS-Public/blob/main/wss_documentation.md#market-status
|
|
117
|
+
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
118
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
119
|
+
* @param {object} [params.method] 'state' (default) or 'price'
|
|
120
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
121
|
+
*/
|
|
122
|
+
await this.loadMarkets();
|
|
123
|
+
const watchTickerOptions = this.safeValue(this.options, 'watchTicker');
|
|
124
|
+
let name = this.safeString(watchTickerOptions, 'name', 'state'); // or price
|
|
125
|
+
[name, params] = this.handleOptionAndParams(params, 'method', 'name', name);
|
|
126
|
+
const market = this.market(symbol);
|
|
127
|
+
const request = [
|
|
128
|
+
market['id'],
|
|
129
|
+
];
|
|
130
|
+
const messageHash = name + '::' + market['symbol'];
|
|
131
|
+
return await this.subscribe(name + '.subscribe', messageHash, request, params);
|
|
132
|
+
}
|
|
133
|
+
async watchTrades(symbol, since = undefined, limit = undefined, params = {}) {
|
|
134
|
+
/**
|
|
135
|
+
* @method
|
|
136
|
+
* @name p2b#watchTrades
|
|
137
|
+
* @description get the list of most recent trades for a particular symbol
|
|
138
|
+
* @see https://github.com/P2B-team/P2B-WSS-Public/blob/main/wss_documentation.md#deals
|
|
139
|
+
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
140
|
+
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
141
|
+
* @param {int} [limit] the maximum amount of trades to fetch
|
|
142
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
143
|
+
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
144
|
+
*/
|
|
145
|
+
await this.loadMarkets();
|
|
146
|
+
const market = this.market(symbol);
|
|
147
|
+
const request = [
|
|
148
|
+
market['id'],
|
|
149
|
+
];
|
|
150
|
+
const messageHash = 'deals::' + market['symbol'];
|
|
151
|
+
const trades = await this.subscribe('deals.subscribe', messageHash, request, params);
|
|
152
|
+
if (this.newUpdates) {
|
|
153
|
+
limit = trades.getLimit(symbol, limit);
|
|
154
|
+
}
|
|
155
|
+
return this.filterBySinceLimit(trades, since, limit, 'timestamp', true);
|
|
156
|
+
}
|
|
157
|
+
async watchOrderBook(symbol, limit = undefined, params = {}) {
|
|
158
|
+
/**
|
|
159
|
+
* @method
|
|
160
|
+
* @name p2b#watchOrderBook
|
|
161
|
+
* @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
162
|
+
* @see https://github.com/P2B-team/P2B-WSS-Public/blob/main/wss_documentation.md#depth-of-market
|
|
163
|
+
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
164
|
+
* @param {int} [limit] 1-100, default=100
|
|
165
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
166
|
+
* @param {float} [params.interval] 0, 0.00000001, 0.0000001, 0.000001, 0.00001, 0.0001, 0.001, 0.01, 0.1, interval of precision for order, default=0.001
|
|
167
|
+
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
168
|
+
*/
|
|
169
|
+
await this.loadMarkets();
|
|
170
|
+
const market = this.market(symbol);
|
|
171
|
+
const name = 'depth.subscribe';
|
|
172
|
+
const messageHash = 'orderbook::' + market['symbol'];
|
|
173
|
+
const interval = this.safeString(params, 'interval', '0.001');
|
|
174
|
+
if (limit === undefined) {
|
|
175
|
+
limit = 100;
|
|
176
|
+
}
|
|
177
|
+
const request = [
|
|
178
|
+
market['id'],
|
|
179
|
+
limit,
|
|
180
|
+
interval,
|
|
181
|
+
];
|
|
182
|
+
const orderbook = await this.subscribe(name, messageHash, request, params);
|
|
183
|
+
return orderbook.limit();
|
|
184
|
+
}
|
|
185
|
+
handleOHLCV(client, message) {
|
|
186
|
+
//
|
|
187
|
+
// {
|
|
188
|
+
// "method": "kline.update",
|
|
189
|
+
// "params": [
|
|
190
|
+
// [
|
|
191
|
+
// 1657648800, // Kline start time
|
|
192
|
+
// "0.054146", // Kline open price
|
|
193
|
+
// "0.053938", // Kline close price (current price)
|
|
194
|
+
// "0.054146", // Kline high price
|
|
195
|
+
// "0.053911", // Kline low price
|
|
196
|
+
// "596.4674", // Volume for stock currency
|
|
197
|
+
// "32.2298758767", // Volume for money currency
|
|
198
|
+
// "ETH_BTC" // Market
|
|
199
|
+
// ]
|
|
200
|
+
// ],
|
|
201
|
+
// "id": null
|
|
202
|
+
// }
|
|
203
|
+
//
|
|
204
|
+
let data = this.safeList(message, 'params');
|
|
205
|
+
data = this.safeList(data, 0);
|
|
206
|
+
const method = this.safeString(message, 'method');
|
|
207
|
+
const splitMethod = method.split('.');
|
|
208
|
+
const channel = this.safeString(splitMethod, 0);
|
|
209
|
+
const marketId = this.safeString(data, 7);
|
|
210
|
+
const market = this.safeMarket(marketId);
|
|
211
|
+
const timeframes = this.safeDict(this.options, 'timeframes', {});
|
|
212
|
+
const timeframe = this.findTimeframe(channel, timeframes);
|
|
213
|
+
const symbol = this.safeString(market, 'symbol');
|
|
214
|
+
const messageHash = channel + '::' + symbol;
|
|
215
|
+
const parsed = this.parseOHLCV(data, market);
|
|
216
|
+
this.ohlcvs[symbol] = this.safeValue(this.ohlcvs, symbol, {});
|
|
217
|
+
let stored = this.safeValue(this.ohlcvs[symbol], timeframe);
|
|
218
|
+
if (symbol !== undefined) {
|
|
219
|
+
if (stored === undefined) {
|
|
220
|
+
const limit = this.safeInteger(this.options, 'OHLCVLimit', 1000);
|
|
221
|
+
stored = new Cache.ArrayCacheByTimestamp(limit);
|
|
222
|
+
this.ohlcvs[symbol][timeframe] = stored;
|
|
223
|
+
}
|
|
224
|
+
stored.append(parsed);
|
|
225
|
+
client.resolve(stored, messageHash);
|
|
226
|
+
}
|
|
227
|
+
return message;
|
|
228
|
+
}
|
|
229
|
+
handleTrade(client, message) {
|
|
230
|
+
//
|
|
231
|
+
// {
|
|
232
|
+
// "method": "deals.update",
|
|
233
|
+
// "params": [
|
|
234
|
+
// "ETH_BTC",
|
|
235
|
+
// [
|
|
236
|
+
// {
|
|
237
|
+
// "id": 4503032979, // Order_id
|
|
238
|
+
// "amount": "0.103",
|
|
239
|
+
// "type": "sell", // Side
|
|
240
|
+
// "time": 1657661950.8487639, // Creation time
|
|
241
|
+
// "price": "0.05361"
|
|
242
|
+
// },
|
|
243
|
+
// ...
|
|
244
|
+
// ]
|
|
245
|
+
// ],
|
|
246
|
+
// "id": null
|
|
247
|
+
// }
|
|
248
|
+
//
|
|
249
|
+
const data = this.safeList(message, 'params', []);
|
|
250
|
+
const trades = this.safeList(data, 1);
|
|
251
|
+
const marketId = this.safeString(data, 0);
|
|
252
|
+
const market = this.safeMarket(marketId);
|
|
253
|
+
const symbol = this.safeString(market, 'symbol');
|
|
254
|
+
let tradesArray = this.safeValue(this.trades, symbol);
|
|
255
|
+
if (tradesArray === undefined) {
|
|
256
|
+
const tradesLimit = this.safeInteger(this.options, 'tradesLimit', 1000);
|
|
257
|
+
tradesArray = new Cache.ArrayCache(tradesLimit);
|
|
258
|
+
this.trades[symbol] = tradesArray;
|
|
259
|
+
}
|
|
260
|
+
for (let i = 0; i < trades.length; i++) {
|
|
261
|
+
const item = trades[i];
|
|
262
|
+
const trade = this.parseTrade(item, market);
|
|
263
|
+
tradesArray.append(trade);
|
|
264
|
+
}
|
|
265
|
+
const messageHash = 'deals::' + symbol;
|
|
266
|
+
client.resolve(tradesArray, messageHash);
|
|
267
|
+
return message;
|
|
268
|
+
}
|
|
269
|
+
handleTicker(client, message) {
|
|
270
|
+
//
|
|
271
|
+
// state
|
|
272
|
+
//
|
|
273
|
+
// {
|
|
274
|
+
// "method": "state.update",
|
|
275
|
+
// "params": [
|
|
276
|
+
// "ETH_BTC",
|
|
277
|
+
// {
|
|
278
|
+
// "high": "0.055774", // High price for the last 24h
|
|
279
|
+
// "close": "0.053679", // Close price for the last 24h
|
|
280
|
+
// "low": "0.053462", // Low price for the last 24h
|
|
281
|
+
// "period": 86400, // Period 24h
|
|
282
|
+
// "last": "0.053679", // Last price for the last 24h
|
|
283
|
+
// "volume": "38463.6132", // Stock volume for the last 24h
|
|
284
|
+
// "open": "0.055682", // Open price for the last 24h
|
|
285
|
+
// "deal": "2091.0038055314" // Money volume for the last 24h
|
|
286
|
+
// }
|
|
287
|
+
// ],
|
|
288
|
+
// "id": null
|
|
289
|
+
// }
|
|
290
|
+
//
|
|
291
|
+
// price
|
|
292
|
+
//
|
|
293
|
+
// {
|
|
294
|
+
// "method": "price.update",
|
|
295
|
+
// "params": [
|
|
296
|
+
// "ETH_BTC", // market
|
|
297
|
+
// "0.053836" // last price
|
|
298
|
+
// ],
|
|
299
|
+
// "id": null
|
|
300
|
+
// }
|
|
301
|
+
//
|
|
302
|
+
const data = this.safeList(message, 'params', []);
|
|
303
|
+
const marketId = this.safeString(data, 0);
|
|
304
|
+
const market = this.safeMarket(marketId);
|
|
305
|
+
const method = this.safeString(message, 'method');
|
|
306
|
+
const splitMethod = method.split('.');
|
|
307
|
+
const messageHashStart = this.safeString(splitMethod, 0);
|
|
308
|
+
const tickerData = this.safeDict(data, 1);
|
|
309
|
+
let ticker = undefined;
|
|
310
|
+
if (method === 'price.update') {
|
|
311
|
+
const lastPrice = this.safeString(data, 1);
|
|
312
|
+
ticker = this.safeTicker({
|
|
313
|
+
'last': lastPrice,
|
|
314
|
+
'close': lastPrice,
|
|
315
|
+
'symbol': market['symbol'],
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
ticker = this.parseTicker(tickerData, market);
|
|
320
|
+
}
|
|
321
|
+
const symbol = ticker['symbol'];
|
|
322
|
+
const messageHash = messageHashStart + '::' + symbol;
|
|
323
|
+
client.resolve(ticker, messageHash);
|
|
324
|
+
return message;
|
|
325
|
+
}
|
|
326
|
+
handleOrderBook(client, message) {
|
|
327
|
+
//
|
|
328
|
+
// {
|
|
329
|
+
// "method": "depth.update",
|
|
330
|
+
// "params": [
|
|
331
|
+
// false, // true - all records, false - new records
|
|
332
|
+
// {
|
|
333
|
+
// "asks": [ // side
|
|
334
|
+
// [
|
|
335
|
+
// "19509.81", // price
|
|
336
|
+
// "0.277" // amount
|
|
337
|
+
// ]
|
|
338
|
+
// ]
|
|
339
|
+
// },
|
|
340
|
+
// "BTC_USDT"
|
|
341
|
+
// ],
|
|
342
|
+
// "id": null
|
|
343
|
+
// }
|
|
344
|
+
//
|
|
345
|
+
const params = this.safeList(message, 'params', []);
|
|
346
|
+
const data = this.safeDict(params, 1);
|
|
347
|
+
const asks = this.safeList(data, 'asks');
|
|
348
|
+
const bids = this.safeList(data, 'bids');
|
|
349
|
+
const marketId = this.safeString(params, 2);
|
|
350
|
+
const market = this.safeMarket(marketId);
|
|
351
|
+
const symbol = market['symbol'];
|
|
352
|
+
const messageHash = 'orderbook::' + market['symbol'];
|
|
353
|
+
const subscription = this.safeValue(client.subscriptions, messageHash, {});
|
|
354
|
+
const limit = this.safeInteger(subscription, 'limit');
|
|
355
|
+
let orderbook = this.safeValue(this.orderbooks, symbol);
|
|
356
|
+
if (orderbook === undefined) {
|
|
357
|
+
this.orderbooks[symbol] = this.orderBook({}, limit);
|
|
358
|
+
orderbook = this.orderbooks[symbol];
|
|
359
|
+
}
|
|
360
|
+
if (bids !== undefined) {
|
|
361
|
+
for (let i = 0; i < bids.length; i++) {
|
|
362
|
+
const bid = this.safeValue(bids, i);
|
|
363
|
+
const price = this.safeNumber(bid, 0);
|
|
364
|
+
const amount = this.safeNumber(bid, 1);
|
|
365
|
+
orderbook['bids'].store(price, amount);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
if (asks !== undefined) {
|
|
369
|
+
for (let i = 0; i < asks.length; i++) {
|
|
370
|
+
const ask = this.safeValue(asks, i);
|
|
371
|
+
const price = this.safeNumber(ask, 0);
|
|
372
|
+
const amount = this.safeNumber(ask, 1);
|
|
373
|
+
orderbook['asks'].store(price, amount);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
orderbook['symbol'] = symbol;
|
|
377
|
+
client.resolve(orderbook, messageHash);
|
|
378
|
+
}
|
|
379
|
+
handleMessage(client, message) {
|
|
380
|
+
if (this.handleErrorMessage(client, message)) {
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
const result = this.safeString(message, 'result');
|
|
384
|
+
if (result === 'pong') {
|
|
385
|
+
this.handlePong(client, message);
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
const method = this.safeString(message, 'method');
|
|
389
|
+
const methods = {
|
|
390
|
+
'depth.update': this.handleOrderBook,
|
|
391
|
+
'price.update': this.handleTicker,
|
|
392
|
+
'kline.update': this.handleOHLCV,
|
|
393
|
+
'state.update': this.handleTicker,
|
|
394
|
+
'deals.update': this.handleTrade,
|
|
395
|
+
};
|
|
396
|
+
const endpoint = this.safeValue(methods, method);
|
|
397
|
+
if (endpoint !== undefined) {
|
|
398
|
+
return endpoint.call(this, client, message);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
handleErrorMessage(client, message) {
|
|
402
|
+
const error = this.safeString(message, 'error');
|
|
403
|
+
if (error !== undefined) {
|
|
404
|
+
throw new errors.ExchangeError(this.id + ' error: ' + this.json(error));
|
|
405
|
+
}
|
|
406
|
+
return false;
|
|
407
|
+
}
|
|
408
|
+
ping(client) {
|
|
409
|
+
/**
|
|
410
|
+
* @see https://github.com/P2B-team/P2B-WSS-Public/blob/main/wss_documentation.md#ping
|
|
411
|
+
* @param client
|
|
412
|
+
*/
|
|
413
|
+
return {
|
|
414
|
+
'method': 'server.ping',
|
|
415
|
+
'params': [],
|
|
416
|
+
'id': this.milliseconds(),
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
handlePong(client, message) {
|
|
420
|
+
//
|
|
421
|
+
// {
|
|
422
|
+
// error: null,
|
|
423
|
+
// result: 'pong',
|
|
424
|
+
// id: 1706539608030
|
|
425
|
+
// }
|
|
426
|
+
//
|
|
427
|
+
client.lastPong = this.safeInteger(message, 'id');
|
|
428
|
+
return message;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
module.exports = p2b;
|
|
@@ -95,7 +95,7 @@ class probit extends probit$1 {
|
|
|
95
95
|
// }
|
|
96
96
|
// }
|
|
97
97
|
//
|
|
98
|
-
const reset = this.
|
|
98
|
+
const reset = this.safeBool(message, 'reset', false);
|
|
99
99
|
const data = this.safeValue(message, 'data', {});
|
|
100
100
|
const currencyIds = Object.keys(data);
|
|
101
101
|
if (reset) {
|
|
@@ -201,7 +201,7 @@ class probit extends probit$1 {
|
|
|
201
201
|
const symbol = this.safeSymbol(marketId);
|
|
202
202
|
const market = this.safeMarket(marketId);
|
|
203
203
|
const trades = this.safeValue(message, 'recent_trades', []);
|
|
204
|
-
const reset = this.
|
|
204
|
+
const reset = this.safeBool(message, 'reset', false);
|
|
205
205
|
const messageHash = 'trades:' + symbol;
|
|
206
206
|
let stored = this.safeValue(this.trades, symbol);
|
|
207
207
|
if (stored === undefined || reset) {
|
|
@@ -274,7 +274,7 @@ class probit extends probit$1 {
|
|
|
274
274
|
if (length === 0) {
|
|
275
275
|
return;
|
|
276
276
|
}
|
|
277
|
-
const reset = this.
|
|
277
|
+
const reset = this.safeBool(message, 'reset', false);
|
|
278
278
|
const messageHash = 'myTrades';
|
|
279
279
|
let stored = this.myTrades;
|
|
280
280
|
if ((stored === undefined) || reset) {
|
|
@@ -362,7 +362,7 @@ class probit extends probit$1 {
|
|
|
362
362
|
return;
|
|
363
363
|
}
|
|
364
364
|
const messageHash = 'orders';
|
|
365
|
-
const reset = this.
|
|
365
|
+
const reset = this.safeBool(message, 'reset', false);
|
|
366
366
|
let stored = this.orders;
|
|
367
367
|
if (stored === undefined || reset) {
|
|
368
368
|
const limit = this.safeInteger(this.options, 'ordersLimit', 1000);
|
|
@@ -454,7 +454,7 @@ class probit extends probit$1 {
|
|
|
454
454
|
storedOrderBook = this.orderBook({});
|
|
455
455
|
this.orderbooks[symbol] = storedOrderBook;
|
|
456
456
|
}
|
|
457
|
-
const reset = this.
|
|
457
|
+
const reset = this.safeBool(message, 'reset', false);
|
|
458
458
|
if (reset) {
|
|
459
459
|
const snapshot = this.parseOrderBook(dataBySide, symbol, undefined, 'buy', 'sell', 'price', 'quantity');
|
|
460
460
|
storedOrderBook.reset(snapshot);
|
|
@@ -738,7 +738,7 @@ class whitebit extends whitebit$1 {
|
|
|
738
738
|
let hasSymbolSubscription = true;
|
|
739
739
|
const market = this.market(symbol);
|
|
740
740
|
const marketId = market['id'];
|
|
741
|
-
const isSubscribed = this.
|
|
741
|
+
const isSubscribed = this.safeBool(subscription, marketId, false);
|
|
742
742
|
if (!isSubscribed) {
|
|
743
743
|
subscription[marketId] = true;
|
|
744
744
|
hasSymbolSubscription = false;
|
package/dist/cjs/src/probit.js
CHANGED
|
@@ -284,7 +284,7 @@ class probit extends probit$1 {
|
|
|
284
284
|
const quoteId = this.safeString(market, 'quote_currency_id');
|
|
285
285
|
const base = this.safeCurrencyCode(baseId);
|
|
286
286
|
const quote = this.safeCurrencyCode(quoteId);
|
|
287
|
-
const closed = this.
|
|
287
|
+
const closed = this.safeBool(market, 'closed', false);
|
|
288
288
|
const takerFeeRate = this.safeString(market, 'taker_fee_rate');
|
|
289
289
|
const taker = Precise["default"].stringDiv(takerFeeRate, '100');
|
|
290
290
|
const makerFeeRate = this.safeString(market, 'maker_fee_rate');
|
package/dist/cjs/src/timex.js
CHANGED
|
@@ -95,7 +95,7 @@ class timex extends timex$1 {
|
|
|
95
95
|
'rest': 'https://plasma-relay-backend.timex.io',
|
|
96
96
|
},
|
|
97
97
|
'www': 'https://timex.io',
|
|
98
|
-
'doc': 'https://
|
|
98
|
+
'doc': 'https://plasma-relay-backend.timex.io/swagger-ui/index.html',
|
|
99
99
|
'referral': 'https://timex.io/?refcode=1x27vNkTbP1uwkCck',
|
|
100
100
|
},
|
|
101
101
|
'api': {
|
|
@@ -721,7 +721,7 @@ class timex extends timex$1 {
|
|
|
721
721
|
const market = this.market(symbol);
|
|
722
722
|
const uppercaseSide = side.toUpperCase();
|
|
723
723
|
let uppercaseType = type.toUpperCase();
|
|
724
|
-
const postOnly = this.
|
|
724
|
+
const postOnly = this.safeBool(params, 'postOnly', false);
|
|
725
725
|
if (postOnly) {
|
|
726
726
|
uppercaseType = 'POST_ONLY';
|
|
727
727
|
params = this.omit(params, ['postOnly']);
|
|
@@ -689,7 +689,7 @@ class tokocrypto extends tokocrypto$1 {
|
|
|
689
689
|
break;
|
|
690
690
|
}
|
|
691
691
|
}
|
|
692
|
-
const isMarginTradingAllowed = this.
|
|
692
|
+
const isMarginTradingAllowed = this.safeBool(market, 'isMarginTradingAllowed', false);
|
|
693
693
|
const entry = {
|
|
694
694
|
'id': id,
|
|
695
695
|
'lowercaseId': lowercaseId,
|
|
@@ -1588,7 +1588,7 @@ class tokocrypto extends tokocrypto$1 {
|
|
|
1588
1588
|
await this.loadMarkets();
|
|
1589
1589
|
const market = this.market(symbol);
|
|
1590
1590
|
const clientOrderId = this.safeString2(params, 'clientOrderId', 'clientId');
|
|
1591
|
-
const postOnly = this.
|
|
1591
|
+
const postOnly = this.safeBool(params, 'postOnly', false);
|
|
1592
1592
|
// only supported for spot/margin api
|
|
1593
1593
|
if (postOnly) {
|
|
1594
1594
|
type = 'LIMIT_MAKER';
|
|
@@ -2462,7 +2462,7 @@ class tokocrypto extends tokocrypto$1 {
|
|
|
2462
2462
|
}
|
|
2463
2463
|
// check success value for wapi endpoints
|
|
2464
2464
|
// response in format {'msg': 'The coin does not exist.', 'success': true/false}
|
|
2465
|
-
const success = this.
|
|
2465
|
+
const success = this.safeBool(response, 'success', true);
|
|
2466
2466
|
if (!success) {
|
|
2467
2467
|
const messageInner = this.safeString(response, 'msg');
|
|
2468
2468
|
let parsedMessage = undefined;
|
|
@@ -395,7 +395,7 @@ class wavesexchange extends wavesexchange$1 {
|
|
|
395
395
|
// "matcherFee":"4077612"
|
|
396
396
|
// }
|
|
397
397
|
// }
|
|
398
|
-
const isDiscountFee = this.
|
|
398
|
+
const isDiscountFee = this.safeBool(params, 'isDiscountFee', false);
|
|
399
399
|
let mode = undefined;
|
|
400
400
|
if (isDiscountFee) {
|
|
401
401
|
mode = this.safeValue(response, 'discount');
|
|
@@ -2412,7 +2412,7 @@ class wavesexchange extends wavesexchange$1 {
|
|
|
2412
2412
|
}
|
|
2413
2413
|
handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
|
2414
2414
|
const errorCode = this.safeString(response, 'error');
|
|
2415
|
-
const success = this.
|
|
2415
|
+
const success = this.safeBool(response, 'success', true);
|
|
2416
2416
|
const Exception = this.safeValue(this.exceptions, errorCode);
|
|
2417
2417
|
if (Exception !== undefined) {
|
|
2418
2418
|
const messageInner = this.safeString(response, 'message');
|
package/dist/cjs/src/whitebit.js
CHANGED
|
@@ -19,7 +19,7 @@ class whitebit extends whitebit$1 {
|
|
|
19
19
|
'name': 'WhiteBit',
|
|
20
20
|
'version': 'v4',
|
|
21
21
|
'countries': ['EE'],
|
|
22
|
-
'rateLimit':
|
|
22
|
+
'rateLimit': 50,
|
|
23
23
|
'pro': true,
|
|
24
24
|
'has': {
|
|
25
25
|
'CORS': undefined,
|
|
@@ -422,8 +422,8 @@ class whitebit extends whitebit$1 {
|
|
|
422
422
|
const currency = response[id];
|
|
423
423
|
// breaks down in Python due to utf8 encoding issues on the exchange side
|
|
424
424
|
// const name = this.safeString (currency, 'name');
|
|
425
|
-
const canDeposit = this.
|
|
426
|
-
const canWithdraw = this.
|
|
425
|
+
const canDeposit = this.safeBool(currency, 'can_deposit', true);
|
|
426
|
+
const canWithdraw = this.safeBool(currency, 'can_withdraw', true);
|
|
427
427
|
const active = canDeposit && canWithdraw;
|
|
428
428
|
const code = this.safeCurrencyCode(id);
|
|
429
429
|
result[code] = {
|
package/dist/cjs/src/woo.js
CHANGED
|
@@ -1133,7 +1133,7 @@ class woo extends woo$1 {
|
|
|
1133
1133
|
* @param {boolean} [params.stop] whether the order is a stop/algo order
|
|
1134
1134
|
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1135
1135
|
*/
|
|
1136
|
-
const stop = this.
|
|
1136
|
+
const stop = this.safeBool(params, 'stop', false);
|
|
1137
1137
|
params = this.omit(params, 'stop');
|
|
1138
1138
|
if (!stop && (symbol === undefined)) {
|
|
1139
1139
|
throw new errors.ArgumentsRequired(this.id + ' cancelOrder() requires a symbol argument');
|
|
@@ -1301,7 +1301,7 @@ class woo extends woo$1 {
|
|
|
1301
1301
|
const request = {};
|
|
1302
1302
|
let market = undefined;
|
|
1303
1303
|
const stop = this.safeValue(params, 'stop');
|
|
1304
|
-
const trailing = this.
|
|
1304
|
+
const trailing = this.safeBool(params, 'trailing', false);
|
|
1305
1305
|
params = this.omit(params, ['stop', 'trailing']);
|
|
1306
1306
|
if (symbol !== undefined) {
|
|
1307
1307
|
market = this.market(symbol);
|
|
@@ -2083,7 +2083,7 @@ class woo extends woo$1 {
|
|
|
2083
2083
|
//
|
|
2084
2084
|
const transfer = this.parseTransfer(response, currency);
|
|
2085
2085
|
const transferOptions = this.safeValue(this.options, 'transfer', {});
|
|
2086
|
-
const fillResponseFromRequest = this.
|
|
2086
|
+
const fillResponseFromRequest = this.safeBool(transferOptions, 'fillResponseFromRequest', true);
|
|
2087
2087
|
if (fillResponseFromRequest) {
|
|
2088
2088
|
transfer['amount'] = amount;
|
|
2089
2089
|
transfer['fromAccount'] = fromAccount;
|
package/dist/cjs/src/yobit.js
CHANGED
|
@@ -1288,7 +1288,7 @@ class yobit extends yobit$1 {
|
|
|
1288
1288
|
//
|
|
1289
1289
|
// To cover points 1, 2, 3 and 4 combined this handler should work like this:
|
|
1290
1290
|
//
|
|
1291
|
-
let success = this.
|
|
1291
|
+
let success = this.safeBool(response, 'success', false);
|
|
1292
1292
|
if (typeof success === 'string') {
|
|
1293
1293
|
if ((success === 'true') || (success === '1')) {
|
|
1294
1294
|
success = true;
|
package/dist/cjs/src/zaif.js
CHANGED
|
@@ -725,7 +725,7 @@ class zaif extends zaif$1 {
|
|
|
725
725
|
this.throwBroadlyMatchedException(this.exceptions['broad'], error, feedback);
|
|
726
726
|
throw new errors.ExchangeError(feedback); // unknown message
|
|
727
727
|
}
|
|
728
|
-
const success = this.
|
|
728
|
+
const success = this.safeBool(response, 'success', true);
|
|
729
729
|
if (!success) {
|
|
730
730
|
throw new errors.ExchangeError(feedback);
|
|
731
731
|
}
|
package/dist/cjs/src/zonda.js
CHANGED
|
@@ -1436,7 +1436,7 @@ class zonda extends zonda$1 {
|
|
|
1436
1436
|
// }
|
|
1437
1437
|
//
|
|
1438
1438
|
const id = this.safeString2(response, 'offerId', 'stopOfferId');
|
|
1439
|
-
const completed = this.
|
|
1439
|
+
const completed = this.safeBool(response, 'completed', false);
|
|
1440
1440
|
const status = completed ? 'closed' : 'open';
|
|
1441
1441
|
const transactions = this.safeValue(response, 'transactions');
|
|
1442
1442
|
return this.safeOrder({
|
|
@@ -1498,7 +1498,7 @@ class zonda extends zonda$1 {
|
|
|
1498
1498
|
'EUR': true,
|
|
1499
1499
|
'PLN': true,
|
|
1500
1500
|
};
|
|
1501
|
-
return this.
|
|
1501
|
+
return this.safeBool(fiatCurrencies, currency, false);
|
|
1502
1502
|
}
|
|
1503
1503
|
parseDepositAddress(depositAddress, currency = undefined) {
|
|
1504
1504
|
//
|
|
@@ -1635,7 +1635,7 @@ class zonda extends zonda$1 {
|
|
|
1635
1635
|
//
|
|
1636
1636
|
const transfer = this.parseTransfer(response, currency);
|
|
1637
1637
|
const transferOptions = this.safeValue(this.options, 'transfer', {});
|
|
1638
|
-
const fillResponseFromRequest = this.
|
|
1638
|
+
const fillResponseFromRequest = this.safeBool(transferOptions, 'fillResponseFromRequest', true);
|
|
1639
1639
|
if (fillResponseFromRequest) {
|
|
1640
1640
|
transfer['amount'] = amount;
|
|
1641
1641
|
}
|