ccxt-look 1.81.50
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/.cache/eslintcache +1 -0
- package/.dockerignore +6 -0
- package/.eslintignore +1 -0
- package/.gitattributes +5 -0
- package/.readthedocs.yaml +16 -0
- package/CONTRIBUTING.md +1049 -0
- package/LICENSE.txt +21 -0
- package/README.md +537 -0
- package/SECURITY.md +5 -0
- package/build/cleanup-old-tags.js +94 -0
- package/build/countries.js +256 -0
- package/build/export-exchanges.js +520 -0
- package/build/fs.js +51 -0
- package/build/transpile.js +1772 -0
- package/build/vss.js +78 -0
- package/ccxt.browser.js +7 -0
- package/ccxt.d.ts +692 -0
- package/ccxt.js +171 -0
- package/cleanup.sh +2 -0
- package/composer-install.sh +20 -0
- package/dist/ccxt.browser.js +208383 -0
- package/gource.sh +3 -0
- package/index.html +7 -0
- package/js/.eslintrc +87 -0
- package/js/aax.js +2686 -0
- package/js/ascendex.js +2584 -0
- package/js/base/.eslintrc.js +43 -0
- package/js/base/Exchange.js +2371 -0
- package/js/base/Precise.js +283 -0
- package/js/base/errorHierarchy.js +47 -0
- package/js/base/errors.js +55 -0
- package/js/base/functions/crypto.js +158 -0
- package/js/base/functions/encode.js +118 -0
- package/js/base/functions/generic.js +270 -0
- package/js/base/functions/misc.js +138 -0
- package/js/base/functions/number.js +329 -0
- package/js/base/functions/platform.js +38 -0
- package/js/base/functions/string.js +21 -0
- package/js/base/functions/throttle.js +79 -0
- package/js/base/functions/time.js +210 -0
- package/js/base/functions/type.js +66 -0
- package/js/base/functions.js +28 -0
- package/js/bequant.js +32 -0
- package/js/bibox.js +1407 -0
- package/js/bigone.js +1366 -0
- package/js/binance.js +5652 -0
- package/js/binancecoinm.js +46 -0
- package/js/binanceus.js +46 -0
- package/js/binanceusdm.js +49 -0
- package/js/bit2c.js +535 -0
- package/js/bitbank.js +842 -0
- package/js/bitbay.js +16 -0
- package/js/bitbns.js +1073 -0
- package/js/bitcoincom.js +15 -0
- package/js/bitfinex.js +1433 -0
- package/js/bitfinex2.js +2025 -0
- package/js/bitflyer.js +840 -0
- package/js/bitforex.js +614 -0
- package/js/bitget.js +2397 -0
- package/js/bithumb.js +980 -0
- package/js/bitmart.js +2516 -0
- package/js/bitmex.js +1809 -0
- package/js/bitopro.js +1443 -0
- package/js/bitpanda.js +1782 -0
- package/js/bitrue.js +1747 -0
- package/js/bitso.js +1062 -0
- package/js/bitstamp.js +1757 -0
- package/js/bitstamp1.js +343 -0
- package/js/bittrex.js +1876 -0
- package/js/bitvavo.js +1579 -0
- package/js/bkex.js +1233 -0
- package/js/bl3p.js +346 -0
- package/js/blockchaincom.js +969 -0
- package/js/btcalpha.js +680 -0
- package/js/btcbox.js +477 -0
- package/js/btcmarkets.js +1022 -0
- package/js/btctradeua.js +466 -0
- package/js/btcturk.js +734 -0
- package/js/buda.js +946 -0
- package/js/bw.js +1265 -0
- package/js/bybit.js +3372 -0
- package/js/bytetrade.js +1336 -0
- package/js/cdax.js +1646 -0
- package/js/cex.js +1410 -0
- package/js/coinbase.js +1342 -0
- package/js/coinbaseprime.js +31 -0
- package/js/coinbasepro.js +1466 -0
- package/js/coincheck.js +755 -0
- package/js/coinex.js +3400 -0
- package/js/coinfalcon.js +880 -0
- package/js/coinmate.js +794 -0
- package/js/coinone.js +816 -0
- package/js/coinspot.js +345 -0
- package/js/crex24.js +1636 -0
- package/js/cryptocom.js +1832 -0
- package/js/currencycom.js +1748 -0
- package/js/delta.js +1547 -0
- package/js/deribit.js +2148 -0
- package/js/digifinex.js +1585 -0
- package/js/eqonex.js +1660 -0
- package/js/exmo.js +1670 -0
- package/js/fairdesk.js +1231 -0
- package/js/flowbtc.js +35 -0
- package/js/fmfwio.js +34 -0
- package/js/ftx.js +2751 -0
- package/js/ftxus.js +38 -0
- package/js/gateio.js +4174 -0
- package/js/gemini.js +1397 -0
- package/js/hitbtc.js +1343 -0
- package/js/hitbtc3.js +2329 -0
- package/js/hollaex.js +1486 -0
- package/js/huobi.js +5706 -0
- package/js/huobijp.js +1710 -0
- package/js/huobipro.js +18 -0
- package/js/idex.js +1439 -0
- package/js/independentreserve.js +649 -0
- package/js/indodax.js +742 -0
- package/js/itbit.js +722 -0
- package/js/kraken.js +2179 -0
- package/js/kucoin.js +2571 -0
- package/js/kucoinfutures.js +1771 -0
- package/js/kuna.js +809 -0
- package/js/latoken.js +1445 -0
- package/js/lbank.js +760 -0
- package/js/liquid.js +1432 -0
- package/js/luno.js +873 -0
- package/js/lykke.js +1147 -0
- package/js/mercado.js +771 -0
- package/js/mexc.js +3151 -0
- package/js/ndax.js +2233 -0
- package/js/novadax.js +1318 -0
- package/js/oceanex.js +816 -0
- package/js/okcoin.js +3841 -0
- package/js/okex.js +16 -0
- package/js/okex5.js +16 -0
- package/js/okx.js +4795 -0
- package/js/paymium.js +498 -0
- package/js/phemex.js +2957 -0
- package/js/poloniex.js +1674 -0
- package/js/probit.js +1346 -0
- package/js/qtrade.js +1588 -0
- package/js/ripio.js +1061 -0
- package/js/static_dependencies/BN/bn.js +3526 -0
- package/js/static_dependencies/README.md +1 -0
- package/js/static_dependencies/crypto-js/crypto-js.js +5988 -0
- package/js/static_dependencies/elliptic/lib/elliptic/curve/base.js +375 -0
- package/js/static_dependencies/elliptic/lib/elliptic/curve/edwards.js +433 -0
- package/js/static_dependencies/elliptic/lib/elliptic/curve/index.js +8 -0
- package/js/static_dependencies/elliptic/lib/elliptic/curve/mont.js +180 -0
- package/js/static_dependencies/elliptic/lib/elliptic/curve/short.js +938 -0
- package/js/static_dependencies/elliptic/lib/elliptic/curves.js +204 -0
- package/js/static_dependencies/elliptic/lib/elliptic/ec/index.js +240 -0
- package/js/static_dependencies/elliptic/lib/elliptic/ec/key.js +119 -0
- package/js/static_dependencies/elliptic/lib/elliptic/ec/signature.js +24 -0
- package/js/static_dependencies/elliptic/lib/elliptic/eddsa/index.js +145 -0
- package/js/static_dependencies/elliptic/lib/elliptic/eddsa/key.js +100 -0
- package/js/static_dependencies/elliptic/lib/elliptic/eddsa/signature.js +65 -0
- package/js/static_dependencies/elliptic/lib/elliptic/precomputed/secp256k1.js +780 -0
- package/js/static_dependencies/elliptic/lib/elliptic/utils.js +214 -0
- package/js/static_dependencies/elliptic/lib/elliptic.js +22 -0
- package/js/static_dependencies/elliptic/lib/hmac-drbg/hmac-drbg.js +114 -0
- package/js/static_dependencies/fetch-ponyfill/fetch-node.js +39 -0
- package/js/static_dependencies/node-fetch/index.js +1564 -0
- package/js/static_dependencies/node-rsa/NodeRSA.js +223 -0
- package/js/static_dependencies/node-rsa/asn1/ber/errors.js +13 -0
- package/js/static_dependencies/node-rsa/asn1/ber/index.js +21 -0
- package/js/static_dependencies/node-rsa/asn1/ber/reader.js +262 -0
- package/js/static_dependencies/node-rsa/asn1/ber/types.js +36 -0
- package/js/static_dependencies/node-rsa/asn1/index.js +17 -0
- package/js/static_dependencies/node-rsa/encryptEngines/js.js +34 -0
- package/js/static_dependencies/node-rsa/formats/components.js +71 -0
- package/js/static_dependencies/node-rsa/formats/formats.js +31 -0
- package/js/static_dependencies/node-rsa/formats/pkcs1.js +148 -0
- package/js/static_dependencies/node-rsa/formats/pkcs8.js +187 -0
- package/js/static_dependencies/node-rsa/libs/jsbn.js +1252 -0
- package/js/static_dependencies/node-rsa/libs/rsa.js +147 -0
- package/js/static_dependencies/node-rsa/schemes/pkcs1.js +176 -0
- package/js/static_dependencies/node-rsa/schemes/schemes.js +21 -0
- package/js/static_dependencies/node-rsa/utils.js +98 -0
- package/js/static_dependencies/qs/formats.js +18 -0
- package/js/static_dependencies/qs/index.js +11 -0
- package/js/static_dependencies/qs/parse.js +242 -0
- package/js/static_dependencies/qs/stringify.js +269 -0
- package/js/static_dependencies/qs/utils.js +230 -0
- package/js/stex.js +1925 -0
- package/js/test/.eslintrc.js +42 -0
- package/js/test/Exchange/test.balance.js +61 -0
- package/js/test/Exchange/test.borrowRate.js +32 -0
- package/js/test/Exchange/test.currency.js +52 -0
- package/js/test/Exchange/test.fetchBalance.js +23 -0
- package/js/test/Exchange/test.fetchBorrowInterest.js +59 -0
- package/js/test/Exchange/test.fetchBorrowRate.js +32 -0
- package/js/test/Exchange/test.fetchBorrowRates.js +28 -0
- package/js/test/Exchange/test.fetchClosedOrders.js +32 -0
- package/js/test/Exchange/test.fetchCurrencies.js +35 -0
- package/js/test/Exchange/test.fetchDeposits.js +31 -0
- package/js/test/Exchange/test.fetchFundingFees.js +19 -0
- package/js/test/Exchange/test.fetchFundingRateHistory.js +40 -0
- package/js/test/Exchange/test.fetchL2OrderBook.js +23 -0
- package/js/test/Exchange/test.fetchLedger.js +42 -0
- package/js/test/Exchange/test.fetchLeverageTiers.js +33 -0
- package/js/test/Exchange/test.fetchMarketLeverageTiers.js +22 -0
- package/js/test/Exchange/test.fetchMarkets.js +33 -0
- package/js/test/Exchange/test.fetchMyTrades.js +42 -0
- package/js/test/Exchange/test.fetchOHLCV.js +46 -0
- package/js/test/Exchange/test.fetchOpenOrders.js +36 -0
- package/js/test/Exchange/test.fetchOrderBook.js +25 -0
- package/js/test/Exchange/test.fetchOrderBooks.js +35 -0
- package/js/test/Exchange/test.fetchOrders.js +41 -0
- package/js/test/Exchange/test.fetchPositions.js +47 -0
- package/js/test/Exchange/test.fetchStatus.js +35 -0
- package/js/test/Exchange/test.fetchTicker.js +38 -0
- package/js/test/Exchange/test.fetchTickers.js +49 -0
- package/js/test/Exchange/test.fetchTrades.js +39 -0
- package/js/test/Exchange/test.fetchTradingFee.js +18 -0
- package/js/test/Exchange/test.fetchTradingFees.js +22 -0
- package/js/test/Exchange/test.fetchTransactions.js +31 -0
- package/js/test/Exchange/test.fetchWithdrawals.js +31 -0
- package/js/test/Exchange/test.ledgerItem.js +46 -0
- package/js/test/Exchange/test.leverageTier.js +33 -0
- package/js/test/Exchange/test.loadMarkets.js +35 -0
- package/js/test/Exchange/test.market.js +129 -0
- package/js/test/Exchange/test.ohlcv.js +33 -0
- package/js/test/Exchange/test.order.js +62 -0
- package/js/test/Exchange/test.orderbook.js +61 -0
- package/js/test/Exchange/test.position.js +21 -0
- package/js/test/Exchange/test.throttle.js +94 -0
- package/js/test/Exchange/test.ticker.js +95 -0
- package/js/test/Exchange/test.trade.js +68 -0
- package/js/test/Exchange/test.tradingFee.js +34 -0
- package/js/test/Exchange/test.transaction.js +35 -0
- package/js/test/base/.eslintrc +38 -0
- package/js/test/base/functions/test.crypto.js +110 -0
- package/js/test/base/functions/test.datetime.js +62 -0
- package/js/test/base/functions/test.generic.js +152 -0
- package/js/test/base/functions/test.number.js +362 -0
- package/js/test/base/functions/test.time.js +56 -0
- package/js/test/base/functions/test.type.js +53 -0
- package/js/test/base/test.base.js +193 -0
- package/js/test/errors/test.InsufficientFunds.js +86 -0
- package/js/test/errors/test.InvalidNonce.js +64 -0
- package/js/test/errors/test.InvalidOrder.js +35 -0
- package/js/test/errors/test.OrderNotFound.js +39 -0
- package/js/test/test.js +426 -0
- package/js/test/test.timeout_hang.js +12 -0
- package/js/therock.js +1431 -0
- package/js/tidebit.js +632 -0
- package/js/tidex.js +939 -0
- package/js/timex.js +1283 -0
- package/js/upbit.js +1622 -0
- package/js/vcc.js +1353 -0
- package/js/wavesexchange.js +2185 -0
- package/js/wazirx.js +732 -0
- package/js/whitebit.js +1352 -0
- package/js/woo.js +1577 -0
- package/js/xena.js +1948 -0
- package/js/yobit.js +1129 -0
- package/js/zaif.js +647 -0
- package/js/zb.js +4088 -0
- package/js/zipmex.js +40 -0
- package/js/zonda.js +1497 -0
- package/multilang.sh +159 -0
- package/package.json +591 -0
- package/postinstall.js +103 -0
package/js/yobit.js
ADDED
@@ -0,0 +1,1129 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
// ---------------------------------------------------------------------------
|
4
|
+
|
5
|
+
const Exchange = require ('./base/Exchange');
|
6
|
+
const { ExchangeError, ArgumentsRequired, ExchangeNotAvailable, InvalidNonce, InsufficientFunds, OrderNotFound, DDoSProtection, InvalidOrder, AuthenticationError, RateLimitExceeded } = require ('./base/errors');
|
7
|
+
const Precise = require ('./base/Precise');
|
8
|
+
|
9
|
+
// ---------------------------------------------------------------------------
|
10
|
+
|
11
|
+
module.exports = class yobit extends Exchange {
|
12
|
+
describe () {
|
13
|
+
return this.deepExtend (super.describe (), {
|
14
|
+
'id': 'yobit',
|
15
|
+
'name': 'YoBit',
|
16
|
+
'countries': [ 'RU' ],
|
17
|
+
'rateLimit': 2000, // responses are cached every 2 seconds
|
18
|
+
'version': '3',
|
19
|
+
'has': {
|
20
|
+
'CORS': undefined,
|
21
|
+
'spot': true,
|
22
|
+
'margin': false,
|
23
|
+
'swap': false,
|
24
|
+
'future': false,
|
25
|
+
'option': false,
|
26
|
+
'addMargin': false,
|
27
|
+
'cancelOrder': true,
|
28
|
+
'createDepositAddress': true,
|
29
|
+
'createMarketOrder': undefined,
|
30
|
+
'createOrder': true,
|
31
|
+
'createReduceOnlyOrder': false,
|
32
|
+
'fetchBalance': true,
|
33
|
+
'fetchBorrowRate': false,
|
34
|
+
'fetchBorrowRateHistories': false,
|
35
|
+
'fetchBorrowRateHistory': false,
|
36
|
+
'fetchBorrowRates': false,
|
37
|
+
'fetchBorrowRatesPerSymbol': false,
|
38
|
+
'fetchDepositAddress': true,
|
39
|
+
'fetchDeposits': undefined,
|
40
|
+
'fetchFundingHistory': false,
|
41
|
+
'fetchFundingRate': false,
|
42
|
+
'fetchFundingRateHistory': false,
|
43
|
+
'fetchFundingRates': false,
|
44
|
+
'fetchIndexOHLCV': false,
|
45
|
+
'fetchLeverage': false,
|
46
|
+
'fetchLeverageTiers': false,
|
47
|
+
'fetchMarkets': true,
|
48
|
+
'fetchMarkOHLCV': false,
|
49
|
+
'fetchMyTrades': true,
|
50
|
+
'fetchOpenOrders': true,
|
51
|
+
'fetchOrder': true,
|
52
|
+
'fetchOrderBook': true,
|
53
|
+
'fetchOrderBooks': true,
|
54
|
+
'fetchPosition': false,
|
55
|
+
'fetchPositions': false,
|
56
|
+
'fetchPositionsRisk': false,
|
57
|
+
'fetchPremiumIndexOHLCV': false,
|
58
|
+
'fetchTicker': true,
|
59
|
+
'fetchTickers': true,
|
60
|
+
'fetchTrades': true,
|
61
|
+
'fetchTradingFee': false,
|
62
|
+
'fetchTradingFees': true,
|
63
|
+
'fetchTransactions': undefined,
|
64
|
+
'fetchWithdrawals': undefined,
|
65
|
+
'reduceMargin': false,
|
66
|
+
'setLeverage': false,
|
67
|
+
'setMarginMode': false,
|
68
|
+
'setPositionMode': false,
|
69
|
+
'withdraw': true,
|
70
|
+
},
|
71
|
+
'urls': {
|
72
|
+
'logo': 'https://user-images.githubusercontent.com/1294454/27766910-cdcbfdae-5eea-11e7-9859-03fea873272d.jpg',
|
73
|
+
'api': {
|
74
|
+
'public': 'https://yobit.net/api',
|
75
|
+
'private': 'https://yobit.net/tapi',
|
76
|
+
},
|
77
|
+
'www': 'https://www.yobit.net',
|
78
|
+
'doc': 'https://www.yobit.net/en/api/',
|
79
|
+
'fees': 'https://www.yobit.net/en/fees/',
|
80
|
+
},
|
81
|
+
'api': {
|
82
|
+
'public': {
|
83
|
+
'get': {
|
84
|
+
'depth/{pair}': 1,
|
85
|
+
'info': 1,
|
86
|
+
'ticker/{pair}': 1,
|
87
|
+
'trades/{pair}': 1,
|
88
|
+
},
|
89
|
+
},
|
90
|
+
'private': {
|
91
|
+
'post': {
|
92
|
+
'ActiveOrders': 1,
|
93
|
+
'CancelOrder': 1,
|
94
|
+
'GetDepositAddress': 1,
|
95
|
+
'getInfo': 1,
|
96
|
+
'OrderInfo': 1,
|
97
|
+
'Trade': 1,
|
98
|
+
'TradeHistory': 1,
|
99
|
+
'WithdrawCoinsToAddress': 1,
|
100
|
+
},
|
101
|
+
},
|
102
|
+
},
|
103
|
+
'fees': {
|
104
|
+
'trading': {
|
105
|
+
'maker': 0.002,
|
106
|
+
'taker': 0.002,
|
107
|
+
},
|
108
|
+
'funding': {
|
109
|
+
'withdraw': {},
|
110
|
+
},
|
111
|
+
},
|
112
|
+
'commonCurrencies': {
|
113
|
+
'AIR': 'AirCoin',
|
114
|
+
'ANI': 'ANICoin',
|
115
|
+
'ANT': 'AntsCoin', // what is this, a coin for ants?
|
116
|
+
'ATMCHA': 'ATM',
|
117
|
+
'ASN': 'Ascension',
|
118
|
+
'AST': 'Astral',
|
119
|
+
'ATM': 'Autumncoin',
|
120
|
+
'AUR': 'AuroraCoin',
|
121
|
+
'BAB': 'Babel',
|
122
|
+
'BAN': 'BANcoin',
|
123
|
+
'BCC': 'BCH',
|
124
|
+
'BCS': 'BitcoinStake',
|
125
|
+
'BITS': 'Bitstar',
|
126
|
+
'BLN': 'Bulleon',
|
127
|
+
'BNS': 'Benefit Bonus Coin',
|
128
|
+
'BOT': 'BOTcoin',
|
129
|
+
'BON': 'BONES',
|
130
|
+
'BPC': 'BitcoinPremium',
|
131
|
+
'BST': 'BitStone',
|
132
|
+
'BTS': 'Bitshares2',
|
133
|
+
'CAT': 'BitClave',
|
134
|
+
'CBC': 'CryptoBossCoin',
|
135
|
+
'CMT': 'CometCoin',
|
136
|
+
'COIN': 'Coin.com',
|
137
|
+
'COV': 'Coven Coin',
|
138
|
+
'COVX': 'COV',
|
139
|
+
'CPC': 'Capricoin',
|
140
|
+
'CREDIT': 'Creditbit',
|
141
|
+
'CS': 'CryptoSpots',
|
142
|
+
'DCT': 'Discount',
|
143
|
+
'DFT': 'DraftCoin',
|
144
|
+
'DGD': 'DarkGoldCoin',
|
145
|
+
'DIRT': 'DIRTY',
|
146
|
+
'DROP': 'FaucetCoin',
|
147
|
+
'DSH': 'DASH',
|
148
|
+
'EGC': 'EverGreenCoin',
|
149
|
+
'EGG': 'EggCoin',
|
150
|
+
'EKO': 'EkoCoin',
|
151
|
+
'ENTER': 'ENTRC',
|
152
|
+
'EPC': 'ExperienceCoin',
|
153
|
+
'ESC': 'EdwardSnowden',
|
154
|
+
'EUROPE': 'EUROP',
|
155
|
+
'EXT': 'LifeExtension',
|
156
|
+
'FUND': 'FUNDChains',
|
157
|
+
'FUNK': 'FUNKCoin',
|
158
|
+
'FX': 'FCoin',
|
159
|
+
'GCC': 'GlobalCryptocurrency',
|
160
|
+
'GEN': 'Genstake',
|
161
|
+
'GENE': 'Genesiscoin',
|
162
|
+
'GMR': 'Gimmer',
|
163
|
+
'GOLD': 'GoldMint',
|
164
|
+
'GOT': 'Giotto Coin',
|
165
|
+
'GSX': 'GlowShares',
|
166
|
+
'GT': 'GTcoin',
|
167
|
+
'HTML5': 'HTML',
|
168
|
+
'HYPERX': 'HYPER',
|
169
|
+
'ICN': 'iCoin',
|
170
|
+
'INSANE': 'INSN',
|
171
|
+
'JNT': 'JointCoin',
|
172
|
+
'JPC': 'JupiterCoin',
|
173
|
+
'JWL': 'Jewels',
|
174
|
+
'KNC': 'KingN Coin',
|
175
|
+
'LBTCX': 'LiteBitcoin',
|
176
|
+
'LIZI': 'LiZi',
|
177
|
+
'LOC': 'LocoCoin',
|
178
|
+
'LOCX': 'LOC',
|
179
|
+
'LUNYR': 'LUN',
|
180
|
+
'LUN': 'LunarCoin', // they just change the ticker if it is already taken
|
181
|
+
'LUNA': 'Luna Coin',
|
182
|
+
'MASK': 'Yobit MASK',
|
183
|
+
'MDT': 'Midnight',
|
184
|
+
'MEME': 'Memez Token', // conflict with Meme Inu / Degenerator Meme
|
185
|
+
'MIS': 'MIScoin',
|
186
|
+
'MM': 'MasterMint', // conflict with MilliMeter
|
187
|
+
'NAV': 'NavajoCoin',
|
188
|
+
'NBT': 'NiceBytes',
|
189
|
+
'OMG': 'OMGame',
|
190
|
+
'ONX': 'Onix',
|
191
|
+
'PAC': '$PAC',
|
192
|
+
'PLAY': 'PlayCoin',
|
193
|
+
'PIVX': 'Darknet',
|
194
|
+
'PRS': 'PRE',
|
195
|
+
'PURE': 'PurePOS',
|
196
|
+
'PUTIN': 'PutinCoin',
|
197
|
+
'SPACE': 'Spacecoin',
|
198
|
+
'STK': 'StakeCoin',
|
199
|
+
'SUB': 'Subscriptio',
|
200
|
+
'PAY': 'EPAY',
|
201
|
+
'PLC': 'Platin Coin',
|
202
|
+
'RAI': 'RaiderCoin',
|
203
|
+
'RCN': 'RCoin',
|
204
|
+
'REP': 'Republicoin',
|
205
|
+
'RUR': 'RUB',
|
206
|
+
'SBTC': 'Super Bitcoin',
|
207
|
+
'SMC': 'SmartCoin',
|
208
|
+
'SOLO': 'SoloCoin',
|
209
|
+
'STAR': 'StarCoin',
|
210
|
+
'SUPER': 'SuperCoin',
|
211
|
+
'TNS': 'Transcodium',
|
212
|
+
'TTC': 'TittieCoin',
|
213
|
+
'UNI': 'Universe',
|
214
|
+
'UST': 'Uservice',
|
215
|
+
'VOL': 'VolumeCoin',
|
216
|
+
'XIN': 'XINCoin',
|
217
|
+
'XMT': 'SummitCoin',
|
218
|
+
'XRA': 'Ratecoin',
|
219
|
+
},
|
220
|
+
'options': {
|
221
|
+
// 'fetchTickersMaxLength': 2048,
|
222
|
+
'fetchOrdersRequiresSymbol': true,
|
223
|
+
'fetchTickersMaxLength': 512,
|
224
|
+
},
|
225
|
+
'exceptions': {
|
226
|
+
'exact': {
|
227
|
+
'803': InvalidOrder, // "Count could not be less than 0.001." (selling below minAmount)
|
228
|
+
'804': InvalidOrder, // "Count could not be more than 10000." (buying above maxAmount)
|
229
|
+
'805': InvalidOrder, // "price could not be less than X." (minPrice violation on buy & sell)
|
230
|
+
'806': InvalidOrder, // "price could not be more than X." (maxPrice violation on buy & sell)
|
231
|
+
'807': InvalidOrder, // "cost could not be less than X." (minCost violation on buy & sell)
|
232
|
+
'831': InsufficientFunds, // "Not enougth X to create buy order." (buying with balance.quote < order.cost)
|
233
|
+
'832': InsufficientFunds, // "Not enougth X to create sell order." (selling with balance.base < order.amount)
|
234
|
+
'833': OrderNotFound, // "Order with id X was not found." (cancelling non-existent, closed and cancelled order)
|
235
|
+
},
|
236
|
+
'broad': {
|
237
|
+
'Invalid pair name': ExchangeError, // {"success":0,"error":"Invalid pair name: btc_eth"}
|
238
|
+
'invalid api key': AuthenticationError,
|
239
|
+
'invalid sign': AuthenticationError,
|
240
|
+
'api key dont have trade permission': AuthenticationError,
|
241
|
+
'invalid parameter': InvalidOrder,
|
242
|
+
'invalid order': InvalidOrder,
|
243
|
+
'The given order has already been cancelled': InvalidOrder,
|
244
|
+
'Requests too often': DDoSProtection,
|
245
|
+
'not available': ExchangeNotAvailable,
|
246
|
+
'data unavailable': ExchangeNotAvailable,
|
247
|
+
'external service unavailable': ExchangeNotAvailable,
|
248
|
+
'Total transaction amount': InvalidOrder, // { "success": 0, "error": "Total transaction amount is less than minimal total: 0.00010000"}
|
249
|
+
'The given order has already been closed and cannot be cancelled': InvalidOrder,
|
250
|
+
'Insufficient funds': InsufficientFunds,
|
251
|
+
'invalid key': AuthenticationError,
|
252
|
+
'invalid nonce': InvalidNonce, // {"success":0,"error":"invalid nonce (has already been used)"}'
|
253
|
+
'Total order amount is less than minimal amount': InvalidOrder,
|
254
|
+
'Rate Limited': RateLimitExceeded,
|
255
|
+
},
|
256
|
+
},
|
257
|
+
'orders': {}, // orders cache / emulation
|
258
|
+
});
|
259
|
+
}
|
260
|
+
|
261
|
+
parseBalance (response) {
|
262
|
+
const balances = this.safeValue (response, 'return', {});
|
263
|
+
const timestamp = this.safeInteger (balances, 'server_time');
|
264
|
+
const result = {
|
265
|
+
'info': response,
|
266
|
+
'timestamp': timestamp,
|
267
|
+
'datetime': this.iso8601 (timestamp),
|
268
|
+
};
|
269
|
+
const free = this.safeValue (balances, 'funds', {});
|
270
|
+
const total = this.safeValue (balances, 'funds_incl_orders', {});
|
271
|
+
const currencyIds = Object.keys (this.extend (free, total));
|
272
|
+
for (let i = 0; i < currencyIds.length; i++) {
|
273
|
+
const currencyId = currencyIds[i];
|
274
|
+
const code = this.safeCurrencyCode (currencyId);
|
275
|
+
const account = this.account ();
|
276
|
+
account['free'] = this.safeString (free, currencyId);
|
277
|
+
account['total'] = this.safeString (total, currencyId);
|
278
|
+
result[code] = account;
|
279
|
+
}
|
280
|
+
return this.safeBalance (result);
|
281
|
+
}
|
282
|
+
|
283
|
+
async fetchBalance (params = {}) {
|
284
|
+
await this.loadMarkets ();
|
285
|
+
const response = await this.privatePostGetInfo (params);
|
286
|
+
//
|
287
|
+
// {
|
288
|
+
// "success":1,
|
289
|
+
// "return":{
|
290
|
+
// "funds":{
|
291
|
+
// "ltc":22,
|
292
|
+
// "nvc":423.998,
|
293
|
+
// "ppc":10,
|
294
|
+
// },
|
295
|
+
// "funds_incl_orders":{
|
296
|
+
// "ltc":32,
|
297
|
+
// "nvc":523.998,
|
298
|
+
// "ppc":20,
|
299
|
+
// },
|
300
|
+
// "rights":{
|
301
|
+
// "info":1,
|
302
|
+
// "trade":0,
|
303
|
+
// "withdraw":0
|
304
|
+
// },
|
305
|
+
// "transaction_count":0,
|
306
|
+
// "open_orders":1,
|
307
|
+
// "server_time":1418654530
|
308
|
+
// }
|
309
|
+
// }
|
310
|
+
//
|
311
|
+
return this.parseBalance (response);
|
312
|
+
}
|
313
|
+
|
314
|
+
async fetchMarkets (params = {}) {
|
315
|
+
const response = await this.publicGetInfo (params);
|
316
|
+
//
|
317
|
+
// {
|
318
|
+
// "server_time":1615856752,
|
319
|
+
// "pairs":{
|
320
|
+
// "ltc_btc":{
|
321
|
+
// "decimal_places":8,
|
322
|
+
// "min_price":0.00000001,
|
323
|
+
// "max_price":10000,
|
324
|
+
// "min_amount":0.0001,
|
325
|
+
// "min_total":0.0001,
|
326
|
+
// "hidden":0,
|
327
|
+
// "fee":0.2,
|
328
|
+
// "fee_buyer":0.2,
|
329
|
+
// "fee_seller":0.2
|
330
|
+
// },
|
331
|
+
// },
|
332
|
+
// }
|
333
|
+
//
|
334
|
+
const markets = this.safeValue (response, 'pairs');
|
335
|
+
const keys = Object.keys (markets);
|
336
|
+
const result = [];
|
337
|
+
for (let i = 0; i < keys.length; i++) {
|
338
|
+
const id = keys[i];
|
339
|
+
const market = markets[id];
|
340
|
+
const [ baseId, quoteId ] = id.split ('_');
|
341
|
+
let base = baseId.toUpperCase ();
|
342
|
+
let quote = quoteId.toUpperCase ();
|
343
|
+
base = this.safeCurrencyCode (base);
|
344
|
+
quote = this.safeCurrencyCode (quote);
|
345
|
+
const hidden = this.safeInteger (market, 'hidden');
|
346
|
+
let feeString = this.safeString (market, 'fee');
|
347
|
+
feeString = Precise.stringDiv (feeString, '100');
|
348
|
+
// yobit maker = taker
|
349
|
+
result.push ({
|
350
|
+
'id': id,
|
351
|
+
'symbol': base + '/' + quote,
|
352
|
+
'base': base,
|
353
|
+
'quote': quote,
|
354
|
+
'settle': undefined,
|
355
|
+
'baseId': baseId,
|
356
|
+
'quoteId': quoteId,
|
357
|
+
'settleId': undefined,
|
358
|
+
'type': 'spot',
|
359
|
+
'spot': true,
|
360
|
+
'margin': false,
|
361
|
+
'swap': false,
|
362
|
+
'future': false,
|
363
|
+
'option': false,
|
364
|
+
'active': (hidden === 0),
|
365
|
+
'contract': false,
|
366
|
+
'linear': undefined,
|
367
|
+
'inverse': undefined,
|
368
|
+
'taker': this.parseNumber (feeString),
|
369
|
+
'maker': this.parseNumber (feeString),
|
370
|
+
'contractSize': undefined,
|
371
|
+
'expiry': undefined,
|
372
|
+
'expiryDatetime': undefined,
|
373
|
+
'strike': undefined,
|
374
|
+
'optionType': undefined,
|
375
|
+
'precision': {
|
376
|
+
'amount': this.safeInteger (market, 'decimal_places'),
|
377
|
+
'price': this.safeInteger (market, 'decimal_places'),
|
378
|
+
},
|
379
|
+
'limits': {
|
380
|
+
'leverage': {
|
381
|
+
'min': undefined,
|
382
|
+
'max': undefined,
|
383
|
+
},
|
384
|
+
'amount': {
|
385
|
+
'min': this.safeNumber (market, 'min_amount'),
|
386
|
+
'max': this.safeNumber (market, 'max_amount'),
|
387
|
+
},
|
388
|
+
'price': {
|
389
|
+
'min': this.safeNumber (market, 'min_price'),
|
390
|
+
'max': this.safeNumber (market, 'max_price'),
|
391
|
+
},
|
392
|
+
'cost': {
|
393
|
+
'min': this.safeNumber (market, 'min_total'),
|
394
|
+
'max': undefined,
|
395
|
+
},
|
396
|
+
},
|
397
|
+
'info': market,
|
398
|
+
});
|
399
|
+
}
|
400
|
+
return result;
|
401
|
+
}
|
402
|
+
|
403
|
+
async fetchOrderBook (symbol, limit = undefined, params = {}) {
|
404
|
+
await this.loadMarkets ();
|
405
|
+
const market = this.market (symbol);
|
406
|
+
const request = {
|
407
|
+
'pair': market['id'],
|
408
|
+
};
|
409
|
+
if (limit !== undefined) {
|
410
|
+
request['limit'] = limit; // default = 150, max = 2000
|
411
|
+
}
|
412
|
+
const response = await this.publicGetDepthPair (this.extend (request, params));
|
413
|
+
const market_id_in_reponse = (market['id'] in response);
|
414
|
+
if (!market_id_in_reponse) {
|
415
|
+
throw new ExchangeError (this.id + ' ' + market['symbol'] + ' order book is empty or not available');
|
416
|
+
}
|
417
|
+
const orderbook = response[market['id']];
|
418
|
+
return this.parseOrderBook (orderbook, symbol);
|
419
|
+
}
|
420
|
+
|
421
|
+
async fetchOrderBooks (symbols = undefined, limit = undefined, params = {}) {
|
422
|
+
await this.loadMarkets ();
|
423
|
+
let ids = undefined;
|
424
|
+
if (symbols === undefined) {
|
425
|
+
ids = this.ids.join ('-');
|
426
|
+
// max URL length is 2083 symbols, including http schema, hostname, tld, etc...
|
427
|
+
if (ids.length > 2048) {
|
428
|
+
const numIds = this.ids.length;
|
429
|
+
throw new ExchangeError (this.id + ' fetchOrderBooks() has ' + numIds.toString () + ' symbols exceeding max URL length, you are required to specify a list of symbols in the first argument to fetchOrderBooks');
|
430
|
+
}
|
431
|
+
} else {
|
432
|
+
ids = this.marketIds (symbols);
|
433
|
+
ids = ids.join ('-');
|
434
|
+
}
|
435
|
+
const request = {
|
436
|
+
'pair': ids,
|
437
|
+
// 'ignore_invalid': true,
|
438
|
+
};
|
439
|
+
if (limit !== undefined) {
|
440
|
+
request['limit'] = limit;
|
441
|
+
}
|
442
|
+
const response = await this.publicGetDepthPair (this.extend (request, params));
|
443
|
+
const result = {};
|
444
|
+
ids = Object.keys (response);
|
445
|
+
for (let i = 0; i < ids.length; i++) {
|
446
|
+
const id = ids[i];
|
447
|
+
const symbol = this.safeSymbol (id);
|
448
|
+
result[symbol] = this.parseOrderBook (response[id], symbol);
|
449
|
+
}
|
450
|
+
return result;
|
451
|
+
}
|
452
|
+
|
453
|
+
parseTicker (ticker, market = undefined) {
|
454
|
+
//
|
455
|
+
// {
|
456
|
+
// high: 0.03497582,
|
457
|
+
// low: 0.03248474,
|
458
|
+
// avg: 0.03373028,
|
459
|
+
// vol: 120.11485715062999,
|
460
|
+
// vol_cur: 3572.24914074,
|
461
|
+
// last: 0.0337611,
|
462
|
+
// buy: 0.0337442,
|
463
|
+
// sell: 0.03377798,
|
464
|
+
// updated: 1537522009
|
465
|
+
// }
|
466
|
+
//
|
467
|
+
const timestamp = this.safeTimestamp (ticker, 'updated');
|
468
|
+
const last = this.safeString (ticker, 'last');
|
469
|
+
return this.safeTicker ({
|
470
|
+
'symbol': this.safeSymbol (undefined, market),
|
471
|
+
'timestamp': timestamp,
|
472
|
+
'datetime': this.iso8601 (timestamp),
|
473
|
+
'high': this.safeString (ticker, 'high'),
|
474
|
+
'low': this.safeString (ticker, 'low'),
|
475
|
+
'bid': this.safeString (ticker, 'buy'),
|
476
|
+
'bidVolume': undefined,
|
477
|
+
'ask': this.safeString (ticker, 'sell'),
|
478
|
+
'askVolume': undefined,
|
479
|
+
'vwap': undefined,
|
480
|
+
'open': undefined,
|
481
|
+
'close': last,
|
482
|
+
'last': last,
|
483
|
+
'previousClose': undefined,
|
484
|
+
'change': undefined,
|
485
|
+
'percentage': undefined,
|
486
|
+
'average': this.safeString (ticker, 'avg'),
|
487
|
+
'baseVolume': this.safeString (ticker, 'vol_cur'),
|
488
|
+
'quoteVolume': this.safeString (ticker, 'vol'),
|
489
|
+
'info': ticker,
|
490
|
+
}, market, false);
|
491
|
+
}
|
492
|
+
|
493
|
+
async fetchTickers (symbols = undefined, params = {}) {
|
494
|
+
await this.loadMarkets ();
|
495
|
+
let ids = this.ids;
|
496
|
+
if (symbols === undefined) {
|
497
|
+
const numIds = ids.length;
|
498
|
+
ids = ids.join ('-');
|
499
|
+
const maxLength = this.safeInteger (this.options, 'fetchTickersMaxLength', 2048);
|
500
|
+
// max URL length is 2048 symbols, including http schema, hostname, tld, etc...
|
501
|
+
if (ids.length > this.options['fetchTickersMaxLength']) {
|
502
|
+
throw new ArgumentsRequired (this.id + ' fetchTickers() has ' + numIds.toString () + ' markets exceeding max URL length for this endpoint (' + maxLength.toString () + ' characters), please, specify a list of symbols of interest in the first argument to fetchTickers');
|
503
|
+
}
|
504
|
+
} else {
|
505
|
+
ids = this.marketIds (symbols);
|
506
|
+
ids = ids.join ('-');
|
507
|
+
}
|
508
|
+
const request = {
|
509
|
+
'pair': ids,
|
510
|
+
};
|
511
|
+
const tickers = await this.publicGetTickerPair (this.extend (request, params));
|
512
|
+
const result = {};
|
513
|
+
const keys = Object.keys (tickers);
|
514
|
+
for (let k = 0; k < keys.length; k++) {
|
515
|
+
const id = keys[k];
|
516
|
+
const ticker = tickers[id];
|
517
|
+
const market = this.safeMarket (id);
|
518
|
+
const symbol = market['symbol'];
|
519
|
+
result[symbol] = this.parseTicker (ticker, market);
|
520
|
+
}
|
521
|
+
return this.filterByArray (result, 'symbol', symbols);
|
522
|
+
}
|
523
|
+
|
524
|
+
async fetchTicker (symbol, params = {}) {
|
525
|
+
const tickers = await this.fetchTickers ([ symbol ], params);
|
526
|
+
return tickers[symbol];
|
527
|
+
}
|
528
|
+
|
529
|
+
parseTrade (trade, market = undefined) {
|
530
|
+
//
|
531
|
+
// fetchTrades (public)
|
532
|
+
//
|
533
|
+
// {
|
534
|
+
// "type":"bid",
|
535
|
+
// "price":0.14046179,
|
536
|
+
// "amount":0.001,
|
537
|
+
// "tid":200256901,
|
538
|
+
// "timestamp":1649861004
|
539
|
+
// }
|
540
|
+
//
|
541
|
+
// fetchMyTrades (private)
|
542
|
+
//
|
543
|
+
// {
|
544
|
+
// "pair":"doge_usdt",
|
545
|
+
// "type":"sell",
|
546
|
+
// "amount":139,
|
547
|
+
// "rate":0.139,
|
548
|
+
// "order_id":"2101103631773172",
|
549
|
+
// "is_your_order":1,
|
550
|
+
// "timestamp":"1649861561"
|
551
|
+
// }
|
552
|
+
//
|
553
|
+
const timestamp = this.safeTimestamp (trade, 'timestamp');
|
554
|
+
let side = this.safeString (trade, 'type');
|
555
|
+
if (side === 'ask') {
|
556
|
+
side = 'sell';
|
557
|
+
} else if (side === 'bid') {
|
558
|
+
side = 'buy';
|
559
|
+
}
|
560
|
+
const priceString = this.safeString2 (trade, 'rate', 'price');
|
561
|
+
const id = this.safeString2 (trade, 'trade_id', 'tid');
|
562
|
+
const order = this.safeString (trade, 'order_id');
|
563
|
+
const marketId = this.safeString (trade, 'pair');
|
564
|
+
const symbol = this.safeSymbol (marketId, market);
|
565
|
+
const amountString = this.safeString (trade, 'amount');
|
566
|
+
// arguments for calculateFee (need to be numbers)
|
567
|
+
const price = this.parseNumber (priceString);
|
568
|
+
const amount = this.parseNumber (amountString);
|
569
|
+
const type = 'limit'; // all trades are still limit trades
|
570
|
+
let fee = undefined;
|
571
|
+
const feeCostString = this.safeNumber (trade, 'commission');
|
572
|
+
if (feeCostString !== undefined) {
|
573
|
+
const feeCurrencyId = this.safeString (trade, 'commissionCurrency');
|
574
|
+
const feeCurrencyCode = this.safeCurrencyCode (feeCurrencyId);
|
575
|
+
fee = {
|
576
|
+
'cost': feeCostString,
|
577
|
+
'currency': feeCurrencyCode,
|
578
|
+
};
|
579
|
+
}
|
580
|
+
const isYourOrder = this.safeValue (trade, 'is_your_order');
|
581
|
+
if (isYourOrder !== undefined) {
|
582
|
+
if (fee === undefined) {
|
583
|
+
const feeInNumbers = this.calculateFee (symbol, type, side, amount, price, 'taker');
|
584
|
+
fee = {
|
585
|
+
'currency': this.safeString (feeInNumbers, 'currency'),
|
586
|
+
'cost': this.safeString (feeInNumbers, 'cost'),
|
587
|
+
'rate': this.safeString (feeInNumbers, 'rate'),
|
588
|
+
};
|
589
|
+
}
|
590
|
+
}
|
591
|
+
return this.safeTrade ({
|
592
|
+
'id': id,
|
593
|
+
'order': order,
|
594
|
+
'timestamp': timestamp,
|
595
|
+
'datetime': this.iso8601 (timestamp),
|
596
|
+
'symbol': symbol,
|
597
|
+
'type': type,
|
598
|
+
'side': side,
|
599
|
+
'takerOrMaker': undefined,
|
600
|
+
'price': priceString,
|
601
|
+
'amount': amountString,
|
602
|
+
'cost': undefined,
|
603
|
+
'fee': fee,
|
604
|
+
'info': trade,
|
605
|
+
}, market);
|
606
|
+
}
|
607
|
+
|
608
|
+
async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) {
|
609
|
+
await this.loadMarkets ();
|
610
|
+
const market = this.market (symbol);
|
611
|
+
const request = {
|
612
|
+
'pair': market['id'],
|
613
|
+
};
|
614
|
+
if (limit !== undefined) {
|
615
|
+
request['limit'] = limit;
|
616
|
+
}
|
617
|
+
const response = await this.publicGetTradesPair (this.extend (request, params));
|
618
|
+
//
|
619
|
+
// {
|
620
|
+
// "doge_usdt": [
|
621
|
+
// {
|
622
|
+
// "type":"ask",
|
623
|
+
// "price":0.13956743,
|
624
|
+
// "amount":0.0008,
|
625
|
+
// "tid":200256900,
|
626
|
+
// "timestamp":1649860521
|
627
|
+
// },
|
628
|
+
// ]
|
629
|
+
// }
|
630
|
+
//
|
631
|
+
if (Array.isArray (response)) {
|
632
|
+
const numElements = response.length;
|
633
|
+
if (numElements === 0) {
|
634
|
+
return [];
|
635
|
+
}
|
636
|
+
}
|
637
|
+
const result = this.safeValue (response, market['id'], []);
|
638
|
+
return this.parseTrades (result, market, since, limit);
|
639
|
+
}
|
640
|
+
|
641
|
+
async fetchTradingFees (params = {}) {
|
642
|
+
await this.loadMarkets ();
|
643
|
+
const response = await this.publicGetInfo (params);
|
644
|
+
//
|
645
|
+
// {
|
646
|
+
// "server_time":1615856752,
|
647
|
+
// "pairs":{
|
648
|
+
// "ltc_btc":{
|
649
|
+
// "decimal_places":8,
|
650
|
+
// "min_price":0.00000001,
|
651
|
+
// "max_price":10000,
|
652
|
+
// "min_amount":0.0001,
|
653
|
+
// "min_total":0.0001,
|
654
|
+
// "hidden":0,
|
655
|
+
// "fee":0.2,
|
656
|
+
// "fee_buyer":0.2,
|
657
|
+
// "fee_seller":0.2
|
658
|
+
// },
|
659
|
+
// ...
|
660
|
+
// },
|
661
|
+
// }
|
662
|
+
//
|
663
|
+
const pairs = this.safeValue (response, 'pairs');
|
664
|
+
const marketIds = Object.keys (pairs);
|
665
|
+
const result = {};
|
666
|
+
for (let i = 0; i < marketIds.length; i++) {
|
667
|
+
const marketId = marketIds[i];
|
668
|
+
const pair = this.safeValue (pairs, marketId, {});
|
669
|
+
const symbol = this.safeSymbol (marketId, undefined, '_');
|
670
|
+
const takerString = this.safeString (pair, 'fee_buyer');
|
671
|
+
const makerString = this.safeString (pair, 'fee_seller');
|
672
|
+
const taker = this.parseNumber (Precise.stringDiv (takerString, '100'));
|
673
|
+
const maker = this.parseNumber (Precise.stringDiv (makerString, '100'));
|
674
|
+
result[symbol] = {
|
675
|
+
'info': pair,
|
676
|
+
'symbol': symbol,
|
677
|
+
'taker': taker,
|
678
|
+
'maker': maker,
|
679
|
+
'percentage': true,
|
680
|
+
'tierBased': false,
|
681
|
+
};
|
682
|
+
}
|
683
|
+
return result;
|
684
|
+
}
|
685
|
+
|
686
|
+
async createOrder (symbol, type, side, amount, price = undefined, params = {}) {
|
687
|
+
if (type === 'market') {
|
688
|
+
throw new ExchangeError (this.id + ' createOrder() allows limit orders only');
|
689
|
+
}
|
690
|
+
await this.loadMarkets ();
|
691
|
+
const market = this.market (symbol);
|
692
|
+
const request = {
|
693
|
+
'pair': market['id'],
|
694
|
+
'type': side,
|
695
|
+
'amount': this.amountToPrecision (symbol, amount),
|
696
|
+
'rate': this.priceToPrecision (symbol, price),
|
697
|
+
};
|
698
|
+
const response = await this.privatePostTrade (this.extend (request, params));
|
699
|
+
//
|
700
|
+
// {
|
701
|
+
// "success":1,
|
702
|
+
// "return": {
|
703
|
+
// "received":0,
|
704
|
+
// "remains":10,
|
705
|
+
// "order_id":1101103635125179,
|
706
|
+
// "funds": {
|
707
|
+
// "usdt":27.84756553,
|
708
|
+
// "usdttrc20":0,
|
709
|
+
// "doge":19.98327206
|
710
|
+
// },
|
711
|
+
// "funds_incl_orders": {
|
712
|
+
// "usdt":30.35256553,
|
713
|
+
// "usdttrc20":0,
|
714
|
+
// "doge":19.98327206
|
715
|
+
// },
|
716
|
+
// "server_time":1650114256
|
717
|
+
// }
|
718
|
+
// }
|
719
|
+
//
|
720
|
+
const result = this.safeValue (response, 'return');
|
721
|
+
return this.parseOrder (result, market);
|
722
|
+
}
|
723
|
+
|
724
|
+
async cancelOrder (id, symbol = undefined, params = {}) {
|
725
|
+
await this.loadMarkets ();
|
726
|
+
const request = {
|
727
|
+
'order_id': parseInt (id),
|
728
|
+
};
|
729
|
+
const response = await this.privatePostCancelOrder (this.extend (request, params));
|
730
|
+
//
|
731
|
+
// {
|
732
|
+
// "success":1,
|
733
|
+
// "return": {
|
734
|
+
// "order_id":1101103632552304,
|
735
|
+
// "funds": {
|
736
|
+
// "usdt":30.71055443,
|
737
|
+
// "usdttrc20":0,
|
738
|
+
// "doge":9.98327206
|
739
|
+
// },
|
740
|
+
// "funds_incl_orders": {
|
741
|
+
// "usdt":31.81275443,
|
742
|
+
// "usdttrc20":0,
|
743
|
+
// "doge":9.98327206
|
744
|
+
// },
|
745
|
+
// "server_time":1649918298
|
746
|
+
// }
|
747
|
+
// }
|
748
|
+
//
|
749
|
+
const result = this.safeValue (response, 'return', {});
|
750
|
+
return this.parseOrder (result);
|
751
|
+
}
|
752
|
+
|
753
|
+
parseOrderStatus (status) {
|
754
|
+
const statuses = {
|
755
|
+
'0': 'open',
|
756
|
+
'1': 'closed',
|
757
|
+
'2': 'canceled',
|
758
|
+
'3': 'open', // or partially-filled and canceled? https://github.com/ccxt/ccxt/issues/1594
|
759
|
+
};
|
760
|
+
return this.safeString (statuses, status, status);
|
761
|
+
}
|
762
|
+
|
763
|
+
parseOrder (order, market = undefined) {
|
764
|
+
//
|
765
|
+
// createOrder (private)
|
766
|
+
//
|
767
|
+
// {
|
768
|
+
// "received":0,
|
769
|
+
// "remains":10,
|
770
|
+
// "order_id":1101103635125179,
|
771
|
+
// "funds": {
|
772
|
+
// "usdt":27.84756553,
|
773
|
+
// "usdttrc20":0,
|
774
|
+
// "doge":19.98327206
|
775
|
+
// },
|
776
|
+
// "funds_incl_orders": {
|
777
|
+
// "usdt":30.35256553,
|
778
|
+
// "usdttrc20":0,
|
779
|
+
// "doge":19.98327206
|
780
|
+
// },
|
781
|
+
// "server_time":1650114256
|
782
|
+
// }
|
783
|
+
//
|
784
|
+
// fetchOrder (private)
|
785
|
+
//
|
786
|
+
// {
|
787
|
+
// "id: "1101103635103335", // id-field is manually added in fetchOrder () from exchange response id-order dictionary structure
|
788
|
+
// "pair":"doge_usdt",
|
789
|
+
// "type":"buy",
|
790
|
+
// "start_amount":10,
|
791
|
+
// "amount":10,
|
792
|
+
// "rate":0.05,
|
793
|
+
// "timestamp_created":"1650112553",
|
794
|
+
// "status":0
|
795
|
+
// }
|
796
|
+
//
|
797
|
+
// fetchOpenOrders (private)
|
798
|
+
//
|
799
|
+
// {
|
800
|
+
// "id":"1101103635103335", // id-field is manually added in fetchOpenOrders () from exchange response id-order dictionary structure
|
801
|
+
// "pair":"doge_usdt",
|
802
|
+
// "type":"buy",
|
803
|
+
// "amount":10,
|
804
|
+
// "rate":0.05,
|
805
|
+
// "timestamp_created":"1650112553",
|
806
|
+
// "status":0
|
807
|
+
// }
|
808
|
+
//
|
809
|
+
// cancelOrder (private)
|
810
|
+
//
|
811
|
+
// {
|
812
|
+
// "order_id":1101103634000197,
|
813
|
+
// "funds": {
|
814
|
+
// "usdt":31.81275443,
|
815
|
+
// "usdttrc20":0,
|
816
|
+
// "doge":9.98327206
|
817
|
+
// },
|
818
|
+
// "funds_incl_orders": {
|
819
|
+
// "usdt":31.81275443,
|
820
|
+
// "usdttrc20":0,
|
821
|
+
// "doge":9.98327206
|
822
|
+
// }
|
823
|
+
// }
|
824
|
+
//
|
825
|
+
let id = this.safeString2 (order, 'id', 'order_id');
|
826
|
+
let status = this.parseOrderStatus (this.safeString (order, 'status', 'open'));
|
827
|
+
if (id === '0') {
|
828
|
+
id = this.safeString (order, 'init_order_id');
|
829
|
+
status = 'closed';
|
830
|
+
}
|
831
|
+
const timestamp = this.safeTimestamp2 (order, 'timestamp_created', 'server_time');
|
832
|
+
const marketId = this.safeString (order, 'pair');
|
833
|
+
const symbol = this.safeSymbol (marketId, market);
|
834
|
+
const amount = this.safeString (order, 'start_amount');
|
835
|
+
const remaining = this.safeString2 (order, 'amount', 'remains');
|
836
|
+
const filled = this.safeString (order, 'received', '0.0');
|
837
|
+
const price = this.safeString (order, 'rate');
|
838
|
+
const fee = undefined;
|
839
|
+
const type = 'limit';
|
840
|
+
const side = this.safeString (order, 'type');
|
841
|
+
return this.safeOrder ({
|
842
|
+
'info': order,
|
843
|
+
'id': id,
|
844
|
+
'clientOrderId': undefined,
|
845
|
+
'symbol': symbol,
|
846
|
+
'timestamp': timestamp,
|
847
|
+
'datetime': this.iso8601 (timestamp),
|
848
|
+
'lastTradeTimestamp': undefined,
|
849
|
+
'type': type,
|
850
|
+
'timeInForce': undefined,
|
851
|
+
'postOnly': undefined,
|
852
|
+
'side': side,
|
853
|
+
'price': price,
|
854
|
+
'stopPrice': undefined,
|
855
|
+
'cost': undefined,
|
856
|
+
'amount': amount,
|
857
|
+
'remaining': remaining,
|
858
|
+
'filled': filled,
|
859
|
+
'status': status,
|
860
|
+
'fee': fee,
|
861
|
+
'average': undefined,
|
862
|
+
'trades': undefined,
|
863
|
+
}, market);
|
864
|
+
}
|
865
|
+
|
866
|
+
async fetchOrder (id, symbol = undefined, params = {}) {
|
867
|
+
await this.loadMarkets ();
|
868
|
+
const request = {
|
869
|
+
'order_id': parseInt (id),
|
870
|
+
};
|
871
|
+
const response = await this.privatePostOrderInfo (this.extend (request, params));
|
872
|
+
id = id.toString ();
|
873
|
+
const orders = this.safeValue (response, 'return', {});
|
874
|
+
//
|
875
|
+
// {
|
876
|
+
// "success":1,
|
877
|
+
// "return": {
|
878
|
+
// "1101103635103335": {
|
879
|
+
// "pair":"doge_usdt",
|
880
|
+
// "type":"buy",
|
881
|
+
// "start_amount":10,
|
882
|
+
// "amount":10,
|
883
|
+
// "rate":0.05,
|
884
|
+
// "timestamp_created":"1650112553",
|
885
|
+
// "status":0
|
886
|
+
// }
|
887
|
+
// }
|
888
|
+
// }
|
889
|
+
//
|
890
|
+
return this.parseOrder (this.extend ({ 'id': id }, orders[id]));
|
891
|
+
}
|
892
|
+
|
893
|
+
async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
894
|
+
if (symbol === undefined) {
|
895
|
+
throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol argument');
|
896
|
+
}
|
897
|
+
await this.loadMarkets ();
|
898
|
+
const request = {};
|
899
|
+
const market = undefined;
|
900
|
+
if (symbol !== undefined) {
|
901
|
+
const market = this.market (symbol);
|
902
|
+
request['pair'] = market['id'];
|
903
|
+
}
|
904
|
+
const response = await this.privatePostActiveOrders (this.extend (request, params));
|
905
|
+
//
|
906
|
+
// {
|
907
|
+
// "success":1,
|
908
|
+
// "return": {
|
909
|
+
// "1101103634006799": {
|
910
|
+
// "pair":"doge_usdt",
|
911
|
+
// "type":"buy",
|
912
|
+
// "amount":10,
|
913
|
+
// "rate":0.1,
|
914
|
+
// "timestamp_created":"1650034937",
|
915
|
+
// "status":0
|
916
|
+
// },
|
917
|
+
// "1101103634006738": {
|
918
|
+
// "pair":"doge_usdt",
|
919
|
+
// "type":"buy",
|
920
|
+
// "amount":10,
|
921
|
+
// "rate":0.1,
|
922
|
+
// "timestamp_created":"1650034932",
|
923
|
+
// "status":0
|
924
|
+
// }
|
925
|
+
// }
|
926
|
+
// }
|
927
|
+
//
|
928
|
+
const result = this.safeValue (response, 'return', {});
|
929
|
+
return this.parseOrders (result, market, since, limit);
|
930
|
+
}
|
931
|
+
|
932
|
+
async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
933
|
+
if (symbol === undefined) {
|
934
|
+
throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a `symbol` argument');
|
935
|
+
}
|
936
|
+
await this.loadMarkets ();
|
937
|
+
const market = this.market (symbol);
|
938
|
+
// some derived classes use camelcase notation for request fields
|
939
|
+
const request = {
|
940
|
+
// 'from': 123456789, // trade ID, from which the display starts numerical 0 (test result: liqui ignores this field)
|
941
|
+
// 'count': 1000, // the number of trades for display numerical, default = 1000
|
942
|
+
// 'from_id': trade ID, from which the display starts numerical 0
|
943
|
+
// 'end_id': trade ID on which the display ends numerical ∞
|
944
|
+
// 'order': 'ASC', // sorting, default = DESC (test result: liqui ignores this field, most recent trade always goes last)
|
945
|
+
// 'since': 1234567890, // UTC start time, default = 0 (test result: liqui ignores this field)
|
946
|
+
// 'end': 1234567890, // UTC end time, default = ∞ (test result: liqui ignores this field)
|
947
|
+
'pair': market['id'],
|
948
|
+
};
|
949
|
+
if (limit !== undefined) {
|
950
|
+
request['count'] = parseInt (limit);
|
951
|
+
}
|
952
|
+
if (since !== undefined) {
|
953
|
+
request['since'] = parseInt (since / 1000);
|
954
|
+
}
|
955
|
+
const response = await this.privatePostTradeHistory (this.extend (request, params));
|
956
|
+
//
|
957
|
+
// {
|
958
|
+
// "success":1,
|
959
|
+
// "return": {
|
960
|
+
// "200257004": {
|
961
|
+
// "pair":"doge_usdt",
|
962
|
+
// "type":"sell",
|
963
|
+
// "amount":139,
|
964
|
+
// "rate":0.139,
|
965
|
+
// "order_id":"2101103631773172",
|
966
|
+
// "is_your_order":1,
|
967
|
+
// "timestamp":"1649861561"
|
968
|
+
// }
|
969
|
+
// }
|
970
|
+
// }
|
971
|
+
//
|
972
|
+
const trades = this.safeValue (response, 'return', {});
|
973
|
+
const ids = Object.keys (trades);
|
974
|
+
const result = [];
|
975
|
+
for (let i = 0; i < ids.length; i++) {
|
976
|
+
const id = ids[i];
|
977
|
+
const trade = this.parseTrade (this.extend (trades[id], {
|
978
|
+
'trade_id': id,
|
979
|
+
}), market);
|
980
|
+
result.push (trade);
|
981
|
+
}
|
982
|
+
return this.filterBySymbolSinceLimit (result, market['symbol'], since, limit);
|
983
|
+
}
|
984
|
+
|
985
|
+
async createDepositAddress (code, params = {}) {
|
986
|
+
const request = {
|
987
|
+
'need_new': 1,
|
988
|
+
};
|
989
|
+
const response = await this.fetchDepositAddress (code, this.extend (request, params));
|
990
|
+
const address = this.safeString (response, 'address');
|
991
|
+
this.checkAddress (address);
|
992
|
+
return {
|
993
|
+
'currency': code,
|
994
|
+
'address': address,
|
995
|
+
'tag': undefined,
|
996
|
+
'info': response['info'],
|
997
|
+
};
|
998
|
+
}
|
999
|
+
|
1000
|
+
async fetchDepositAddress (code, params = {}) {
|
1001
|
+
await this.loadMarkets ();
|
1002
|
+
const currency = this.currency (code);
|
1003
|
+
const request = {
|
1004
|
+
'coinName': currency['id'],
|
1005
|
+
'need_new': 0,
|
1006
|
+
};
|
1007
|
+
const response = await this.privatePostGetDepositAddress (this.extend (request, params));
|
1008
|
+
const address = this.safeString (response['return'], 'address');
|
1009
|
+
this.checkAddress (address);
|
1010
|
+
return {
|
1011
|
+
'currency': code,
|
1012
|
+
'address': address,
|
1013
|
+
'tag': undefined,
|
1014
|
+
'network': undefined,
|
1015
|
+
'info': response,
|
1016
|
+
};
|
1017
|
+
}
|
1018
|
+
|
1019
|
+
async withdraw (code, amount, address, tag = undefined, params = {}) {
|
1020
|
+
[ tag, params ] = this.handleWithdrawTagAndParams (tag, params);
|
1021
|
+
this.checkAddress (address);
|
1022
|
+
await this.loadMarkets ();
|
1023
|
+
const currency = this.currency (code);
|
1024
|
+
const request = {
|
1025
|
+
'coinName': currency['id'],
|
1026
|
+
'amount': amount,
|
1027
|
+
'address': address,
|
1028
|
+
};
|
1029
|
+
// no docs on the tag, yet...
|
1030
|
+
if (tag !== undefined) {
|
1031
|
+
throw new ExchangeError (this.id + ' withdraw() does not support the tag argument yet due to a lack of docs on withdrawing with tag/memo on behalf of the exchange.');
|
1032
|
+
}
|
1033
|
+
const response = await this.privatePostWithdrawCoinsToAddress (this.extend (request, params));
|
1034
|
+
return {
|
1035
|
+
'info': response,
|
1036
|
+
'id': undefined,
|
1037
|
+
};
|
1038
|
+
}
|
1039
|
+
|
1040
|
+
sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
1041
|
+
let url = this.urls['api'][api];
|
1042
|
+
const query = this.omit (params, this.extractParams (path));
|
1043
|
+
if (api === 'private') {
|
1044
|
+
this.checkRequiredCredentials ();
|
1045
|
+
const nonce = this.nonce ();
|
1046
|
+
body = this.urlencode (this.extend ({
|
1047
|
+
'nonce': nonce,
|
1048
|
+
'method': path,
|
1049
|
+
}, query));
|
1050
|
+
const signature = this.hmac (this.encode (body), this.encode (this.secret), 'sha512');
|
1051
|
+
headers = {
|
1052
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
1053
|
+
'Key': this.apiKey,
|
1054
|
+
'Sign': signature,
|
1055
|
+
};
|
1056
|
+
} else if (api === 'public') {
|
1057
|
+
url += '/' + this.version + '/' + this.implodeParams (path, params);
|
1058
|
+
if (Object.keys (query).length) {
|
1059
|
+
url += '?' + this.urlencode (query);
|
1060
|
+
}
|
1061
|
+
} else {
|
1062
|
+
url += '/' + this.implodeParams (path, params);
|
1063
|
+
if (method === 'GET') {
|
1064
|
+
if (Object.keys (query).length) {
|
1065
|
+
url += '?' + this.urlencode (query);
|
1066
|
+
}
|
1067
|
+
} else {
|
1068
|
+
if (Object.keys (query).length) {
|
1069
|
+
body = this.json (query);
|
1070
|
+
headers = {
|
1071
|
+
'Content-Type': 'application/json',
|
1072
|
+
};
|
1073
|
+
}
|
1074
|
+
}
|
1075
|
+
}
|
1076
|
+
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
1077
|
+
}
|
1078
|
+
|
1079
|
+
handleErrors (httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
1080
|
+
if (response === undefined) {
|
1081
|
+
return; // fallback to default error handler
|
1082
|
+
}
|
1083
|
+
if ('success' in response) {
|
1084
|
+
//
|
1085
|
+
// 1 - Liqui only returns the integer 'success' key from their private API
|
1086
|
+
//
|
1087
|
+
// { "success": 1, ... } httpCode === 200
|
1088
|
+
// { "success": 0, ... } httpCode === 200
|
1089
|
+
//
|
1090
|
+
// 2 - However, exchanges derived from Liqui, can return non-integers
|
1091
|
+
//
|
1092
|
+
// It can be a numeric string
|
1093
|
+
// { "sucesss": "1", ... }
|
1094
|
+
// { "sucesss": "0", ... }, httpCode >= 200 (can be 403, 502, etc)
|
1095
|
+
//
|
1096
|
+
// Or just a string
|
1097
|
+
// { "success": "true", ... }
|
1098
|
+
// { "success": "false", ... }, httpCode >= 200
|
1099
|
+
//
|
1100
|
+
// Or a boolean
|
1101
|
+
// { "success": true, ... }
|
1102
|
+
// { "success": false, ... }, httpCode >= 200
|
1103
|
+
//
|
1104
|
+
// 3 - Oversimplified, Python PEP8 forbids comparison operator (===) of different types
|
1105
|
+
//
|
1106
|
+
// 4 - We do not want to copy-paste and duplicate the code of this handler to other exchanges derived from Liqui
|
1107
|
+
//
|
1108
|
+
// To cover points 1, 2, 3 and 4 combined this handler should work like this:
|
1109
|
+
//
|
1110
|
+
let success = this.safeValue (response, 'success', false);
|
1111
|
+
if (typeof success === 'string') {
|
1112
|
+
if ((success === 'true') || (success === '1')) {
|
1113
|
+
success = true;
|
1114
|
+
} else {
|
1115
|
+
success = false;
|
1116
|
+
}
|
1117
|
+
}
|
1118
|
+
if (!success) {
|
1119
|
+
const code = this.safeString (response, 'code');
|
1120
|
+
const message = this.safeString (response, 'error');
|
1121
|
+
const feedback = this.id + ' ' + body;
|
1122
|
+
this.throwExactlyMatchedException (this.exceptions['exact'], code, feedback);
|
1123
|
+
this.throwExactlyMatchedException (this.exceptions['exact'], message, feedback);
|
1124
|
+
this.throwBroadlyMatchedException (this.exceptions['broad'], message, feedback);
|
1125
|
+
throw new ExchangeError (feedback); // unknown message
|
1126
|
+
}
|
1127
|
+
}
|
1128
|
+
}
|
1129
|
+
};
|