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/paymium.js
ADDED
@@ -0,0 +1,498 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
// ---------------------------------------------------------------------------
|
4
|
+
|
5
|
+
const Exchange = require ('./base/Exchange');
|
6
|
+
const { ExchangeError } = require ('./base/errors');
|
7
|
+
const Precise = require ('./base/Precise');
|
8
|
+
|
9
|
+
// ---------------------------------------------------------------------------
|
10
|
+
|
11
|
+
module.exports = class paymium extends Exchange {
|
12
|
+
describe () {
|
13
|
+
return this.deepExtend (super.describe (), {
|
14
|
+
'id': 'paymium',
|
15
|
+
'name': 'Paymium',
|
16
|
+
'countries': [ 'FR', 'EU' ],
|
17
|
+
'rateLimit': 2000,
|
18
|
+
'version': 'v1',
|
19
|
+
'has': {
|
20
|
+
'CORS': true,
|
21
|
+
'spot': true,
|
22
|
+
'margin': undefined,
|
23
|
+
'swap': false,
|
24
|
+
'future': false,
|
25
|
+
'option': false,
|
26
|
+
'cancelOrder': true,
|
27
|
+
'createDepositAddress': true,
|
28
|
+
'createOrder': true,
|
29
|
+
'fetchBalance': true,
|
30
|
+
'fetchDepositAddress': true,
|
31
|
+
'fetchDepositAddresses': true,
|
32
|
+
'fetchFundingHistory': false,
|
33
|
+
'fetchFundingRate': false,
|
34
|
+
'fetchFundingRateHistory': false,
|
35
|
+
'fetchFundingRates': false,
|
36
|
+
'fetchIndexOHLCV': false,
|
37
|
+
'fetchMarkOHLCV': false,
|
38
|
+
'fetchOrderBook': true,
|
39
|
+
'fetchPremiumIndexOHLCV': false,
|
40
|
+
'fetchTicker': true,
|
41
|
+
'fetchTrades': true,
|
42
|
+
'fetchTradingFee': false,
|
43
|
+
'fetchTradingFees': false,
|
44
|
+
'transfer': true,
|
45
|
+
},
|
46
|
+
'urls': {
|
47
|
+
'logo': 'https://user-images.githubusercontent.com/51840849/87153930-f0f02200-c2c0-11ea-9c0a-40337375ae89.jpg',
|
48
|
+
'api': 'https://paymium.com/api',
|
49
|
+
'www': 'https://www.paymium.com',
|
50
|
+
'fees': 'https://www.paymium.com/page/help/fees',
|
51
|
+
'doc': [
|
52
|
+
'https://github.com/Paymium/api-documentation',
|
53
|
+
'https://www.paymium.com/page/developers',
|
54
|
+
'https://paymium.github.io/api-documentation/',
|
55
|
+
],
|
56
|
+
'referral': 'https://www.paymium.com/page/sign-up?referral=eDAzPoRQFMvaAB8sf-qj',
|
57
|
+
},
|
58
|
+
'api': {
|
59
|
+
'public': {
|
60
|
+
'get': [
|
61
|
+
'countries',
|
62
|
+
'data/{currency}/ticker',
|
63
|
+
'data/{currency}/trades',
|
64
|
+
'data/{currency}/depth',
|
65
|
+
'bitcoin_charts/{id}/trades',
|
66
|
+
'bitcoin_charts/{id}/depth',
|
67
|
+
],
|
68
|
+
},
|
69
|
+
'private': {
|
70
|
+
'get': [
|
71
|
+
'user',
|
72
|
+
'user/addresses',
|
73
|
+
'user/addresses/{address}',
|
74
|
+
'user/orders',
|
75
|
+
'user/orders/{uuid}',
|
76
|
+
'user/price_alerts',
|
77
|
+
'merchant/get_payment/{uuid}',
|
78
|
+
],
|
79
|
+
'post': [
|
80
|
+
'user/addresses',
|
81
|
+
'user/orders',
|
82
|
+
'user/withdrawals',
|
83
|
+
'user/email_transfers',
|
84
|
+
'user/payment_requests',
|
85
|
+
'user/price_alerts',
|
86
|
+
'merchant/create_payment',
|
87
|
+
],
|
88
|
+
'delete': [
|
89
|
+
'user/orders/{uuid}',
|
90
|
+
'user/orders/{uuid}/cancel',
|
91
|
+
'user/price_alerts/{id}',
|
92
|
+
],
|
93
|
+
},
|
94
|
+
},
|
95
|
+
'markets': {
|
96
|
+
'BTC/EUR': { 'id': 'eur', 'symbol': 'BTC/EUR', 'base': 'BTC', 'quote': 'EUR', 'baseId': 'btc', 'quoteId': 'eur', 'type': 'spot', 'spot': true },
|
97
|
+
},
|
98
|
+
'fees': {
|
99
|
+
'trading': {
|
100
|
+
'maker': this.parseNumber ('-0.001'),
|
101
|
+
'taker': this.parseNumber ('0.005'),
|
102
|
+
},
|
103
|
+
},
|
104
|
+
});
|
105
|
+
}
|
106
|
+
|
107
|
+
parseBalance (response) {
|
108
|
+
const result = { 'info': response };
|
109
|
+
const currencies = Object.keys (this.currencies);
|
110
|
+
for (let i = 0; i < currencies.length; i++) {
|
111
|
+
const code = currencies[i];
|
112
|
+
const currency = this.currency (code);
|
113
|
+
const currencyId = currency['id'];
|
114
|
+
const free = 'balance_' + currencyId;
|
115
|
+
if (free in response) {
|
116
|
+
const account = this.account ();
|
117
|
+
const used = 'locked_' + currencyId;
|
118
|
+
account['free'] = this.safeString (response, free);
|
119
|
+
account['used'] = this.safeString (response, used);
|
120
|
+
result[code] = account;
|
121
|
+
}
|
122
|
+
}
|
123
|
+
return this.safeBalance (result);
|
124
|
+
}
|
125
|
+
|
126
|
+
async fetchBalance (params = {}) {
|
127
|
+
await this.loadMarkets ();
|
128
|
+
const response = await this.privateGetUser (params);
|
129
|
+
return this.parseBalance (response);
|
130
|
+
}
|
131
|
+
|
132
|
+
async fetchOrderBook (symbol, limit = undefined, params = {}) {
|
133
|
+
await this.loadMarkets ();
|
134
|
+
const request = {
|
135
|
+
'currency': this.marketId (symbol),
|
136
|
+
};
|
137
|
+
const response = await this.publicGetDataCurrencyDepth (this.extend (request, params));
|
138
|
+
return this.parseOrderBook (response, symbol, undefined, 'bids', 'asks', 'price', 'amount');
|
139
|
+
}
|
140
|
+
|
141
|
+
parseTicker (ticker, market = undefined) {
|
142
|
+
//
|
143
|
+
// {
|
144
|
+
// "high":"33740.82",
|
145
|
+
// "low":"32185.15",
|
146
|
+
// "volume":"4.7890433",
|
147
|
+
// "bid":"33313.53",
|
148
|
+
// "ask":"33497.97",
|
149
|
+
// "midpoint":"33405.75",
|
150
|
+
// "vwap":"32802.5263553",
|
151
|
+
// "at":1643381654,
|
152
|
+
// "price":"33143.91",
|
153
|
+
// "open":"33116.86",
|
154
|
+
// "variation":"0.0817",
|
155
|
+
// "currency":"EUR",
|
156
|
+
// "trade_id":"ce2f5152-3ac5-412d-9b24-9fa72338474c",
|
157
|
+
// "size":"0.00041087"
|
158
|
+
// }
|
159
|
+
//
|
160
|
+
const symbol = this.safeSymbol (undefined, market);
|
161
|
+
const timestamp = this.safeTimestamp (ticker, 'at');
|
162
|
+
const vwap = this.safeString (ticker, 'vwap');
|
163
|
+
const baseVolume = this.safeString (ticker, 'volume');
|
164
|
+
const quoteVolume = Precise.stringMul (baseVolume, vwap);
|
165
|
+
const last = this.safeString (ticker, 'price');
|
166
|
+
return this.safeTicker ({
|
167
|
+
'symbol': symbol,
|
168
|
+
'timestamp': timestamp,
|
169
|
+
'datetime': this.iso8601 (timestamp),
|
170
|
+
'high': this.safeString (ticker, 'high'),
|
171
|
+
'low': this.safeString (ticker, 'low'),
|
172
|
+
'bid': this.safeString (ticker, 'bid'),
|
173
|
+
'bidVolume': undefined,
|
174
|
+
'ask': this.safeString (ticker, 'ask'),
|
175
|
+
'askVolume': undefined,
|
176
|
+
'vwap': vwap,
|
177
|
+
'open': this.safeString (ticker, 'open'),
|
178
|
+
'close': last,
|
179
|
+
'last': last,
|
180
|
+
'previousClose': undefined,
|
181
|
+
'change': undefined,
|
182
|
+
'percentage': this.safeString (ticker, 'variation'),
|
183
|
+
'average': undefined,
|
184
|
+
'baseVolume': baseVolume,
|
185
|
+
'quoteVolume': quoteVolume,
|
186
|
+
'info': ticker,
|
187
|
+
}, market, false);
|
188
|
+
}
|
189
|
+
|
190
|
+
async fetchTicker (symbol, params = {}) {
|
191
|
+
await this.loadMarkets ();
|
192
|
+
const market = this.market (symbol);
|
193
|
+
const request = {
|
194
|
+
'currency': market['id'],
|
195
|
+
};
|
196
|
+
const ticker = await this.publicGetDataCurrencyTicker (this.extend (request, params));
|
197
|
+
//
|
198
|
+
// {
|
199
|
+
// "high":"33740.82",
|
200
|
+
// "low":"32185.15",
|
201
|
+
// "volume":"4.7890433",
|
202
|
+
// "bid":"33313.53",
|
203
|
+
// "ask":"33497.97",
|
204
|
+
// "midpoint":"33405.75",
|
205
|
+
// "vwap":"32802.5263553",
|
206
|
+
// "at":1643381654,
|
207
|
+
// "price":"33143.91",
|
208
|
+
// "open":"33116.86",
|
209
|
+
// "variation":"0.0817",
|
210
|
+
// "currency":"EUR",
|
211
|
+
// "trade_id":"ce2f5152-3ac5-412d-9b24-9fa72338474c",
|
212
|
+
// "size":"0.00041087"
|
213
|
+
// }
|
214
|
+
//
|
215
|
+
return this.parseTicker (ticker, market);
|
216
|
+
}
|
217
|
+
|
218
|
+
parseTrade (trade, market) {
|
219
|
+
const timestamp = this.safeTimestamp (trade, 'created_at_int');
|
220
|
+
const id = this.safeString (trade, 'uuid');
|
221
|
+
market = this.safeMarket (undefined, market);
|
222
|
+
const side = this.safeString (trade, 'side');
|
223
|
+
const price = this.safeString (trade, 'price');
|
224
|
+
const amountField = 'traded_' + market['base'].toLowerCase ();
|
225
|
+
const amount = this.safeString (trade, amountField);
|
226
|
+
return this.safeTrade ({
|
227
|
+
'info': trade,
|
228
|
+
'id': id,
|
229
|
+
'order': undefined,
|
230
|
+
'timestamp': timestamp,
|
231
|
+
'datetime': this.iso8601 (timestamp),
|
232
|
+
'symbol': market['symbol'],
|
233
|
+
'type': undefined,
|
234
|
+
'side': side,
|
235
|
+
'takerOrMaker': undefined,
|
236
|
+
'price': price,
|
237
|
+
'amount': amount,
|
238
|
+
'cost': undefined,
|
239
|
+
'fee': undefined,
|
240
|
+
}, market);
|
241
|
+
}
|
242
|
+
|
243
|
+
async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) {
|
244
|
+
await this.loadMarkets ();
|
245
|
+
const market = this.market (symbol);
|
246
|
+
const request = {
|
247
|
+
'currency': market['id'],
|
248
|
+
};
|
249
|
+
const response = await this.publicGetDataCurrencyTrades (this.extend (request, params));
|
250
|
+
return this.parseTrades (response, market, since, limit);
|
251
|
+
}
|
252
|
+
|
253
|
+
async createDepositAddress (code, params = {}) {
|
254
|
+
await this.loadMarkets ();
|
255
|
+
const response = await this.privatePostUserAddresses (params);
|
256
|
+
//
|
257
|
+
// {
|
258
|
+
// "address": "1HdjGr6WCTcnmW1tNNsHX7fh4Jr5C2PeKe",
|
259
|
+
// "valid_until": 1620041926,
|
260
|
+
// "currency": "BTC",
|
261
|
+
// "label": "Savings"
|
262
|
+
// }
|
263
|
+
//
|
264
|
+
return this.parseDepositAddress (response);
|
265
|
+
}
|
266
|
+
|
267
|
+
async fetchDepositAddress (code, params = {}) {
|
268
|
+
await this.loadMarkets ();
|
269
|
+
const request = {
|
270
|
+
'address': code,
|
271
|
+
};
|
272
|
+
const response = await this.privateGetUserAddressesAddress (this.extend (request, params));
|
273
|
+
//
|
274
|
+
// {
|
275
|
+
// "address": "1HdjGr6WCTcnmW1tNNsHX7fh4Jr5C2PeKe",
|
276
|
+
// "valid_until": 1620041926,
|
277
|
+
// "currency": "BTC",
|
278
|
+
// "label": "Savings"
|
279
|
+
// }
|
280
|
+
//
|
281
|
+
return this.parseDepositAddress (response);
|
282
|
+
}
|
283
|
+
|
284
|
+
async fetchDepositAddresses (codes = undefined, params = {}) {
|
285
|
+
await this.loadMarkets ();
|
286
|
+
const response = await this.privateGetUserAddresses (params);
|
287
|
+
//
|
288
|
+
// [
|
289
|
+
// {
|
290
|
+
// "address": "1HdjGr6WCTcnmW1tNNsHX7fh4Jr5C2PeKe",
|
291
|
+
// "valid_until": 1620041926,
|
292
|
+
// "currency": "BTC",
|
293
|
+
// "label": "Savings"
|
294
|
+
// }
|
295
|
+
// ]
|
296
|
+
//
|
297
|
+
return this.parseDepositAddresses (response, codes);
|
298
|
+
}
|
299
|
+
|
300
|
+
parseDepositAddress (depositAddress, currency = undefined) {
|
301
|
+
//
|
302
|
+
// {
|
303
|
+
// "address": "1HdjGr6WCTcnmW1tNNsHX7fh4Jr5C2PeKe",
|
304
|
+
// "valid_until": 1620041926,
|
305
|
+
// "currency": "BTC",
|
306
|
+
// "label": "Savings"
|
307
|
+
// }
|
308
|
+
//
|
309
|
+
const address = this.safeString (depositAddress, 'address');
|
310
|
+
const currencyId = this.safeString (depositAddress, 'currency');
|
311
|
+
return {
|
312
|
+
'info': depositAddress,
|
313
|
+
'currency': this.safeCurrencyCode (currencyId, currency),
|
314
|
+
'address': address,
|
315
|
+
'tag': undefined,
|
316
|
+
'network': undefined,
|
317
|
+
};
|
318
|
+
}
|
319
|
+
|
320
|
+
async createOrder (symbol, type, side, amount, price = undefined, params = {}) {
|
321
|
+
await this.loadMarkets ();
|
322
|
+
const request = {
|
323
|
+
'type': this.capitalize (type) + 'Order',
|
324
|
+
'currency': this.marketId (symbol),
|
325
|
+
'direction': side,
|
326
|
+
'amount': amount,
|
327
|
+
};
|
328
|
+
if (type !== 'market') {
|
329
|
+
request['price'] = price;
|
330
|
+
}
|
331
|
+
const response = await this.privatePostUserOrders (this.extend (request, params));
|
332
|
+
return {
|
333
|
+
'info': response,
|
334
|
+
'id': response['uuid'],
|
335
|
+
};
|
336
|
+
}
|
337
|
+
|
338
|
+
async cancelOrder (id, symbol = undefined, params = {}) {
|
339
|
+
const request = {
|
340
|
+
'uuid': id,
|
341
|
+
};
|
342
|
+
return await this.privateDeleteUserOrdersUuidCancel (this.extend (request, params));
|
343
|
+
}
|
344
|
+
|
345
|
+
async transfer (code, amount, fromAccount, toAccount, params = {}) {
|
346
|
+
await this.loadMarkets ();
|
347
|
+
const currency = this.currency (code);
|
348
|
+
if (toAccount.indexOf ('@') < 0) {
|
349
|
+
throw new ExchangeError (this.id + ' transfer() only allows transfers to an email address');
|
350
|
+
}
|
351
|
+
if (code !== 'BTC' && code !== 'EUR') {
|
352
|
+
throw new ExchangeError (this.id + ' transfer() only allows BTC or EUR');
|
353
|
+
}
|
354
|
+
const request = {
|
355
|
+
'currency': currency['id'],
|
356
|
+
'amount': this.currencyToPrecision (code, amount),
|
357
|
+
'email': toAccount,
|
358
|
+
// 'comment': 'a small note explaining the transfer'
|
359
|
+
};
|
360
|
+
const response = await this.privatePostUserEmailTransfers (this.extend (request, params));
|
361
|
+
//
|
362
|
+
// {
|
363
|
+
// "uuid": "968f4580-e26c-4ad8-8bcd-874d23d55296",
|
364
|
+
// "type": "Transfer",
|
365
|
+
// "currency": "BTC",
|
366
|
+
// "currency_amount": "string",
|
367
|
+
// "created_at": "2013-10-24T10:34:37.000Z",
|
368
|
+
// "updated_at": "2013-10-24T10:34:37.000Z",
|
369
|
+
// "amount": "1.0",
|
370
|
+
// "state": "executed",
|
371
|
+
// "currency_fee": "0.0",
|
372
|
+
// "btc_fee": "0.0",
|
373
|
+
// "comment": "string",
|
374
|
+
// "traded_btc": "string",
|
375
|
+
// "traded_currency": "string",
|
376
|
+
// "direction": "buy",
|
377
|
+
// "price": "string",
|
378
|
+
// "account_operations": [
|
379
|
+
// {
|
380
|
+
// "uuid": "968f4580-e26c-4ad8-8bcd-874d23d55296",
|
381
|
+
// "amount": "1.0",
|
382
|
+
// "currency": "BTC",
|
383
|
+
// "created_at": "2013-10-24T10:34:37.000Z",
|
384
|
+
// "created_at_int": 1389094259,
|
385
|
+
// "name": "account_operation",
|
386
|
+
// "address": "1FPDBXNqSkZMsw1kSkkajcj8berxDQkUoc",
|
387
|
+
// "tx_hash": "string",
|
388
|
+
// "is_trading_account": true
|
389
|
+
// }
|
390
|
+
// ]
|
391
|
+
// }
|
392
|
+
//
|
393
|
+
return this.parseTransfer (response, currency);
|
394
|
+
}
|
395
|
+
|
396
|
+
parseTransfer (transfer, currency = undefined) {
|
397
|
+
//
|
398
|
+
// {
|
399
|
+
// "uuid": "968f4580-e26c-4ad8-8bcd-874d23d55296",
|
400
|
+
// "type": "Transfer",
|
401
|
+
// "currency": "BTC",
|
402
|
+
// "currency_amount": "string",
|
403
|
+
// "created_at": "2013-10-24T10:34:37.000Z",
|
404
|
+
// "updated_at": "2013-10-24T10:34:37.000Z",
|
405
|
+
// "amount": "1.0",
|
406
|
+
// "state": "executed",
|
407
|
+
// "currency_fee": "0.0",
|
408
|
+
// "btc_fee": "0.0",
|
409
|
+
// "comment": "string",
|
410
|
+
// "traded_btc": "string",
|
411
|
+
// "traded_currency": "string",
|
412
|
+
// "direction": "buy",
|
413
|
+
// "price": "string",
|
414
|
+
// "account_operations": [
|
415
|
+
// {
|
416
|
+
// "uuid": "968f4580-e26c-4ad8-8bcd-874d23d55296",
|
417
|
+
// "amount": "1.0",
|
418
|
+
// "currency": "BTC",
|
419
|
+
// "created_at": "2013-10-24T10:34:37.000Z",
|
420
|
+
// "created_at_int": 1389094259,
|
421
|
+
// "name": "account_operation",
|
422
|
+
// "address": "1FPDBXNqSkZMsw1kSkkajcj8berxDQkUoc",
|
423
|
+
// "tx_hash": "string",
|
424
|
+
// "is_trading_account": true
|
425
|
+
// }
|
426
|
+
// ]
|
427
|
+
// }
|
428
|
+
//
|
429
|
+
const currencyId = this.safeString (transfer, 'currency');
|
430
|
+
const updatedAt = this.safeString (transfer, 'updated_at');
|
431
|
+
const timetstamp = this.parseDate (updatedAt);
|
432
|
+
const accountOperations = this.safeValue (transfer, 'account_operations');
|
433
|
+
const firstOperation = this.safeValue (accountOperations, 0, {});
|
434
|
+
const status = this.safeString (transfer, 'state');
|
435
|
+
return {
|
436
|
+
'info': transfer,
|
437
|
+
'id': this.safeString (transfer, 'uuid'),
|
438
|
+
'timestamp': timetstamp,
|
439
|
+
'datetime': this.iso8601 (timetstamp),
|
440
|
+
'currency': this.safeCurrencyCode (currencyId, currency),
|
441
|
+
'amount': this.safeNumber (transfer, 'amount'),
|
442
|
+
'fromAccount': undefined,
|
443
|
+
'toAccount': this.safeString (firstOperation, 'address'),
|
444
|
+
'status': this.parseTransferStatus (status),
|
445
|
+
};
|
446
|
+
}
|
447
|
+
|
448
|
+
parseTransferStatus (status) {
|
449
|
+
const statuses = {
|
450
|
+
'executed': 'ok',
|
451
|
+
// what are the other statuses?
|
452
|
+
};
|
453
|
+
return this.safeString (statuses, status, status);
|
454
|
+
}
|
455
|
+
|
456
|
+
sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
457
|
+
let url = this.urls['api'] + '/' + this.version + '/' + this.implodeParams (path, params);
|
458
|
+
const query = this.omit (params, this.extractParams (path));
|
459
|
+
if (api === 'public') {
|
460
|
+
if (Object.keys (query).length) {
|
461
|
+
url += '?' + this.urlencode (query);
|
462
|
+
}
|
463
|
+
} else {
|
464
|
+
this.checkRequiredCredentials ();
|
465
|
+
const nonce = this.nonce ().toString ();
|
466
|
+
let auth = nonce + url;
|
467
|
+
headers = {
|
468
|
+
'Api-Key': this.apiKey,
|
469
|
+
'Api-Nonce': nonce,
|
470
|
+
};
|
471
|
+
if (method === 'POST') {
|
472
|
+
if (Object.keys (query).length) {
|
473
|
+
body = this.json (query);
|
474
|
+
auth += body;
|
475
|
+
headers['Content-Type'] = 'application/json';
|
476
|
+
}
|
477
|
+
} else {
|
478
|
+
if (Object.keys (query).length) {
|
479
|
+
const queryString = this.urlencode (query);
|
480
|
+
auth += queryString;
|
481
|
+
url += '?' + queryString;
|
482
|
+
}
|
483
|
+
}
|
484
|
+
headers['Api-Signature'] = this.hmac (this.encode (auth), this.encode (this.secret));
|
485
|
+
}
|
486
|
+
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
487
|
+
}
|
488
|
+
|
489
|
+
handleErrors (httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
490
|
+
if (response === undefined) {
|
491
|
+
return;
|
492
|
+
}
|
493
|
+
const errors = this.safeValue (response, 'errors');
|
494
|
+
if (errors !== undefined) {
|
495
|
+
throw new ExchangeError (this.id + ' ' + this.json (response));
|
496
|
+
}
|
497
|
+
}
|
498
|
+
};
|