ccxt 4.1.51 → 4.1.52
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/README.md +110 -113
- package/dist/ccxt.browser.js +1361 -2933
- package/dist/ccxt.browser.min.js +7 -7
- package/dist/cjs/ccxt.js +1 -7
- package/dist/cjs/src/alpaca.js +62 -64
- package/dist/cjs/src/ascendex.js +3 -1
- package/dist/cjs/src/base/Exchange.js +10 -0
- package/dist/cjs/src/bigone.js +60 -77
- package/dist/cjs/src/binance.js +1 -0
- package/dist/cjs/src/bingx.js +4 -11
- package/dist/cjs/src/bitbank.js +58 -59
- package/dist/cjs/src/bitbns.js +1 -0
- package/dist/cjs/src/bitfinex.js +1 -0
- package/dist/cjs/src/bitfinex2.js +1 -0
- package/dist/cjs/src/bitflyer.js +1 -0
- package/dist/cjs/src/bitget.js +3 -8
- package/dist/cjs/src/bithumb.js +1 -0
- package/dist/cjs/src/bitmart.js +10 -1
- package/dist/cjs/src/bitmex.js +114 -119
- package/dist/cjs/src/bitopro.js +63 -65
- package/dist/cjs/src/bitpanda.js +60 -60
- package/dist/cjs/src/bitrue.js +67 -71
- package/dist/cjs/src/bitso.js +1 -0
- package/dist/cjs/src/bitstamp.js +1 -0
- package/dist/cjs/src/bittrex.js +57 -57
- package/dist/cjs/src/bitvavo.js +10 -2
- package/dist/cjs/src/blockchaincom.js +2 -2
- package/dist/cjs/src/btcalpha.js +59 -60
- package/dist/cjs/src/btcmarkets.js +68 -69
- package/dist/cjs/src/btcturk.js +72 -74
- package/dist/cjs/src/bybit.js +3 -1
- package/dist/cjs/src/coinbase.js +7 -2
- package/dist/cjs/src/coinbasepro.js +1 -0
- package/dist/cjs/src/coincheck.js +1 -0
- package/dist/cjs/src/coinex.js +4 -0
- package/dist/cjs/src/coinlist.js +60 -60
- package/dist/cjs/src/coinmate.js +1 -0
- package/dist/cjs/src/coinsph.js +2 -4
- package/dist/cjs/src/cryptocom.js +1 -0
- package/dist/cjs/src/currencycom.js +2 -2
- package/dist/cjs/src/deribit.js +2 -0
- package/dist/cjs/src/digifinex.js +5 -2
- package/dist/cjs/src/exmo.js +1 -0
- package/dist/cjs/src/gate.js +2 -0
- package/dist/cjs/src/gemini.js +2 -0
- package/dist/cjs/src/hitbtc.js +4 -0
- package/dist/cjs/src/hollaex.js +2 -0
- package/dist/cjs/src/htx.js +4 -0
- package/dist/cjs/src/huobijp.js +2 -0
- package/dist/cjs/src/idex.js +2 -0
- package/dist/cjs/src/indodax.js +1 -0
- package/dist/cjs/src/kraken.js +3 -3
- package/dist/cjs/src/kucoin.js +6 -5
- package/dist/cjs/src/kuna.js +3 -1
- package/dist/cjs/src/latoken.js +1 -0
- package/dist/cjs/src/lbank.js +1 -0
- package/dist/cjs/src/lykke.js +2 -0
- package/dist/cjs/src/mercado.js +1 -0
- package/dist/cjs/src/mexc.js +2 -0
- package/dist/cjs/src/ndax.js +2 -0
- package/dist/cjs/src/novadax.js +1 -0
- package/dist/cjs/src/okcoin.js +2 -0
- package/dist/cjs/src/okx.js +2 -0
- package/dist/cjs/src/phemex.js +2 -0
- package/dist/cjs/src/poloniex.js +1 -0
- package/dist/cjs/src/pro/binance.js +5 -3
- package/dist/cjs/src/pro/coinbase.js +12 -3
- package/dist/cjs/src/pro/cryptocom.js +17 -17
- package/dist/cjs/src/pro/krakenfutures.js +15 -15
- package/dist/cjs/src/probit.js +4 -2
- package/dist/cjs/src/tidex.js +1 -0
- package/dist/cjs/src/timex.js +2 -0
- package/dist/cjs/src/upbit.js +2 -0
- package/dist/cjs/src/wavesexchange.js +2 -1
- package/dist/cjs/src/whitebit.js +1 -0
- package/dist/cjs/src/woo.js +1 -0
- package/dist/cjs/src/zaif.js +1 -0
- package/dist/cjs/src/zonda.js +1 -0
- package/js/ccxt.d.ts +2 -8
- package/js/ccxt.js +2 -6
- package/js/src/alpaca.d.ts +3 -2
- package/js/src/alpaca.js +62 -64
- package/js/src/ascendex.js +3 -1
- package/js/src/base/Exchange.d.ts +2 -0
- package/js/src/base/Exchange.js +10 -0
- package/js/src/base/types.d.ts +6 -3
- package/js/src/bigone.d.ts +3 -3
- package/js/src/bigone.js +60 -77
- package/js/src/binance.js +1 -0
- package/js/src/bingx.d.ts +2 -2
- package/js/src/bingx.js +4 -11
- package/js/src/bitbank.d.ts +3 -2
- package/js/src/bitbank.js +58 -59
- package/js/src/bitbns.js +1 -0
- package/js/src/bitfinex.js +1 -0
- package/js/src/bitfinex2.js +1 -0
- package/js/src/bitflyer.js +1 -0
- package/js/src/bitget.d.ts +1 -2
- package/js/src/bitget.js +3 -8
- package/js/src/bithumb.js +1 -0
- package/js/src/bitmart.js +10 -1
- package/js/src/bitmex.d.ts +3 -2
- package/js/src/bitmex.js +114 -119
- package/js/src/bitopro.d.ts +3 -2
- package/js/src/bitopro.js +63 -65
- package/js/src/bitpanda.d.ts +3 -2
- package/js/src/bitpanda.js +60 -60
- package/js/src/bitrue.d.ts +3 -2
- package/js/src/bitrue.js +67 -71
- package/js/src/bitso.js +1 -0
- package/js/src/bitstamp.js +1 -0
- package/js/src/bittrex.d.ts +3 -2
- package/js/src/bittrex.js +57 -57
- package/js/src/bitvavo.js +10 -2
- package/js/src/blockchaincom.js +2 -2
- package/js/src/btcalpha.d.ts +3 -2
- package/js/src/btcalpha.js +59 -60
- package/js/src/btcmarkets.d.ts +3 -2
- package/js/src/btcmarkets.js +68 -69
- package/js/src/btcturk.d.ts +3 -2
- package/js/src/btcturk.js +72 -74
- package/js/src/bybit.js +3 -1
- package/js/src/coinbase.js +7 -2
- package/js/src/coinbasepro.js +1 -0
- package/js/src/coincheck.js +1 -0
- package/js/src/coinex.js +4 -0
- package/js/src/coinlist.d.ts +3 -2
- package/js/src/coinlist.js +60 -60
- package/js/src/coinmate.js +1 -0
- package/js/src/coinsph.js +2 -4
- package/js/src/cryptocom.js +1 -0
- package/js/src/currencycom.js +2 -2
- package/js/src/deribit.js +2 -0
- package/js/src/digifinex.js +5 -2
- package/js/src/exmo.js +1 -0
- package/js/src/gate.js +2 -0
- package/js/src/gemini.js +2 -0
- package/js/src/hitbtc.js +4 -0
- package/js/src/hollaex.js +2 -0
- package/js/src/htx.js +4 -0
- package/js/src/huobijp.js +2 -0
- package/js/src/idex.js +2 -0
- package/js/src/indodax.js +1 -0
- package/js/src/kraken.js +3 -3
- package/js/src/kucoin.js +6 -5
- package/js/src/kuna.js +3 -1
- package/js/src/latoken.js +1 -0
- package/js/src/lbank.js +1 -0
- package/js/src/lykke.js +2 -0
- package/js/src/mercado.js +1 -0
- package/js/src/mexc.js +2 -0
- package/js/src/ndax.js +2 -0
- package/js/src/novadax.js +1 -0
- package/js/src/okcoin.js +2 -0
- package/js/src/okx.js +2 -0
- package/js/src/phemex.js +2 -0
- package/js/src/poloniex.js +1 -0
- package/js/src/pro/binance.js +5 -3
- package/js/src/pro/coinbase.js +12 -3
- package/js/src/pro/cryptocom.js +17 -17
- package/js/src/pro/krakenfutures.js +15 -15
- package/js/src/probit.js +4 -2
- package/js/src/tidex.js +1 -0
- package/js/src/timex.js +2 -0
- package/js/src/upbit.js +2 -0
- package/js/src/wavesexchange.js +2 -1
- package/js/src/whitebit.js +1 -0
- package/js/src/woo.js +1 -0
- package/js/src/zaif.js +1 -0
- package/js/src/zonda.js +1 -0
- package/package.json +1 -1
- package/skip-tests.json +2 -3
- package/dist/cjs/src/btctradeua.js +0 -571
- package/dist/cjs/src/coinfalcon.js +0 -1012
- package/js/src/abstract/btctradeua.d.ts +0 -20
- package/js/src/abstract/btctradeua.js +0 -11
- package/js/src/abstract/coinfalcon.d.ts +0 -26
- package/js/src/abstract/coinfalcon.js +0 -11
- package/js/src/btctradeua.d.ts +0 -30
- package/js/src/btctradeua.js +0 -572
- package/js/src/coinfalcon.d.ts +0 -53
- package/js/src/coinfalcon.js +0 -1013
|
@@ -1,1012 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var coinfalcon$1 = require('./abstract/coinfalcon.js');
|
|
4
|
-
var errors = require('./base/errors.js');
|
|
5
|
-
var Precise = require('./base/Precise.js');
|
|
6
|
-
var number = require('./base/functions/number.js');
|
|
7
|
-
var sha256 = require('./static_dependencies/noble-hashes/sha256.js');
|
|
8
|
-
|
|
9
|
-
// ---------------------------------------------------------------------------
|
|
10
|
-
// ---------------------------------------------------------------------------
|
|
11
|
-
/**
|
|
12
|
-
* @class coinfalcon
|
|
13
|
-
* @extends Exchange
|
|
14
|
-
*/
|
|
15
|
-
class coinfalcon extends coinfalcon$1 {
|
|
16
|
-
describe() {
|
|
17
|
-
return this.deepExtend(super.describe(), {
|
|
18
|
-
'id': 'coinfalcon',
|
|
19
|
-
'name': 'CoinFalcon',
|
|
20
|
-
'countries': ['GB'],
|
|
21
|
-
'rateLimit': 1000,
|
|
22
|
-
'version': 'v1',
|
|
23
|
-
'has': {
|
|
24
|
-
'CORS': undefined,
|
|
25
|
-
'spot': true,
|
|
26
|
-
'margin': false,
|
|
27
|
-
'swap': false,
|
|
28
|
-
'future': false,
|
|
29
|
-
'option': false,
|
|
30
|
-
'addMargin': false,
|
|
31
|
-
'cancelOrder': true,
|
|
32
|
-
'createOrder': true,
|
|
33
|
-
'createReduceOnlyOrder': false,
|
|
34
|
-
'createStopLimitOrder': false,
|
|
35
|
-
'createStopMarketOrder': false,
|
|
36
|
-
'createStopOrder': false,
|
|
37
|
-
'fetchBalance': true,
|
|
38
|
-
'fetchBorrowRate': false,
|
|
39
|
-
'fetchBorrowRateHistories': false,
|
|
40
|
-
'fetchBorrowRateHistory': false,
|
|
41
|
-
'fetchBorrowRates': false,
|
|
42
|
-
'fetchBorrowRatesPerSymbol': false,
|
|
43
|
-
'fetchDepositAddress': true,
|
|
44
|
-
'fetchDepositAddresses': false,
|
|
45
|
-
'fetchDeposits': true,
|
|
46
|
-
'fetchFundingHistory': false,
|
|
47
|
-
'fetchFundingRate': false,
|
|
48
|
-
'fetchFundingRateHistory': false,
|
|
49
|
-
'fetchFundingRates': false,
|
|
50
|
-
'fetchIndexOHLCV': false,
|
|
51
|
-
'fetchLeverage': false,
|
|
52
|
-
'fetchLeverageTiers': false,
|
|
53
|
-
'fetchMarginMode': false,
|
|
54
|
-
'fetchMarkets': true,
|
|
55
|
-
'fetchMarkOHLCV': false,
|
|
56
|
-
'fetchMyTrades': true,
|
|
57
|
-
'fetchOpenInterestHistory': false,
|
|
58
|
-
'fetchOpenOrders': true,
|
|
59
|
-
'fetchOrder': true,
|
|
60
|
-
'fetchOrderBook': true,
|
|
61
|
-
'fetchPosition': false,
|
|
62
|
-
'fetchPositionMode': false,
|
|
63
|
-
'fetchPositions': false,
|
|
64
|
-
'fetchPositionsRisk': false,
|
|
65
|
-
'fetchPremiumIndexOHLCV': false,
|
|
66
|
-
'fetchTicker': true,
|
|
67
|
-
'fetchTickers': true,
|
|
68
|
-
'fetchTrades': true,
|
|
69
|
-
'fetchTradinFee': false,
|
|
70
|
-
'fetchTradingFees': true,
|
|
71
|
-
'fetchTransfer': false,
|
|
72
|
-
'fetchTransfers': false,
|
|
73
|
-
'fetchWithdrawals': true,
|
|
74
|
-
'reduceMargin': false,
|
|
75
|
-
'setLeverage': false,
|
|
76
|
-
'setMarginMode': false,
|
|
77
|
-
'setPositionMode': false,
|
|
78
|
-
'transfer': false,
|
|
79
|
-
'withdraw': true,
|
|
80
|
-
},
|
|
81
|
-
'urls': {
|
|
82
|
-
'logo': 'https://user-images.githubusercontent.com/1294454/41822275-ed982188-77f5-11e8-92bb-496bcd14ca52.jpg',
|
|
83
|
-
'api': {
|
|
84
|
-
'rest': 'https://coinfalcon.com',
|
|
85
|
-
},
|
|
86
|
-
'www': 'https://coinfalcon.com',
|
|
87
|
-
'doc': 'https://docs.coinfalcon.com',
|
|
88
|
-
'fees': 'https://coinfalcon.com/fees',
|
|
89
|
-
'referral': 'https://coinfalcon.com/?ref=CFJSVGTUPASB',
|
|
90
|
-
},
|
|
91
|
-
'api': {
|
|
92
|
-
'public': {
|
|
93
|
-
'get': [
|
|
94
|
-
'markets',
|
|
95
|
-
'markets/{market}',
|
|
96
|
-
'markets/{market}/orders',
|
|
97
|
-
'markets/{market}/trades',
|
|
98
|
-
],
|
|
99
|
-
},
|
|
100
|
-
'private': {
|
|
101
|
-
'get': [
|
|
102
|
-
'user/accounts',
|
|
103
|
-
'user/orders',
|
|
104
|
-
'user/orders/{id}',
|
|
105
|
-
'user/orders/{id}/trades',
|
|
106
|
-
'user/trades',
|
|
107
|
-
'user/fees',
|
|
108
|
-
'account/withdrawals/{id}',
|
|
109
|
-
'account/withdrawals',
|
|
110
|
-
'account/deposit/{id}',
|
|
111
|
-
'account/deposits',
|
|
112
|
-
'account/deposit_address',
|
|
113
|
-
],
|
|
114
|
-
'post': [
|
|
115
|
-
'user/orders',
|
|
116
|
-
'account/withdraw',
|
|
117
|
-
],
|
|
118
|
-
'delete': [
|
|
119
|
-
'user/orders/{id}',
|
|
120
|
-
'account/withdrawals/{id}',
|
|
121
|
-
],
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
'fees': {
|
|
125
|
-
'trading': {
|
|
126
|
-
'tierBased': true,
|
|
127
|
-
'maker': 0.0,
|
|
128
|
-
'taker': 0.002, // tiered fee starts at 0.2%
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
'precisionMode': number.TICK_SIZE,
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
async fetchMarkets(params = {}) {
|
|
135
|
-
/**
|
|
136
|
-
* @method
|
|
137
|
-
* @name coinfalcon#fetchMarkets
|
|
138
|
-
* @description retrieves data on all markets for coinfalcon
|
|
139
|
-
* @param {object} [params] extra parameters specific to the exchange api endpoint
|
|
140
|
-
* @returns {object[]} an array of objects representing market data
|
|
141
|
-
*/
|
|
142
|
-
const response = await this.publicGetMarkets(params);
|
|
143
|
-
//
|
|
144
|
-
// {
|
|
145
|
-
// "data": [
|
|
146
|
-
// {
|
|
147
|
-
// "name": "ETH-BTC",
|
|
148
|
-
// "precision": 6,
|
|
149
|
-
// "min_volume": "0.00000001",
|
|
150
|
-
// "min_price": "0.000001",
|
|
151
|
-
// "volume": "0.015713",
|
|
152
|
-
// "last_price": "0.069322",
|
|
153
|
-
// "highest_bid": "0.063892",
|
|
154
|
-
// "lowest_ask": "0.071437",
|
|
155
|
-
// "change_in_24h": "2.85",
|
|
156
|
-
// "size_precision": 8,
|
|
157
|
-
// "price_precision": 6
|
|
158
|
-
// },
|
|
159
|
-
// ...
|
|
160
|
-
// ]
|
|
161
|
-
// }
|
|
162
|
-
//
|
|
163
|
-
const markets = this.safeValue(response, 'data', []);
|
|
164
|
-
const result = [];
|
|
165
|
-
for (let i = 0; i < markets.length; i++) {
|
|
166
|
-
const market = markets[i];
|
|
167
|
-
const [baseId, quoteId] = market['name'].split('-');
|
|
168
|
-
const base = this.safeCurrencyCode(baseId);
|
|
169
|
-
const quote = this.safeCurrencyCode(quoteId);
|
|
170
|
-
result.push({
|
|
171
|
-
'id': market['name'],
|
|
172
|
-
'symbol': base + '/' + quote,
|
|
173
|
-
'base': base,
|
|
174
|
-
'quote': quote,
|
|
175
|
-
'settle': undefined,
|
|
176
|
-
'baseId': baseId,
|
|
177
|
-
'quoteId': quoteId,
|
|
178
|
-
'settleId': undefined,
|
|
179
|
-
'type': 'spot',
|
|
180
|
-
'spot': true,
|
|
181
|
-
'margin': false,
|
|
182
|
-
'swap': false,
|
|
183
|
-
'future': false,
|
|
184
|
-
'option': false,
|
|
185
|
-
'active': true,
|
|
186
|
-
'contract': false,
|
|
187
|
-
'linear': undefined,
|
|
188
|
-
'inverse': undefined,
|
|
189
|
-
'contractSize': undefined,
|
|
190
|
-
'expiry': undefined,
|
|
191
|
-
'expiryDatetime': undefined,
|
|
192
|
-
'strike': undefined,
|
|
193
|
-
'optionType': undefined,
|
|
194
|
-
'precision': {
|
|
195
|
-
'amount': this.parseNumber(this.parsePrecision(this.safeString(market, 'size_precision'))),
|
|
196
|
-
'price': this.parseNumber(this.parsePrecision(this.safeString(market, 'price_precision'))),
|
|
197
|
-
},
|
|
198
|
-
'limits': {
|
|
199
|
-
'leverage': {
|
|
200
|
-
'min': undefined,
|
|
201
|
-
'max': undefined,
|
|
202
|
-
},
|
|
203
|
-
'amount': {
|
|
204
|
-
'min': this.safeNumber(market, 'minPrice'),
|
|
205
|
-
'max': undefined,
|
|
206
|
-
},
|
|
207
|
-
'price': {
|
|
208
|
-
'min': this.safeNumber(market, 'minVolume'),
|
|
209
|
-
'max': undefined,
|
|
210
|
-
},
|
|
211
|
-
'cost': {
|
|
212
|
-
'min': undefined,
|
|
213
|
-
'max': undefined,
|
|
214
|
-
},
|
|
215
|
-
},
|
|
216
|
-
'created': undefined,
|
|
217
|
-
'info': market,
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
return result;
|
|
221
|
-
}
|
|
222
|
-
parseTicker(ticker, market = undefined) {
|
|
223
|
-
//
|
|
224
|
-
// {
|
|
225
|
-
// "name":"ETH-BTC",
|
|
226
|
-
// "precision":6,
|
|
227
|
-
// "min_volume":"0.00000001",
|
|
228
|
-
// "min_price":"0.000001",
|
|
229
|
-
// "volume":"0.000452",
|
|
230
|
-
// "last_price":"0.079059",
|
|
231
|
-
// "highest_bid":"0.073472",
|
|
232
|
-
// "lowest_ask":"0.079059",
|
|
233
|
-
// "change_in_24h":"8.9",
|
|
234
|
-
// "size_precision":8,
|
|
235
|
-
// "price_precision":6
|
|
236
|
-
// }
|
|
237
|
-
//
|
|
238
|
-
const marketId = this.safeString(ticker, 'name');
|
|
239
|
-
market = this.safeMarket(marketId, market, '-');
|
|
240
|
-
const timestamp = this.milliseconds();
|
|
241
|
-
const last = this.safeString(ticker, 'last_price');
|
|
242
|
-
return this.safeTicker({
|
|
243
|
-
'symbol': market['symbol'],
|
|
244
|
-
'timestamp': timestamp,
|
|
245
|
-
'datetime': this.iso8601(timestamp),
|
|
246
|
-
'high': undefined,
|
|
247
|
-
'low': undefined,
|
|
248
|
-
'bid': this.safeString(ticker, 'highest_bid'),
|
|
249
|
-
'bidVolume': undefined,
|
|
250
|
-
'ask': this.safeString(ticker, 'lowest_ask'),
|
|
251
|
-
'askVolume': undefined,
|
|
252
|
-
'vwap': undefined,
|
|
253
|
-
'open': undefined,
|
|
254
|
-
'close': last,
|
|
255
|
-
'last': last,
|
|
256
|
-
'previousClose': undefined,
|
|
257
|
-
'change': this.safeString(ticker, 'change_in_24h'),
|
|
258
|
-
'percentage': undefined,
|
|
259
|
-
'average': undefined,
|
|
260
|
-
'baseVolume': undefined,
|
|
261
|
-
'quoteVolume': this.safeString(ticker, 'volume'),
|
|
262
|
-
'info': ticker,
|
|
263
|
-
}, market);
|
|
264
|
-
}
|
|
265
|
-
async fetchTicker(symbol, params = {}) {
|
|
266
|
-
/**
|
|
267
|
-
* @method
|
|
268
|
-
* @name coinfalcon#fetchTicker
|
|
269
|
-
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
270
|
-
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
271
|
-
* @param {object} [params] extra parameters specific to the coinfalcon api endpoint
|
|
272
|
-
* @returns {object} a [ticker structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#ticker-structure}
|
|
273
|
-
*/
|
|
274
|
-
await this.loadMarkets();
|
|
275
|
-
const tickers = await this.fetchTickers([symbol], params);
|
|
276
|
-
return tickers[symbol];
|
|
277
|
-
}
|
|
278
|
-
async fetchTickers(symbols = undefined, params = {}) {
|
|
279
|
-
/**
|
|
280
|
-
* @method
|
|
281
|
-
* @name coinfalcon#fetchTickers
|
|
282
|
-
* @description fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
|
|
283
|
-
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
284
|
-
* @param {object} [params] extra parameters specific to the coinfalcon api endpoint
|
|
285
|
-
* @returns {object} a dictionary of [ticker structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#ticker-structure}
|
|
286
|
-
*/
|
|
287
|
-
await this.loadMarkets();
|
|
288
|
-
symbols = this.marketSymbols(symbols);
|
|
289
|
-
const response = await this.publicGetMarkets(params);
|
|
290
|
-
//
|
|
291
|
-
// {
|
|
292
|
-
// "data":[
|
|
293
|
-
// {
|
|
294
|
-
// "name":"ETH-BTC",
|
|
295
|
-
// "precision":6,
|
|
296
|
-
// "min_volume":"0.00000001",
|
|
297
|
-
// "min_price":"0.000001",
|
|
298
|
-
// "volume":"0.000452",
|
|
299
|
-
// "last_price":"0.079059",
|
|
300
|
-
// "highest_bid":"0.073472",
|
|
301
|
-
// "lowest_ask":"0.079059",
|
|
302
|
-
// "change_in_24h":"8.9",
|
|
303
|
-
// "size_precision":8,
|
|
304
|
-
// "price_precision":6
|
|
305
|
-
// }
|
|
306
|
-
// ]
|
|
307
|
-
// }
|
|
308
|
-
//
|
|
309
|
-
const tickers = this.safeValue(response, 'data', []);
|
|
310
|
-
const result = {};
|
|
311
|
-
for (let i = 0; i < tickers.length; i++) {
|
|
312
|
-
const ticker = this.parseTicker(tickers[i]);
|
|
313
|
-
const symbol = ticker['symbol'];
|
|
314
|
-
result[symbol] = ticker;
|
|
315
|
-
}
|
|
316
|
-
return this.filterByArrayTickers(result, 'symbol', symbols);
|
|
317
|
-
}
|
|
318
|
-
async fetchOrderBook(symbol, limit = undefined, params = {}) {
|
|
319
|
-
/**
|
|
320
|
-
* @method
|
|
321
|
-
* @name coinfalcon#fetchOrderBook
|
|
322
|
-
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
323
|
-
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
324
|
-
* @param {int} [limit] the maximum amount of order book entries to return
|
|
325
|
-
* @param {object} [params] extra parameters specific to the coinfalcon api endpoint
|
|
326
|
-
* @returns {object} A dictionary of [order book structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-book-structure} indexed by market symbols
|
|
327
|
-
*/
|
|
328
|
-
await this.loadMarkets();
|
|
329
|
-
const market = this.market(symbol);
|
|
330
|
-
const request = {
|
|
331
|
-
'market': market['id'],
|
|
332
|
-
'level': '3',
|
|
333
|
-
};
|
|
334
|
-
const response = await this.publicGetMarketsMarketOrders(this.extend(request, params));
|
|
335
|
-
const data = this.safeValue(response, 'data', {});
|
|
336
|
-
return this.parseOrderBook(data, market['symbol'], undefined, 'bids', 'asks', 'price', 'size');
|
|
337
|
-
}
|
|
338
|
-
parseTrade(trade, market = undefined) {
|
|
339
|
-
//
|
|
340
|
-
// fetchTrades (public)
|
|
341
|
-
//
|
|
342
|
-
// {
|
|
343
|
-
// "id":"5ec36295-5c8d-4874-8d66-2609d4938557",
|
|
344
|
-
// "price":"4050.06","size":"0.0044",
|
|
345
|
-
// "market_name":"ETH-USDT",
|
|
346
|
-
// "side":"sell",
|
|
347
|
-
// "created_at":"2021-12-07T17:47:36.811000Z"
|
|
348
|
-
// }
|
|
349
|
-
//
|
|
350
|
-
// fetchMyTrades (private)
|
|
351
|
-
//
|
|
352
|
-
// {
|
|
353
|
-
// "id": "0718d520-c796-4061-a16b-915cd13f20c6",
|
|
354
|
-
// "price": "0.00000358",
|
|
355
|
-
// "size": "50.0",
|
|
356
|
-
// "market_name": "DOGE-BTC",
|
|
357
|
-
// "order_id": "ff2616d8-58d4-40fd-87ae-937c73eb6f1c",
|
|
358
|
-
// "side": "buy",
|
|
359
|
-
// "fee': "0.00000036",
|
|
360
|
-
// "fee_currency_code": "btc",
|
|
361
|
-
// "liquidity": "T",
|
|
362
|
-
// "created_at": "2021-12-08T18:26:33.840000Z"
|
|
363
|
-
// }
|
|
364
|
-
//
|
|
365
|
-
const timestamp = this.parse8601(this.safeString(trade, 'created_at'));
|
|
366
|
-
const priceString = this.safeString(trade, 'price');
|
|
367
|
-
const amountString = this.safeString(trade, 'size');
|
|
368
|
-
const symbol = market['symbol'];
|
|
369
|
-
const tradeId = this.safeString(trade, 'id');
|
|
370
|
-
const side = this.safeString(trade, 'side');
|
|
371
|
-
const orderId = this.safeString(trade, 'order_id');
|
|
372
|
-
let fee = undefined;
|
|
373
|
-
const feeCostString = this.safeString(trade, 'fee');
|
|
374
|
-
if (feeCostString !== undefined) {
|
|
375
|
-
const feeCurrencyCode = this.safeString(trade, 'fee_currency_code');
|
|
376
|
-
fee = {
|
|
377
|
-
'cost': feeCostString,
|
|
378
|
-
'currency': this.safeCurrencyCode(feeCurrencyCode),
|
|
379
|
-
};
|
|
380
|
-
}
|
|
381
|
-
return this.safeTrade({
|
|
382
|
-
'info': trade,
|
|
383
|
-
'timestamp': timestamp,
|
|
384
|
-
'datetime': this.iso8601(timestamp),
|
|
385
|
-
'symbol': symbol,
|
|
386
|
-
'id': tradeId,
|
|
387
|
-
'order': orderId,
|
|
388
|
-
'type': undefined,
|
|
389
|
-
'side': side,
|
|
390
|
-
'takerOrMaker': undefined,
|
|
391
|
-
'price': priceString,
|
|
392
|
-
'amount': amountString,
|
|
393
|
-
'cost': undefined,
|
|
394
|
-
'fee': fee,
|
|
395
|
-
}, market);
|
|
396
|
-
}
|
|
397
|
-
async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
398
|
-
/**
|
|
399
|
-
* @method
|
|
400
|
-
* @name coinfalcon#fetchMyTrades
|
|
401
|
-
* @description fetch all trades made by the user
|
|
402
|
-
* @param {string} symbol unified market symbol
|
|
403
|
-
* @param {int} [since] the earliest time in ms to fetch trades for
|
|
404
|
-
* @param {int} [limit] the maximum number of trades structures to retrieve
|
|
405
|
-
* @param {object} [params] extra parameters specific to the coinfalcon api endpoint
|
|
406
|
-
* @returns {Trade[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#trade-structure}
|
|
407
|
-
*/
|
|
408
|
-
this.checkRequiredSymbol('fetchMyTrades', symbol);
|
|
409
|
-
await this.loadMarkets();
|
|
410
|
-
const market = this.market(symbol);
|
|
411
|
-
const request = {
|
|
412
|
-
'market': market['id'],
|
|
413
|
-
};
|
|
414
|
-
if (since !== undefined) {
|
|
415
|
-
request['start_time'] = this.iso8601(since);
|
|
416
|
-
}
|
|
417
|
-
if (limit !== undefined) {
|
|
418
|
-
request['limit'] = limit;
|
|
419
|
-
}
|
|
420
|
-
const response = await this.privateGetUserTrades(this.extend(request, params));
|
|
421
|
-
//
|
|
422
|
-
// {
|
|
423
|
-
// "data": [
|
|
424
|
-
// {
|
|
425
|
-
// "id": "0718d520-c796-4061-a16b-915cd13f20c6",
|
|
426
|
-
// "price": "0.00000358",
|
|
427
|
-
// "size": "50.0",
|
|
428
|
-
// "market_name": "DOGE-BTC",
|
|
429
|
-
// "order_id": "ff2616d8-58d4-40fd-87ae-937c73eb6f1c",
|
|
430
|
-
// "side": "buy",
|
|
431
|
-
// "fee': "0.00000036",
|
|
432
|
-
// "fee_currency_code": "btc",
|
|
433
|
-
// "liquidity": "T",
|
|
434
|
-
// "created_at": "2021-12-08T18:26:33.840000Z"
|
|
435
|
-
// },
|
|
436
|
-
// ]
|
|
437
|
-
// }
|
|
438
|
-
//
|
|
439
|
-
const data = this.safeValue(response, 'data', []);
|
|
440
|
-
return this.parseTrades(data, market, since, limit);
|
|
441
|
-
}
|
|
442
|
-
async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
|
|
443
|
-
/**
|
|
444
|
-
* @method
|
|
445
|
-
* @name coinfalcon#fetchTrades
|
|
446
|
-
* @description get the list of most recent trades for a particular symbol
|
|
447
|
-
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
448
|
-
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
449
|
-
* @param {int} [limit] the maximum amount of trades to fetch
|
|
450
|
-
* @param {object} [params] extra parameters specific to the coinfalcon api endpoint
|
|
451
|
-
* @returns {Trade[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#public-trades}
|
|
452
|
-
*/
|
|
453
|
-
await this.loadMarkets();
|
|
454
|
-
const market = this.market(symbol);
|
|
455
|
-
const request = {
|
|
456
|
-
'market': market['id'],
|
|
457
|
-
};
|
|
458
|
-
if (since !== undefined) {
|
|
459
|
-
request['since'] = this.iso8601(since);
|
|
460
|
-
}
|
|
461
|
-
const response = await this.publicGetMarketsMarketTrades(this.extend(request, params));
|
|
462
|
-
//
|
|
463
|
-
// {
|
|
464
|
-
// "data":[
|
|
465
|
-
// {
|
|
466
|
-
// "id":"5ec36295-5c8d-4874-8d66-2609d4938557",
|
|
467
|
-
// "price":"4050.06","size":"0.0044",
|
|
468
|
-
// "market_name":"ETH-USDT",
|
|
469
|
-
// "side":"sell",
|
|
470
|
-
// "created_at":"2021-12-07T17:47:36.811000Z"
|
|
471
|
-
// },
|
|
472
|
-
// ]
|
|
473
|
-
// }
|
|
474
|
-
//
|
|
475
|
-
const data = this.safeValue(response, 'data', []);
|
|
476
|
-
return this.parseTrades(data, market, since, limit);
|
|
477
|
-
}
|
|
478
|
-
async fetchTradingFees(params = {}) {
|
|
479
|
-
/**
|
|
480
|
-
* @method
|
|
481
|
-
* @name coinfalcon#fetchTradingFees
|
|
482
|
-
* @description fetch the trading fees for multiple markets
|
|
483
|
-
* @param {object} [params] extra parameters specific to the coinfalcon api endpoint
|
|
484
|
-
* @returns {object} a dictionary of [fee structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#fee-structure} indexed by market symbols
|
|
485
|
-
*/
|
|
486
|
-
await this.loadMarkets();
|
|
487
|
-
const response = await this.privateGetUserFees(params);
|
|
488
|
-
//
|
|
489
|
-
// {
|
|
490
|
-
// "data": {
|
|
491
|
-
// "maker_fee": "0.0",
|
|
492
|
-
// "taker_fee": "0.2",
|
|
493
|
-
// "btc_volume_30d": "0.0"
|
|
494
|
-
// }
|
|
495
|
-
// }
|
|
496
|
-
//
|
|
497
|
-
const data = this.safeValue(response, 'data', {});
|
|
498
|
-
const makerString = this.safeString(data, 'maker_fee');
|
|
499
|
-
const takerString = this.safeString(data, 'taker_fee');
|
|
500
|
-
const maker = this.parseNumber(Precise["default"].stringDiv(makerString, '100'));
|
|
501
|
-
const taker = this.parseNumber(Precise["default"].stringDiv(takerString, '100'));
|
|
502
|
-
const result = {};
|
|
503
|
-
for (let i = 0; i < this.symbols.length; i++) {
|
|
504
|
-
const symbol = this.symbols[i];
|
|
505
|
-
result[symbol] = {
|
|
506
|
-
'info': response,
|
|
507
|
-
'symbol': symbol,
|
|
508
|
-
'maker': maker,
|
|
509
|
-
'taker': taker,
|
|
510
|
-
'percentage': true,
|
|
511
|
-
'tierBased': true,
|
|
512
|
-
};
|
|
513
|
-
}
|
|
514
|
-
return result;
|
|
515
|
-
}
|
|
516
|
-
parseBalance(response) {
|
|
517
|
-
const result = { 'info': response };
|
|
518
|
-
const balances = this.safeValue(response, 'data', []);
|
|
519
|
-
for (let i = 0; i < balances.length; i++) {
|
|
520
|
-
const balance = balances[i];
|
|
521
|
-
const currencyId = this.safeString(balance, 'currency_code');
|
|
522
|
-
const code = this.safeCurrencyCode(currencyId);
|
|
523
|
-
const account = this.account();
|
|
524
|
-
account['free'] = this.safeString(balance, 'available_balance');
|
|
525
|
-
account['used'] = this.safeString(balance, 'hold_balance');
|
|
526
|
-
account['total'] = this.safeString(balance, 'balance');
|
|
527
|
-
result[code] = account;
|
|
528
|
-
}
|
|
529
|
-
return this.safeBalance(result);
|
|
530
|
-
}
|
|
531
|
-
async fetchBalance(params = {}) {
|
|
532
|
-
/**
|
|
533
|
-
* @method
|
|
534
|
-
* @name coinfalcon#fetchBalance
|
|
535
|
-
* @description query for balance and get the amount of funds available for trading or funds locked in orders
|
|
536
|
-
* @param {object} [params] extra parameters specific to the coinfalcon api endpoint
|
|
537
|
-
* @returns {object} a [balance structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#balance-structure}
|
|
538
|
-
*/
|
|
539
|
-
await this.loadMarkets();
|
|
540
|
-
const response = await this.privateGetUserAccounts(params);
|
|
541
|
-
return this.parseBalance(response);
|
|
542
|
-
}
|
|
543
|
-
parseDepositAddress(depositAddress, currency = undefined) {
|
|
544
|
-
//
|
|
545
|
-
// {
|
|
546
|
-
// "address":"0x77b5051f97efa9cc52c9ad5b023a53fc15c200d3",
|
|
547
|
-
// "tag":"0"
|
|
548
|
-
// }
|
|
549
|
-
//
|
|
550
|
-
const address = this.safeString(depositAddress, 'address');
|
|
551
|
-
const tag = this.safeString(depositAddress, 'tag');
|
|
552
|
-
this.checkAddress(address);
|
|
553
|
-
return {
|
|
554
|
-
'currency': this.safeCurrencyCode(undefined, currency),
|
|
555
|
-
'address': address,
|
|
556
|
-
'tag': tag,
|
|
557
|
-
'network': undefined,
|
|
558
|
-
'info': depositAddress,
|
|
559
|
-
};
|
|
560
|
-
}
|
|
561
|
-
async fetchDepositAddress(code, params = {}) {
|
|
562
|
-
/**
|
|
563
|
-
* @method
|
|
564
|
-
* @name coinfalcon#fetchDepositAddress
|
|
565
|
-
* @description fetch the deposit address for a currency associated with this account
|
|
566
|
-
* @param {string} code unified currency code
|
|
567
|
-
* @param {object} [params] extra parameters specific to the coinfalcon api endpoint
|
|
568
|
-
* @returns {object} an [address structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#address-structure}
|
|
569
|
-
*/
|
|
570
|
-
await this.loadMarkets();
|
|
571
|
-
const currency = this.safeCurrency(code);
|
|
572
|
-
const request = {
|
|
573
|
-
'currency': this.safeStringLower(currency, 'id'),
|
|
574
|
-
};
|
|
575
|
-
const response = await this.privateGetAccountDepositAddress(this.extend(request, params));
|
|
576
|
-
//
|
|
577
|
-
// {
|
|
578
|
-
// "data": {
|
|
579
|
-
// "address": "0x9918987bbe865a1a9301dc736cf6cf3205956694",
|
|
580
|
-
// "tag":null
|
|
581
|
-
// }
|
|
582
|
-
// }
|
|
583
|
-
//
|
|
584
|
-
const data = this.safeValue(response, 'data', {});
|
|
585
|
-
return this.parseDepositAddress(data, currency);
|
|
586
|
-
}
|
|
587
|
-
parseOrderStatus(status) {
|
|
588
|
-
const statuses = {
|
|
589
|
-
'fulfilled': 'closed',
|
|
590
|
-
'canceled': 'canceled',
|
|
591
|
-
'pending': 'open',
|
|
592
|
-
'open': 'open',
|
|
593
|
-
'partially_filled': 'open',
|
|
594
|
-
};
|
|
595
|
-
return this.safeString(statuses, status, status);
|
|
596
|
-
}
|
|
597
|
-
parseOrder(order, market = undefined) {
|
|
598
|
-
//
|
|
599
|
-
// {
|
|
600
|
-
// "id":"8bdd79f4-8414-40a2-90c3-e9f4d6d1eef4"
|
|
601
|
-
// "market":"IOT-BTC"
|
|
602
|
-
// "price":"0.0000003"
|
|
603
|
-
// "size":"4.0"
|
|
604
|
-
// "size_filled":"3.0"
|
|
605
|
-
// "fee":"0.0075"
|
|
606
|
-
// "fee_currency_code":"iot"
|
|
607
|
-
// "funds":"0.0"
|
|
608
|
-
// "status":"canceled"
|
|
609
|
-
// "order_type":"buy"
|
|
610
|
-
// "post_only":false
|
|
611
|
-
// "operation_type":"market_order"
|
|
612
|
-
// "created_at":"2018-01-12T21:14:06.747828Z"
|
|
613
|
-
// }
|
|
614
|
-
//
|
|
615
|
-
const marketId = this.safeString(order, 'market');
|
|
616
|
-
const symbol = this.safeSymbol(marketId, market, '-');
|
|
617
|
-
const timestamp = this.parse8601(this.safeString(order, 'created_at'));
|
|
618
|
-
const priceString = this.safeString(order, 'price');
|
|
619
|
-
const amountString = this.safeString(order, 'size');
|
|
620
|
-
const filledString = this.safeString(order, 'size_filled');
|
|
621
|
-
const status = this.parseOrderStatus(this.safeString(order, 'status'));
|
|
622
|
-
let type = this.safeString(order, 'operation_type');
|
|
623
|
-
if (type !== undefined) {
|
|
624
|
-
const typeParts = type.split('_');
|
|
625
|
-
type = typeParts[0];
|
|
626
|
-
}
|
|
627
|
-
const side = this.safeString(order, 'order_type');
|
|
628
|
-
const postOnly = this.safeValue(order, 'post_only');
|
|
629
|
-
return this.safeOrder({
|
|
630
|
-
'id': this.safeString(order, 'id'),
|
|
631
|
-
'clientOrderId': undefined,
|
|
632
|
-
'datetime': this.iso8601(timestamp),
|
|
633
|
-
'timestamp': timestamp,
|
|
634
|
-
'status': status,
|
|
635
|
-
'symbol': symbol,
|
|
636
|
-
'type': type,
|
|
637
|
-
'timeInForce': undefined,
|
|
638
|
-
'postOnly': postOnly,
|
|
639
|
-
'side': side,
|
|
640
|
-
'price': priceString,
|
|
641
|
-
'stopPrice': undefined,
|
|
642
|
-
'triggerPrice': undefined,
|
|
643
|
-
'cost': undefined,
|
|
644
|
-
'amount': amountString,
|
|
645
|
-
'filled': filledString,
|
|
646
|
-
'remaining': undefined,
|
|
647
|
-
'trades': undefined,
|
|
648
|
-
'fee': undefined,
|
|
649
|
-
'info': order,
|
|
650
|
-
'lastTradeTimestamp': undefined,
|
|
651
|
-
'average': undefined,
|
|
652
|
-
}, market);
|
|
653
|
-
}
|
|
654
|
-
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
655
|
-
/**
|
|
656
|
-
* @method
|
|
657
|
-
* @name coinfalcon#createOrder
|
|
658
|
-
* @description create a trade order
|
|
659
|
-
* @param {string} symbol unified symbol of the market to create an order in
|
|
660
|
-
* @param {string} type 'market' or 'limit'
|
|
661
|
-
* @param {string} side 'buy' or 'sell'
|
|
662
|
-
* @param {float} amount how much of currency you want to trade in units of base currency
|
|
663
|
-
* @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
|
664
|
-
* @param {object} [params] extra parameters specific to the coinfalcon api endpoint
|
|
665
|
-
* @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
|
|
666
|
-
*/
|
|
667
|
-
await this.loadMarkets();
|
|
668
|
-
const market = this.market(symbol);
|
|
669
|
-
// price/size must be string
|
|
670
|
-
const request = {
|
|
671
|
-
'market': market['id'],
|
|
672
|
-
'size': this.amountToPrecision(symbol, amount),
|
|
673
|
-
'order_type': side,
|
|
674
|
-
};
|
|
675
|
-
if (type === 'limit') {
|
|
676
|
-
price = this.priceToPrecision(symbol, price);
|
|
677
|
-
request['price'] = price.toString();
|
|
678
|
-
}
|
|
679
|
-
request['operation_type'] = type + '_order';
|
|
680
|
-
const response = await this.privatePostUserOrders(this.extend(request, params));
|
|
681
|
-
const data = this.safeValue(response, 'data', {});
|
|
682
|
-
return this.parseOrder(data, market);
|
|
683
|
-
}
|
|
684
|
-
async cancelOrder(id, symbol = undefined, params = {}) {
|
|
685
|
-
/**
|
|
686
|
-
* @method
|
|
687
|
-
* @name coinfalcon#cancelOrder
|
|
688
|
-
* @description cancels an open order
|
|
689
|
-
* @param {string} id order id
|
|
690
|
-
* @param {string} symbol unified symbol of the market the order was made in
|
|
691
|
-
* @param {object} [params] extra parameters specific to the coinfalcon api endpoint
|
|
692
|
-
* @returns {object} An [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
|
|
693
|
-
*/
|
|
694
|
-
await this.loadMarkets();
|
|
695
|
-
const request = {
|
|
696
|
-
'id': id,
|
|
697
|
-
};
|
|
698
|
-
const response = await this.privateDeleteUserOrdersId(this.extend(request, params));
|
|
699
|
-
const market = this.market(symbol);
|
|
700
|
-
const data = this.safeValue(response, 'data', {});
|
|
701
|
-
return this.parseOrder(data, market);
|
|
702
|
-
}
|
|
703
|
-
async fetchOrder(id, symbol = undefined, params = {}) {
|
|
704
|
-
/**
|
|
705
|
-
* @method
|
|
706
|
-
* @name coinfalcon#fetchOrder
|
|
707
|
-
* @description fetches information on an order made by the user
|
|
708
|
-
* @param {string} symbol unified symbol of the market the order was made in
|
|
709
|
-
* @param {object} [params] extra parameters specific to the coinfalcon api endpoint
|
|
710
|
-
* @returns {object} An [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
|
|
711
|
-
*/
|
|
712
|
-
await this.loadMarkets();
|
|
713
|
-
const request = {
|
|
714
|
-
'id': id,
|
|
715
|
-
};
|
|
716
|
-
const response = await this.privateGetUserOrdersId(this.extend(request, params));
|
|
717
|
-
const data = this.safeValue(response, 'data', {});
|
|
718
|
-
return this.parseOrder(data);
|
|
719
|
-
}
|
|
720
|
-
async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
721
|
-
/**
|
|
722
|
-
* @method
|
|
723
|
-
* @name coinfalcon#fetchOpenOrders
|
|
724
|
-
* @description fetch all unfilled currently open orders
|
|
725
|
-
* @param {string} symbol unified market symbol
|
|
726
|
-
* @param {int} [since] the earliest time in ms to fetch open orders for
|
|
727
|
-
* @param {int} [limit] the maximum number of open orders structures to retrieve
|
|
728
|
-
* @param {object} [params] extra parameters specific to the coinfalcon api endpoint
|
|
729
|
-
* @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
|
|
730
|
-
*/
|
|
731
|
-
await this.loadMarkets();
|
|
732
|
-
const request = {};
|
|
733
|
-
let market = undefined;
|
|
734
|
-
if (symbol !== undefined) {
|
|
735
|
-
market = this.market(symbol);
|
|
736
|
-
request['market'] = market['id'];
|
|
737
|
-
}
|
|
738
|
-
if (since !== undefined) {
|
|
739
|
-
request['since_time'] = this.iso8601(since);
|
|
740
|
-
}
|
|
741
|
-
// TODO: test status=all if it works for closed orders too
|
|
742
|
-
const response = await this.privateGetUserOrders(this.extend(request, params));
|
|
743
|
-
const data = this.safeValue(response, 'data', []);
|
|
744
|
-
const orders = this.filterByArray(data, 'status', ['pending', 'open', 'partially_filled'], false);
|
|
745
|
-
return this.parseOrders(orders, market, since, limit);
|
|
746
|
-
}
|
|
747
|
-
async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
748
|
-
/**
|
|
749
|
-
* @method
|
|
750
|
-
* @name coinfalcon#fetchDeposits
|
|
751
|
-
* @description fetch all deposits made to an account
|
|
752
|
-
* @param {string} code unified currency code
|
|
753
|
-
* @param {int} [since] the earliest time in ms to fetch deposits for
|
|
754
|
-
* @param {int} [limit] the maximum number of deposits structures to retrieve
|
|
755
|
-
* @param {object} [params] extra parameters specific to the coinfalcon api endpoint
|
|
756
|
-
* @returns {object[]} a list of [transaction structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#transaction-structure}
|
|
757
|
-
*/
|
|
758
|
-
await this.loadMarkets();
|
|
759
|
-
const request = {
|
|
760
|
-
// currency: 'xrp', // optional: currency code in lowercase
|
|
761
|
-
// status: 'completed', // optional: withdrawal status
|
|
762
|
-
// since_time // datetime in ISO8601 format (2017-11-06T09:53:08.383210Z)
|
|
763
|
-
// end_time // datetime in ISO8601 format (2017-11-06T09:53:08.383210Z)
|
|
764
|
-
// start_time // datetime in ISO8601 format (2017-11-06T09:53:08.383210Z)
|
|
765
|
-
};
|
|
766
|
-
let currency = undefined;
|
|
767
|
-
if (code !== undefined) {
|
|
768
|
-
currency = this.currency(code);
|
|
769
|
-
request['currency'] = this.safeStringLower(currency, 'id');
|
|
770
|
-
}
|
|
771
|
-
if (since !== undefined) {
|
|
772
|
-
request['since_time'] = this.iso8601(since);
|
|
773
|
-
}
|
|
774
|
-
const response = await this.privateGetAccountDeposits(this.extend(request, params));
|
|
775
|
-
//
|
|
776
|
-
// "data": [
|
|
777
|
-
// {
|
|
778
|
-
// "id": "6e2f18b5-f80e-xxx-xxx-xxx",
|
|
779
|
-
// "amount": "0.1",
|
|
780
|
-
// "status": "completed",
|
|
781
|
-
// "currency_code": "eth",
|
|
782
|
-
// "txid": "0xxxx",
|
|
783
|
-
// "address": "0xxxx",
|
|
784
|
-
// "tag": null,
|
|
785
|
-
// "type": "deposit"
|
|
786
|
-
// },
|
|
787
|
-
// ]
|
|
788
|
-
//
|
|
789
|
-
const transactions = this.safeValue(response, 'data', []);
|
|
790
|
-
transactions.reverse(); // no timestamp but in reversed order
|
|
791
|
-
return this.parseTransactions(transactions, currency, undefined, limit);
|
|
792
|
-
}
|
|
793
|
-
async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
794
|
-
/**
|
|
795
|
-
* @method
|
|
796
|
-
* @name coinfalcon#fetchWithdrawals
|
|
797
|
-
* @description fetch all withdrawals made from an account
|
|
798
|
-
* @param {string} code unified currency code
|
|
799
|
-
* @param {int} [since] the earliest time in ms to fetch withdrawals for
|
|
800
|
-
* @param {int} [limit] the maximum number of withdrawals structures to retrieve
|
|
801
|
-
* @param {object} [params] extra parameters specific to the coinfalcon api endpoint
|
|
802
|
-
* @returns {object[]} a list of [transaction structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#transaction-structure}
|
|
803
|
-
*/
|
|
804
|
-
await this.loadMarkets();
|
|
805
|
-
const request = {
|
|
806
|
-
// currency: 'xrp', // optional: currency code in lowercase
|
|
807
|
-
// status: 'completed', // optional: withdrawal status
|
|
808
|
-
// since_time // datetime in ISO8601 format (2017-11-06T09:53:08.383210Z)
|
|
809
|
-
// end_time // datetime in ISO8601 format (2017-11-06T09:53:08.383210Z)
|
|
810
|
-
// start_time // datetime in ISO8601 format (2017-11-06T09:53:08.383210Z)
|
|
811
|
-
};
|
|
812
|
-
let currency = undefined;
|
|
813
|
-
if (code !== undefined) {
|
|
814
|
-
currency = this.currency(code);
|
|
815
|
-
request['currency'] = this.safeStringLower(currency, 'id');
|
|
816
|
-
}
|
|
817
|
-
if (since !== undefined) {
|
|
818
|
-
request['since_time'] = this.iso8601(since);
|
|
819
|
-
}
|
|
820
|
-
const response = await this.privateGetAccountWithdrawals(this.extend(request, params));
|
|
821
|
-
//
|
|
822
|
-
// "data": [
|
|
823
|
-
// {
|
|
824
|
-
// "id": "25f6f144-3666-xxx-xxx-xxx",
|
|
825
|
-
// "amount": "0.01",
|
|
826
|
-
// "status": "completed",
|
|
827
|
-
// "fee": "0.0005",
|
|
828
|
-
// "currency_code": "btc",
|
|
829
|
-
// "txid": "4xxx",
|
|
830
|
-
// "address": "bc1xxx",
|
|
831
|
-
// "tag": null,
|
|
832
|
-
// "type": "withdraw"
|
|
833
|
-
// },
|
|
834
|
-
// ]
|
|
835
|
-
//
|
|
836
|
-
const transactions = this.safeValue(response, 'data', []);
|
|
837
|
-
transactions.reverse(); // no timestamp but in reversed order
|
|
838
|
-
return this.parseTransactions(transactions, currency, undefined, limit);
|
|
839
|
-
}
|
|
840
|
-
async withdraw(code, amount, address, tag = undefined, params = {}) {
|
|
841
|
-
/**
|
|
842
|
-
* @method
|
|
843
|
-
* @name coinfalcon#withdraw
|
|
844
|
-
* @description make a withdrawal
|
|
845
|
-
* @param {string} code unified currency code
|
|
846
|
-
* @param {float} amount the amount to withdraw
|
|
847
|
-
* @param {string} address the address to withdraw to
|
|
848
|
-
* @param {string} tag
|
|
849
|
-
* @param {object} [params] extra parameters specific to the coinfalcon api endpoint
|
|
850
|
-
* @returns {object} a [transaction structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#transaction-structure}
|
|
851
|
-
*/
|
|
852
|
-
[tag, params] = this.handleWithdrawTagAndParams(tag, params);
|
|
853
|
-
this.checkAddress(address);
|
|
854
|
-
await this.loadMarkets();
|
|
855
|
-
const currency = this.currency(code);
|
|
856
|
-
const request = {
|
|
857
|
-
'currency': this.safeStringLower(currency, 'id'),
|
|
858
|
-
'address': address,
|
|
859
|
-
'amount': amount,
|
|
860
|
-
// 'tag': 'string', // withdraw tag/memo
|
|
861
|
-
};
|
|
862
|
-
if (tag !== undefined) {
|
|
863
|
-
request['tag'] = tag;
|
|
864
|
-
}
|
|
865
|
-
const response = await this.privatePostAccountWithdraw(this.extend(request, params));
|
|
866
|
-
//
|
|
867
|
-
// "data": [
|
|
868
|
-
// {
|
|
869
|
-
// "id": "25f6f144-3666-xxx-xxx-xxx",
|
|
870
|
-
// "amount": "0.01",
|
|
871
|
-
// "status": "approval_pending",
|
|
872
|
-
// "fee": "0.0005",
|
|
873
|
-
// "currency_code": "btc",
|
|
874
|
-
// "txid": null,
|
|
875
|
-
// "address": "bc1xxx",
|
|
876
|
-
// "tag": null,
|
|
877
|
-
// "type": "withdraw"
|
|
878
|
-
// },
|
|
879
|
-
// ]
|
|
880
|
-
//
|
|
881
|
-
const transaction = this.safeValue(response, 'data', []);
|
|
882
|
-
return this.parseTransaction(transaction, currency);
|
|
883
|
-
}
|
|
884
|
-
parseTransactionStatus(status) {
|
|
885
|
-
const statuses = {
|
|
886
|
-
'completed': 'ok',
|
|
887
|
-
'denied': 'failed',
|
|
888
|
-
'approval_pending': 'pending',
|
|
889
|
-
};
|
|
890
|
-
return this.safeString(statuses, status, status);
|
|
891
|
-
}
|
|
892
|
-
parseTransaction(transaction, currency = undefined) {
|
|
893
|
-
//
|
|
894
|
-
// fetchWithdrawals, withdraw
|
|
895
|
-
//
|
|
896
|
-
// {
|
|
897
|
-
// "id": "25f6f144-3666-xxx-xxx-xxx",
|
|
898
|
-
// "amount": "0.01",
|
|
899
|
-
// "status": "completed",
|
|
900
|
-
// "fee": "0.0005",
|
|
901
|
-
// "currency_code": "btc",
|
|
902
|
-
// "txid": "4xxx",
|
|
903
|
-
// "address": "bc1xxx",
|
|
904
|
-
// "tag": null,
|
|
905
|
-
// "type": "withdraw"
|
|
906
|
-
// },
|
|
907
|
-
//
|
|
908
|
-
// fetchDeposits
|
|
909
|
-
//
|
|
910
|
-
// {
|
|
911
|
-
// "id": "6e2f18b5-f80e-xxx-xxx-xxx",
|
|
912
|
-
// "amount": "0.1",
|
|
913
|
-
// "status": "completed",
|
|
914
|
-
// "currency_code": "eth",
|
|
915
|
-
// "txid": "0xxxx",
|
|
916
|
-
// "address": "0xxxx",
|
|
917
|
-
// "tag": null,
|
|
918
|
-
// "type": "deposit"
|
|
919
|
-
// },
|
|
920
|
-
//
|
|
921
|
-
const id = this.safeString(transaction, 'id');
|
|
922
|
-
const address = this.safeString(transaction, 'address');
|
|
923
|
-
const tag = this.safeString(transaction, 'tag');
|
|
924
|
-
const txid = this.safeString(transaction, 'txid');
|
|
925
|
-
const currencyId = this.safeString(transaction, 'currency_code');
|
|
926
|
-
const code = this.safeCurrencyCode(currencyId, currency);
|
|
927
|
-
let type = this.safeString(transaction, 'type');
|
|
928
|
-
if (type === 'withdraw') {
|
|
929
|
-
type = 'withdrawal';
|
|
930
|
-
}
|
|
931
|
-
const status = this.parseTransactionStatus(this.safeString(transaction, 'status'));
|
|
932
|
-
const amountString = this.safeString(transaction, 'amount');
|
|
933
|
-
const amount = this.parseNumber(amountString);
|
|
934
|
-
const feeCostString = this.safeString(transaction, 'fee');
|
|
935
|
-
let feeCost = '0';
|
|
936
|
-
if (feeCostString !== undefined) {
|
|
937
|
-
feeCost = feeCostString;
|
|
938
|
-
}
|
|
939
|
-
return {
|
|
940
|
-
'info': transaction,
|
|
941
|
-
'id': id,
|
|
942
|
-
'txid': txid,
|
|
943
|
-
'timestamp': undefined,
|
|
944
|
-
'datetime': undefined,
|
|
945
|
-
'network': undefined,
|
|
946
|
-
'address': address,
|
|
947
|
-
'addressTo': undefined,
|
|
948
|
-
'addressFrom': undefined,
|
|
949
|
-
'tag': tag,
|
|
950
|
-
'tagTo': undefined,
|
|
951
|
-
'tagFrom': undefined,
|
|
952
|
-
'type': type,
|
|
953
|
-
'amount': amount,
|
|
954
|
-
'currency': code,
|
|
955
|
-
'status': status,
|
|
956
|
-
'updated': undefined,
|
|
957
|
-
'fee': {
|
|
958
|
-
'currency': code,
|
|
959
|
-
'cost': this.parseNumber(feeCost),
|
|
960
|
-
},
|
|
961
|
-
};
|
|
962
|
-
}
|
|
963
|
-
nonce() {
|
|
964
|
-
return this.milliseconds();
|
|
965
|
-
}
|
|
966
|
-
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
967
|
-
let request = '/api/' + this.version + '/' + this.implodeParams(path, params);
|
|
968
|
-
const query = this.omit(params, this.extractParams(path));
|
|
969
|
-
if (api === 'public') {
|
|
970
|
-
if (Object.keys(query).length) {
|
|
971
|
-
request += '?' + this.urlencode(query);
|
|
972
|
-
}
|
|
973
|
-
}
|
|
974
|
-
else {
|
|
975
|
-
this.checkRequiredCredentials();
|
|
976
|
-
if (method === 'GET') {
|
|
977
|
-
if (Object.keys(query).length) {
|
|
978
|
-
request += '?' + this.urlencode(query);
|
|
979
|
-
}
|
|
980
|
-
}
|
|
981
|
-
else {
|
|
982
|
-
body = this.json(query);
|
|
983
|
-
}
|
|
984
|
-
const seconds = this.seconds().toString();
|
|
985
|
-
let payload = [seconds, method, request].join('|');
|
|
986
|
-
if (body) {
|
|
987
|
-
payload += '|' + body;
|
|
988
|
-
}
|
|
989
|
-
const signature = this.hmac(this.encode(payload), this.encode(this.secret), sha256.sha256);
|
|
990
|
-
headers = {
|
|
991
|
-
'CF-API-KEY': this.apiKey,
|
|
992
|
-
'CF-API-TIMESTAMP': seconds,
|
|
993
|
-
'CF-API-SIGNATURE': signature,
|
|
994
|
-
'Content-Type': 'application/json',
|
|
995
|
-
};
|
|
996
|
-
}
|
|
997
|
-
const url = this.urls['api']['rest'] + request;
|
|
998
|
-
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
|
999
|
-
}
|
|
1000
|
-
handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
|
1001
|
-
if (code < 400) {
|
|
1002
|
-
return undefined;
|
|
1003
|
-
}
|
|
1004
|
-
const ErrorClass = this.safeValue({
|
|
1005
|
-
'401': errors.AuthenticationError,
|
|
1006
|
-
'429': errors.RateLimitExceeded,
|
|
1007
|
-
}, code, errors.ExchangeError);
|
|
1008
|
-
throw new ErrorClass(body);
|
|
1009
|
-
}
|
|
1010
|
-
}
|
|
1011
|
-
|
|
1012
|
-
module.exports = coinfalcon;
|