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/btctradeua.js
ADDED
@@ -0,0 +1,466 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
// ---------------------------------------------------------------------------
|
4
|
+
|
5
|
+
const Exchange = require ('./base/Exchange');
|
6
|
+
const { ExchangeError, ArgumentsRequired } = require ('./base/errors');
|
7
|
+
const Precise = require ('./base/Precise');
|
8
|
+
|
9
|
+
// ---------------------------------------------------------------------------
|
10
|
+
|
11
|
+
module.exports = class btctradeua extends Exchange {
|
12
|
+
describe () {
|
13
|
+
return this.deepExtend (super.describe (), {
|
14
|
+
'id': 'btctradeua',
|
15
|
+
'name': 'BTC Trade UA',
|
16
|
+
'countries': [ 'UA' ], // Ukraine,
|
17
|
+
'rateLimit': 3000,
|
18
|
+
'has': {
|
19
|
+
'CORS': undefined,
|
20
|
+
'spot': true,
|
21
|
+
'margin': false,
|
22
|
+
'swap': false,
|
23
|
+
'future': false,
|
24
|
+
'option': false,
|
25
|
+
'addMargin': false,
|
26
|
+
'cancelOrder': true,
|
27
|
+
'createMarketOrder': undefined,
|
28
|
+
'createOrder': true,
|
29
|
+
'createReduceOnlyOrder': false,
|
30
|
+
'fetchBalance': true,
|
31
|
+
'fetchBorrowRate': false,
|
32
|
+
'fetchBorrowRateHistories': false,
|
33
|
+
'fetchBorrowRateHistory': false,
|
34
|
+
'fetchBorrowRates': false,
|
35
|
+
'fetchBorrowRatesPerSymbol': false,
|
36
|
+
'fetchFundingHistory': false,
|
37
|
+
'fetchFundingRate': false,
|
38
|
+
'fetchFundingRateHistory': false,
|
39
|
+
'fetchFundingRates': false,
|
40
|
+
'fetchIndexOHLCV': false,
|
41
|
+
'fetchLeverage': false,
|
42
|
+
'fetchMarkOHLCV': false,
|
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': false,
|
53
|
+
'reduceMargin': false,
|
54
|
+
'setLeverage': false,
|
55
|
+
'setMarginMode': false,
|
56
|
+
'setPositionMode': false,
|
57
|
+
'signIn': true,
|
58
|
+
},
|
59
|
+
'urls': {
|
60
|
+
'referral': 'https://btc-trade.com.ua/registration/22689',
|
61
|
+
'logo': 'https://user-images.githubusercontent.com/1294454/27941483-79fc7350-62d9-11e7-9f61-ac47f28fcd96.jpg',
|
62
|
+
'api': 'https://btc-trade.com.ua/api',
|
63
|
+
'www': 'https://btc-trade.com.ua',
|
64
|
+
'doc': 'https://docs.google.com/document/d/1ocYA0yMy_RXd561sfG3qEPZ80kyll36HUxvCRe5GbhE/edit',
|
65
|
+
},
|
66
|
+
'api': {
|
67
|
+
'public': {
|
68
|
+
'get': [
|
69
|
+
'deals/{symbol}',
|
70
|
+
'trades/sell/{symbol}',
|
71
|
+
'trades/buy/{symbol}',
|
72
|
+
'japan_stat/high/{symbol}',
|
73
|
+
],
|
74
|
+
},
|
75
|
+
'private': {
|
76
|
+
'post': [
|
77
|
+
'auth',
|
78
|
+
'ask/{symbol}',
|
79
|
+
'balance',
|
80
|
+
'bid/{symbol}',
|
81
|
+
'buy/{symbol}',
|
82
|
+
'my_orders/{symbol}',
|
83
|
+
'order/status/{id}',
|
84
|
+
'remove/order/{id}',
|
85
|
+
'sell/{symbol}',
|
86
|
+
],
|
87
|
+
},
|
88
|
+
},
|
89
|
+
'markets': {
|
90
|
+
'BCH/UAH': { 'id': 'bch_uah', 'symbol': 'BCH/UAH', 'base': 'BCH', 'quote': 'UAH', 'baseId': 'bch', 'quoteId': 'uah', 'type': 'spot', 'spot': true },
|
91
|
+
'BTC/UAH': { 'id': 'btc_uah', 'symbol': 'BTC/UAH', 'base': 'BTC', 'quote': 'UAH', 'baseId': 'btc', 'quoteId': 'uah', 'precision': { 'price': 1 }, 'limits': { 'amount': { 'min': 0.0000000001 }}, 'type': 'spot', 'spot': true },
|
92
|
+
'DASH/BTC': { 'id': 'dash_btc', 'symbol': 'DASH/BTC', 'base': 'DASH', 'quote': 'BTC', 'baseId': 'dash', 'quoteId': 'btc', 'type': 'spot', 'spot': true },
|
93
|
+
'DASH/UAH': { 'id': 'dash_uah', 'symbol': 'DASH/UAH', 'base': 'DASH', 'quote': 'UAH', 'baseId': 'dash', 'quoteId': 'uah', 'type': 'spot', 'spot': true },
|
94
|
+
'DOGE/BTC': { 'id': 'doge_btc', 'symbol': 'DOGE/BTC', 'base': 'DOGE', 'quote': 'BTC', 'baseId': 'doge', 'quoteId': 'btc', 'type': 'spot', 'spot': true },
|
95
|
+
'DOGE/UAH': { 'id': 'doge_uah', 'symbol': 'DOGE/UAH', 'base': 'DOGE', 'quote': 'UAH', 'baseId': 'doge', 'quoteId': 'uah', 'type': 'spot', 'spot': true },
|
96
|
+
'ETH/UAH': { 'id': 'eth_uah', 'symbol': 'ETH/UAH', 'base': 'ETH', 'quote': 'UAH', 'baseId': 'eth', 'quoteId': 'uah', 'type': 'spot', 'spot': true },
|
97
|
+
'ITI/UAH': { 'id': 'iti_uah', 'symbol': 'ITI/UAH', 'base': 'ITI', 'quote': 'UAH', 'baseId': 'iti', 'quoteId': 'uah', 'type': 'spot', 'spot': true },
|
98
|
+
'KRB/UAH': { 'id': 'krb_uah', 'symbol': 'KRB/UAH', 'base': 'KRB', 'quote': 'UAH', 'baseId': 'krb', 'quoteId': 'uah', 'type': 'spot', 'spot': true },
|
99
|
+
'LTC/BTC': { 'id': 'ltc_btc', 'symbol': 'LTC/BTC', 'base': 'LTC', 'quote': 'BTC', 'baseId': 'ltc', 'quoteId': 'btc', 'type': 'spot', 'spot': true },
|
100
|
+
'LTC/UAH': { 'id': 'ltc_uah', 'symbol': 'LTC/UAH', 'base': 'LTC', 'quote': 'UAH', 'baseId': 'ltc', 'quoteId': 'uah', 'type': 'spot', 'spot': true },
|
101
|
+
'NVC/BTC': { 'id': 'nvc_btc', 'symbol': 'NVC/BTC', 'base': 'NVC', 'quote': 'BTC', 'baseId': 'nvc', 'quoteId': 'btc', 'type': 'spot', 'spot': true },
|
102
|
+
'NVC/UAH': { 'id': 'nvc_uah', 'symbol': 'NVC/UAH', 'base': 'NVC', 'quote': 'UAH', 'baseId': 'nvc', 'quoteId': 'uah', 'type': 'spot', 'spot': true },
|
103
|
+
'PPC/BTC': { 'id': 'ppc_btc', 'symbol': 'PPC/BTC', 'base': 'PPC', 'quote': 'BTC', 'baseId': 'ppc', 'quoteId': 'btc', 'type': 'spot', 'spot': true },
|
104
|
+
'SIB/UAH': { 'id': 'sib_uah', 'symbol': 'SIB/UAH', 'base': 'SIB', 'quote': 'UAH', 'baseId': 'sib', 'quoteId': 'uah', 'type': 'spot', 'spot': true },
|
105
|
+
'XMR/UAH': { 'id': 'xmr_uah', 'symbol': 'XMR/UAH', 'base': 'XMR', 'quote': 'UAH', 'baseId': 'xmr', 'quoteId': 'uah', 'type': 'spot', 'spot': true },
|
106
|
+
'ZEC/UAH': { 'id': 'zec_uah', 'symbol': 'ZEC/UAH', 'base': 'ZEC', 'quote': 'UAH', 'baseId': 'zec', 'quoteId': 'uah', 'type': 'spot', 'spot': true },
|
107
|
+
},
|
108
|
+
'fees': {
|
109
|
+
'trading': {
|
110
|
+
'maker': 0.1 / 100,
|
111
|
+
'taker': 0.1 / 100,
|
112
|
+
},
|
113
|
+
'funding': {
|
114
|
+
'withdraw': {
|
115
|
+
'BTC': 0.0006,
|
116
|
+
'LTC': 0.01,
|
117
|
+
'NVC': 0.01,
|
118
|
+
'DOGE': 10,
|
119
|
+
},
|
120
|
+
},
|
121
|
+
},
|
122
|
+
});
|
123
|
+
}
|
124
|
+
|
125
|
+
async signIn (params = {}) {
|
126
|
+
return await this.privatePostAuth (params);
|
127
|
+
}
|
128
|
+
|
129
|
+
parseBalance (response) {
|
130
|
+
const result = { 'info': response };
|
131
|
+
const balances = this.safeValue (response, 'accounts');
|
132
|
+
for (let i = 0; i < balances.length; i++) {
|
133
|
+
const balance = balances[i];
|
134
|
+
const currencyId = this.safeString (balance, 'currency');
|
135
|
+
const code = this.safeCurrencyCode (currencyId);
|
136
|
+
const account = this.account ();
|
137
|
+
account['total'] = this.safeString (balance, 'balance');
|
138
|
+
result[code] = account;
|
139
|
+
}
|
140
|
+
return this.safeBalance (result);
|
141
|
+
}
|
142
|
+
|
143
|
+
async fetchBalance (params = {}) {
|
144
|
+
await this.loadMarkets ();
|
145
|
+
const response = await this.privatePostBalance (params);
|
146
|
+
return this.parseBalance (response);
|
147
|
+
}
|
148
|
+
|
149
|
+
async fetchOrderBook (symbol, limit = undefined, params = {}) {
|
150
|
+
await this.loadMarkets ();
|
151
|
+
const market = this.market (symbol);
|
152
|
+
const request = {
|
153
|
+
'symbol': market['id'],
|
154
|
+
};
|
155
|
+
const bids = await this.publicGetTradesBuySymbol (this.extend (request, params));
|
156
|
+
const asks = await this.publicGetTradesSellSymbol (this.extend (request, params));
|
157
|
+
const orderbook = {
|
158
|
+
'bids': [],
|
159
|
+
'asks': [],
|
160
|
+
};
|
161
|
+
if (bids) {
|
162
|
+
if ('list' in bids) {
|
163
|
+
orderbook['bids'] = bids['list'];
|
164
|
+
}
|
165
|
+
}
|
166
|
+
if (asks) {
|
167
|
+
if ('list' in asks) {
|
168
|
+
orderbook['asks'] = asks['list'];
|
169
|
+
}
|
170
|
+
}
|
171
|
+
return this.parseOrderBook (orderbook, symbol, undefined, 'bids', 'asks', 'price', 'currency_trade');
|
172
|
+
}
|
173
|
+
|
174
|
+
parseTicker (ticker, market = undefined) {
|
175
|
+
//
|
176
|
+
// [
|
177
|
+
// [1640789101000, 1292663.0, 1311823.61303, 1295794.252, 1311823.61303, 0.030175],
|
178
|
+
// [1640790902000, 1311823.61303, 1310820.96, 1290000.0, 1290000.0, 0.042533],
|
179
|
+
// ],
|
180
|
+
//
|
181
|
+
const symbol = this.safeSymbol (undefined, market);
|
182
|
+
const timestamp = this.milliseconds ();
|
183
|
+
const result = {
|
184
|
+
'symbol': symbol,
|
185
|
+
'timestamp': timestamp,
|
186
|
+
'datetime': this.iso8601 (timestamp),
|
187
|
+
'high': undefined,
|
188
|
+
'low': undefined,
|
189
|
+
'bid': undefined,
|
190
|
+
'bidVolume': undefined,
|
191
|
+
'ask': undefined,
|
192
|
+
'askVolume': undefined,
|
193
|
+
'vwap': undefined,
|
194
|
+
'open': undefined,
|
195
|
+
'close': undefined,
|
196
|
+
'last': undefined,
|
197
|
+
'previousClose': undefined,
|
198
|
+
'change': undefined,
|
199
|
+
'percentage': undefined,
|
200
|
+
'average': undefined,
|
201
|
+
'baseVolume': undefined,
|
202
|
+
'quoteVolume': undefined,
|
203
|
+
'info': ticker,
|
204
|
+
};
|
205
|
+
const tickerLength = ticker.length;
|
206
|
+
if (tickerLength > 0) {
|
207
|
+
const start = Math.max (tickerLength - 48, 0);
|
208
|
+
for (let i = start; i < ticker.length; i++) {
|
209
|
+
const candle = ticker[i];
|
210
|
+
if (result['open'] === undefined) {
|
211
|
+
result['open'] = this.safeString (candle, 1);
|
212
|
+
}
|
213
|
+
const high = this.safeString (candle, 2);
|
214
|
+
if ((result['high'] === undefined) || ((high !== undefined) && Precise.stringLt (result['high'], high))) {
|
215
|
+
result['high'] = high;
|
216
|
+
}
|
217
|
+
const low = this.safeString (candle, 3);
|
218
|
+
if ((result['low'] === undefined) || ((low !== undefined) && Precise.stringLt (result['low'], low))) {
|
219
|
+
result['low'] = low;
|
220
|
+
}
|
221
|
+
const baseVolume = this.safeString (candle, 5);
|
222
|
+
if (result['baseVolume'] === undefined) {
|
223
|
+
result['baseVolume'] = baseVolume;
|
224
|
+
} else {
|
225
|
+
result['baseVolume'] = Precise.stringAdd (result['baseVolume'], baseVolume);
|
226
|
+
}
|
227
|
+
}
|
228
|
+
const last = tickerLength - 1;
|
229
|
+
result['last'] = this.safeString (ticker[last], 4);
|
230
|
+
result['close'] = result['last'];
|
231
|
+
}
|
232
|
+
return this.safeTicker (result, market, false);
|
233
|
+
}
|
234
|
+
|
235
|
+
async fetchTicker (symbol, params = {}) {
|
236
|
+
await this.loadMarkets ();
|
237
|
+
const market = this.market (symbol);
|
238
|
+
const request = {
|
239
|
+
'symbol': market['id'],
|
240
|
+
};
|
241
|
+
const response = await this.publicGetJapanStatHighSymbol (this.extend (request, params));
|
242
|
+
const ticker = this.safeValue (response, 'trades');
|
243
|
+
//
|
244
|
+
// {
|
245
|
+
// "status": true,
|
246
|
+
// "volume_trade": "0.495703",
|
247
|
+
// "trades": [
|
248
|
+
// [1640789101000, 1292663.0, 1311823.61303, 1295794.252, 1311823.61303, 0.030175],
|
249
|
+
// [1640790902000, 1311823.61303, 1310820.96, 1290000.0, 1290000.0, 0.042533],
|
250
|
+
// ],
|
251
|
+
// }
|
252
|
+
//
|
253
|
+
return this.parseTicker (ticker, market);
|
254
|
+
}
|
255
|
+
|
256
|
+
convertMonthNameToString (cyrillic) {
|
257
|
+
const months = {
|
258
|
+
'Jan': '01',
|
259
|
+
'Feb': '02',
|
260
|
+
'Mar': '03',
|
261
|
+
'Apr': '04',
|
262
|
+
'May': '05',
|
263
|
+
'Jun': '06',
|
264
|
+
'Jul': '07',
|
265
|
+
'Aug': '08',
|
266
|
+
'Sept': '09',
|
267
|
+
'Oct': '10',
|
268
|
+
'Nov': '11',
|
269
|
+
'Dec': '12',
|
270
|
+
};
|
271
|
+
return this.safeString (months, cyrillic);
|
272
|
+
}
|
273
|
+
|
274
|
+
parseExchangeSpecificDatetime (cyrillic) {
|
275
|
+
const parts = cyrillic.split (' ');
|
276
|
+
let month = parts[0];
|
277
|
+
let day = parts[1].replace (',', '');
|
278
|
+
if (day.length < 2) {
|
279
|
+
day = '0' + day;
|
280
|
+
}
|
281
|
+
const year = parts[2].replace (',', '');
|
282
|
+
month = month.replace (',', '');
|
283
|
+
month = month.replace ('.', '');
|
284
|
+
month = this.convertMonthNameToString (month);
|
285
|
+
if (!month) {
|
286
|
+
throw new ExchangeError (this.id + ' parseTrade() unrecognized month name: ' + cyrillic);
|
287
|
+
}
|
288
|
+
const hms = parts[3];
|
289
|
+
const hmsParts = hms.split (':');
|
290
|
+
let h = this.safeString (hmsParts, 0);
|
291
|
+
let m = '00';
|
292
|
+
const ampm = this.safeString (parts, 4);
|
293
|
+
if (h === 'noon') {
|
294
|
+
h = '12';
|
295
|
+
} else {
|
296
|
+
let intH = parseInt (h);
|
297
|
+
if ((ampm !== undefined) && (ampm[0] === 'p')) {
|
298
|
+
intH = 12 + intH;
|
299
|
+
if (intH > 23) {
|
300
|
+
intH = 0;
|
301
|
+
}
|
302
|
+
}
|
303
|
+
h = intH.toString ();
|
304
|
+
if (h.length < 2) {
|
305
|
+
h = '0' + h;
|
306
|
+
}
|
307
|
+
m = this.safeString (hmsParts, 1, '00');
|
308
|
+
if (m.length < 2) {
|
309
|
+
m = '0' + m;
|
310
|
+
}
|
311
|
+
}
|
312
|
+
const ymd = [ year, month, day ].join ('-');
|
313
|
+
const ymdhms = ymd + 'T' + h + ':' + m + ':00';
|
314
|
+
const timestamp = this.parse8601 (ymdhms);
|
315
|
+
// server reports local time, adjust to UTC
|
316
|
+
// a special case for DST
|
317
|
+
// subtract 2 hours during winter
|
318
|
+
const intM = parseInt (m);
|
319
|
+
if (intM < 11 || intM > 2) {
|
320
|
+
return timestamp - 7200000;
|
321
|
+
}
|
322
|
+
// subtract 3 hours during summer
|
323
|
+
return timestamp - 10800000;
|
324
|
+
}
|
325
|
+
|
326
|
+
parseTrade (trade, market = undefined) {
|
327
|
+
const timestamp = this.parseExchangeSpecificDatetime (this.safeString (trade, 'pub_date'));
|
328
|
+
const id = this.safeString (trade, 'id');
|
329
|
+
const type = 'limit';
|
330
|
+
const side = this.safeString (trade, 'type');
|
331
|
+
const priceString = this.safeString (trade, 'price');
|
332
|
+
const amountString = this.safeString (trade, 'amnt_trade');
|
333
|
+
market = this.safeMarket (undefined, market);
|
334
|
+
return this.safeTrade ({
|
335
|
+
'id': id,
|
336
|
+
'info': trade,
|
337
|
+
'timestamp': timestamp,
|
338
|
+
'datetime': this.iso8601 (timestamp),
|
339
|
+
'symbol': market['symbol'],
|
340
|
+
'type': type,
|
341
|
+
'side': side,
|
342
|
+
'order': undefined,
|
343
|
+
'takerOrMaker': undefined,
|
344
|
+
'price': priceString,
|
345
|
+
'amount': amountString,
|
346
|
+
'cost': undefined,
|
347
|
+
'fee': undefined,
|
348
|
+
}, market);
|
349
|
+
}
|
350
|
+
|
351
|
+
async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) {
|
352
|
+
await this.loadMarkets ();
|
353
|
+
const market = this.market (symbol);
|
354
|
+
const request = {
|
355
|
+
'symbol': market['id'],
|
356
|
+
};
|
357
|
+
const response = await this.publicGetDealsSymbol (this.extend (request, params));
|
358
|
+
// they report each trade twice (once for both of the two sides of the fill)
|
359
|
+
// deduplicate trades for that reason
|
360
|
+
const trades = [];
|
361
|
+
for (let i = 0; i < response.length; i++) {
|
362
|
+
const id = this.safeInteger (response[i], 'id');
|
363
|
+
if (id % 2) {
|
364
|
+
trades.push (response[i]);
|
365
|
+
}
|
366
|
+
}
|
367
|
+
return this.parseTrades (trades, market, since, limit);
|
368
|
+
}
|
369
|
+
|
370
|
+
async createOrder (symbol, type, side, amount, price = undefined, params = {}) {
|
371
|
+
if (type === 'market') {
|
372
|
+
throw new ExchangeError (this.id + ' createOrder() allows limit orders only');
|
373
|
+
}
|
374
|
+
await this.loadMarkets ();
|
375
|
+
const market = this.market (symbol);
|
376
|
+
const method = 'privatePost' + this.capitalize (side) + 'Id';
|
377
|
+
const request = {
|
378
|
+
'count': amount,
|
379
|
+
'currency1': market['quoteId'],
|
380
|
+
'currency': market['baseId'],
|
381
|
+
'price': price,
|
382
|
+
};
|
383
|
+
return this[method] (this.extend (request, params));
|
384
|
+
}
|
385
|
+
|
386
|
+
async cancelOrder (id, symbol = undefined, params = {}) {
|
387
|
+
const request = {
|
388
|
+
'id': id,
|
389
|
+
};
|
390
|
+
return await this.privatePostRemoveOrderId (this.extend (request, params));
|
391
|
+
}
|
392
|
+
|
393
|
+
parseOrder (order, market = undefined) {
|
394
|
+
const timestamp = this.milliseconds ();
|
395
|
+
const symbol = this.safeSymbol (undefined, market);
|
396
|
+
const side = this.safeString (order, 'type');
|
397
|
+
const price = this.safeString (order, 'price');
|
398
|
+
const amount = this.safeString (order, 'amnt_trade');
|
399
|
+
const remaining = this.safeString (order, 'amnt_trade');
|
400
|
+
return this.safeOrder ({
|
401
|
+
'id': this.safeString (order, 'id'),
|
402
|
+
'clientOrderId': undefined,
|
403
|
+
'timestamp': timestamp, // until they fix their timestamp
|
404
|
+
'datetime': this.iso8601 (timestamp),
|
405
|
+
'lastTradeTimestamp': undefined,
|
406
|
+
'status': 'open',
|
407
|
+
'symbol': symbol,
|
408
|
+
'type': undefined,
|
409
|
+
'timeInForce': undefined,
|
410
|
+
'postOnly': undefined,
|
411
|
+
'side': side,
|
412
|
+
'price': price,
|
413
|
+
'stopPrice': undefined,
|
414
|
+
'amount': amount,
|
415
|
+
'filled': undefined,
|
416
|
+
'remaining': remaining,
|
417
|
+
'trades': undefined,
|
418
|
+
'info': order,
|
419
|
+
'cost': undefined,
|
420
|
+
'average': undefined,
|
421
|
+
'fee': undefined,
|
422
|
+
}, market);
|
423
|
+
}
|
424
|
+
|
425
|
+
async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
426
|
+
if (symbol === undefined) {
|
427
|
+
throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol argument');
|
428
|
+
}
|
429
|
+
await this.loadMarkets ();
|
430
|
+
const market = this.market (symbol);
|
431
|
+
const request = {
|
432
|
+
'symbol': market['id'],
|
433
|
+
};
|
434
|
+
const response = await this.privatePostMyOrdersSymbol (this.extend (request, params));
|
435
|
+
const orders = this.safeValue (response, 'your_open_orders');
|
436
|
+
return this.parseOrders (orders, market, since, limit);
|
437
|
+
}
|
438
|
+
|
439
|
+
nonce () {
|
440
|
+
return this.milliseconds ();
|
441
|
+
}
|
442
|
+
|
443
|
+
sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
444
|
+
let url = this.urls['api'] + '/' + this.implodeParams (path, params);
|
445
|
+
const query = this.omit (params, this.extractParams (path));
|
446
|
+
if (api === 'public') {
|
447
|
+
if (Object.keys (query).length) {
|
448
|
+
url += this.implodeParams (path, query);
|
449
|
+
}
|
450
|
+
} else {
|
451
|
+
this.checkRequiredCredentials ();
|
452
|
+
const nonce = this.nonce ();
|
453
|
+
body = this.urlencode (this.extend ({
|
454
|
+
'out_order_id': nonce,
|
455
|
+
'nonce': nonce,
|
456
|
+
}, query));
|
457
|
+
const auth = body + this.secret;
|
458
|
+
headers = {
|
459
|
+
'public-key': this.apiKey,
|
460
|
+
'api-sign': this.hash (this.encode (auth), 'sha256'),
|
461
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
462
|
+
};
|
463
|
+
}
|
464
|
+
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
465
|
+
}
|
466
|
+
};
|