-
Notifications
You must be signed in to change notification settings - Fork 0
/
ccxt.d.ts
656 lines (625 loc) · 23 KB
/
ccxt.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
declare module 'ccxt' {
/**
* Represents an associative array of a same type.
*/
interface Dictionary<T> {
[key: string]: T;
}
// errors.js -----------------------------------------
export class BaseError extends Error {
constructor(message: string);
}
export class ExchangeError extends BaseError {}
export class AuthenticationError extends ExchangeError {}
export class PermissionDenied extends AuthenticationError {}
export class AccountSuspended extends AuthenticationError {}
export class ArgumentsRequired extends ExchangeError {}
export class BadRequest extends ExchangeError {}
export class BadSymbol extends BadRequest {}
export class BadResponse extends ExchangeError {}
export class NullResponse extends BadResponse {}
export class InsufficientFunds extends ExchangeError {}
export class InvalidAddress extends ExchangeError {}
export class AddressPending extends InvalidAddress {}
export class InvalidOrder extends ExchangeError {}
export class OrderNotFound extends InvalidOrder {}
export class OrderNotCached extends InvalidOrder {}
export class CancelPending extends InvalidOrder {}
export class OrderImmediatelyFillable extends InvalidOrder {}
export class OrderNotFillable extends InvalidOrder {}
export class DuplicateOrderId extends InvalidOrder {}
export class NotSupported extends ExchangeError {}
export class NetworkError extends BaseError {}
export class DDoSProtection extends NetworkError {}
export class RateLimitExceeded extends DDoSProtection {}
export class ExchangeNotAvailable extends NetworkError {}
export class OnMaintenance extends ExchangeNotAvailable {}
export class InvalidNonce extends NetworkError {}
export class RequestTimeout extends NetworkError {}
// -----------------------------------------------
export const version: string;
export const exchanges: string[];
export interface MinMax {
min: number;
max: number | undefined;
}
export interface Market {
id: string;
symbol: string;
base: string;
quote: string;
baseId: string;
quoteId: string;
type?: string;
spot?: boolean;
margin?: boolean;
swap?: boolean;
future?: boolean;
active: boolean;
precision: { base: number, quote: number, amount: number, price: number };
limits: { amount: MinMax, price: MinMax, cost?: MinMax };
tierBased: boolean;
percentage: boolean;
taker: number;
maker: number;
info: any;
}
export interface Order {
id: string;
clientOrderId: string;
datetime: string;
timestamp: number;
lastTradeTimestamp: number;
status: 'open' | 'closed' | 'canceled';
symbol: string;
type: string;
timeInForce?: string;
side: 'buy' | 'sell';
price: number;
average?: number;
amount: number;
filled: number;
remaining: number;
cost: number;
trades: Trade[];
fee: Fee;
info: any;
}
export interface OrderBook {
asks: [number, number][];
bids: [number, number][];
datetime: string;
timestamp: number;
nonce: number;
}
export interface Trade {
amount: number; // amount of base currency
datetime: string; // ISO8601 datetime with milliseconds;
id: string; // string trade id
info: any; // the original decoded JSON as is
order?: string; // string order id or undefined/None/null
price: number; // float price in quote currency
timestamp: number; // Unix timestamp in milliseconds
type?: string; // order type, 'market', 'limit', ... or undefined/None/null
side: 'buy' | 'sell'; // direction of the trade, 'buy' or 'sell'
symbol: string; // symbol in CCXT format
takerOrMaker: 'taker' | 'maker'; // string, 'taker' or 'maker'
cost: number; // total cost (including fees), `price * amount`
fee: Fee;
}
export interface Ticker {
symbol: string;
info: any;
timestamp: number;
datetime: string;
high: number;
low: number;
bid: number;
bidVolume?: number;
ask: number;
askVolume?: number;
vwap?: number;
open?: number;
close?: number;
last?: number;
previousClose?: number;
change?: number;
percentage?: number;
average?: number;
quoteVolume?: number;
baseVolume?: number;
}
export interface Transaction {
info: any;
id: string;
txid?: string;
timestamp: number;
datetime: string;
address: string;
type: "deposit" | "withdrawal";
amount: number;
currency: string;
status: "pending" | "ok";
updated: number;
fee: Fee;
}
export interface Tickers extends Dictionary<Ticker> {
info: any;
}
export interface Currency {
id: string;
code: string;
numericId?: number;
precision: number;
}
export interface Balance {
free: number;
used: number;
total: number;
}
export interface PartialBalances extends Dictionary<number> {
}
export interface Balances extends Dictionary<Balance> {
info: any;
}
export interface DepositAddress {
currency: string;
address: string;
status: string;
info: any;
}
export interface Fee {
type: 'taker' | 'maker';
currency: string;
rate: number;
cost: number;
}
export interface WithdrawalResponse {
info: any;
id: string;
}
export interface DepositAddressResponse {
currency: string;
address: string;
info: any;
tag?: string;
}
/** [ timestamp, open, high, low, close, volume ] */
export type OHLCV = [number, number, number, number, number, number];
/** Request parameters */
type Params = Dictionary<string | number | boolean>;
export class Exchange {
constructor(config?: {[key in keyof Exchange]?: Exchange[key]});
// allow dynamic keys
[key: string]: any;
// properties
version: string;
apiKey: string;
secret: string;
password: string;
uid: string;
requiredCredentials: {
apiKey: boolean;
secret: boolean;
uid: boolean;
login: boolean;
password: boolean;
twofa: boolean;
privateKey: boolean;
walletAddress: boolean;
token: boolean;
};
options: {
[key: string]: any;
};
urls: {
logo: string;
api: string | Dictionary<string>;
test: string | Dictionary<string>;
www: string;
doc: string[];
api_management?: string;
fees: string;
referral: string;
};
precisionMode: number;
hash: any;
hmac: any;
jwt: any;
binaryConcat: any;
stringToBinary: any;
stringToBase64: any;
base64ToBinary: any;
base64ToString: any;
binaryToString: any;
utf16ToBase64: any;
urlencode: any;
pluck: any;
unique: any;
extend: any;
deepExtend: any;
flatten: any;
groupBy: any;
indexBy: any;
sortBy: any;
keysort: any;
decimal: any;
safeFloat: any;
safeString: any;
safeInteger: any;
safeValue: any;
capitalize: any;
json: JSON["stringify"]
sum: any;
ordered: any;
aggregate: any;
truncate: any;
name: string;
// nodeVersion: string;
fees: object;
enableRateLimit: boolean;
countries: string[];
// set by loadMarkets
markets: Dictionary<Market>;
marketsById: Dictionary<Market>;
currencies: Dictionary<Currency>;
ids: string[];
symbols: string[];
id: ExchangeId;
proxy: string;
parse8601: typeof Date.parse
milliseconds: typeof Date.now;
rateLimit: number; // milliseconds = seconds * 1000
timeout: number; // milliseconds
verbose: boolean;
twofa: boolean;// two-factor authentication
substituteCommonCurrencyCodes: boolean;
timeframes: Dictionary<number | string>;
has: Dictionary<boolean | 'emulated'>; // https://github.com/ccxt/ccxt/pull/1984
balance: object;
orderbooks: object;
orders: object;
trades: object;
userAgent: { 'User-Agent': string } | false;
limits: { amount: MinMax, price: MinMax, cost: MinMax };
hasCancelAllOrders: boolean;
hasCancelOrder: boolean;
hasCancelOrders: boolean;
hasCORS: boolean;
hasCreateDepositAddress: boolean;
hasCreateLimitOrder: boolean;
hasCreateMarketOrder: boolean;
hasCreateOrder: boolean;
hasDeposit: boolean;
hasEditOrder: boolean;
hasFetchBalance: boolean;
hasFetchBidsAsks: boolean;
hasFetchClosedOrders: boolean;
hasFetchCurrencies: boolean;
hasFetchDepositAddress: boolean;
hasFetchDeposits: boolean;
hasFetchFundingFees: boolean;
hasFetchL2OrderBook: boolean;
hasFetchLedger: boolean;
hasFetchMarkets: boolean;
hasFetchMyTrades: boolean;
hasFetchOHLCV: boolean;
hasFetchOpenOrders: boolean;
hasFetchOrder: boolean;
hasFetchOrderBook: boolean;
hasFetchOrderBooks: boolean;
hasFetchOrders: boolean;
hasFetchStatus: boolean;
hasFetchTicker: boolean;
hasFetchTickers: boolean;
hasFetchTime: boolean;
hasFetchTrades: boolean;
hasFetchTradingFee: boolean;
hasFetchTradingFees: boolean;
hasFetchTradingLimits: boolean;
hasFetchTransactions: boolean;
hasFetchWithdrawals: boolean;
hasPrivateAPI: boolean;
hasPublicAPI: boolean;
hasWithdraw: boolean;
// methods
account (): Balance;
cancelAllOrders (...args: any): Promise<any>; // TODO: add function signatures
cancelOrder (id: string, symbol?: string, params?: Params): Promise<Order>;
cancelOrders (...args: any): Promise<any>; // TODO: add function signatures
checkRequiredCredentials (): void;
commonCurrencyCode (currency: string): string;
createDepositAddress (currency: string, params?: Params): Promise<DepositAddressResponse>;
createLimitOrder (symbol: string, side: Order['side'], amount: number, price: number, params?: Params): Promise<Order>;
createLimitBuyOrder (symbol: string, amount: number, price: number, params?: Params): Promise<Order>;
createLimitSellOrder (symbol: string, amount: number, price: number, params?: Params): Promise<Order>;
createMarketOrder (symbol: string, side: Order['side'], amount: number, price?: number, params?: Params): Promise<Order>;
createOrder (symbol: string, type: Order['type'], side: Order['side'], amount: number, price?: number, params?: Params): Promise<Order>;
decode (str: string): string;
defaults (): any;
defineRestApi (api: any, methodName: any, options?: Dictionary<any>): void;
deposit (...args: any): Promise<any>; // TODO: add function signatures
describe (): any;
editOrder (id: string, symbol: string, type: Order['type'], side: Order['side'], amount: number, price?: number, params?: Params): Promise<Order>;
encode (str: string): string;
encodeURIComponent (...args: any[]): string;
extractParams (str: string): string[];
fetch (url: string, method?: string, headers?: any, body?: any): Promise<any>;
fetch2 (path: any, api?: string, method?: string, params?: Params, headers?: any, body?: any): Promise<any>;
fetchBalance (params?: Params): Promise<Balances>;
fetchBidsAsks (symbols?: string[], params?: Params): Promise<any>;
fetchClosedOrders (symbol?: string, since?: number, limit?: number, params?: Params): Promise<Order[]>;
fetchCurrencies (params?: Params): Promise<Dictionary<Currency>>;
fetchDepositAddress (currency: string, params?: Params): Promise<DepositAddressResponse>;
fetchDeposits (currency?: string, since?: number, limit?: number, params?: Params): Promise<Transaction[]>;
fetchFreeBalance (params?: Params): Promise<PartialBalances>;
fetchFundingFees (...args: any): Promise<any>; // TODO: add function signatures
fetchL2OrderBook (...args: any): Promise<any>; // TODO: add function signatures
fetchLedger (...args: any): Promise<any>; // TODO: add function signatures
fetchMarkets (): Promise<Market[]>;
fetchMyTrades (symbol?: string, since?: any, limit?: any, params?: Params): Promise<Trade[]>;
fetchOHLCV (symbol: string, timeframe?: string, since?: number, limit?: number, params?: Params): Promise<OHLCV[]>;
fetchOpenOrders (symbol?: string, since?: number, limit?: number, params?: Params): Promise<Order[]>;
fetchOrder (id: string, symbol: string, params?: Params): Promise<Order>;
fetchOrderBook (symbol: string, limit?: number, params?: Params): Promise<OrderBook>;
fetchOrderBooks (...args: any): Promise<any>; // TODO: add function signatures
fetchOrders (symbol?: string, since?: number, limit?: number, params?: Params): Promise<Order[]>;
fetchOrderStatus (id: string, market: string): Promise<string>;
fetchStatus (...args: any): Promise<any>; // TODO: add function signatures
fetchTicker (symbol: string, params?: Params): Promise<Ticker>;
fetchTickers (symbols?: string[], params?: Params): Promise<Dictionary<Ticker>>;
fetchTime (params?: Params): Promise<number>;
fetchTotalBalance (params?: Params): Promise<PartialBalances>;
fetchTrades (symbol: string, since?: number, limit?: number, params?: Params): Promise<Trade[]>;
fetchTradingFee (...args: any): Promise<any>; // TODO: add function signatures
fetchTradingFees (...args: any): Promise<any>; // TODO: add function signatures
fetchTradingLimits (...args: any): Promise<any>; // TODO: add function signatures
fetchTransactions (currency?: string, since?: number, limit?: number, params?: Params): Promise<Transaction[]>;
fetchUsedBalance (params?: Params): Promise<PartialBalances>;
fetchWithdrawals (currency?: string, since?: number, limit?: number, params?: Params): Promise<Transaction[]>;
getMarket (symbol: string): Market;
initRestRateLimiter (): void;
iso8601 (timestamp: number | string): string;
loadMarkets (reload?: boolean): Promise<Dictionary<Market>>;
market (symbol: string): Market;
marketId (symbol: string): string;
marketIds (symbols: string[]): string[];
microseconds (): number;
nonce (): number;
parseTimeframe (timeframe: string): number;
purgeCachedOrders (timestamp: number): void;
request (path: string, api?: string, method?: string, params?: Params, headers?: any, body?: any): Promise<any>;
seconds (): number;
setMarkets (markets: Market[], currencies?: Currency[]): Dictionary<Market>;
symbol (symbol: string): string;
withdraw (currency: string, amount: number, address: string, tag?: string, params?: Params): Promise<WithdrawalResponse>;
YmdHMS (timestamp: string, infix: string) : string;
}
/* tslint:disable */
export class aax extends Exchange {}
export class aofex extends Exchange {}
export class ascendex extends Exchange {}
export class bequant extends hitbtc {}
export class bibox extends Exchange {}
export class bigone extends Exchange {}
export class binance extends Exchange {}
export class binancecoinm extends binance {}
export class binanceus extends binance {}
export class binanceusdm extends binance {}
export class bit2c extends Exchange {}
export class bitbank extends Exchange {}
export class bitbay extends Exchange {}
export class bitbns extends Exchange {}
export class bitcoincom extends hitbtc {}
export class bitfinex extends Exchange {}
export class bitfinex2 extends bitfinex {}
export class bitflyer extends Exchange {}
export class bitforex extends Exchange {}
export class bitget extends Exchange {}
export class bithumb extends Exchange {}
export class bitmart extends Exchange {}
export class bitmex extends Exchange {}
export class bitpanda extends Exchange {}
export class bitso extends Exchange {}
export class bitstamp extends Exchange {}
export class bitstamp1 extends Exchange {}
export class bittrex extends Exchange {}
export class bitvavo extends Exchange {}
export class bitz extends Exchange {}
export class bl3p extends Exchange {}
export class braziliex extends Exchange {}
export class btcalpha extends Exchange {}
export class btcbox extends Exchange {}
export class btcmarkets extends Exchange {}
export class btctradeua extends Exchange {}
export class btcturk extends Exchange {}
export class buda extends Exchange {}
export class bw extends Exchange {}
export class bybit extends Exchange {}
export class cdax extends huobipro {}
export class cex extends Exchange {}
export class coinbase extends Exchange {}
export class coinbaseprime extends coinbasepro {}
export class coinbasepro extends Exchange {}
export class coincheck extends Exchange {}
export class coinegg extends Exchange {}
export class coinex extends Exchange {}
export class coinfalcon extends Exchange {}
export class coinfloor extends Exchange {}
export class coinmarketcap extends Exchange {}
export class coinmate extends Exchange {}
export class coinone extends Exchange {}
export class coinspot extends Exchange {}
export class crex24 extends Exchange {}
export class currencycom extends Exchange {}
export class delta extends Exchange {}
export class deribit extends Exchange {}
export class digifinex extends Exchange {}
export class eqonex extends Exchange {}
export class equos extends eqonex {}
export class exmo extends Exchange {}
export class exx extends Exchange {}
export class flowbtc extends Exchange {}
export class ftx extends Exchange {}
export class gateio extends Exchange {}
export class gemini extends Exchange {}
export class gopax extends Exchange {}
export class hbtc extends Exchange {}
export class hitbtc extends Exchange {}
export class hollaex extends Exchange {}
export class huobijp extends huobipro {}
export class huobipro extends Exchange {}
export class idex extends Exchange {}
export class independentreserve extends Exchange {}
export class indodax extends Exchange {}
export class itbit extends Exchange {}
export class kraken extends Exchange {}
export class kucoin extends Exchange {}
export class kuna extends Exchange {}
export class latoken extends Exchange {}
export class lbank extends Exchange {}
export class liquid extends Exchange {}
export class luno extends Exchange {}
export class lykke extends Exchange {}
export class mercado extends Exchange {}
export class mixcoins extends Exchange {}
export class ndax extends Exchange {}
export class novadax extends Exchange {}
export class oceanex extends Exchange {}
export class okcoin extends okex {}
export class okex extends Exchange {}
export class okex5 extends Exchange {}
export class paymium extends Exchange {}
export class phemex extends Exchange {}
export class poloniex extends Exchange {}
export class probit extends Exchange {}
export class qtrade extends Exchange {}
export class ripio extends Exchange {}
export class stex extends Exchange {}
export class therock extends Exchange {}
export class tidebit extends Exchange {}
export class tidex extends Exchange {}
export class timex extends Exchange {}
export class upbit extends Exchange {}
export class vcc extends Exchange {}
export class wavesexchange extends Exchange {}
export class whitebit extends Exchange {}
export class xena extends Exchange {}
export class yobit extends Exchange {}
export class zaif extends Exchange {}
export class zb extends Exchange {}
/* tslint:enable */
export type ExchangeId =
| 'aax'
| 'aofex'
| 'ascendex'
| 'bequant'
| 'bibox'
| 'bigone'
| 'binance'
| 'binancecoinm'
| 'binanceus'
| 'binanceusdm'
| 'bit2c'
| 'bitbank'
| 'bitbay'
| 'bitbns'
| 'bitcoincom'
| 'bitfinex'
| 'bitfinex2'
| 'bitflyer'
| 'bitforex'
| 'bitget'
| 'bithumb'
| 'bitmart'
| 'bitmex'
| 'bitpanda'
| 'bitso'
| 'bitstamp'
| 'bitstamp1'
| 'bittrex'
| 'bitvavo'
| 'bitz'
| 'bl3p'
| 'braziliex'
| 'btcalpha'
| 'btcbox'
| 'btcmarkets'
| 'btctradeua'
| 'btcturk'
| 'buda'
| 'bw'
| 'bybit'
| 'cdax'
| 'cex'
| 'coinbase'
| 'coinbaseprime'
| 'coinbasepro'
| 'coincheck'
| 'coinegg'
| 'coinex'
| 'coinfalcon'
| 'coinfloor'
| 'coinmarketcap'
| 'coinmate'
| 'coinone'
| 'coinspot'
| 'crex24'
| 'currencycom'
| 'delta'
| 'deribit'
| 'digifinex'
| 'eqonex'
| 'equos'
| 'exmo'
| 'exx'
| 'flowbtc'
| 'ftx'
| 'gateio'
| 'gemini'
| 'gopax'
| 'hbtc'
| 'hitbtc'
| 'hollaex'
| 'huobijp'
| 'huobipro'
| 'idex'
| 'independentreserve'
| 'indodax'
| 'itbit'
| 'kraken'
| 'kucoin'
| 'kuna'
| 'latoken'
| 'lbank'
| 'liquid'
| 'luno'
| 'lykke'
| 'mercado'
| 'mixcoins'
| 'ndax'
| 'novadax'
| 'oceanex'
| 'okcoin'
| 'okex'
| 'okex5'
| 'paymium'
| 'phemex'
| 'poloniex'
| 'probit'
| 'qtrade'
| 'ripio'
| 'stex'
| 'therock'
| 'tidebit'
| 'tidex'
| 'timex'
| 'upbit'
| 'vcc'
| 'wavesexchange'
| 'whitebit'
| 'xena'
| 'yobit'
| 'zaif'
| 'zb'
}