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/coincheck.js
ADDED
@@ -0,0 +1,755 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
// ---------------------------------------------------------------------------
|
4
|
+
|
5
|
+
const Exchange = require ('./base/Exchange');
|
6
|
+
const { BadSymbol, ExchangeError, AuthenticationError } = require ('./base/errors');
|
7
|
+
|
8
|
+
// ---------------------------------------------------------------------------
|
9
|
+
|
10
|
+
module.exports = class coincheck extends Exchange {
|
11
|
+
describe () {
|
12
|
+
return this.deepExtend (super.describe (), {
|
13
|
+
'id': 'coincheck',
|
14
|
+
'name': 'coincheck',
|
15
|
+
'countries': [ 'JP', 'ID' ],
|
16
|
+
'rateLimit': 1500,
|
17
|
+
'has': {
|
18
|
+
'CORS': undefined,
|
19
|
+
'spot': true,
|
20
|
+
'margin': false,
|
21
|
+
'swap': false,
|
22
|
+
'future': false,
|
23
|
+
'option': false,
|
24
|
+
'addMargin': false,
|
25
|
+
'cancelOrder': true,
|
26
|
+
'createOrder': true,
|
27
|
+
'createReduceOnlyOrder': false,
|
28
|
+
'fetchBalance': true,
|
29
|
+
'fetchBorrowRate': false,
|
30
|
+
'fetchBorrowRateHistories': false,
|
31
|
+
'fetchBorrowRateHistory': false,
|
32
|
+
'fetchBorrowRates': false,
|
33
|
+
'fetchBorrowRatesPerSymbol': false,
|
34
|
+
'fetchDeposits': true,
|
35
|
+
'fetchFundingHistory': false,
|
36
|
+
'fetchFundingRate': false,
|
37
|
+
'fetchFundingRateHistory': false,
|
38
|
+
'fetchFundingRates': false,
|
39
|
+
'fetchIndexOHLCV': false,
|
40
|
+
'fetchLeverage': false,
|
41
|
+
'fetchMarkOHLCV': false,
|
42
|
+
'fetchMyTrades': true,
|
43
|
+
'fetchOpenOrders': true,
|
44
|
+
'fetchOrderBook': true,
|
45
|
+
'fetchPosition': false,
|
46
|
+
'fetchPositions': false,
|
47
|
+
'fetchPositionsRisk': false,
|
48
|
+
'fetchPremiumIndexOHLCV': false,
|
49
|
+
'fetchTicker': true,
|
50
|
+
'fetchTrades': true,
|
51
|
+
'fetchTradingFee': false,
|
52
|
+
'fetchTradingFees': true,
|
53
|
+
'fetchWithdrawals': true,
|
54
|
+
'reduceMargin': false,
|
55
|
+
'setLeverage': false,
|
56
|
+
'setMarginMode': false,
|
57
|
+
'setPositionMode': false,
|
58
|
+
},
|
59
|
+
'urls': {
|
60
|
+
'logo': 'https://user-images.githubusercontent.com/51840849/87182088-1d6d6380-c2ec-11ea-9c64-8ab9f9b289f5.jpg',
|
61
|
+
'api': 'https://coincheck.com/api',
|
62
|
+
'www': 'https://coincheck.com',
|
63
|
+
'doc': 'https://coincheck.com/documents/exchange/api',
|
64
|
+
'fees': [
|
65
|
+
'https://coincheck.com/exchange/fee',
|
66
|
+
'https://coincheck.com/info/fee',
|
67
|
+
],
|
68
|
+
},
|
69
|
+
'api': {
|
70
|
+
'public': {
|
71
|
+
'get': [
|
72
|
+
'exchange/orders/rate',
|
73
|
+
'order_books',
|
74
|
+
'rate/{pair}',
|
75
|
+
'ticker',
|
76
|
+
'trades',
|
77
|
+
],
|
78
|
+
},
|
79
|
+
'private': {
|
80
|
+
'get': [
|
81
|
+
'accounts',
|
82
|
+
'accounts/balance',
|
83
|
+
'accounts/leverage_balance',
|
84
|
+
'bank_accounts',
|
85
|
+
'deposit_money',
|
86
|
+
'exchange/orders/opens',
|
87
|
+
'exchange/orders/transactions',
|
88
|
+
'exchange/orders/transactions_pagination',
|
89
|
+
'exchange/leverage/positions',
|
90
|
+
'lending/borrows/matches',
|
91
|
+
'send_money',
|
92
|
+
'withdraws',
|
93
|
+
],
|
94
|
+
'post': [
|
95
|
+
'bank_accounts',
|
96
|
+
'deposit_money/{id}/fast',
|
97
|
+
'exchange/orders',
|
98
|
+
'exchange/transfers/to_leverage',
|
99
|
+
'exchange/transfers/from_leverage',
|
100
|
+
'lending/borrows',
|
101
|
+
'lending/borrows/{id}/repay',
|
102
|
+
'send_money',
|
103
|
+
'withdraws',
|
104
|
+
],
|
105
|
+
'delete': [
|
106
|
+
'bank_accounts/{id}',
|
107
|
+
'exchange/orders/{id}',
|
108
|
+
'withdraws/{id}',
|
109
|
+
],
|
110
|
+
},
|
111
|
+
},
|
112
|
+
'markets': {
|
113
|
+
'BTC/JPY': { 'id': 'btc_jpy', 'symbol': 'BTC/JPY', 'base': 'BTC', 'quote': 'JPY', 'baseId': 'btc', 'quoteId': 'jpy', 'type': 'spot', 'spot': true }, // the only real pair
|
114
|
+
// 'ETH/JPY': { 'id': 'eth_jpy', 'symbol': 'ETH/JPY', 'base': 'ETH', 'quote': 'JPY', 'baseId': 'eth', 'quoteId': 'jpy' },
|
115
|
+
'ETC/JPY': { 'id': 'etc_jpy', 'symbol': 'ETC/JPY', 'base': 'ETC', 'quote': 'JPY', 'baseId': 'etc', 'quoteId': 'jpy', 'type': 'spot', 'spot': true },
|
116
|
+
// 'DAO/JPY': { 'id': 'dao_jpy', 'symbol': 'DAO/JPY', 'base': 'DAO', 'quote': 'JPY', 'baseId': 'dao', 'quoteId': 'jpy' },
|
117
|
+
// 'LSK/JPY': { 'id': 'lsk_jpy', 'symbol': 'LSK/JPY', 'base': 'LSK', 'quote': 'JPY', 'baseId': 'lsk', 'quoteId': 'jpy' },
|
118
|
+
'FCT/JPY': { 'id': 'fct_jpy', 'symbol': 'FCT/JPY', 'base': 'FCT', 'quote': 'JPY', 'baseId': 'fct', 'quoteId': 'jpy', 'type': 'spot', 'spot': true },
|
119
|
+
'MONA/JPY': { 'id': 'mona_jpy', 'symbol': 'MONA/JPY', 'base': 'MONA', 'quote': 'JPY', 'baseId': 'mona', 'quoteId': 'jpy', 'type': 'spot', 'spot': true },
|
120
|
+
// 'XMR/JPY': { 'id': 'xmr_jpy', 'symbol': 'XMR/JPY', 'base': 'XMR', 'quote': 'JPY', 'baseId': 'xmr', 'quoteId': 'jpy' },
|
121
|
+
// 'REP/JPY': { 'id': 'rep_jpy', 'symbol': 'REP/JPY', 'base': 'REP', 'quote': 'JPY', 'baseId': 'rep', 'quoteId': 'jpy' },
|
122
|
+
// 'XRP/JPY': { 'id': 'xrp_jpy', 'symbol': 'XRP/JPY', 'base': 'XRP', 'quote': 'JPY', 'baseId': 'xrp', 'quoteId': 'jpy' },
|
123
|
+
// 'ZEC/JPY': { 'id': 'zec_jpy', 'symbol': 'ZEC/JPY', 'base': 'ZEC', 'quote': 'JPY', 'baseId': 'zec', 'quoteId': 'jpy' },
|
124
|
+
// 'XEM/JPY': { 'id': 'xem_jpy', 'symbol': 'XEM/JPY', 'base': 'XEM', 'quote': 'JPY', 'baseId': 'xem', 'quoteId': 'jpy' },
|
125
|
+
// 'LTC/JPY': { 'id': 'ltc_jpy', 'symbol': 'LTC/JPY', 'base': 'LTC', 'quote': 'JPY', 'baseId': 'ltc', 'quoteId': 'jpy' },
|
126
|
+
// 'DASH/JPY': { 'id': 'dash_jpy', 'symbol': 'DASH/JPY', 'base': 'DASH', 'quote': 'JPY', 'baseId': 'dash', 'quoteId': 'jpy' },
|
127
|
+
// 'ETH/BTC': { 'id': 'eth_btc', 'symbol': 'ETH/BTC', 'base': 'ETH', 'quote': 'BTC', 'baseId': 'eth', 'quoteId': 'btc' },
|
128
|
+
'ETC/BTC': { 'id': 'etc_btc', 'symbol': 'ETC/BTC', 'base': 'ETC', 'quote': 'BTC', 'baseId': 'etc', 'quoteId': 'btc', 'type': 'spot', 'spot': true },
|
129
|
+
// 'LSK/BTC': { 'id': 'lsk_btc', 'symbol': 'LSK/BTC', 'base': 'LSK', 'quote': 'BTC', 'baseId': 'lsk', 'quoteId': 'btc' },
|
130
|
+
// 'FCT/BTC': { 'id': 'fct_btc', 'symbol': 'FCT/BTC', 'base': 'FCT', 'quote': 'BTC', 'baseId': 'fct', 'quoteId': 'btc' },
|
131
|
+
// 'XMR/BTC': { 'id': 'xmr_btc', 'symbol': 'XMR/BTC', 'base': 'XMR', 'quote': 'BTC', 'baseId': 'xmr', 'quoteId': 'btc' },
|
132
|
+
// 'REP/BTC': { 'id': 'rep_btc', 'symbol': 'REP/BTC', 'base': 'REP', 'quote': 'BTC', 'baseId': 'rep', 'quoteId': 'btc' },
|
133
|
+
// 'XRP/BTC': { 'id': 'xrp_btc', 'symbol': 'XRP/BTC', 'base': 'XRP', 'quote': 'BTC', 'baseId': 'xrp', 'quoteId': 'btc' },
|
134
|
+
// 'ZEC/BTC': { 'id': 'zec_btc', 'symbol': 'ZEC/BTC', 'base': 'ZEC', 'quote': 'BTC', 'baseId': 'zec', 'quoteId': 'btc' },
|
135
|
+
// 'XEM/BTC': { 'id': 'xem_btc', 'symbol': 'XEM/BTC', 'base': 'XEM', 'quote': 'BTC', 'baseId': 'xem', 'quoteId': 'btc' },
|
136
|
+
// 'LTC/BTC': { 'id': 'ltc_btc', 'symbol': 'LTC/BTC', 'base': 'LTC', 'quote': 'BTC', 'baseId': 'ltc', 'quoteId': 'btc' },
|
137
|
+
// 'DASH/BTC': { 'id': 'dash_btc', 'symbol': 'DASH/BTC', 'base': 'DASH', 'quote': 'BTC', 'baseId': 'dash', 'quoteId': 'btc' },
|
138
|
+
},
|
139
|
+
'fees': {
|
140
|
+
'trading': {
|
141
|
+
'tierBased': false,
|
142
|
+
'percentage': true,
|
143
|
+
'maker': this.parseNumber ('0'),
|
144
|
+
'taker': this.parseNumber ('0'),
|
145
|
+
},
|
146
|
+
},
|
147
|
+
'exceptions': {
|
148
|
+
'exact': {
|
149
|
+
'disabled API Key': AuthenticationError, // {"success":false,"error":"disabled API Key"}'
|
150
|
+
'invalid authentication': AuthenticationError, // {"success":false,"error":"invalid authentication"}
|
151
|
+
},
|
152
|
+
'broad': {},
|
153
|
+
},
|
154
|
+
});
|
155
|
+
}
|
156
|
+
|
157
|
+
parseBalance (response) {
|
158
|
+
const result = { 'info': response };
|
159
|
+
const codes = Object.keys (this.currencies);
|
160
|
+
for (let i = 0; i < codes.length; i++) {
|
161
|
+
const code = codes[i];
|
162
|
+
const currency = this.currency (code);
|
163
|
+
const currencyId = currency['id'];
|
164
|
+
if (currencyId in response) {
|
165
|
+
const account = this.account ();
|
166
|
+
const reserved = currencyId + '_reserved';
|
167
|
+
account['free'] = this.safeString (response, currencyId);
|
168
|
+
account['used'] = this.safeString (response, reserved);
|
169
|
+
result[code] = account;
|
170
|
+
}
|
171
|
+
}
|
172
|
+
return this.safeBalance (result);
|
173
|
+
}
|
174
|
+
|
175
|
+
async fetchBalance (params = {}) {
|
176
|
+
await this.loadMarkets ();
|
177
|
+
const response = await this.privateGetAccountsBalance (params);
|
178
|
+
return this.parseBalance (response);
|
179
|
+
}
|
180
|
+
|
181
|
+
async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
182
|
+
await this.loadMarkets ();
|
183
|
+
// Only BTC/JPY is meaningful
|
184
|
+
let market = undefined;
|
185
|
+
if (symbol !== undefined) {
|
186
|
+
market = this.market (symbol);
|
187
|
+
}
|
188
|
+
const response = await this.privateGetExchangeOrdersOpens (params);
|
189
|
+
const rawOrders = this.safeValue (response, 'orders', []);
|
190
|
+
const parsedOrders = this.parseOrders (rawOrders, market, since, limit);
|
191
|
+
const result = [];
|
192
|
+
for (let i = 0; i < parsedOrders.length; i++) {
|
193
|
+
result.push (this.extend (parsedOrders[i], { 'status': 'open' }));
|
194
|
+
}
|
195
|
+
return result;
|
196
|
+
}
|
197
|
+
|
198
|
+
parseOrder (order, market = undefined) {
|
199
|
+
//
|
200
|
+
// fetchOpenOrders
|
201
|
+
//
|
202
|
+
// { id: 202835,
|
203
|
+
// order_type: "buy",
|
204
|
+
// rate: 26890,
|
205
|
+
// pair: "btc_jpy",
|
206
|
+
// pending_amount: "0.5527",
|
207
|
+
// pending_market_buy_amount: null,
|
208
|
+
// stop_loss_rate: null,
|
209
|
+
// created_at: "2015-01-10T05:55:38.000Z" }
|
210
|
+
//
|
211
|
+
// todo: add formats for fetchOrder, fetchClosedOrders here
|
212
|
+
//
|
213
|
+
const id = this.safeString (order, 'id');
|
214
|
+
const side = this.safeString (order, 'order_type');
|
215
|
+
const timestamp = this.parse8601 (this.safeString (order, 'created_at'));
|
216
|
+
const amount = this.safeString (order, 'pending_amount');
|
217
|
+
const remaining = this.safeString (order, 'pending_amount');
|
218
|
+
const price = this.safeString (order, 'rate');
|
219
|
+
const status = undefined;
|
220
|
+
const marketId = this.safeString (order, 'pair');
|
221
|
+
const symbol = this.safeSymbol (marketId, market, '_');
|
222
|
+
return this.safeOrder ({
|
223
|
+
'id': id,
|
224
|
+
'clientOrderId': undefined,
|
225
|
+
'timestamp': timestamp,
|
226
|
+
'datetime': this.iso8601 (timestamp),
|
227
|
+
'lastTradeTimestamp': undefined,
|
228
|
+
'amount': amount,
|
229
|
+
'remaining': remaining,
|
230
|
+
'filled': undefined,
|
231
|
+
'side': side,
|
232
|
+
'type': undefined,
|
233
|
+
'timeInForce': undefined,
|
234
|
+
'postOnly': undefined,
|
235
|
+
'status': status,
|
236
|
+
'symbol': symbol,
|
237
|
+
'price': price,
|
238
|
+
'stopPrice': undefined,
|
239
|
+
'cost': undefined,
|
240
|
+
'fee': undefined,
|
241
|
+
'info': order,
|
242
|
+
'average': undefined,
|
243
|
+
'trades': undefined,
|
244
|
+
}, market);
|
245
|
+
}
|
246
|
+
|
247
|
+
async fetchOrderBook (symbol, limit = undefined, params = {}) {
|
248
|
+
await this.loadMarkets ();
|
249
|
+
const market = this.market (symbol);
|
250
|
+
const request = {
|
251
|
+
'pair': market['id'],
|
252
|
+
};
|
253
|
+
const response = await this.publicGetOrderBooks (this.extend (request, params));
|
254
|
+
return this.parseOrderBook (response, symbol);
|
255
|
+
}
|
256
|
+
|
257
|
+
parseTicker (ticker, market = undefined) {
|
258
|
+
//
|
259
|
+
// {
|
260
|
+
// "last":4192632.0,
|
261
|
+
// "bid":4192496.0,
|
262
|
+
// "ask":4193749.0,
|
263
|
+
// "high":4332000.0,
|
264
|
+
// "low":4101047.0,
|
265
|
+
// "volume":2313.43191762,
|
266
|
+
// "timestamp":1643374115
|
267
|
+
// }
|
268
|
+
//
|
269
|
+
const symbol = this.safeSymbol (undefined, market);
|
270
|
+
const timestamp = this.safeTimestamp (ticker, 'timestamp');
|
271
|
+
const last = this.safeString (ticker, 'last');
|
272
|
+
return this.safeTicker ({
|
273
|
+
'symbol': symbol,
|
274
|
+
'timestamp': timestamp,
|
275
|
+
'datetime': this.iso8601 (timestamp),
|
276
|
+
'high': this.safeString (ticker, 'high'),
|
277
|
+
'low': this.safeString (ticker, 'low'),
|
278
|
+
'bid': this.safeString (ticker, 'bid'),
|
279
|
+
'bidVolume': undefined,
|
280
|
+
'ask': this.safeString (ticker, 'ask'),
|
281
|
+
'askVolume': undefined,
|
282
|
+
'vwap': undefined,
|
283
|
+
'open': undefined,
|
284
|
+
'close': last,
|
285
|
+
'last': last,
|
286
|
+
'previousClose': undefined,
|
287
|
+
'change': undefined,
|
288
|
+
'percentage': undefined,
|
289
|
+
'average': undefined,
|
290
|
+
'baseVolume': this.safeString (ticker, 'volume'),
|
291
|
+
'quoteVolume': undefined,
|
292
|
+
'info': ticker,
|
293
|
+
}, market, false);
|
294
|
+
}
|
295
|
+
|
296
|
+
async fetchTicker (symbol, params = {}) {
|
297
|
+
if (symbol !== 'BTC/JPY') {
|
298
|
+
throw new BadSymbol (this.id + ' fetchTicker() supports BTC/JPY only');
|
299
|
+
}
|
300
|
+
await this.loadMarkets ();
|
301
|
+
const market = this.market (symbol);
|
302
|
+
const request = {
|
303
|
+
'pair': market['id'],
|
304
|
+
};
|
305
|
+
const ticker = await this.publicGetTicker (this.extend (request, params));
|
306
|
+
//
|
307
|
+
// {
|
308
|
+
// "last":4192632.0,
|
309
|
+
// "bid":4192496.0,
|
310
|
+
// "ask":4193749.0,
|
311
|
+
// "high":4332000.0,
|
312
|
+
// "low":4101047.0,
|
313
|
+
// "volume":2313.43191762,
|
314
|
+
// "timestamp":1643374115
|
315
|
+
// }
|
316
|
+
//
|
317
|
+
return this.parseTicker (ticker, market);
|
318
|
+
}
|
319
|
+
|
320
|
+
parseTrade (trade, market = undefined) {
|
321
|
+
//
|
322
|
+
// fetchTrades (public)
|
323
|
+
//
|
324
|
+
// {
|
325
|
+
// "id": "206849494",
|
326
|
+
// "amount": "0.01",
|
327
|
+
// "rate": "5598346.0",
|
328
|
+
// "pair": "btc_jpy",
|
329
|
+
// "order_type": "sell",
|
330
|
+
// "created_at": "2021-12-08T14:10:33.000Z"
|
331
|
+
// }
|
332
|
+
//
|
333
|
+
// fetchMyTrades (private) - example from docs
|
334
|
+
//
|
335
|
+
// {
|
336
|
+
// "id": 38,
|
337
|
+
// "order_id": 49,
|
338
|
+
// "created_at": "2015-11-18T07:02:21.000Z",
|
339
|
+
// "funds": {
|
340
|
+
// "btc": "0.1",
|
341
|
+
// "jpy": "-4096.135"
|
342
|
+
// },
|
343
|
+
// "pair": "btc_jpy",
|
344
|
+
// "rate": "40900.0",
|
345
|
+
// "fee_currency": "JPY",
|
346
|
+
// "fee": "6.135",
|
347
|
+
// "liquidity": "T",
|
348
|
+
// "side": "buy"
|
349
|
+
// }
|
350
|
+
//
|
351
|
+
const timestamp = this.parse8601 (this.safeString (trade, 'created_at'));
|
352
|
+
const id = this.safeString (trade, 'id');
|
353
|
+
const priceString = this.safeString (trade, 'rate');
|
354
|
+
const marketId = this.safeString (trade, 'pair');
|
355
|
+
market = this.safeValue (this.markets_by_id, marketId, market);
|
356
|
+
let symbol = undefined;
|
357
|
+
let baseId = undefined;
|
358
|
+
let quoteId = undefined;
|
359
|
+
if (marketId !== undefined) {
|
360
|
+
if (marketId in this.markets_by_id) {
|
361
|
+
market = this.markets_by_id[marketId];
|
362
|
+
baseId = market['baseId'];
|
363
|
+
quoteId = market['quoteId'];
|
364
|
+
symbol = market['symbol'];
|
365
|
+
} else {
|
366
|
+
const ids = marketId.split ('_');
|
367
|
+
baseId = ids[0];
|
368
|
+
quoteId = ids[1];
|
369
|
+
const base = this.safeCurrencyCode (baseId);
|
370
|
+
const quote = this.safeCurrencyCode (quoteId);
|
371
|
+
symbol = base + '/' + quote;
|
372
|
+
}
|
373
|
+
}
|
374
|
+
if (symbol === undefined) {
|
375
|
+
symbol = this.safeSymbol (undefined, market);
|
376
|
+
}
|
377
|
+
let takerOrMaker = undefined;
|
378
|
+
let amountString = undefined;
|
379
|
+
let costString = undefined;
|
380
|
+
let side = undefined;
|
381
|
+
let fee = undefined;
|
382
|
+
let orderId = undefined;
|
383
|
+
if ('liquidity' in trade) {
|
384
|
+
if (this.safeString (trade, 'liquidity') === 'T') {
|
385
|
+
takerOrMaker = 'taker';
|
386
|
+
} else if (this.safeString (trade, 'liquidity') === 'M') {
|
387
|
+
takerOrMaker = 'maker';
|
388
|
+
}
|
389
|
+
const funds = this.safeValue (trade, 'funds', {});
|
390
|
+
amountString = this.safeString (funds, baseId);
|
391
|
+
costString = this.safeString (funds, quoteId);
|
392
|
+
fee = {
|
393
|
+
'currency': this.safeString (trade, 'fee_currency'),
|
394
|
+
'cost': this.safeString (trade, 'fee'),
|
395
|
+
};
|
396
|
+
side = this.safeString (trade, 'side');
|
397
|
+
orderId = this.safeString (trade, 'order_id');
|
398
|
+
} else {
|
399
|
+
amountString = this.safeString (trade, 'amount');
|
400
|
+
side = this.safeString (trade, 'order_type');
|
401
|
+
}
|
402
|
+
return this.safeTrade ({
|
403
|
+
'id': id,
|
404
|
+
'info': trade,
|
405
|
+
'datetime': this.iso8601 (timestamp),
|
406
|
+
'timestamp': timestamp,
|
407
|
+
'symbol': symbol,
|
408
|
+
'type': undefined,
|
409
|
+
'side': side,
|
410
|
+
'order': orderId,
|
411
|
+
'takerOrMaker': takerOrMaker,
|
412
|
+
'price': priceString,
|
413
|
+
'amount': amountString,
|
414
|
+
'cost': costString,
|
415
|
+
'fee': fee,
|
416
|
+
}, market);
|
417
|
+
}
|
418
|
+
|
419
|
+
async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
420
|
+
await this.loadMarkets ();
|
421
|
+
const market = this.market (symbol);
|
422
|
+
const request = {};
|
423
|
+
if (limit !== undefined) {
|
424
|
+
request['limit'] = limit;
|
425
|
+
}
|
426
|
+
const response = await this.privateGetExchangeOrdersTransactionsPagination (this.extend (request, params));
|
427
|
+
//
|
428
|
+
// {
|
429
|
+
// "success": true,
|
430
|
+
// "transactions": [
|
431
|
+
// {
|
432
|
+
// "id": 38,
|
433
|
+
// "order_id": 49,
|
434
|
+
// "created_at": "2015-11-18T07:02:21.000Z",
|
435
|
+
// "funds": {
|
436
|
+
// "btc": "0.1",
|
437
|
+
// "jpy": "-4096.135"
|
438
|
+
// },
|
439
|
+
// "pair": "btc_jpy",
|
440
|
+
// "rate": "40900.0",
|
441
|
+
// "fee_currency": "JPY",
|
442
|
+
// "fee": "6.135",
|
443
|
+
// "liquidity": "T",
|
444
|
+
// "side": "buy"
|
445
|
+
// },
|
446
|
+
// ]
|
447
|
+
// }
|
448
|
+
//
|
449
|
+
const transactions = this.safeValue (response, 'transactions', []);
|
450
|
+
return this.parseTrades (transactions, market, since, limit);
|
451
|
+
}
|
452
|
+
|
453
|
+
async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) {
|
454
|
+
await this.loadMarkets ();
|
455
|
+
const market = this.market (symbol);
|
456
|
+
const request = {
|
457
|
+
'pair': market['id'],
|
458
|
+
};
|
459
|
+
if (limit !== undefined) {
|
460
|
+
request['limit'] = limit;
|
461
|
+
}
|
462
|
+
const response = await this.publicGetTrades (this.extend (request, params));
|
463
|
+
//
|
464
|
+
// {
|
465
|
+
// "id": "206849494",
|
466
|
+
// "amount": "0.01",
|
467
|
+
// "rate": "5598346.0",
|
468
|
+
// "pair": "btc_jpy",
|
469
|
+
// "order_type": "sell",
|
470
|
+
// "created_at": "2021-12-08T14:10:33.000Z"
|
471
|
+
// }
|
472
|
+
//
|
473
|
+
const data = this.safeValue (response, 'data', []);
|
474
|
+
return this.parseTrades (data, market, since, limit);
|
475
|
+
}
|
476
|
+
|
477
|
+
async fetchTradingFees (params = {}) {
|
478
|
+
await this.loadMarkets ();
|
479
|
+
const response = await this.privateGetAccounts (params);
|
480
|
+
//
|
481
|
+
// {
|
482
|
+
// success: true,
|
483
|
+
// id: '7487995',
|
484
|
+
// email: 'some@email.com',
|
485
|
+
// identity_status: 'identity_pending',
|
486
|
+
// bitcoin_address: null,
|
487
|
+
// lending_leverage: '4',
|
488
|
+
// taker_fee: '0.0',
|
489
|
+
// maker_fee: '0.0',
|
490
|
+
// exchange_fees: {
|
491
|
+
// btc_jpy: { taker_fee: '0.0', maker_fee: '0.0' },
|
492
|
+
// etc_jpy: { taker_fee: '0.0', maker_fee: '0.0' },
|
493
|
+
// fct_jpy: { taker_fee: '0.0', maker_fee: '0.0' },
|
494
|
+
// mona_jpy: { taker_fee: '0.0', maker_fee: '0.0' },
|
495
|
+
// plt_jpy: { taker_fee: '0.0', maker_fee: '0.0' }
|
496
|
+
// }
|
497
|
+
// }
|
498
|
+
//
|
499
|
+
const fees = this.safeValue (response, 'exchange_fees', {});
|
500
|
+
const result = {};
|
501
|
+
for (let i = 0; i < this.symbols.length; i++) {
|
502
|
+
const symbol = this.symbols[i];
|
503
|
+
const market = this.market (symbol);
|
504
|
+
const fee = this.safeValue (fees, market['id'], {});
|
505
|
+
result[symbol] = {
|
506
|
+
'info': fee,
|
507
|
+
'symbol': symbol,
|
508
|
+
'maker': this.safeNumber (fee, 'maker_fee'),
|
509
|
+
'taker': this.safeNumber (fee, 'taker_fee'),
|
510
|
+
'percentage': true,
|
511
|
+
'tierBased': false,
|
512
|
+
};
|
513
|
+
}
|
514
|
+
return result;
|
515
|
+
}
|
516
|
+
|
517
|
+
async createOrder (symbol, type, side, amount, price = undefined, params = {}) {
|
518
|
+
await this.loadMarkets ();
|
519
|
+
const request = {
|
520
|
+
'pair': this.marketId (symbol),
|
521
|
+
};
|
522
|
+
if (type === 'market') {
|
523
|
+
const order_type = type + '_' + side;
|
524
|
+
request['order_type'] = order_type;
|
525
|
+
const prefix = (side === 'buy') ? (order_type + '_') : '';
|
526
|
+
request[prefix + 'amount'] = amount;
|
527
|
+
} else {
|
528
|
+
request['order_type'] = side;
|
529
|
+
request['rate'] = price;
|
530
|
+
request['amount'] = amount;
|
531
|
+
}
|
532
|
+
const response = await this.privatePostExchangeOrders (this.extend (request, params));
|
533
|
+
const id = this.safeString (response, 'id');
|
534
|
+
return {
|
535
|
+
'info': response,
|
536
|
+
'id': id,
|
537
|
+
};
|
538
|
+
}
|
539
|
+
|
540
|
+
async cancelOrder (id, symbol = undefined, params = {}) {
|
541
|
+
const request = {
|
542
|
+
'id': id,
|
543
|
+
};
|
544
|
+
return await this.privateDeleteExchangeOrdersId (this.extend (request, params));
|
545
|
+
}
|
546
|
+
|
547
|
+
async fetchDeposits (code = undefined, since = undefined, limit = undefined, params = {}) {
|
548
|
+
await this.loadMarkets ();
|
549
|
+
let currency = undefined;
|
550
|
+
const request = {};
|
551
|
+
if (code !== undefined) {
|
552
|
+
currency = this.currency (code);
|
553
|
+
request['currency'] = currency['id'];
|
554
|
+
}
|
555
|
+
if (limit !== undefined) {
|
556
|
+
request['limit'] = limit;
|
557
|
+
}
|
558
|
+
const response = await this.privateGetDepositMoney (this.extend (request, params));
|
559
|
+
// {
|
560
|
+
// "success": true,
|
561
|
+
// "deposits": [
|
562
|
+
// {
|
563
|
+
// "id": 2,
|
564
|
+
// "amount": "0.05",
|
565
|
+
// "currency": "BTC",
|
566
|
+
// "address": "13PhzoK8me3u5nHzzFD85qT9RqEWR9M4Ty",
|
567
|
+
// "status": "confirmed",
|
568
|
+
// "confirmed_at": "2015-06-13T08:29:18.000Z",
|
569
|
+
// "created_at": "2015-06-13T08:22:18.000Z"
|
570
|
+
// },
|
571
|
+
// {
|
572
|
+
// "id": 1,
|
573
|
+
// "amount": "0.01",
|
574
|
+
// "currency": "BTC",
|
575
|
+
// "address": "13PhzoK8me3u5nHzzFD85qT9RqEWR9M4Ty",
|
576
|
+
// "status": "received",
|
577
|
+
// "confirmed_at": "2015-06-13T08:21:18.000Z",
|
578
|
+
// "created_at": "2015-06-13T08:21:18.000Z"
|
579
|
+
// }
|
580
|
+
// ]
|
581
|
+
// }
|
582
|
+
const data = this.safeValue (response, 'deposits', []);
|
583
|
+
return this.parseTransactions (data, currency, since, limit, { 'type': 'deposit' });
|
584
|
+
}
|
585
|
+
|
586
|
+
async fetchWithdrawals (code = undefined, since = undefined, limit = undefined, params = {}) {
|
587
|
+
await this.loadMarkets ();
|
588
|
+
let currency = undefined;
|
589
|
+
if (code !== undefined) {
|
590
|
+
currency = this.currency (code);
|
591
|
+
}
|
592
|
+
const request = {};
|
593
|
+
if (limit !== undefined) {
|
594
|
+
request['limit'] = limit;
|
595
|
+
}
|
596
|
+
const response = await this.privateGetWithdraws (this.extend (request, params));
|
597
|
+
// {
|
598
|
+
// "success": true,
|
599
|
+
// "pagination": {
|
600
|
+
// "limit": 25,
|
601
|
+
// "order": "desc",
|
602
|
+
// "starting_after": null,
|
603
|
+
// "ending_before": null
|
604
|
+
// },
|
605
|
+
// "data": [
|
606
|
+
// {
|
607
|
+
// "id": 398,
|
608
|
+
// "status": "finished",
|
609
|
+
// "amount": "242742.0",
|
610
|
+
// "currency": "JPY",
|
611
|
+
// "created_at": "2014-12-04T15:00:00.000Z",
|
612
|
+
// "bank_account_id": 243,
|
613
|
+
// "fee": "400.0",
|
614
|
+
// "is_fast": true
|
615
|
+
// }
|
616
|
+
// ]
|
617
|
+
// }
|
618
|
+
const data = this.safeValue (response, 'data', []);
|
619
|
+
return this.parseTransactions (data, currency, since, limit, { 'type': 'withdrawal' });
|
620
|
+
}
|
621
|
+
|
622
|
+
parseTransactionStatus (status) {
|
623
|
+
const statuses = {
|
624
|
+
// withdrawals
|
625
|
+
'pending': 'pending',
|
626
|
+
'processing': 'pending',
|
627
|
+
'finished': 'ok',
|
628
|
+
'canceled': 'canceled',
|
629
|
+
// deposits
|
630
|
+
'confirmed': 'pending',
|
631
|
+
'received': 'ok',
|
632
|
+
};
|
633
|
+
return this.safeString (statuses, status, status);
|
634
|
+
}
|
635
|
+
|
636
|
+
parseTransaction (transaction, currency = undefined) {
|
637
|
+
//
|
638
|
+
// fetchDeposits
|
639
|
+
//
|
640
|
+
// {
|
641
|
+
// "id": 2,
|
642
|
+
// "amount": "0.05",
|
643
|
+
// "currency": "BTC",
|
644
|
+
// "address": "13PhzoK8me3u5nHzzFD85qT9RqEWR9M4Ty",
|
645
|
+
// "status": "confirmed",
|
646
|
+
// "confirmed_at": "2015-06-13T08:29:18.000Z",
|
647
|
+
// "created_at": "2015-06-13T08:22:18.000Z"
|
648
|
+
// }
|
649
|
+
//
|
650
|
+
// fetchWithdrawals
|
651
|
+
//
|
652
|
+
// {
|
653
|
+
// "id": 398,
|
654
|
+
// "status": "finished",
|
655
|
+
// "amount": "242742.0",
|
656
|
+
// "currency": "JPY",
|
657
|
+
// "created_at": "2014-12-04T15:00:00.000Z",
|
658
|
+
// "bank_account_id": 243,
|
659
|
+
// "fee": "400.0",
|
660
|
+
// "is_fast": true
|
661
|
+
// }
|
662
|
+
//
|
663
|
+
const id = this.safeString (transaction, 'id');
|
664
|
+
const timestamp = this.parse8601 (this.safeString (transaction, 'created_at'));
|
665
|
+
const address = this.safeString (transaction, 'address');
|
666
|
+
const amount = this.safeNumber (transaction, 'amount');
|
667
|
+
const currencyId = this.safeString (transaction, 'currency');
|
668
|
+
const code = this.safeCurrencyCode (currencyId, currency);
|
669
|
+
const status = this.parseTransactionStatus (this.safeString (transaction, 'status'));
|
670
|
+
const updated = this.parse8601 (this.safeString (transaction, 'confirmed_at'));
|
671
|
+
let fee = undefined;
|
672
|
+
const feeCost = this.safeNumber (transaction, 'fee');
|
673
|
+
if (feeCost !== undefined) {
|
674
|
+
fee = {
|
675
|
+
'cost': feeCost,
|
676
|
+
'currency': code,
|
677
|
+
};
|
678
|
+
}
|
679
|
+
return {
|
680
|
+
'info': transaction,
|
681
|
+
'id': id,
|
682
|
+
'txid': undefined,
|
683
|
+
'timestamp': timestamp,
|
684
|
+
'datetime': this.iso8601 (timestamp),
|
685
|
+
'network': undefined,
|
686
|
+
'address': address,
|
687
|
+
'addressTo': address,
|
688
|
+
'addressFrom': undefined,
|
689
|
+
'tag': undefined,
|
690
|
+
'tagTo': undefined,
|
691
|
+
'tagFrom': undefined,
|
692
|
+
'type': undefined,
|
693
|
+
'amount': amount,
|
694
|
+
'currency': code,
|
695
|
+
'status': status,
|
696
|
+
'updated': updated,
|
697
|
+
'internal': undefined,
|
698
|
+
'fee': fee,
|
699
|
+
};
|
700
|
+
}
|
701
|
+
|
702
|
+
nonce () {
|
703
|
+
return this.milliseconds ();
|
704
|
+
}
|
705
|
+
|
706
|
+
sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
707
|
+
let url = this.urls['api'] + '/' + this.implodeParams (path, params);
|
708
|
+
const query = this.omit (params, this.extractParams (path));
|
709
|
+
if (api === 'public') {
|
710
|
+
if (Object.keys (query).length) {
|
711
|
+
url += '?' + this.urlencode (query);
|
712
|
+
}
|
713
|
+
} else {
|
714
|
+
this.checkRequiredCredentials ();
|
715
|
+
const nonce = this.nonce ().toString ();
|
716
|
+
let queryString = '';
|
717
|
+
if (method === 'GET') {
|
718
|
+
if (Object.keys (query).length) {
|
719
|
+
url += '?' + this.urlencode (this.keysort (query));
|
720
|
+
}
|
721
|
+
} else {
|
722
|
+
if (Object.keys (query).length) {
|
723
|
+
body = this.urlencode (this.keysort (query));
|
724
|
+
queryString = body;
|
725
|
+
}
|
726
|
+
}
|
727
|
+
const auth = nonce + url + queryString;
|
728
|
+
headers = {
|
729
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
730
|
+
'ACCESS-KEY': this.apiKey,
|
731
|
+
'ACCESS-NONCE': nonce,
|
732
|
+
'ACCESS-SIGNATURE': this.hmac (this.encode (auth), this.encode (this.secret)),
|
733
|
+
};
|
734
|
+
}
|
735
|
+
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
736
|
+
}
|
737
|
+
|
738
|
+
handleErrors (httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
739
|
+
if (response === undefined) {
|
740
|
+
return;
|
741
|
+
}
|
742
|
+
//
|
743
|
+
// {"success":false,"error":"disabled API Key"}'
|
744
|
+
// {"success":false,"error":"invalid authentication"}
|
745
|
+
//
|
746
|
+
const success = this.safeValue (response, 'success', true);
|
747
|
+
if (!success) {
|
748
|
+
const error = this.safeString (response, 'error');
|
749
|
+
const feedback = this.id + ' ' + this.json (response);
|
750
|
+
this.throwExactlyMatchedException (this.exceptions['exact'], error, feedback);
|
751
|
+
this.throwBroadlyMatchedException (this.exceptions['broad'], body, feedback);
|
752
|
+
throw new ExchangeError (this.id + ' ' + this.json (response));
|
753
|
+
}
|
754
|
+
}
|
755
|
+
};
|