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/bitstamp1.js
ADDED
@@ -0,0 +1,343 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
// ---------------------------------------------------------------------------
|
4
|
+
|
5
|
+
const Exchange = require ('./base/Exchange');
|
6
|
+
const { BadSymbol, ExchangeError } = require ('./base/errors');
|
7
|
+
const Precise = require ('./base/Precise');
|
8
|
+
|
9
|
+
// ---------------------------------------------------------------------------
|
10
|
+
|
11
|
+
module.exports = class bitstamp1 extends Exchange {
|
12
|
+
describe () {
|
13
|
+
return this.deepExtend (super.describe (), {
|
14
|
+
'id': 'bitstamp1',
|
15
|
+
'name': 'Bitstamp',
|
16
|
+
'countries': [ 'GB' ],
|
17
|
+
'rateLimit': 1000,
|
18
|
+
'version': 'v1',
|
19
|
+
'has': {
|
20
|
+
'CORS': true,
|
21
|
+
'spot': true,
|
22
|
+
'margin': false,
|
23
|
+
'swap': false,
|
24
|
+
'future': false,
|
25
|
+
'option': false,
|
26
|
+
'addMargin': false,
|
27
|
+
'cancelOrder': true,
|
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
|
+
'fetchMyTrades': true,
|
44
|
+
'fetchOrder': undefined,
|
45
|
+
'fetchOrderBook': true,
|
46
|
+
'fetchPosition': false,
|
47
|
+
'fetchPositions': false,
|
48
|
+
'fetchPositionsRisk': false,
|
49
|
+
'fetchPremiumIndexOHLCV': false,
|
50
|
+
'fetchTicker': true,
|
51
|
+
'fetchTrades': true,
|
52
|
+
'reduceMargin': false,
|
53
|
+
'setLeverage': false,
|
54
|
+
'setMarginMode': false,
|
55
|
+
'setPositionMode': false,
|
56
|
+
},
|
57
|
+
'urls': {
|
58
|
+
'logo': 'https://user-images.githubusercontent.com/1294454/27786377-8c8ab57e-5fe9-11e7-8ea4-2b05b6bcceec.jpg',
|
59
|
+
'api': 'https://www.bitstamp.net/api',
|
60
|
+
'www': 'https://www.bitstamp.net',
|
61
|
+
'doc': 'https://www.bitstamp.net/api',
|
62
|
+
},
|
63
|
+
'requiredCredentials': {
|
64
|
+
'apiKey': true,
|
65
|
+
'secret': true,
|
66
|
+
'uid': true,
|
67
|
+
},
|
68
|
+
'api': {
|
69
|
+
'public': {
|
70
|
+
'get': [
|
71
|
+
'ticker',
|
72
|
+
'ticker_hour',
|
73
|
+
'order_book',
|
74
|
+
'transactions',
|
75
|
+
'eur_usd',
|
76
|
+
],
|
77
|
+
},
|
78
|
+
'private': {
|
79
|
+
'post': [
|
80
|
+
'balance',
|
81
|
+
'user_transactions',
|
82
|
+
'open_orders',
|
83
|
+
'order_status',
|
84
|
+
'cancel_order',
|
85
|
+
'cancel_all_orders',
|
86
|
+
'buy',
|
87
|
+
'sell',
|
88
|
+
'bitcoin_deposit_address',
|
89
|
+
'unconfirmed_btc',
|
90
|
+
'ripple_withdrawal',
|
91
|
+
'ripple_address',
|
92
|
+
'withdrawal_requests',
|
93
|
+
'bitcoin_withdrawal',
|
94
|
+
],
|
95
|
+
},
|
96
|
+
},
|
97
|
+
'markets': {
|
98
|
+
'BTC/USD': { 'id': 'btcusd', 'symbol': 'BTC/USD', 'base': 'BTC', 'quote': 'USD', 'baseId': 'btc', 'quoteId': 'usd', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': true },
|
99
|
+
'BTC/EUR': { 'id': 'btceur', 'symbol': 'BTC/EUR', 'base': 'BTC', 'quote': 'EUR', 'baseId': 'btc', 'quoteId': 'eur', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': true },
|
100
|
+
'EUR/USD': { 'id': 'eurusd', 'symbol': 'EUR/USD', 'base': 'EUR', 'quote': 'USD', 'baseId': 'eur', 'quoteId': 'usd', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': true },
|
101
|
+
'XRP/USD': { 'id': 'xrpusd', 'symbol': 'XRP/USD', 'base': 'XRP', 'quote': 'USD', 'baseId': 'xrp', 'quoteId': 'usd', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': true },
|
102
|
+
'XRP/EUR': { 'id': 'xrpeur', 'symbol': 'XRP/EUR', 'base': 'XRP', 'quote': 'EUR', 'baseId': 'xrp', 'quoteId': 'eur', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': true },
|
103
|
+
'XRP/BTC': { 'id': 'xrpbtc', 'symbol': 'XRP/BTC', 'base': 'XRP', 'quote': 'BTC', 'baseId': 'xrp', 'quoteId': 'btc', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': true },
|
104
|
+
'LTC/USD': { 'id': 'ltcusd', 'symbol': 'LTC/USD', 'base': 'LTC', 'quote': 'USD', 'baseId': 'ltc', 'quoteId': 'usd', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': true },
|
105
|
+
'LTC/EUR': { 'id': 'ltceur', 'symbol': 'LTC/EUR', 'base': 'LTC', 'quote': 'EUR', 'baseId': 'ltc', 'quoteId': 'eur', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': true },
|
106
|
+
'LTC/BTC': { 'id': 'ltcbtc', 'symbol': 'LTC/BTC', 'base': 'LTC', 'quote': 'BTC', 'baseId': 'ltc', 'quoteId': 'btc', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': true },
|
107
|
+
'ETH/USD': { 'id': 'ethusd', 'symbol': 'ETH/USD', 'base': 'ETH', 'quote': 'USD', 'baseId': 'eth', 'quoteId': 'usd', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': true },
|
108
|
+
'ETH/EUR': { 'id': 'etheur', 'symbol': 'ETH/EUR', 'base': 'ETH', 'quote': 'EUR', 'baseId': 'eth', 'quoteId': 'eur', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': true },
|
109
|
+
'ETH/BTC': { 'id': 'ethbtc', 'symbol': 'ETH/BTC', 'base': 'ETH', 'quote': 'BTC', 'baseId': 'eth', 'quoteId': 'btc', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': true },
|
110
|
+
},
|
111
|
+
});
|
112
|
+
}
|
113
|
+
|
114
|
+
async fetchOrderBook (symbol, limit = undefined, params = {}) {
|
115
|
+
if (symbol !== 'BTC/USD') {
|
116
|
+
throw new ExchangeError (this.id + ' ' + this.version + " fetchOrderBook doesn't support " + symbol + ', use it for BTC/USD only');
|
117
|
+
}
|
118
|
+
await this.loadMarkets ();
|
119
|
+
const orderbook = await this.publicGetOrderBook (params);
|
120
|
+
const timestamp = this.safeTimestamp (orderbook, 'timestamp');
|
121
|
+
return this.parseOrderBook (orderbook, symbol, timestamp);
|
122
|
+
}
|
123
|
+
|
124
|
+
parseTicker (ticker, market = undefined) {
|
125
|
+
//
|
126
|
+
// {
|
127
|
+
// "volume": "2836.47827985",
|
128
|
+
// "last": "36544.93",
|
129
|
+
// "timestamp": "1643372072",
|
130
|
+
// "bid": "36535.79",
|
131
|
+
// "vwap":"36594.20",
|
132
|
+
// "high": "37534.15",
|
133
|
+
// "low": "35511.32",
|
134
|
+
// "ask": "36548.47",
|
135
|
+
// "open": 37179.62
|
136
|
+
// }
|
137
|
+
//
|
138
|
+
const symbol = this.safeSymbol (undefined, market);
|
139
|
+
const timestamp = this.safeTimestamp (ticker, 'timestamp');
|
140
|
+
const vwap = this.safeString (ticker, 'vwap');
|
141
|
+
const baseVolume = this.safeString (ticker, 'volume');
|
142
|
+
const quoteVolume = Precise.stringMul (baseVolume, vwap);
|
143
|
+
const last = this.safeString (ticker, 'last');
|
144
|
+
return this.safeTicker ({
|
145
|
+
'symbol': symbol,
|
146
|
+
'timestamp': timestamp,
|
147
|
+
'datetime': this.iso8601 (timestamp),
|
148
|
+
'high': this.safeString (ticker, 'high'),
|
149
|
+
'low': this.safeString (ticker, 'low'),
|
150
|
+
'bid': this.safeString (ticker, 'bid'),
|
151
|
+
'bidVolume': undefined,
|
152
|
+
'ask': this.safeString (ticker, 'ask'),
|
153
|
+
'askVolume': undefined,
|
154
|
+
'vwap': vwap,
|
155
|
+
'open': this.safeString (ticker, 'open'),
|
156
|
+
'close': last,
|
157
|
+
'last': last,
|
158
|
+
'previousClose': undefined,
|
159
|
+
'change': undefined,
|
160
|
+
'percentage': undefined,
|
161
|
+
'average': undefined,
|
162
|
+
'baseVolume': baseVolume,
|
163
|
+
'quoteVolume': quoteVolume,
|
164
|
+
'info': ticker,
|
165
|
+
}, market, false);
|
166
|
+
}
|
167
|
+
|
168
|
+
async fetchTicker (symbol, params = {}) {
|
169
|
+
if (symbol !== 'BTC/USD') {
|
170
|
+
throw new ExchangeError (this.id + ' ' + this.version + " fetchTicker doesn't support " + symbol + ', use it for BTC/USD only');
|
171
|
+
}
|
172
|
+
await this.loadMarkets ();
|
173
|
+
const market = this.market (symbol);
|
174
|
+
const ticker = await this.publicGetTicker (params);
|
175
|
+
//
|
176
|
+
// {
|
177
|
+
// "volume": "2836.47827985",
|
178
|
+
// "last": "36544.93",
|
179
|
+
// "timestamp": "1643372072",
|
180
|
+
// "bid": "36535.79",
|
181
|
+
// "vwap":"36594.20",
|
182
|
+
// "high": "37534.15",
|
183
|
+
// "low": "35511.32",
|
184
|
+
// "ask": "36548.47",
|
185
|
+
// "open": 37179.62
|
186
|
+
// }
|
187
|
+
//
|
188
|
+
return this.parseTicker (ticker, market);
|
189
|
+
}
|
190
|
+
|
191
|
+
parseTrade (trade, market = undefined) {
|
192
|
+
const timestamp = this.safeTimestamp2 (trade, 'date', 'datetime');
|
193
|
+
const side = (trade['type'] === 0) ? 'buy' : 'sell';
|
194
|
+
const orderId = this.safeString (trade, 'order_id');
|
195
|
+
const id = this.safeString (trade, 'tid');
|
196
|
+
const price = this.safeString (trade, 'price');
|
197
|
+
const amount = this.safeString (trade, 'amount');
|
198
|
+
const marketId = this.safeString (trade, 'currency_pair');
|
199
|
+
market = this.safeMarket (marketId, market);
|
200
|
+
return this.safeTrade ({
|
201
|
+
'id': id,
|
202
|
+
'info': trade,
|
203
|
+
'timestamp': timestamp,
|
204
|
+
'datetime': this.iso8601 (timestamp),
|
205
|
+
'symbol': market['symbol'],
|
206
|
+
'order': orderId,
|
207
|
+
'type': undefined,
|
208
|
+
'side': side,
|
209
|
+
'takerOrMaker': undefined,
|
210
|
+
'price': price,
|
211
|
+
'amount': amount,
|
212
|
+
'cost': undefined,
|
213
|
+
'fee': undefined,
|
214
|
+
}, market);
|
215
|
+
}
|
216
|
+
|
217
|
+
async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) {
|
218
|
+
if (symbol !== 'BTC/USD') {
|
219
|
+
throw new BadSymbol (this.id + ' ' + this.version + " fetchTrades doesn't support " + symbol + ', use it for BTC/USD only');
|
220
|
+
}
|
221
|
+
await this.loadMarkets ();
|
222
|
+
const market = this.market (symbol);
|
223
|
+
const request = {
|
224
|
+
'time': 'minute',
|
225
|
+
};
|
226
|
+
const response = await this.publicGetTransactions (this.extend (request, params));
|
227
|
+
return this.parseTrades (response, market, since, limit);
|
228
|
+
}
|
229
|
+
|
230
|
+
parseBalance (response) {
|
231
|
+
const result = { 'info': response };
|
232
|
+
const codes = Object.keys (this.currencies);
|
233
|
+
for (let i = 0; i < codes.length; i++) {
|
234
|
+
const code = codes[i];
|
235
|
+
const currency = this.currency (code);
|
236
|
+
const currencyId = currency['id'];
|
237
|
+
const account = this.account ();
|
238
|
+
account['free'] = this.safeString (response, currencyId + '_available');
|
239
|
+
account['used'] = this.safeString (response, currencyId + '_reserved');
|
240
|
+
account['total'] = this.safeString (response, currencyId + '_balance');
|
241
|
+
result[code] = account;
|
242
|
+
}
|
243
|
+
return this.safeBalance (result);
|
244
|
+
}
|
245
|
+
|
246
|
+
async fetchBalance (params = {}) {
|
247
|
+
const response = await this.privatePostBalance (params);
|
248
|
+
return this.parseBalance (response);
|
249
|
+
}
|
250
|
+
|
251
|
+
async createOrder (symbol, type, side, amount, price = undefined, params = {}) {
|
252
|
+
if (type !== 'limit') {
|
253
|
+
throw new ExchangeError (this.id + ' ' + this.version + ' accepts limit orders only');
|
254
|
+
}
|
255
|
+
if (symbol !== 'BTC/USD') {
|
256
|
+
throw new ExchangeError (this.id + ' v1 supports BTC/USD orders only');
|
257
|
+
}
|
258
|
+
await this.loadMarkets ();
|
259
|
+
const method = 'privatePost' + this.capitalize (side);
|
260
|
+
const request = {
|
261
|
+
'amount': amount,
|
262
|
+
'price': price,
|
263
|
+
};
|
264
|
+
const response = await this[method] (this.extend (request, params));
|
265
|
+
const id = this.safeString (response, 'id');
|
266
|
+
return {
|
267
|
+
'info': response,
|
268
|
+
'id': id,
|
269
|
+
};
|
270
|
+
}
|
271
|
+
|
272
|
+
async cancelOrder (id, symbol = undefined, params = {}) {
|
273
|
+
return await this.privatePostCancelOrder ({ 'id': id });
|
274
|
+
}
|
275
|
+
|
276
|
+
parseOrderStatus (status) {
|
277
|
+
const statuses = {
|
278
|
+
'In Queue': 'open',
|
279
|
+
'Open': 'open',
|
280
|
+
'Finished': 'closed',
|
281
|
+
'Canceled': 'canceled',
|
282
|
+
};
|
283
|
+
return this.safeString (statuses, status, status);
|
284
|
+
}
|
285
|
+
|
286
|
+
async fetchOrderStatus (id, symbol = undefined, params = {}) {
|
287
|
+
await this.loadMarkets ();
|
288
|
+
const request = {
|
289
|
+
'id': id,
|
290
|
+
};
|
291
|
+
const response = await this.privatePostOrderStatus (this.extend (request, params));
|
292
|
+
return this.parseOrderStatus (response);
|
293
|
+
}
|
294
|
+
|
295
|
+
async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
296
|
+
await this.loadMarkets ();
|
297
|
+
let market = undefined;
|
298
|
+
if (symbol !== undefined) {
|
299
|
+
market = this.market (symbol);
|
300
|
+
}
|
301
|
+
const pair = market ? market['id'] : 'all';
|
302
|
+
const request = {
|
303
|
+
'id': pair,
|
304
|
+
};
|
305
|
+
const response = await this.privatePostOpenOrdersId (this.extend (request, params));
|
306
|
+
return this.parseTrades (response, market, since, limit);
|
307
|
+
}
|
308
|
+
|
309
|
+
sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
310
|
+
let url = this.urls['api'] + '/' + this.implodeParams (path, params);
|
311
|
+
let query = this.omit (params, this.extractParams (path));
|
312
|
+
if (api === 'public') {
|
313
|
+
if (Object.keys (query).length) {
|
314
|
+
url += '?' + this.urlencode (query);
|
315
|
+
}
|
316
|
+
} else {
|
317
|
+
this.checkRequiredCredentials ();
|
318
|
+
const nonce = this.nonce ().toString ();
|
319
|
+
const auth = nonce + this.uid + this.apiKey;
|
320
|
+
const signature = this.encode (this.hmac (this.encode (auth), this.encode (this.secret)));
|
321
|
+
query = this.extend ({
|
322
|
+
'key': this.apiKey,
|
323
|
+
'signature': signature.toUpperCase (),
|
324
|
+
'nonce': nonce,
|
325
|
+
}, query);
|
326
|
+
body = this.urlencode (query);
|
327
|
+
headers = {
|
328
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
329
|
+
};
|
330
|
+
}
|
331
|
+
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
332
|
+
}
|
333
|
+
|
334
|
+
handleErrors (httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
335
|
+
if (response === undefined) {
|
336
|
+
return;
|
337
|
+
}
|
338
|
+
const status = this.safeString (response, 'status');
|
339
|
+
if (status === 'error') {
|
340
|
+
throw new ExchangeError (this.id + ' ' + this.json (response));
|
341
|
+
}
|
342
|
+
}
|
343
|
+
};
|