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/zaif.js
ADDED
@@ -0,0 +1,647 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
// ---------------------------------------------------------------------------
|
4
|
+
|
5
|
+
const Exchange = require ('./base/Exchange');
|
6
|
+
const { ExchangeError, BadRequest } = require ('./base/errors');
|
7
|
+
const Precise = require ('./base/Precise');
|
8
|
+
|
9
|
+
// ---------------------------------------------------------------------------
|
10
|
+
|
11
|
+
module.exports = class zaif extends Exchange {
|
12
|
+
describe () {
|
13
|
+
return this.deepExtend (super.describe (), {
|
14
|
+
'id': 'zaif',
|
15
|
+
'name': 'Zaif',
|
16
|
+
'countries': [ 'JP' ],
|
17
|
+
// 10 requests per second = 1000ms / 10 = 100ms between requests (public market endpoints)
|
18
|
+
'rateLimit': 100,
|
19
|
+
'version': '1',
|
20
|
+
'has': {
|
21
|
+
'CORS': undefined,
|
22
|
+
'spot': true,
|
23
|
+
'margin': undefined, // has but unimplemented
|
24
|
+
'swap': false,
|
25
|
+
'future': false,
|
26
|
+
'option': false,
|
27
|
+
'cancelOrder': true,
|
28
|
+
'createMarketOrder': undefined,
|
29
|
+
'createOrder': true,
|
30
|
+
'fetchBalance': true,
|
31
|
+
'fetchClosedOrders': true,
|
32
|
+
'fetchFundingHistory': false,
|
33
|
+
'fetchFundingRate': false,
|
34
|
+
'fetchFundingRateHistory': false,
|
35
|
+
'fetchFundingRates': false,
|
36
|
+
'fetchIndexOHLCV': false,
|
37
|
+
'fetchMarkets': true,
|
38
|
+
'fetchMarkOHLCV': false,
|
39
|
+
'fetchOpenOrders': true,
|
40
|
+
'fetchOrderBook': true,
|
41
|
+
'fetchPremiumIndexOHLCV': false,
|
42
|
+
'fetchTicker': true,
|
43
|
+
'fetchTrades': true,
|
44
|
+
'fetchTradingFee': false,
|
45
|
+
'fetchTradingFees': false,
|
46
|
+
'withdraw': true,
|
47
|
+
},
|
48
|
+
'urls': {
|
49
|
+
'logo': 'https://user-images.githubusercontent.com/1294454/27766927-39ca2ada-5eeb-11e7-972f-1b4199518ca6.jpg',
|
50
|
+
'api': 'https://api.zaif.jp',
|
51
|
+
'www': 'https://zaif.jp',
|
52
|
+
'doc': [
|
53
|
+
'https://techbureau-api-document.readthedocs.io/ja/latest/index.html',
|
54
|
+
'https://corp.zaif.jp/api-docs',
|
55
|
+
'https://corp.zaif.jp/api-docs/api_links',
|
56
|
+
'https://www.npmjs.com/package/zaif.jp',
|
57
|
+
'https://github.com/you21979/node-zaif',
|
58
|
+
],
|
59
|
+
'fees': 'https://zaif.jp/fee?lang=en',
|
60
|
+
},
|
61
|
+
'fees': {
|
62
|
+
'trading': {
|
63
|
+
'percentage': true,
|
64
|
+
'taker': this.parseNumber ('0.001'),
|
65
|
+
'maker': this.parseNumber ('0'),
|
66
|
+
},
|
67
|
+
},
|
68
|
+
'api': {
|
69
|
+
'public': {
|
70
|
+
'get': {
|
71
|
+
'depth/{pair}': 1,
|
72
|
+
'currencies/{pair}': 1,
|
73
|
+
'currencies/all': 1,
|
74
|
+
'currency_pairs/{pair}': 1,
|
75
|
+
'currency_pairs/all': 1,
|
76
|
+
'last_price/{pair}': 1,
|
77
|
+
'ticker/{pair}': 1,
|
78
|
+
'trades/{pair}': 1,
|
79
|
+
},
|
80
|
+
},
|
81
|
+
'private': {
|
82
|
+
'post': {
|
83
|
+
'active_orders': 5, // 10 in 5 seconds = 2 per second => cost = 10 / 2 = 5
|
84
|
+
'cancel_order': 5,
|
85
|
+
'deposit_history': 5,
|
86
|
+
'get_id_info': 5,
|
87
|
+
'get_info': 10, // 10 in 10 seconds = 1 per second => cost = 10 / 1 = 10
|
88
|
+
'get_info2': 5, // 20 in 10 seconds = 2 per second => cost = 10 / 2 = 5
|
89
|
+
'get_personal_info': 5,
|
90
|
+
'trade': 5,
|
91
|
+
'trade_history': 50, // 12 in 60 seconds = 0.2 per second => cost = 10 / 0.2 = 50
|
92
|
+
'withdraw': 5,
|
93
|
+
'withdraw_history': 5,
|
94
|
+
},
|
95
|
+
},
|
96
|
+
'ecapi': {
|
97
|
+
'post': {
|
98
|
+
'createInvoice': 1, // unverified
|
99
|
+
'getInvoice': 1,
|
100
|
+
'getInvoiceIdsByOrderNumber': 1,
|
101
|
+
'cancelInvoice': 1,
|
102
|
+
},
|
103
|
+
},
|
104
|
+
'tlapi': {
|
105
|
+
'post': {
|
106
|
+
'get_positions': 66, // 10 in 60 seconds = 0.166 per second => cost = 10 / 0.166 = 66
|
107
|
+
'position_history': 66, // 10 in 60 seconds
|
108
|
+
'active_positions': 5, // 20 in 10 seconds
|
109
|
+
'create_position': 33, // 3 in 10 seconds = 0.3 per second => cost = 10 / 0.3 = 33
|
110
|
+
'change_position': 33, // 3 in 10 seconds
|
111
|
+
'cancel_position': 33, // 3 in 10 seconds
|
112
|
+
},
|
113
|
+
},
|
114
|
+
'fapi': {
|
115
|
+
'get': {
|
116
|
+
'groups/{group_id}': 1, // testing
|
117
|
+
'last_price/{group_id}/{pair}': 1,
|
118
|
+
'ticker/{group_id}/{pair}': 1,
|
119
|
+
'trades/{group_id}/{pair}': 1,
|
120
|
+
'depth/{group_id}/{pair}': 1,
|
121
|
+
},
|
122
|
+
},
|
123
|
+
},
|
124
|
+
'options': {
|
125
|
+
// zaif schedule defines several market-specific fees
|
126
|
+
'fees': {
|
127
|
+
'BTC/JPY': { 'maker': 0, 'taker': 0.1 / 100 },
|
128
|
+
'BCH/JPY': { 'maker': 0, 'taker': 0.3 / 100 },
|
129
|
+
'BCH/BTC': { 'maker': 0, 'taker': 0.3 / 100 },
|
130
|
+
'PEPECASH/JPY': { 'maker': 0, 'taker': 0.01 / 100 },
|
131
|
+
'PEPECASH/BT': { 'maker': 0, 'taker': 0.01 / 100 },
|
132
|
+
},
|
133
|
+
},
|
134
|
+
'exceptions': {
|
135
|
+
'exact': {
|
136
|
+
'unsupported currency_pair': BadRequest, // {"error": "unsupported currency_pair"}
|
137
|
+
},
|
138
|
+
'broad': {
|
139
|
+
},
|
140
|
+
},
|
141
|
+
});
|
142
|
+
}
|
143
|
+
|
144
|
+
async fetchMarkets (params = {}) {
|
145
|
+
const markets = await this.publicGetCurrencyPairsAll (params);
|
146
|
+
//
|
147
|
+
// [
|
148
|
+
// {
|
149
|
+
// "aux_unit_point": 0,
|
150
|
+
// "item_japanese": "\u30d3\u30c3\u30c8\u30b3\u30a4\u30f3",
|
151
|
+
// "aux_unit_step": 5.0,
|
152
|
+
// "description": "\u30d3\u30c3\u30c8\u30b3\u30a4\u30f3\u30fb\u65e5\u672c\u5186\u306e\u53d6\u5f15\u3092\u884c\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059",
|
153
|
+
// "item_unit_min": 0.001,
|
154
|
+
// "event_number": 0,
|
155
|
+
// "currency_pair": "btc_jpy",
|
156
|
+
// "is_token": false,
|
157
|
+
// "aux_unit_min": 5.0,
|
158
|
+
// "aux_japanese": "\u65e5\u672c\u5186",
|
159
|
+
// "id": 1,
|
160
|
+
// "item_unit_step": 0.0001,
|
161
|
+
// "name": "BTC/JPY",
|
162
|
+
// "seq": 0,
|
163
|
+
// "title": "BTC/JPY"
|
164
|
+
// }
|
165
|
+
// ]
|
166
|
+
//
|
167
|
+
const result = [];
|
168
|
+
for (let i = 0; i < markets.length; i++) {
|
169
|
+
const market = markets[i];
|
170
|
+
const id = this.safeString (market, 'currency_pair');
|
171
|
+
const name = this.safeString (market, 'name');
|
172
|
+
const [ baseId, quoteId ] = name.split ('/');
|
173
|
+
const base = this.safeCurrencyCode (baseId);
|
174
|
+
const quote = this.safeCurrencyCode (quoteId);
|
175
|
+
const symbol = base + '/' + quote;
|
176
|
+
const fees = this.safeValue (this.options['fees'], symbol, this.fees['trading']);
|
177
|
+
const itemUnitStep = this.safeString (market, 'item_unit_step');
|
178
|
+
result.push ({
|
179
|
+
'id': id,
|
180
|
+
'symbol': symbol,
|
181
|
+
'base': base,
|
182
|
+
'quote': quote,
|
183
|
+
'settle': undefined,
|
184
|
+
'baseId': baseId,
|
185
|
+
'quoteId': quoteId,
|
186
|
+
'settleId': undefined,
|
187
|
+
'type': 'spot',
|
188
|
+
'spot': true,
|
189
|
+
'margin': undefined,
|
190
|
+
'swap': false,
|
191
|
+
'future': false,
|
192
|
+
'option': false,
|
193
|
+
'active': undefined, // can trade or not
|
194
|
+
'contract': false,
|
195
|
+
'linear': undefined,
|
196
|
+
'inverse': undefined,
|
197
|
+
'taker': fees['taker'],
|
198
|
+
'maker': fees['maker'],
|
199
|
+
'contractSize': undefined,
|
200
|
+
'expiry': undefined,
|
201
|
+
'expiryDatetime': undefined,
|
202
|
+
'strike': undefined,
|
203
|
+
'optionType': undefined,
|
204
|
+
'precision': {
|
205
|
+
'amount': Precise.stringMul (itemUnitStep, '-1e10'),
|
206
|
+
'price': this.safeInteger (market, 'aux_unit_point'),
|
207
|
+
},
|
208
|
+
'limits': {
|
209
|
+
'leverage': {
|
210
|
+
'min': undefined,
|
211
|
+
'max': undefined,
|
212
|
+
},
|
213
|
+
'amount': {
|
214
|
+
'min': this.safeNumber (market, 'item_unit_min'),
|
215
|
+
'max': undefined,
|
216
|
+
},
|
217
|
+
'price': {
|
218
|
+
'min': this.safeNumber (market, 'aux_unit_min'),
|
219
|
+
'max': undefined,
|
220
|
+
},
|
221
|
+
'cost': {
|
222
|
+
'min': undefined,
|
223
|
+
'max': undefined,
|
224
|
+
},
|
225
|
+
},
|
226
|
+
'info': market,
|
227
|
+
});
|
228
|
+
}
|
229
|
+
return result;
|
230
|
+
}
|
231
|
+
|
232
|
+
parseBalance (response) {
|
233
|
+
const balances = this.safeValue (response, 'return', {});
|
234
|
+
const deposit = this.safeValue (balances, 'deposit');
|
235
|
+
const result = {
|
236
|
+
'info': response,
|
237
|
+
'timestamp': undefined,
|
238
|
+
'datetime': undefined,
|
239
|
+
};
|
240
|
+
const funds = this.safeValue (balances, 'funds', {});
|
241
|
+
const currencyIds = Object.keys (funds);
|
242
|
+
for (let i = 0; i < currencyIds.length; i++) {
|
243
|
+
const currencyId = currencyIds[i];
|
244
|
+
const code = this.safeCurrencyCode (currencyId);
|
245
|
+
const balance = this.safeString (funds, currencyId);
|
246
|
+
const account = this.account ();
|
247
|
+
account['free'] = balance;
|
248
|
+
account['total'] = balance;
|
249
|
+
if (deposit !== undefined) {
|
250
|
+
if (currencyId in deposit) {
|
251
|
+
account['total'] = this.safeString (deposit, currencyId);
|
252
|
+
}
|
253
|
+
}
|
254
|
+
result[code] = account;
|
255
|
+
}
|
256
|
+
return this.safeBalance (result);
|
257
|
+
}
|
258
|
+
|
259
|
+
async fetchBalance (params = {}) {
|
260
|
+
await this.loadMarkets ();
|
261
|
+
const response = await this.privatePostGetInfo (params);
|
262
|
+
return this.parseBalance (response);
|
263
|
+
}
|
264
|
+
|
265
|
+
async fetchOrderBook (symbol, limit = undefined, params = {}) {
|
266
|
+
await this.loadMarkets ();
|
267
|
+
const request = {
|
268
|
+
'pair': this.marketId (symbol),
|
269
|
+
};
|
270
|
+
const response = await this.publicGetDepthPair (this.extend (request, params));
|
271
|
+
return this.parseOrderBook (response, symbol);
|
272
|
+
}
|
273
|
+
|
274
|
+
parseTicker (ticker, market = undefined) {
|
275
|
+
//
|
276
|
+
// {
|
277
|
+
// "last": 9e-08,
|
278
|
+
// "high": 1e-07,
|
279
|
+
// "low": 9e-08,
|
280
|
+
// "vwap": 0.0,
|
281
|
+
// "volume": 135250.0,
|
282
|
+
// "bid": 9e-08,
|
283
|
+
// "ask": 1e-07
|
284
|
+
// }
|
285
|
+
//
|
286
|
+
const symbol = this.safeSymbol (undefined, market);
|
287
|
+
const timestamp = this.milliseconds ();
|
288
|
+
const vwap = this.safeString (ticker, 'vwap');
|
289
|
+
const baseVolume = this.safeString (ticker, 'volume');
|
290
|
+
const quoteVolume = Precise.stringMul (baseVolume, vwap);
|
291
|
+
const last = this.safeString (ticker, 'last');
|
292
|
+
return this.safeTicker ({
|
293
|
+
'symbol': symbol,
|
294
|
+
'timestamp': timestamp,
|
295
|
+
'datetime': this.iso8601 (timestamp),
|
296
|
+
'high': this.safeString (ticker, 'high'),
|
297
|
+
'low': this.safeString (ticker, 'low'),
|
298
|
+
'bid': this.safeString (ticker, 'bid'),
|
299
|
+
'bidVolume': undefined,
|
300
|
+
'ask': this.safeString (ticker, 'ask'),
|
301
|
+
'askVolume': undefined,
|
302
|
+
'vwap': vwap,
|
303
|
+
'open': undefined,
|
304
|
+
'close': last,
|
305
|
+
'last': last,
|
306
|
+
'previousClose': undefined,
|
307
|
+
'change': undefined,
|
308
|
+
'percentage': undefined,
|
309
|
+
'average': undefined,
|
310
|
+
'baseVolume': baseVolume,
|
311
|
+
'quoteVolume': quoteVolume,
|
312
|
+
'info': ticker,
|
313
|
+
}, market, false);
|
314
|
+
}
|
315
|
+
|
316
|
+
async fetchTicker (symbol, params = {}) {
|
317
|
+
await this.loadMarkets ();
|
318
|
+
const market = this.market (symbol);
|
319
|
+
const request = {
|
320
|
+
'pair': market['id'],
|
321
|
+
};
|
322
|
+
const ticker = await this.publicGetTickerPair (this.extend (request, params));
|
323
|
+
//
|
324
|
+
// {
|
325
|
+
// "last": 9e-08,
|
326
|
+
// "high": 1e-07,
|
327
|
+
// "low": 9e-08,
|
328
|
+
// "vwap": 0.0,
|
329
|
+
// "volume": 135250.0,
|
330
|
+
// "bid": 9e-08,
|
331
|
+
// "ask": 1e-07
|
332
|
+
// }
|
333
|
+
//
|
334
|
+
return this.parseTicker (ticker, market);
|
335
|
+
}
|
336
|
+
|
337
|
+
parseTrade (trade, market = undefined) {
|
338
|
+
//
|
339
|
+
// fetchTrades (public)
|
340
|
+
//
|
341
|
+
// {
|
342
|
+
// "date": 1648559414,
|
343
|
+
// "price": 5880375.0,
|
344
|
+
// "amount": 0.017,
|
345
|
+
// "tid": 176126557,
|
346
|
+
// "currency_pair": "btc_jpy",
|
347
|
+
// "trade_type": "ask"
|
348
|
+
// }
|
349
|
+
//
|
350
|
+
let side = this.safeString (trade, 'trade_type');
|
351
|
+
side = (side === 'bid') ? 'buy' : 'sell';
|
352
|
+
const timestamp = this.safeTimestamp (trade, 'date');
|
353
|
+
const id = this.safeString2 (trade, 'id', 'tid');
|
354
|
+
const priceString = this.safeString (trade, 'price');
|
355
|
+
const amountString = this.safeString (trade, 'amount');
|
356
|
+
const marketId = this.safeString (trade, 'currency_pair');
|
357
|
+
const symbol = this.safeSymbol (marketId, market, '_');
|
358
|
+
return this.safeTrade ({
|
359
|
+
'id': id,
|
360
|
+
'info': trade,
|
361
|
+
'timestamp': timestamp,
|
362
|
+
'datetime': this.iso8601 (timestamp),
|
363
|
+
'symbol': symbol,
|
364
|
+
'type': undefined,
|
365
|
+
'side': side,
|
366
|
+
'order': undefined,
|
367
|
+
'takerOrMaker': undefined,
|
368
|
+
'price': priceString,
|
369
|
+
'amount': amountString,
|
370
|
+
'cost': undefined,
|
371
|
+
'fee': undefined,
|
372
|
+
}, market);
|
373
|
+
}
|
374
|
+
|
375
|
+
async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) {
|
376
|
+
await this.loadMarkets ();
|
377
|
+
const market = this.market (symbol);
|
378
|
+
const request = {
|
379
|
+
'pair': market['id'],
|
380
|
+
};
|
381
|
+
let response = await this.publicGetTradesPair (this.extend (request, params));
|
382
|
+
//
|
383
|
+
// [
|
384
|
+
// {
|
385
|
+
// "date": 1648559414,
|
386
|
+
// "price": 5880375.0,
|
387
|
+
// "amount": 0.017,
|
388
|
+
// "tid": 176126557,
|
389
|
+
// "currency_pair": "btc_jpy",
|
390
|
+
// "trade_type": "ask"
|
391
|
+
// }, ...
|
392
|
+
// ]
|
393
|
+
//
|
394
|
+
const numTrades = response.length;
|
395
|
+
if (numTrades === 1) {
|
396
|
+
const firstTrade = response[0];
|
397
|
+
if (!Object.keys (firstTrade).length) {
|
398
|
+
response = [];
|
399
|
+
}
|
400
|
+
}
|
401
|
+
return this.parseTrades (response, market, since, limit);
|
402
|
+
}
|
403
|
+
|
404
|
+
async createOrder (symbol, type, side, amount, price = undefined, params = {}) {
|
405
|
+
await this.loadMarkets ();
|
406
|
+
if (type !== 'limit') {
|
407
|
+
throw new ExchangeError (this.id + ' createOrder() allows limit orders only');
|
408
|
+
}
|
409
|
+
const request = {
|
410
|
+
'currency_pair': this.marketId (symbol),
|
411
|
+
'action': (side === 'buy') ? 'bid' : 'ask',
|
412
|
+
'amount': amount,
|
413
|
+
'price': price,
|
414
|
+
};
|
415
|
+
const response = await this.privatePostTrade (this.extend (request, params));
|
416
|
+
return {
|
417
|
+
'info': response,
|
418
|
+
'id': response['return']['order_id'].toString (),
|
419
|
+
};
|
420
|
+
}
|
421
|
+
|
422
|
+
async cancelOrder (id, symbol = undefined, params = {}) {
|
423
|
+
const request = {
|
424
|
+
'order_id': id,
|
425
|
+
};
|
426
|
+
return await this.privatePostCancelOrder (this.extend (request, params));
|
427
|
+
}
|
428
|
+
|
429
|
+
parseOrder (order, market = undefined) {
|
430
|
+
//
|
431
|
+
// {
|
432
|
+
// "currency_pair": "btc_jpy",
|
433
|
+
// "action": "ask",
|
434
|
+
// "amount": 0.03,
|
435
|
+
// "price": 56000,
|
436
|
+
// "timestamp": 1402021125,
|
437
|
+
// "comment" : "demo"
|
438
|
+
// }
|
439
|
+
//
|
440
|
+
let side = this.safeString (order, 'action');
|
441
|
+
side = (side === 'bid') ? 'buy' : 'sell';
|
442
|
+
const timestamp = this.safeTimestamp (order, 'timestamp');
|
443
|
+
const marketId = this.safeString (order, 'currency_pair');
|
444
|
+
const symbol = this.safeSymbol (marketId, market, '_');
|
445
|
+
const price = this.safeString (order, 'price');
|
446
|
+
const amount = this.safeString (order, 'amount');
|
447
|
+
const id = this.safeString (order, 'id');
|
448
|
+
return this.safeOrder ({
|
449
|
+
'id': id,
|
450
|
+
'clientOrderId': undefined,
|
451
|
+
'timestamp': timestamp,
|
452
|
+
'datetime': this.iso8601 (timestamp),
|
453
|
+
'lastTradeTimestamp': undefined,
|
454
|
+
'status': 'open',
|
455
|
+
'symbol': symbol,
|
456
|
+
'type': 'limit',
|
457
|
+
'timeInForce': undefined,
|
458
|
+
'postOnly': undefined,
|
459
|
+
'side': side,
|
460
|
+
'price': price,
|
461
|
+
'stopPrice': undefined,
|
462
|
+
'cost': undefined,
|
463
|
+
'amount': amount,
|
464
|
+
'filled': undefined,
|
465
|
+
'remaining': undefined,
|
466
|
+
'trades': undefined,
|
467
|
+
'fee': undefined,
|
468
|
+
'info': order,
|
469
|
+
'average': undefined,
|
470
|
+
}, market);
|
471
|
+
}
|
472
|
+
|
473
|
+
async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
474
|
+
await this.loadMarkets ();
|
475
|
+
let market = undefined;
|
476
|
+
const request = {
|
477
|
+
// 'is_token': false,
|
478
|
+
// 'is_token_both': false,
|
479
|
+
};
|
480
|
+
if (symbol !== undefined) {
|
481
|
+
market = this.market (symbol);
|
482
|
+
request['currency_pair'] = market['id'];
|
483
|
+
}
|
484
|
+
const response = await this.privatePostActiveOrders (this.extend (request, params));
|
485
|
+
return this.parseOrders (response['return'], market, since, limit);
|
486
|
+
}
|
487
|
+
|
488
|
+
async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
489
|
+
await this.loadMarkets ();
|
490
|
+
let market = undefined;
|
491
|
+
const request = {
|
492
|
+
// 'from': 0,
|
493
|
+
// 'count': 1000,
|
494
|
+
// 'from_id': 0,
|
495
|
+
// 'end_id': 1000,
|
496
|
+
// 'order': 'DESC',
|
497
|
+
// 'since': 1503821051,
|
498
|
+
// 'end': 1503821051,
|
499
|
+
// 'is_token': false,
|
500
|
+
};
|
501
|
+
if (symbol !== undefined) {
|
502
|
+
market = this.market (symbol);
|
503
|
+
request['currency_pair'] = market['id'];
|
504
|
+
}
|
505
|
+
const response = await this.privatePostTradeHistory (this.extend (request, params));
|
506
|
+
return this.parseOrders (response['return'], market, since, limit);
|
507
|
+
}
|
508
|
+
|
509
|
+
async withdraw (code, amount, address, tag = undefined, params = {}) {
|
510
|
+
[ tag, params ] = this.handleWithdrawTagAndParams (tag, params);
|
511
|
+
this.checkAddress (address);
|
512
|
+
await this.loadMarkets ();
|
513
|
+
const currency = this.currency (code);
|
514
|
+
if (code === 'JPY') {
|
515
|
+
throw new ExchangeError (this.id + ' withdraw() does not allow ' + code + ' withdrawals');
|
516
|
+
}
|
517
|
+
const request = {
|
518
|
+
'currency': currency['id'],
|
519
|
+
'amount': amount,
|
520
|
+
'address': address,
|
521
|
+
// 'message': 'Hi!', // XEM and others
|
522
|
+
// 'opt_fee': 0.003, // BTC and MONA only
|
523
|
+
};
|
524
|
+
if (tag !== undefined) {
|
525
|
+
request['message'] = tag;
|
526
|
+
}
|
527
|
+
const result = await this.privatePostWithdraw (this.extend (request, params));
|
528
|
+
//
|
529
|
+
// {
|
530
|
+
// "success": 1,
|
531
|
+
// "return": {
|
532
|
+
// "id": 23634,
|
533
|
+
// "fee": 0.001,
|
534
|
+
// "txid":,
|
535
|
+
// "funds": {
|
536
|
+
// "jpy": 15320,
|
537
|
+
// "btc": 1.392,
|
538
|
+
// "xem": 100.2,
|
539
|
+
// "mona": 2600
|
540
|
+
// }
|
541
|
+
// }
|
542
|
+
// }
|
543
|
+
//
|
544
|
+
const returnData = this.safeValue (result, 'return');
|
545
|
+
return this.parseTransaction (returnData, currency);
|
546
|
+
}
|
547
|
+
|
548
|
+
parseTransaction (transaction, currency = undefined) {
|
549
|
+
//
|
550
|
+
// {
|
551
|
+
// "id": 23634,
|
552
|
+
// "fee": 0.001,
|
553
|
+
// "txid":,
|
554
|
+
// "funds": {
|
555
|
+
// "jpy": 15320,
|
556
|
+
// "btc": 1.392,
|
557
|
+
// "xem": 100.2,
|
558
|
+
// "mona": 2600
|
559
|
+
// }
|
560
|
+
// }
|
561
|
+
//
|
562
|
+
currency = this.safeCurrency (undefined, currency);
|
563
|
+
let fee = undefined;
|
564
|
+
const feeCost = this.safeValue (transaction, 'fee');
|
565
|
+
if (feeCost !== undefined) {
|
566
|
+
fee = {
|
567
|
+
'cost': feeCost,
|
568
|
+
'currency': currency['code'],
|
569
|
+
};
|
570
|
+
}
|
571
|
+
return {
|
572
|
+
'id': this.safeString (transaction, 'id'),
|
573
|
+
'txid': this.safeString (transaction, 'txid'),
|
574
|
+
'timestamp': undefined,
|
575
|
+
'datetime': undefined,
|
576
|
+
'network': undefined,
|
577
|
+
'addressFrom': undefined,
|
578
|
+
'address': undefined,
|
579
|
+
'addressTo': undefined,
|
580
|
+
'amount': undefined,
|
581
|
+
'type': undefined,
|
582
|
+
'currency': currency['code'],
|
583
|
+
'status': undefined,
|
584
|
+
'updated': undefined,
|
585
|
+
'tagFrom': undefined,
|
586
|
+
'tag': undefined,
|
587
|
+
'tagTo': undefined,
|
588
|
+
'comment': undefined,
|
589
|
+
'fee': fee,
|
590
|
+
'info': transaction,
|
591
|
+
};
|
592
|
+
}
|
593
|
+
|
594
|
+
nonce () {
|
595
|
+
const nonce = parseFloat (this.milliseconds () / 1000);
|
596
|
+
return nonce.toFixed (8);
|
597
|
+
}
|
598
|
+
|
599
|
+
sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
600
|
+
let url = this.urls['api'] + '/';
|
601
|
+
if (api === 'public') {
|
602
|
+
url += 'api/' + this.version + '/' + this.implodeParams (path, params);
|
603
|
+
} else if (api === 'fapi') {
|
604
|
+
url += 'fapi/' + this.version + '/' + this.implodeParams (path, params);
|
605
|
+
} else {
|
606
|
+
this.checkRequiredCredentials ();
|
607
|
+
if (api === 'ecapi') {
|
608
|
+
url += 'ecapi';
|
609
|
+
} else if (api === 'tlapi') {
|
610
|
+
url += 'tlapi';
|
611
|
+
} else {
|
612
|
+
url += 'tapi';
|
613
|
+
}
|
614
|
+
const nonce = this.nonce ();
|
615
|
+
body = this.urlencode (this.extend ({
|
616
|
+
'method': path,
|
617
|
+
'nonce': nonce,
|
618
|
+
}, params));
|
619
|
+
headers = {
|
620
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
621
|
+
'Key': this.apiKey,
|
622
|
+
'Sign': this.hmac (this.encode (body), this.encode (this.secret), 'sha512'),
|
623
|
+
};
|
624
|
+
}
|
625
|
+
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
626
|
+
}
|
627
|
+
|
628
|
+
handleErrors (httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
629
|
+
if (response === undefined) {
|
630
|
+
return;
|
631
|
+
}
|
632
|
+
//
|
633
|
+
// {"error": "unsupported currency_pair"}
|
634
|
+
//
|
635
|
+
const feedback = this.id + ' ' + body;
|
636
|
+
const error = this.safeString (response, 'error');
|
637
|
+
if (error !== undefined) {
|
638
|
+
this.throwExactlyMatchedException (this.exceptions['exact'], error, feedback);
|
639
|
+
this.throwBroadlyMatchedException (this.exceptions['broad'], error, feedback);
|
640
|
+
throw new ExchangeError (feedback); // unknown message
|
641
|
+
}
|
642
|
+
const success = this.safeValue (response, 'success', true);
|
643
|
+
if (!success) {
|
644
|
+
throw new ExchangeError (feedback);
|
645
|
+
}
|
646
|
+
}
|
647
|
+
};
|