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/bitflyer.js
ADDED
@@ -0,0 +1,840 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
// ---------------------------------------------------------------------------
|
4
|
+
|
5
|
+
const Exchange = require ('./base/Exchange');
|
6
|
+
const { ExchangeError, ArgumentsRequired, OrderNotFound } = require ('./base/errors');
|
7
|
+
|
8
|
+
// ---------------------------------------------------------------------------
|
9
|
+
|
10
|
+
module.exports = class bitflyer extends Exchange {
|
11
|
+
describe () {
|
12
|
+
return this.deepExtend (super.describe (), {
|
13
|
+
'id': 'bitflyer',
|
14
|
+
'name': 'bitFlyer',
|
15
|
+
'countries': [ 'JP' ],
|
16
|
+
'version': 'v1',
|
17
|
+
'rateLimit': 1000, // their nonce-timestamp is in seconds...
|
18
|
+
'hostname': 'bitflyer.com', // or bitflyer.com
|
19
|
+
'has': {
|
20
|
+
'CORS': undefined,
|
21
|
+
'spot': true,
|
22
|
+
'margin': false,
|
23
|
+
'swap': undefined, // has but not fully implemented
|
24
|
+
'future': undefined, // has but not fully implemented
|
25
|
+
'option': false,
|
26
|
+
'cancelOrder': true,
|
27
|
+
'createOrder': true,
|
28
|
+
'fetchBalance': true,
|
29
|
+
'fetchClosedOrders': 'emulated',
|
30
|
+
'fetchDeposits': true,
|
31
|
+
'fetchMarkets': true,
|
32
|
+
'fetchMyTrades': true,
|
33
|
+
'fetchOpenOrders': 'emulated',
|
34
|
+
'fetchOrder': 'emulated',
|
35
|
+
'fetchOrderBook': true,
|
36
|
+
'fetchOrders': true,
|
37
|
+
'fetchPositions': true,
|
38
|
+
'fetchTicker': true,
|
39
|
+
'fetchTrades': true,
|
40
|
+
'fetchTradingFee': true,
|
41
|
+
'fetchTradingFees': false,
|
42
|
+
'fetchTransfer': false,
|
43
|
+
'fetchTransfers': false,
|
44
|
+
'fetchWithdrawals': true,
|
45
|
+
'transfer': false,
|
46
|
+
'withdraw': true,
|
47
|
+
},
|
48
|
+
'urls': {
|
49
|
+
'logo': 'https://user-images.githubusercontent.com/1294454/28051642-56154182-660e-11e7-9b0d-6042d1e6edd8.jpg',
|
50
|
+
'api': 'https://api.{hostname}',
|
51
|
+
'www': 'https://bitflyer.com',
|
52
|
+
'doc': 'https://lightning.bitflyer.com/docs?lang=en',
|
53
|
+
},
|
54
|
+
'api': {
|
55
|
+
'public': {
|
56
|
+
'get': [
|
57
|
+
'getmarkets/usa', // new (wip)
|
58
|
+
'getmarkets/eu', // new (wip)
|
59
|
+
'getmarkets', // or 'markets'
|
60
|
+
'getboard', // ...
|
61
|
+
'getticker',
|
62
|
+
'getexecutions',
|
63
|
+
'gethealth',
|
64
|
+
'getboardstate',
|
65
|
+
'getchats',
|
66
|
+
],
|
67
|
+
},
|
68
|
+
'private': {
|
69
|
+
'get': [
|
70
|
+
'getpermissions',
|
71
|
+
'getbalance',
|
72
|
+
'getbalancehistory',
|
73
|
+
'getcollateral',
|
74
|
+
'getcollateralhistory',
|
75
|
+
'getcollateralaccounts',
|
76
|
+
'getaddresses',
|
77
|
+
'getcoinins',
|
78
|
+
'getcoinouts',
|
79
|
+
'getbankaccounts',
|
80
|
+
'getdeposits',
|
81
|
+
'getwithdrawals',
|
82
|
+
'getchildorders',
|
83
|
+
'getparentorders',
|
84
|
+
'getparentorder',
|
85
|
+
'getexecutions',
|
86
|
+
'getpositions',
|
87
|
+
'gettradingcommission',
|
88
|
+
],
|
89
|
+
'post': [
|
90
|
+
'sendcoin',
|
91
|
+
'withdraw',
|
92
|
+
'sendchildorder',
|
93
|
+
'cancelchildorder',
|
94
|
+
'sendparentorder',
|
95
|
+
'cancelparentorder',
|
96
|
+
'cancelallchildorders',
|
97
|
+
],
|
98
|
+
},
|
99
|
+
},
|
100
|
+
'fees': {
|
101
|
+
'trading': {
|
102
|
+
'maker': this.parseNumber ('0.002'),
|
103
|
+
'taker': this.parseNumber ('0.002'),
|
104
|
+
},
|
105
|
+
},
|
106
|
+
});
|
107
|
+
}
|
108
|
+
|
109
|
+
parseExpiryDate (expiry) {
|
110
|
+
const day = expiry.slice (0, 2);
|
111
|
+
const monthName = expiry.slice (2, 5);
|
112
|
+
const year = expiry.slice (5, 9);
|
113
|
+
const months = {
|
114
|
+
'JAN': '01',
|
115
|
+
'FEB': '02',
|
116
|
+
'MAR': '03',
|
117
|
+
'APR': '04',
|
118
|
+
'MAY': '05',
|
119
|
+
'JUN': '06',
|
120
|
+
'JUL': '07',
|
121
|
+
'AUG': '08',
|
122
|
+
'SEP': '09',
|
123
|
+
'OCT': '10',
|
124
|
+
'NOV': '11',
|
125
|
+
'DEC': '12',
|
126
|
+
};
|
127
|
+
const month = this.safeString (months, monthName);
|
128
|
+
return this.parse8601 (year + '-' + month + '-' + day + 'T00:00:00Z');
|
129
|
+
}
|
130
|
+
|
131
|
+
async fetchMarkets (params = {}) {
|
132
|
+
const jp_markets = await this.publicGetGetmarkets (params);
|
133
|
+
//
|
134
|
+
// [
|
135
|
+
// // spot
|
136
|
+
// { "product_code": "BTC_JPY", "market_type": "Spot" },
|
137
|
+
// { "product_code": "BCH_BTC", "market_type": "Spot" },
|
138
|
+
// // forex swap
|
139
|
+
// { "product_code": "FX_BTC_JPY", "market_type": "FX" },
|
140
|
+
// // future
|
141
|
+
// {
|
142
|
+
// "product_code": "BTCJPY11FEB2022",
|
143
|
+
// "alias": "BTCJPY_MAT1WK",
|
144
|
+
// "market_type": "Futures",
|
145
|
+
// },
|
146
|
+
// ];
|
147
|
+
//
|
148
|
+
const us_markets = await this.publicGetGetmarketsUsa (params);
|
149
|
+
//
|
150
|
+
// [
|
151
|
+
// { "product_code": "BTC_USD", "market_type": "Spot" },
|
152
|
+
// { "product_code": "BTC_JPY", "market_type": "Spot" },
|
153
|
+
// ];
|
154
|
+
//
|
155
|
+
const eu_markets = await this.publicGetGetmarketsEu (params);
|
156
|
+
//
|
157
|
+
// [
|
158
|
+
// { "product_code": "BTC_EUR", "market_type": "Spot" },
|
159
|
+
// { "product_code": "BTC_JPY", "market_type": "Spot" },
|
160
|
+
// ];
|
161
|
+
//
|
162
|
+
let markets = this.arrayConcat (jp_markets, us_markets);
|
163
|
+
markets = this.arrayConcat (markets, eu_markets);
|
164
|
+
const result = [];
|
165
|
+
for (let i = 0; i < markets.length; i++) {
|
166
|
+
const market = markets[i];
|
167
|
+
const id = this.safeString (market, 'product_code');
|
168
|
+
const currencies = id.split ('_');
|
169
|
+
const marketType = this.safeString (market, 'market_type');
|
170
|
+
const swap = (marketType === 'FX');
|
171
|
+
const future = (marketType === 'Futures');
|
172
|
+
const spot = !swap && !future;
|
173
|
+
let type = 'spot';
|
174
|
+
let settle = undefined;
|
175
|
+
let baseId = undefined;
|
176
|
+
let quoteId = undefined;
|
177
|
+
let expiry = undefined;
|
178
|
+
if (spot) {
|
179
|
+
baseId = this.safeString (currencies, 0);
|
180
|
+
quoteId = this.safeString (currencies, 1);
|
181
|
+
} else if (swap) {
|
182
|
+
type = 'swap';
|
183
|
+
baseId = this.safeString (currencies, 1);
|
184
|
+
quoteId = this.safeString (currencies, 2);
|
185
|
+
} else if (future) {
|
186
|
+
const alias = this.safeString (market, 'alias');
|
187
|
+
if (alias === undefined) {
|
188
|
+
// no alias:
|
189
|
+
// { product_code: 'BTCJPY11MAR2022', market_type: 'Futures' }
|
190
|
+
// TODO this will break if there are products with 4 chars
|
191
|
+
baseId = id.slice (0, 3);
|
192
|
+
quoteId = id.slice (3, 6);
|
193
|
+
// last 9 chars are expiry date
|
194
|
+
const expiryDate = id.slice (-9);
|
195
|
+
expiry = this.parseExpiryDate (expiryDate);
|
196
|
+
} else {
|
197
|
+
const splitAlias = alias.split ('_');
|
198
|
+
const currencyIds = this.safeString (splitAlias, 0);
|
199
|
+
baseId = currencyIds.slice (0, -3);
|
200
|
+
quoteId = currencyIds.slice (-3);
|
201
|
+
const splitId = id.split (currencyIds);
|
202
|
+
const expiryDate = this.safeString (splitId, 1);
|
203
|
+
expiry = this.parseExpiryDate (expiryDate);
|
204
|
+
}
|
205
|
+
type = 'future';
|
206
|
+
}
|
207
|
+
const base = this.safeCurrencyCode (baseId);
|
208
|
+
const quote = this.safeCurrencyCode (quoteId);
|
209
|
+
let symbol = base + '/' + quote;
|
210
|
+
let taker = this.fees['trading']['taker'];
|
211
|
+
let maker = this.fees['trading']['maker'];
|
212
|
+
const contract = swap || future;
|
213
|
+
if (contract) {
|
214
|
+
maker = 0.0;
|
215
|
+
taker = 0.0;
|
216
|
+
settle = 'JPY';
|
217
|
+
symbol = symbol + ':' + settle;
|
218
|
+
if (future) {
|
219
|
+
symbol = symbol + '-' + this.yymmdd (expiry);
|
220
|
+
}
|
221
|
+
}
|
222
|
+
result.push ({
|
223
|
+
'id': id,
|
224
|
+
'symbol': symbol,
|
225
|
+
'base': base,
|
226
|
+
'quote': quote,
|
227
|
+
'settle': settle,
|
228
|
+
'baseId': baseId,
|
229
|
+
'quoteId': quoteId,
|
230
|
+
'settleId': undefined,
|
231
|
+
'type': type,
|
232
|
+
'spot': spot,
|
233
|
+
'margin': false,
|
234
|
+
'swap': swap,
|
235
|
+
'future': future,
|
236
|
+
'option': false,
|
237
|
+
'active': true,
|
238
|
+
'contract': contract,
|
239
|
+
'linear': spot ? undefined : true,
|
240
|
+
'inverse': spot ? undefined : false,
|
241
|
+
'taker': taker,
|
242
|
+
'maker': maker,
|
243
|
+
'contractSize': undefined,
|
244
|
+
'expiry': expiry,
|
245
|
+
'expiryDatetime': this.iso8601 (expiry),
|
246
|
+
'strike': undefined,
|
247
|
+
'optionType': undefined,
|
248
|
+
'precision': {
|
249
|
+
'amount': undefined,
|
250
|
+
'price': undefined,
|
251
|
+
},
|
252
|
+
'limits': {
|
253
|
+
'leverage': {
|
254
|
+
'min': undefined,
|
255
|
+
'max': undefined,
|
256
|
+
},
|
257
|
+
'amount': {
|
258
|
+
'min': undefined,
|
259
|
+
'max': undefined,
|
260
|
+
},
|
261
|
+
'price': {
|
262
|
+
'min': undefined,
|
263
|
+
'max': undefined,
|
264
|
+
},
|
265
|
+
'cost': {
|
266
|
+
'min': undefined,
|
267
|
+
'max': undefined,
|
268
|
+
},
|
269
|
+
},
|
270
|
+
'info': market,
|
271
|
+
});
|
272
|
+
}
|
273
|
+
return result;
|
274
|
+
}
|
275
|
+
|
276
|
+
parseBalance (response) {
|
277
|
+
const result = { 'info': response };
|
278
|
+
for (let i = 0; i < response.length; i++) {
|
279
|
+
const balance = response[i];
|
280
|
+
const currencyId = this.safeString (balance, 'currency_code');
|
281
|
+
const code = this.safeCurrencyCode (currencyId);
|
282
|
+
const account = this.account ();
|
283
|
+
account['total'] = this.safeString (balance, 'amount');
|
284
|
+
account['free'] = this.safeString (balance, 'available');
|
285
|
+
result[code] = account;
|
286
|
+
}
|
287
|
+
return this.safeBalance (result);
|
288
|
+
}
|
289
|
+
|
290
|
+
async fetchBalance (params = {}) {
|
291
|
+
await this.loadMarkets ();
|
292
|
+
const response = await this.privateGetGetbalance (params);
|
293
|
+
//
|
294
|
+
// [
|
295
|
+
// {
|
296
|
+
// "currency_code": "JPY",
|
297
|
+
// "amount": 1024078,
|
298
|
+
// "available": 508000
|
299
|
+
// },
|
300
|
+
// {
|
301
|
+
// "currency_code": "BTC",
|
302
|
+
// "amount": 10.24,
|
303
|
+
// "available": 4.12
|
304
|
+
// },
|
305
|
+
// {
|
306
|
+
// "currency_code": "ETH",
|
307
|
+
// "amount": 20.48,
|
308
|
+
// "available": 16.38
|
309
|
+
// }
|
310
|
+
// ]
|
311
|
+
//
|
312
|
+
return this.parseBalance (response);
|
313
|
+
}
|
314
|
+
|
315
|
+
async fetchOrderBook (symbol, limit = undefined, params = {}) {
|
316
|
+
await this.loadMarkets ();
|
317
|
+
const request = {
|
318
|
+
'product_code': this.marketId (symbol),
|
319
|
+
};
|
320
|
+
const orderbook = await this.publicGetGetboard (this.extend (request, params));
|
321
|
+
return this.parseOrderBook (orderbook, symbol, undefined, 'bids', 'asks', 'price', 'size');
|
322
|
+
}
|
323
|
+
|
324
|
+
parseTicker (ticker, market = undefined) {
|
325
|
+
const symbol = this.safeSymbol (undefined, market);
|
326
|
+
const timestamp = this.parse8601 (this.safeString (ticker, 'timestamp'));
|
327
|
+
const last = this.safeString (ticker, 'ltp');
|
328
|
+
return this.safeTicker ({
|
329
|
+
'symbol': symbol,
|
330
|
+
'timestamp': timestamp,
|
331
|
+
'datetime': this.iso8601 (timestamp),
|
332
|
+
'high': undefined,
|
333
|
+
'low': undefined,
|
334
|
+
'bid': this.safeString (ticker, 'best_bid'),
|
335
|
+
'bidVolume': undefined,
|
336
|
+
'ask': this.safeString (ticker, 'best_ask'),
|
337
|
+
'askVolume': undefined,
|
338
|
+
'vwap': undefined,
|
339
|
+
'open': undefined,
|
340
|
+
'close': last,
|
341
|
+
'last': last,
|
342
|
+
'previousClose': undefined,
|
343
|
+
'change': undefined,
|
344
|
+
'percentage': undefined,
|
345
|
+
'average': undefined,
|
346
|
+
'baseVolume': this.safeString (ticker, 'volume_by_product'),
|
347
|
+
'quoteVolume': undefined,
|
348
|
+
'info': ticker,
|
349
|
+
}, market, false);
|
350
|
+
}
|
351
|
+
|
352
|
+
async fetchTicker (symbol, params = {}) {
|
353
|
+
await this.loadMarkets ();
|
354
|
+
const market = this.market (symbol);
|
355
|
+
const request = {
|
356
|
+
'product_code': market['id'],
|
357
|
+
};
|
358
|
+
const response = await this.publicGetGetticker (this.extend (request, params));
|
359
|
+
return this.parseTicker (response, market);
|
360
|
+
}
|
361
|
+
|
362
|
+
parseTrade (trade, market = undefined) {
|
363
|
+
//
|
364
|
+
// fetchTrades (public) v1
|
365
|
+
//
|
366
|
+
// {
|
367
|
+
// "id":2278466664,
|
368
|
+
// "side":"SELL",
|
369
|
+
// "price":56810.7,
|
370
|
+
// "size":0.08798,
|
371
|
+
// "exec_date":"2021-11-19T11:46:39.323",
|
372
|
+
// "buy_child_order_acceptance_id":"JRF20211119-114209-236525",
|
373
|
+
// "sell_child_order_acceptance_id":"JRF20211119-114639-236919"
|
374
|
+
// }
|
375
|
+
//
|
376
|
+
// {
|
377
|
+
// "id":2278463423,
|
378
|
+
// "side":"BUY",
|
379
|
+
// "price":56757.83,
|
380
|
+
// "size":0.6003,"exec_date":"2021-11-19T11:28:00.523",
|
381
|
+
// "buy_child_order_acceptance_id":"JRF20211119-112800-236526",
|
382
|
+
// "sell_child_order_acceptance_id":"JRF20211119-112734-062017"
|
383
|
+
// }
|
384
|
+
//
|
385
|
+
//
|
386
|
+
//
|
387
|
+
let side = this.safeStringLower (trade, 'side');
|
388
|
+
if (side !== undefined) {
|
389
|
+
if (side.length < 1) {
|
390
|
+
side = undefined;
|
391
|
+
}
|
392
|
+
}
|
393
|
+
let order = undefined;
|
394
|
+
if (side !== undefined) {
|
395
|
+
const id = side + '_child_order_acceptance_id';
|
396
|
+
if (id in trade) {
|
397
|
+
order = trade[id];
|
398
|
+
}
|
399
|
+
}
|
400
|
+
if (order === undefined) {
|
401
|
+
order = this.safeString (trade, 'child_order_acceptance_id');
|
402
|
+
}
|
403
|
+
const timestamp = this.parse8601 (this.safeString (trade, 'exec_date'));
|
404
|
+
const priceString = this.safeString (trade, 'price');
|
405
|
+
const amountString = this.safeString (trade, 'size');
|
406
|
+
const id = this.safeString (trade, 'id');
|
407
|
+
market = this.safeMarket (undefined, market);
|
408
|
+
return this.safeTrade ({
|
409
|
+
'id': id,
|
410
|
+
'info': trade,
|
411
|
+
'timestamp': timestamp,
|
412
|
+
'datetime': this.iso8601 (timestamp),
|
413
|
+
'symbol': market['symbol'],
|
414
|
+
'order': order,
|
415
|
+
'type': undefined,
|
416
|
+
'side': side,
|
417
|
+
'takerOrMaker': undefined,
|
418
|
+
'price': priceString,
|
419
|
+
'amount': amountString,
|
420
|
+
'cost': undefined,
|
421
|
+
'fee': undefined,
|
422
|
+
}, market);
|
423
|
+
}
|
424
|
+
|
425
|
+
async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) {
|
426
|
+
await this.loadMarkets ();
|
427
|
+
const market = this.market (symbol);
|
428
|
+
const request = {
|
429
|
+
'product_code': market['id'],
|
430
|
+
};
|
431
|
+
const response = await this.publicGetGetexecutions (this.extend (request, params));
|
432
|
+
return this.parseTrades (response, market, since, limit);
|
433
|
+
}
|
434
|
+
|
435
|
+
async fetchTradingFee (symbol, params = {}) {
|
436
|
+
await this.loadMarkets ();
|
437
|
+
const market = this.market (symbol);
|
438
|
+
const request = {
|
439
|
+
'product_code': market['id'],
|
440
|
+
};
|
441
|
+
const response = await this.privateGetGettradingcommission (this.extend (request, params));
|
442
|
+
//
|
443
|
+
// {
|
444
|
+
// commission_rate: '0.0020'
|
445
|
+
// }
|
446
|
+
//
|
447
|
+
const fee = this.safeNumber (response, 'commission_rate');
|
448
|
+
return {
|
449
|
+
'info': response,
|
450
|
+
'symbol': symbol,
|
451
|
+
'maker': fee,
|
452
|
+
'taker': fee,
|
453
|
+
};
|
454
|
+
}
|
455
|
+
|
456
|
+
async createOrder (symbol, type, side, amount, price = undefined, params = {}) {
|
457
|
+
await this.loadMarkets ();
|
458
|
+
const request = {
|
459
|
+
'product_code': this.marketId (symbol),
|
460
|
+
'child_order_type': type.toUpperCase (),
|
461
|
+
'side': side.toUpperCase (),
|
462
|
+
'price': price,
|
463
|
+
'size': amount,
|
464
|
+
};
|
465
|
+
const result = await this.privatePostSendchildorder (this.extend (request, params));
|
466
|
+
// { "status": - 200, "error_message": "Insufficient funds", "data": null }
|
467
|
+
const id = this.safeString (result, 'child_order_acceptance_id');
|
468
|
+
return {
|
469
|
+
'info': result,
|
470
|
+
'id': id,
|
471
|
+
};
|
472
|
+
}
|
473
|
+
|
474
|
+
async cancelOrder (id, symbol = undefined, params = {}) {
|
475
|
+
if (symbol === undefined) {
|
476
|
+
throw new ArgumentsRequired (this.id + ' cancelOrder() requires a `symbol` argument');
|
477
|
+
}
|
478
|
+
await this.loadMarkets ();
|
479
|
+
const request = {
|
480
|
+
'product_code': this.marketId (symbol),
|
481
|
+
'child_order_acceptance_id': id,
|
482
|
+
};
|
483
|
+
return await this.privatePostCancelchildorder (this.extend (request, params));
|
484
|
+
}
|
485
|
+
|
486
|
+
parseOrderStatus (status) {
|
487
|
+
const statuses = {
|
488
|
+
'ACTIVE': 'open',
|
489
|
+
'COMPLETED': 'closed',
|
490
|
+
'CANCELED': 'canceled',
|
491
|
+
'EXPIRED': 'canceled',
|
492
|
+
'REJECTED': 'canceled',
|
493
|
+
};
|
494
|
+
return this.safeString (statuses, status, status);
|
495
|
+
}
|
496
|
+
|
497
|
+
parseOrder (order, market = undefined) {
|
498
|
+
const timestamp = this.parse8601 (this.safeString (order, 'child_order_date'));
|
499
|
+
const price = this.safeString (order, 'price');
|
500
|
+
const amount = this.safeString (order, 'size');
|
501
|
+
const filled = this.safeString (order, 'executed_size');
|
502
|
+
const remaining = this.safeString (order, 'outstanding_size');
|
503
|
+
const status = this.parseOrderStatus (this.safeString (order, 'child_order_state'));
|
504
|
+
const type = this.safeStringLower (order, 'child_order_type');
|
505
|
+
const side = this.safeStringLower (order, 'side');
|
506
|
+
const marketId = this.safeString (order, 'product_code');
|
507
|
+
const symbol = this.safeSymbol (marketId, market);
|
508
|
+
let fee = undefined;
|
509
|
+
const feeCost = this.safeNumber (order, 'total_commission');
|
510
|
+
if (feeCost !== undefined) {
|
511
|
+
fee = {
|
512
|
+
'cost': feeCost,
|
513
|
+
'currency': undefined,
|
514
|
+
'rate': undefined,
|
515
|
+
};
|
516
|
+
}
|
517
|
+
const id = this.safeString (order, 'child_order_acceptance_id');
|
518
|
+
return this.safeOrder ({
|
519
|
+
'id': id,
|
520
|
+
'clientOrderId': undefined,
|
521
|
+
'info': order,
|
522
|
+
'timestamp': timestamp,
|
523
|
+
'datetime': this.iso8601 (timestamp),
|
524
|
+
'lastTradeTimestamp': undefined,
|
525
|
+
'status': status,
|
526
|
+
'symbol': symbol,
|
527
|
+
'type': type,
|
528
|
+
'timeInForce': undefined,
|
529
|
+
'postOnly': undefined,
|
530
|
+
'side': side,
|
531
|
+
'price': price,
|
532
|
+
'stopPrice': undefined,
|
533
|
+
'cost': undefined,
|
534
|
+
'amount': amount,
|
535
|
+
'filled': filled,
|
536
|
+
'remaining': remaining,
|
537
|
+
'fee': fee,
|
538
|
+
'average': undefined,
|
539
|
+
'trades': undefined,
|
540
|
+
}, market);
|
541
|
+
}
|
542
|
+
|
543
|
+
async fetchOrders (symbol = undefined, since = undefined, limit = 100, params = {}) {
|
544
|
+
if (symbol === undefined) {
|
545
|
+
throw new ArgumentsRequired (this.id + ' fetchOrders() requires a `symbol` argument');
|
546
|
+
}
|
547
|
+
await this.loadMarkets ();
|
548
|
+
const market = this.market (symbol);
|
549
|
+
const request = {
|
550
|
+
'product_code': market['id'],
|
551
|
+
'count': limit,
|
552
|
+
};
|
553
|
+
const response = await this.privateGetGetchildorders (this.extend (request, params));
|
554
|
+
let orders = this.parseOrders (response, market, since, limit);
|
555
|
+
if (symbol !== undefined) {
|
556
|
+
orders = this.filterBy (orders, 'symbol', symbol);
|
557
|
+
}
|
558
|
+
return orders;
|
559
|
+
}
|
560
|
+
|
561
|
+
async fetchOpenOrders (symbol = undefined, since = undefined, limit = 100, params = {}) {
|
562
|
+
const request = {
|
563
|
+
'child_order_state': 'ACTIVE',
|
564
|
+
};
|
565
|
+
return await this.fetchOrders (symbol, since, limit, this.extend (request, params));
|
566
|
+
}
|
567
|
+
|
568
|
+
async fetchClosedOrders (symbol = undefined, since = undefined, limit = 100, params = {}) {
|
569
|
+
const request = {
|
570
|
+
'child_order_state': 'COMPLETED',
|
571
|
+
};
|
572
|
+
return await this.fetchOrders (symbol, since, limit, this.extend (request, params));
|
573
|
+
}
|
574
|
+
|
575
|
+
async fetchOrder (id, symbol = undefined, params = {}) {
|
576
|
+
if (symbol === undefined) {
|
577
|
+
throw new ArgumentsRequired (this.id + ' fetchOrder() requires a `symbol` argument');
|
578
|
+
}
|
579
|
+
const orders = await this.fetchOrders (symbol);
|
580
|
+
const ordersById = this.indexBy (orders, 'id');
|
581
|
+
if (id in ordersById) {
|
582
|
+
return ordersById[id];
|
583
|
+
}
|
584
|
+
throw new OrderNotFound (this.id + ' No order found with id ' + id);
|
585
|
+
}
|
586
|
+
|
587
|
+
async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
588
|
+
if (symbol === undefined) {
|
589
|
+
throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a `symbol` argument');
|
590
|
+
}
|
591
|
+
await this.loadMarkets ();
|
592
|
+
const market = this.market (symbol);
|
593
|
+
const request = {
|
594
|
+
'product_code': market['id'],
|
595
|
+
};
|
596
|
+
if (limit !== undefined) {
|
597
|
+
request['count'] = limit;
|
598
|
+
}
|
599
|
+
const response = await this.privateGetGetexecutions (this.extend (request, params));
|
600
|
+
return this.parseTrades (response, market, since, limit);
|
601
|
+
}
|
602
|
+
|
603
|
+
async fetchPositions (symbols = undefined, params = {}) {
|
604
|
+
if (symbols === undefined) {
|
605
|
+
throw new ArgumentsRequired (this.id + ' fetchPositions() requires a `symbols` argument, exactly one symbol in an array');
|
606
|
+
}
|
607
|
+
await this.loadMarkets ();
|
608
|
+
const request = {
|
609
|
+
'product_code': this.marketIds (symbols),
|
610
|
+
};
|
611
|
+
const response = await this.privateGetpositions (this.extend (request, params));
|
612
|
+
//
|
613
|
+
// [
|
614
|
+
// {
|
615
|
+
// "product_code": "FX_BTC_JPY",
|
616
|
+
// "side": "BUY",
|
617
|
+
// "price": 36000,
|
618
|
+
// "size": 10,
|
619
|
+
// "commission": 0,
|
620
|
+
// "swap_point_accumulate": -35,
|
621
|
+
// "require_collateral": 120000,
|
622
|
+
// "open_date": "2015-11-03T10:04:45.011",
|
623
|
+
// "leverage": 3,
|
624
|
+
// "pnl": 965,
|
625
|
+
// "sfd": -0.5
|
626
|
+
// }
|
627
|
+
// ]
|
628
|
+
//
|
629
|
+
// todo unify parsePosition/parsePositions
|
630
|
+
return response;
|
631
|
+
}
|
632
|
+
|
633
|
+
async withdraw (code, amount, address, tag = undefined, params = {}) {
|
634
|
+
this.checkAddress (address);
|
635
|
+
await this.loadMarkets ();
|
636
|
+
if (code !== 'JPY' && code !== 'USD' && code !== 'EUR') {
|
637
|
+
throw new ExchangeError (this.id + ' allows withdrawing JPY, USD, EUR only, ' + code + ' is not supported');
|
638
|
+
}
|
639
|
+
const currency = this.currency (code);
|
640
|
+
const request = {
|
641
|
+
'currency_code': currency['id'],
|
642
|
+
'amount': amount,
|
643
|
+
// 'bank_account_id': 1234,
|
644
|
+
};
|
645
|
+
const response = await this.privatePostWithdraw (this.extend (request, params));
|
646
|
+
//
|
647
|
+
// {
|
648
|
+
// "message_id": "69476620-5056-4003-bcbe-42658a2b041b"
|
649
|
+
// }
|
650
|
+
//
|
651
|
+
return this.parseTransaction (response, currency);
|
652
|
+
}
|
653
|
+
|
654
|
+
async fetchDeposits (code = undefined, since = undefined, limit = undefined, params = {}) {
|
655
|
+
await this.loadMarkets ();
|
656
|
+
let currency = undefined;
|
657
|
+
const request = {};
|
658
|
+
if (code !== undefined) {
|
659
|
+
currency = this.currency (code);
|
660
|
+
}
|
661
|
+
if (limit !== undefined) {
|
662
|
+
request['count'] = limit; // default 100
|
663
|
+
}
|
664
|
+
const response = await this.privateGetGetcoinins (this.extend (request, params));
|
665
|
+
//
|
666
|
+
// [
|
667
|
+
// {
|
668
|
+
// "id": 100,
|
669
|
+
// "order_id": "CDP20151227-024141-055555",
|
670
|
+
// "currency_code": "BTC",
|
671
|
+
// "amount": 0.00002,
|
672
|
+
// "address": "1WriteySQufKZ2pVuM1oMhPrTtTVFq35j",
|
673
|
+
// "tx_hash": "9f92ee65a176bb9545f7becb8706c50d07d4cee5ffca34d8be3ef11d411405ae",
|
674
|
+
// "status": "COMPLETED",
|
675
|
+
// "event_date": "2015-11-27T08:59:20.301"
|
676
|
+
// }
|
677
|
+
// ]
|
678
|
+
//
|
679
|
+
return this.parseTransactions (response, currency, since, limit);
|
680
|
+
}
|
681
|
+
|
682
|
+
async fetchWithdrawals (code = undefined, since = undefined, limit = undefined, params = {}) {
|
683
|
+
await this.loadMarkets ();
|
684
|
+
let currency = undefined;
|
685
|
+
const request = {};
|
686
|
+
if (code !== undefined) {
|
687
|
+
currency = this.currency (code);
|
688
|
+
}
|
689
|
+
if (limit !== undefined) {
|
690
|
+
request['count'] = limit; // default 100
|
691
|
+
}
|
692
|
+
const response = await this.privateGetGetcoinouts (this.extend (request, params));
|
693
|
+
//
|
694
|
+
// [
|
695
|
+
// {
|
696
|
+
// "id": 500,
|
697
|
+
// "order_id": "CWD20151224-014040-077777",
|
698
|
+
// "currency_code": "BTC",
|
699
|
+
// "amount": 0.1234,
|
700
|
+
// "address": "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa",
|
701
|
+
// "tx_hash": "724c07dfd4044abcb390b0412c3e707dd5c4f373f0a52b3bd295ce32b478c60a",
|
702
|
+
// "fee": 0.0005,
|
703
|
+
// "additional_fee": 0.0001,
|
704
|
+
// "status": "COMPLETED",
|
705
|
+
// "event_date": "2015-12-24T01:40:40.397"
|
706
|
+
// }
|
707
|
+
// ]
|
708
|
+
//
|
709
|
+
return this.parseTransactions (response, currency, since, limit);
|
710
|
+
}
|
711
|
+
|
712
|
+
parseDepositStatus (status) {
|
713
|
+
const statuses = {
|
714
|
+
'PENDING': 'pending',
|
715
|
+
'COMPLETED': 'ok',
|
716
|
+
};
|
717
|
+
return this.safeString (statuses, status, status);
|
718
|
+
}
|
719
|
+
|
720
|
+
parseWithdrawalStatus (status) {
|
721
|
+
const statuses = {
|
722
|
+
'PENDING': 'pending',
|
723
|
+
'COMPLETED': 'ok',
|
724
|
+
};
|
725
|
+
return this.safeString (statuses, status, status);
|
726
|
+
}
|
727
|
+
|
728
|
+
parseTransaction (transaction, currency = undefined) {
|
729
|
+
//
|
730
|
+
// fetchDeposits
|
731
|
+
//
|
732
|
+
// {
|
733
|
+
// "id": 100,
|
734
|
+
// "order_id": "CDP20151227-024141-055555",
|
735
|
+
// "currency_code": "BTC",
|
736
|
+
// "amount": 0.00002,
|
737
|
+
// "address": "1WriteySQufKZ2pVuM1oMhPrTtTVFq35j",
|
738
|
+
// "tx_hash": "9f92ee65a176bb9545f7becb8706c50d07d4cee5ffca34d8be3ef11d411405ae",
|
739
|
+
// "status": "COMPLETED",
|
740
|
+
// "event_date": "2015-11-27T08:59:20.301"
|
741
|
+
// }
|
742
|
+
//
|
743
|
+
// fetchWithdrawals
|
744
|
+
//
|
745
|
+
// {
|
746
|
+
// "id": 500,
|
747
|
+
// "order_id": "CWD20151224-014040-077777",
|
748
|
+
// "currency_code": "BTC",
|
749
|
+
// "amount": 0.1234,
|
750
|
+
// "address": "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa",
|
751
|
+
// "tx_hash": "724c07dfd4044abcb390b0412c3e707dd5c4f373f0a52b3bd295ce32b478c60a",
|
752
|
+
// "fee": 0.0005,
|
753
|
+
// "additional_fee": 0.0001,
|
754
|
+
// "status": "COMPLETED",
|
755
|
+
// "event_date": "2015-12-24T01:40:40.397"
|
756
|
+
// }
|
757
|
+
//
|
758
|
+
// withdraw
|
759
|
+
//
|
760
|
+
// {
|
761
|
+
// "message_id": "69476620-5056-4003-bcbe-42658a2b041b"
|
762
|
+
// }
|
763
|
+
//
|
764
|
+
const id = this.safeString2 (transaction, 'id', 'message_id');
|
765
|
+
const address = this.safeString (transaction, 'address');
|
766
|
+
const currencyId = this.safeString (transaction, 'currency_code');
|
767
|
+
const code = this.safeCurrencyCode (currencyId, currency);
|
768
|
+
const timestamp = this.parse8601 (this.safeString (transaction, 'event_date'));
|
769
|
+
const amount = this.safeNumber (transaction, 'amount');
|
770
|
+
const txId = this.safeString (transaction, 'tx_hash');
|
771
|
+
const rawStatus = this.safeString (transaction, 'status');
|
772
|
+
let type = undefined;
|
773
|
+
let status = undefined;
|
774
|
+
let fee = undefined;
|
775
|
+
if ('fee' in transaction) {
|
776
|
+
type = 'withdrawal';
|
777
|
+
status = this.parseWithdrawalStatus (rawStatus);
|
778
|
+
const feeCost = this.safeNumber (transaction, 'fee');
|
779
|
+
const additionalFee = this.safeNumber (transaction, 'additional_fee');
|
780
|
+
fee = { 'currency': code, 'cost': feeCost + additionalFee };
|
781
|
+
} else {
|
782
|
+
type = 'deposit';
|
783
|
+
status = this.parseDepositStatus (rawStatus);
|
784
|
+
}
|
785
|
+
return {
|
786
|
+
'info': transaction,
|
787
|
+
'id': id,
|
788
|
+
'txid': txId,
|
789
|
+
'timestamp': timestamp,
|
790
|
+
'datetime': this.iso8601 (timestamp),
|
791
|
+
'network': undefined,
|
792
|
+
'address': address,
|
793
|
+
'addressTo': address,
|
794
|
+
'addressFrom': undefined,
|
795
|
+
'tag': undefined,
|
796
|
+
'tagTo': undefined,
|
797
|
+
'tagFrom': undefined,
|
798
|
+
'type': type,
|
799
|
+
'amount': amount,
|
800
|
+
'currency': code,
|
801
|
+
'status': status,
|
802
|
+
'updated': undefined,
|
803
|
+
'internal': undefined,
|
804
|
+
'fee': fee,
|
805
|
+
};
|
806
|
+
}
|
807
|
+
|
808
|
+
sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
809
|
+
let request = '/' + this.version + '/';
|
810
|
+
if (api === 'private') {
|
811
|
+
request += 'me/';
|
812
|
+
}
|
813
|
+
request += path;
|
814
|
+
if (method === 'GET') {
|
815
|
+
if (Object.keys (params).length) {
|
816
|
+
request += '?' + this.urlencode (params);
|
817
|
+
}
|
818
|
+
}
|
819
|
+
const baseUrl = this.implodeHostname (this.urls['api']);
|
820
|
+
const url = baseUrl + request;
|
821
|
+
if (api === 'private') {
|
822
|
+
this.checkRequiredCredentials ();
|
823
|
+
const nonce = this.nonce ().toString ();
|
824
|
+
let auth = [ nonce, method, request ].join ('');
|
825
|
+
if (Object.keys (params).length) {
|
826
|
+
if (method !== 'GET') {
|
827
|
+
body = this.json (params);
|
828
|
+
auth += body;
|
829
|
+
}
|
830
|
+
}
|
831
|
+
headers = {
|
832
|
+
'ACCESS-KEY': this.apiKey,
|
833
|
+
'ACCESS-TIMESTAMP': nonce,
|
834
|
+
'ACCESS-SIGN': this.hmac (this.encode (auth), this.encode (this.secret)),
|
835
|
+
'Content-Type': 'application/json',
|
836
|
+
};
|
837
|
+
}
|
838
|
+
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
839
|
+
}
|
840
|
+
};
|