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/btcturk.js
ADDED
@@ -0,0 +1,734 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
// ---------------------------------------------------------------------------
|
4
|
+
|
5
|
+
const Exchange = require ('./base/Exchange');
|
6
|
+
const { ExchangeError, InsufficientFunds, InvalidOrder } = require ('./base/errors');
|
7
|
+
const Precise = require ('./base/Precise');
|
8
|
+
|
9
|
+
// ---------------------------------------------------------------------------
|
10
|
+
|
11
|
+
module.exports = class btcturk extends Exchange {
|
12
|
+
describe () {
|
13
|
+
return this.deepExtend (super.describe (), {
|
14
|
+
'id': 'btcturk',
|
15
|
+
'name': 'BTCTurk',
|
16
|
+
'countries': [ 'TR' ], // Turkey
|
17
|
+
'rateLimit': 100,
|
18
|
+
'has': {
|
19
|
+
'CORS': true,
|
20
|
+
'spot': true,
|
21
|
+
'margin': false,
|
22
|
+
'swap': false,
|
23
|
+
'future': false,
|
24
|
+
'option': false,
|
25
|
+
'addMargin': false,
|
26
|
+
'cancelOrder': true,
|
27
|
+
'createOrder': true,
|
28
|
+
'createReduceOnlyOrder': false,
|
29
|
+
'fetchBalance': true,
|
30
|
+
'fetchBorrowRate': false,
|
31
|
+
'fetchBorrowRateHistories': false,
|
32
|
+
'fetchBorrowRateHistory': false,
|
33
|
+
'fetchBorrowRates': false,
|
34
|
+
'fetchBorrowRatesPerSymbol': false,
|
35
|
+
'fetchFundingHistory': false,
|
36
|
+
'fetchFundingRate': false,
|
37
|
+
'fetchFundingRateHistory': false,
|
38
|
+
'fetchFundingRates': false,
|
39
|
+
'fetchIndexOHLCV': false,
|
40
|
+
'fetchLeverage': false,
|
41
|
+
'fetchMarkets': true,
|
42
|
+
'fetchMarkOHLCV': false,
|
43
|
+
'fetchMyTrades': true,
|
44
|
+
'fetchOHLCV': true,
|
45
|
+
'fetchOpenOrders': true,
|
46
|
+
'fetchOrderBook': true,
|
47
|
+
'fetchOrders': true,
|
48
|
+
'fetchPosition': false,
|
49
|
+
'fetchPositions': false,
|
50
|
+
'fetchPositionsRisk': false,
|
51
|
+
'fetchPremiumIndexOHLCV': false,
|
52
|
+
'fetchTicker': true,
|
53
|
+
'fetchTickers': true,
|
54
|
+
'fetchTrades': true,
|
55
|
+
'reduceMargin': false,
|
56
|
+
'setLeverage': false,
|
57
|
+
'setMarginMode': false,
|
58
|
+
'setPositionMode': false,
|
59
|
+
},
|
60
|
+
'timeframes': {
|
61
|
+
'1d': '1d',
|
62
|
+
},
|
63
|
+
'urls': {
|
64
|
+
'logo': 'https://user-images.githubusercontent.com/51840849/87153926-efbef500-c2c0-11ea-9842-05b63612c4b9.jpg',
|
65
|
+
'api': {
|
66
|
+
'public': 'https://api.btcturk.com/api/v2',
|
67
|
+
'private': 'https://api.btcturk.com/api/v1',
|
68
|
+
'graph': 'https://graph-api.btcturk.com/v1',
|
69
|
+
},
|
70
|
+
'www': 'https://www.btcturk.com',
|
71
|
+
'doc': 'https://github.com/BTCTrader/broker-api-docs',
|
72
|
+
},
|
73
|
+
'api': {
|
74
|
+
'public': {
|
75
|
+
'get': {
|
76
|
+
'orderbook': 1,
|
77
|
+
'ticker': 0.1,
|
78
|
+
'trades': 1, // ?last=COUNT (max 50)
|
79
|
+
'server/exchangeinfo': 1,
|
80
|
+
},
|
81
|
+
},
|
82
|
+
'private': {
|
83
|
+
'get': {
|
84
|
+
'users/balances': 1,
|
85
|
+
'openOrders': 1,
|
86
|
+
'allOrders': 1,
|
87
|
+
'users/transactions/trade': 1,
|
88
|
+
},
|
89
|
+
'post': {
|
90
|
+
'order': 1,
|
91
|
+
'cancelOrder': 1,
|
92
|
+
},
|
93
|
+
'delete': {
|
94
|
+
'order': 1,
|
95
|
+
},
|
96
|
+
},
|
97
|
+
'graph': {
|
98
|
+
'get': {
|
99
|
+
'ohlcs': 1,
|
100
|
+
},
|
101
|
+
},
|
102
|
+
},
|
103
|
+
'fees': {
|
104
|
+
'trading': {
|
105
|
+
'maker': this.parseNumber ('0.0005'),
|
106
|
+
'taker': this.parseNumber ('0.0009'),
|
107
|
+
},
|
108
|
+
},
|
109
|
+
'exceptions': {
|
110
|
+
'exact': {
|
111
|
+
'FAILED_ORDER_WITH_OPEN_ORDERS': InsufficientFunds,
|
112
|
+
'FAILED_LIMIT_ORDER': InvalidOrder,
|
113
|
+
'FAILED_MARKET_ORDER': InvalidOrder,
|
114
|
+
},
|
115
|
+
},
|
116
|
+
});
|
117
|
+
}
|
118
|
+
|
119
|
+
async fetchMarkets (params = {}) {
|
120
|
+
const response = await this.publicGetServerExchangeinfo (params);
|
121
|
+
//
|
122
|
+
// {
|
123
|
+
// "data": {
|
124
|
+
// "timeZone": "UTC",
|
125
|
+
// "serverTime": "1618826678404",
|
126
|
+
// "symbols": [
|
127
|
+
// {
|
128
|
+
// "id": "1",
|
129
|
+
// "name": "BTCTRY",
|
130
|
+
// "nameNormalized": "BTC_TRY",
|
131
|
+
// "status": "TRADING",
|
132
|
+
// "numerator": "BTC",
|
133
|
+
// "denominator": "TRY",
|
134
|
+
// "numeratorScale": "8",
|
135
|
+
// "denominatorScale": "2",
|
136
|
+
// "hasFraction": false,
|
137
|
+
// "filters": [
|
138
|
+
// {
|
139
|
+
// "filterType": "PRICE_FILTER",
|
140
|
+
// "minPrice": "0.0000000000001",
|
141
|
+
// "maxPrice": "10000000",
|
142
|
+
// "tickSize": "10",
|
143
|
+
// "minExchangeValue": "99.91",
|
144
|
+
// "minAmount": null,
|
145
|
+
// "maxAmount": null
|
146
|
+
// }
|
147
|
+
// ],
|
148
|
+
// "orderMethods": [
|
149
|
+
// "MARKET",
|
150
|
+
// "LIMIT",
|
151
|
+
// "STOP_MARKET",
|
152
|
+
// "STOP_LIMIT"
|
153
|
+
// ],
|
154
|
+
// "displayFormat": "#,###",
|
155
|
+
// "commissionFromNumerator": false,
|
156
|
+
// "order": "1000",
|
157
|
+
// "priceRounding": false
|
158
|
+
// },
|
159
|
+
// },
|
160
|
+
// ],
|
161
|
+
// }
|
162
|
+
//
|
163
|
+
const data = this.safeValue (response, 'data');
|
164
|
+
const markets = this.safeValue (data, 'symbols', []);
|
165
|
+
const result = [];
|
166
|
+
for (let i = 0; i < markets.length; i++) {
|
167
|
+
const entry = markets[i];
|
168
|
+
const id = this.safeString (entry, 'name');
|
169
|
+
const baseId = this.safeString (entry, 'numerator');
|
170
|
+
const quoteId = this.safeString (entry, 'denominator');
|
171
|
+
const base = this.safeCurrencyCode (baseId);
|
172
|
+
const quote = this.safeCurrencyCode (quoteId);
|
173
|
+
const filters = this.safeValue (entry, 'filters');
|
174
|
+
let minPrice = undefined;
|
175
|
+
let maxPrice = undefined;
|
176
|
+
let minAmount = undefined;
|
177
|
+
let maxAmount = undefined;
|
178
|
+
let minCost = undefined;
|
179
|
+
for (let j = 0; j < filters.length; j++) {
|
180
|
+
const filter = filters[j];
|
181
|
+
const filterType = this.safeString (filter, 'filterType');
|
182
|
+
if (filterType === 'PRICE_FILTER') {
|
183
|
+
minPrice = this.safeNumber (filter, 'minPrice');
|
184
|
+
maxPrice = this.safeNumber (filter, 'maxPrice');
|
185
|
+
minAmount = this.safeNumber (filter, 'minAmount');
|
186
|
+
maxAmount = this.safeNumber (filter, 'maxAmount');
|
187
|
+
minCost = this.safeNumber (filter, 'minExchangeValue');
|
188
|
+
}
|
189
|
+
}
|
190
|
+
const status = this.safeString (entry, 'status');
|
191
|
+
result.push ({
|
192
|
+
'id': id,
|
193
|
+
'symbol': base + '/' + quote,
|
194
|
+
'base': base,
|
195
|
+
'quote': quote,
|
196
|
+
'settle': undefined,
|
197
|
+
'baseId': baseId,
|
198
|
+
'quoteId': quoteId,
|
199
|
+
'settleId': undefined,
|
200
|
+
'type': 'spot',
|
201
|
+
'spot': true,
|
202
|
+
'margin': false,
|
203
|
+
'swap': false,
|
204
|
+
'future': false,
|
205
|
+
'option': false,
|
206
|
+
'active': (status === 'TRADING'),
|
207
|
+
'contract': false,
|
208
|
+
'linear': undefined,
|
209
|
+
'inverse': undefined,
|
210
|
+
'contractSize': undefined,
|
211
|
+
'expiry': undefined,
|
212
|
+
'expiryDatetime': undefined,
|
213
|
+
'strike': undefined,
|
214
|
+
'optionType': undefined,
|
215
|
+
'precision': {
|
216
|
+
'amount': this.safeInteger (entry, 'numeratorScale'),
|
217
|
+
'price': this.safeInteger (entry, 'denominatorScale'),
|
218
|
+
},
|
219
|
+
'limits': {
|
220
|
+
'leverage': {
|
221
|
+
'min': undefined,
|
222
|
+
'max': undefined,
|
223
|
+
},
|
224
|
+
'amount': {
|
225
|
+
'min': minAmount,
|
226
|
+
'max': maxAmount,
|
227
|
+
},
|
228
|
+
'price': {
|
229
|
+
'min': minPrice,
|
230
|
+
'max': maxPrice,
|
231
|
+
},
|
232
|
+
'cost': {
|
233
|
+
'min': minCost,
|
234
|
+
'max': undefined,
|
235
|
+
},
|
236
|
+
},
|
237
|
+
'info': entry,
|
238
|
+
});
|
239
|
+
}
|
240
|
+
return result;
|
241
|
+
}
|
242
|
+
|
243
|
+
parseBalance (response) {
|
244
|
+
const data = this.safeValue (response, 'data', []);
|
245
|
+
const result = {
|
246
|
+
'info': response,
|
247
|
+
'timestamp': undefined,
|
248
|
+
'datetime': undefined,
|
249
|
+
};
|
250
|
+
for (let i = 0; i < data.length; i++) {
|
251
|
+
const entry = data[i];
|
252
|
+
const currencyId = this.safeString (entry, 'asset');
|
253
|
+
const code = this.safeCurrencyCode (currencyId);
|
254
|
+
const account = this.account ();
|
255
|
+
account['total'] = this.safeString (entry, 'balance');
|
256
|
+
account['free'] = this.safeString (entry, 'free');
|
257
|
+
account['used'] = this.safeString (entry, 'locked');
|
258
|
+
result[code] = account;
|
259
|
+
}
|
260
|
+
return this.safeBalance (result);
|
261
|
+
}
|
262
|
+
|
263
|
+
async fetchBalance (params = {}) {
|
264
|
+
await this.loadMarkets ();
|
265
|
+
const response = await this.privateGetUsersBalances (params);
|
266
|
+
//
|
267
|
+
// {
|
268
|
+
// "data": [
|
269
|
+
// {
|
270
|
+
// "asset": "TRY",
|
271
|
+
// "assetname": "Türk Lirası",
|
272
|
+
// "balance": "0",
|
273
|
+
// "locked": "0",
|
274
|
+
// "free": "0",
|
275
|
+
// "orderFund": "0",
|
276
|
+
// "requestFund": "0",
|
277
|
+
// "precision": 2
|
278
|
+
// }
|
279
|
+
// ]
|
280
|
+
// }
|
281
|
+
//
|
282
|
+
return this.parseBalance (response);
|
283
|
+
}
|
284
|
+
|
285
|
+
async fetchOrderBook (symbol, limit = undefined, params = {}) {
|
286
|
+
await this.loadMarkets ();
|
287
|
+
const market = this.market (symbol);
|
288
|
+
const request = {
|
289
|
+
'pairSymbol': market['id'],
|
290
|
+
};
|
291
|
+
const response = await this.publicGetOrderbook (this.extend (request, params));
|
292
|
+
// {
|
293
|
+
// "data": {
|
294
|
+
// "timestamp": 1618827901241,
|
295
|
+
// "bids": [
|
296
|
+
// [
|
297
|
+
// "460263.00",
|
298
|
+
// "0.04244000"
|
299
|
+
// ]
|
300
|
+
// ]
|
301
|
+
// }
|
302
|
+
// }
|
303
|
+
const data = this.safeValue (response, 'data');
|
304
|
+
const timestamp = this.safeInteger (data, 'timestamp');
|
305
|
+
return this.parseOrderBook (data, symbol, timestamp, 'bids', 'asks', 0, 1);
|
306
|
+
}
|
307
|
+
|
308
|
+
parseTicker (ticker, market = undefined) {
|
309
|
+
//
|
310
|
+
// {
|
311
|
+
// "pair": "BTCTRY",
|
312
|
+
// "pairNormalized": "BTC_TRY",
|
313
|
+
// "timestamp": 1618826361234,
|
314
|
+
// "last": 462485,
|
315
|
+
// "high": 473976,
|
316
|
+
// "low": 444201,
|
317
|
+
// "bid": 461928,
|
318
|
+
// "ask": 462485,
|
319
|
+
// "open": 456915,
|
320
|
+
// "volume": 917.41368645,
|
321
|
+
// "average": 462868.29574589,
|
322
|
+
// "daily": 5570,
|
323
|
+
// "dailyPercent": 1.22,
|
324
|
+
// "denominatorSymbol": "TRY",
|
325
|
+
// "numeratorSymbol": "BTC",
|
326
|
+
// "order": 1000
|
327
|
+
// }
|
328
|
+
//
|
329
|
+
const marketId = this.safeString (ticker, 'pair');
|
330
|
+
market = this.safeMarket (marketId, market);
|
331
|
+
const symbol = market['symbol'];
|
332
|
+
const timestamp = this.safeInteger (ticker, 'timestamp');
|
333
|
+
const last = this.safeString (ticker, 'last');
|
334
|
+
return this.safeTicker ({
|
335
|
+
'symbol': symbol,
|
336
|
+
'timestamp': timestamp,
|
337
|
+
'datetime': this.iso8601 (timestamp),
|
338
|
+
'high': this.safeString (ticker, 'high'),
|
339
|
+
'low': this.safeString (ticker, 'low'),
|
340
|
+
'bid': this.safeString (ticker, 'bid'),
|
341
|
+
'bidVolume': undefined,
|
342
|
+
'ask': this.safeString (ticker, 'ask'),
|
343
|
+
'askVolume': undefined,
|
344
|
+
'vwap': undefined,
|
345
|
+
'open': this.safeString (ticker, 'open'),
|
346
|
+
'close': last,
|
347
|
+
'last': last,
|
348
|
+
'previousClose': undefined,
|
349
|
+
'change': this.safeString (ticker, 'daily'),
|
350
|
+
'percentage': this.safeString (ticker, 'dailyPercent'),
|
351
|
+
'average': this.safeString (ticker, 'average'),
|
352
|
+
'baseVolume': this.safeString (ticker, 'volume'),
|
353
|
+
'quoteVolume': undefined,
|
354
|
+
'info': ticker,
|
355
|
+
}, market, false);
|
356
|
+
}
|
357
|
+
|
358
|
+
async fetchTickers (symbols = undefined, params = {}) {
|
359
|
+
await this.loadMarkets ();
|
360
|
+
const response = await this.publicGetTicker (params);
|
361
|
+
const tickers = this.safeValue (response, 'data');
|
362
|
+
return this.parseTickers (tickers, symbols);
|
363
|
+
}
|
364
|
+
|
365
|
+
async fetchTicker (symbol, params = {}) {
|
366
|
+
await this.loadMarkets ();
|
367
|
+
const tickers = await this.fetchTickers ([ symbol ], params);
|
368
|
+
return this.safeValue (tickers, symbol);
|
369
|
+
}
|
370
|
+
|
371
|
+
parseTrade (trade, market = undefined) {
|
372
|
+
//
|
373
|
+
// fetchTrades
|
374
|
+
// {
|
375
|
+
// "pair": "BTCUSDT",
|
376
|
+
// "pairNormalized": "BTC_USDT",
|
377
|
+
// "numerator": "BTC",
|
378
|
+
// "denominator": "USDT",
|
379
|
+
// "date": "1618916879083",
|
380
|
+
// "tid": "637545136790672520",
|
381
|
+
// "price": "55774",
|
382
|
+
// "amount": "0.27917100",
|
383
|
+
// "side": "buy"
|
384
|
+
// }
|
385
|
+
//
|
386
|
+
// fetchMyTrades
|
387
|
+
// {
|
388
|
+
// "price": "56000",
|
389
|
+
// "numeratorSymbol": "BTC",
|
390
|
+
// "denominatorSymbol": "USDT",
|
391
|
+
// "orderType": "buy",
|
392
|
+
// "orderId": "2606935102",
|
393
|
+
// "id": "320874372",
|
394
|
+
// "timestamp": "1618916479593",
|
395
|
+
// "amount": "0.00020000",
|
396
|
+
// "fee": "0",
|
397
|
+
// "tax": "0"
|
398
|
+
// }
|
399
|
+
//
|
400
|
+
const timestamp = this.safeInteger2 (trade, 'date', 'timestamp');
|
401
|
+
const id = this.safeString2 (trade, 'tid', 'id');
|
402
|
+
const order = this.safeString (trade, 'orderId');
|
403
|
+
const priceString = this.safeString (trade, 'price');
|
404
|
+
const amountString = Precise.stringAbs (this.safeString (trade, 'amount'));
|
405
|
+
const marketId = this.safeString (trade, 'pair');
|
406
|
+
const symbol = this.safeSymbol (marketId, market);
|
407
|
+
const side = this.safeString2 (trade, 'side', 'orderType');
|
408
|
+
let fee = undefined;
|
409
|
+
const feeAmountString = this.safeString (trade, 'fee');
|
410
|
+
if (feeAmountString !== undefined) {
|
411
|
+
const feeCurrency = this.safeString (trade, 'denominatorSymbol');
|
412
|
+
fee = {
|
413
|
+
'cost': Precise.stringAbs (feeAmountString),
|
414
|
+
'currency': this.safeCurrencyCode (feeCurrency),
|
415
|
+
};
|
416
|
+
}
|
417
|
+
return this.safeTrade ({
|
418
|
+
'info': trade,
|
419
|
+
'id': id,
|
420
|
+
'order': order,
|
421
|
+
'timestamp': timestamp,
|
422
|
+
'datetime': this.iso8601 (timestamp),
|
423
|
+
'symbol': symbol,
|
424
|
+
'type': undefined,
|
425
|
+
'side': side,
|
426
|
+
'takerOrMaker': undefined,
|
427
|
+
'price': priceString,
|
428
|
+
'amount': amountString,
|
429
|
+
'cost': undefined,
|
430
|
+
'fee': fee,
|
431
|
+
}, market);
|
432
|
+
}
|
433
|
+
|
434
|
+
async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) {
|
435
|
+
await this.loadMarkets ();
|
436
|
+
const market = this.market (symbol);
|
437
|
+
// let maxCount = 50;
|
438
|
+
const request = {
|
439
|
+
'pairSymbol': market['id'],
|
440
|
+
};
|
441
|
+
if (limit !== undefined) {
|
442
|
+
request['last'] = limit;
|
443
|
+
}
|
444
|
+
const response = await this.publicGetTrades (this.extend (request, params));
|
445
|
+
//
|
446
|
+
// {
|
447
|
+
// "data": [
|
448
|
+
// {
|
449
|
+
// "pair": "BTCTRY",
|
450
|
+
// "pairNormalized": "BTC_TRY",
|
451
|
+
// "numerator": "BTC",
|
452
|
+
// "denominator": "TRY",
|
453
|
+
// "date": 1618828421497,
|
454
|
+
// "tid": "637544252214980918",
|
455
|
+
// "price": "462585.00",
|
456
|
+
// "amount": "0.01618411",
|
457
|
+
// "side": "sell"
|
458
|
+
// }
|
459
|
+
// ]
|
460
|
+
// }
|
461
|
+
//
|
462
|
+
const data = this.safeValue (response, 'data');
|
463
|
+
return this.parseTrades (data, market, since, limit);
|
464
|
+
}
|
465
|
+
|
466
|
+
parseOHLCV (ohlcv, market = undefined) {
|
467
|
+
// {
|
468
|
+
// "pair": "BTCTRY",
|
469
|
+
// "time": 1508284800,
|
470
|
+
// "open": 20873.689453125,
|
471
|
+
// "high": 20925.0,
|
472
|
+
// "low": 19310.0,
|
473
|
+
// "close": 20679.55078125,
|
474
|
+
// "volume": 402.216101626982,
|
475
|
+
// "total": 8103096.44443274,
|
476
|
+
// "average": 20146.13,
|
477
|
+
// "dailyChangeAmount": -194.14,
|
478
|
+
// "dailyChangePercentage": -0.93
|
479
|
+
// },
|
480
|
+
return [
|
481
|
+
this.safeTimestamp (ohlcv, 'time'),
|
482
|
+
this.safeNumber (ohlcv, 'open'),
|
483
|
+
this.safeNumber (ohlcv, 'high'),
|
484
|
+
this.safeNumber (ohlcv, 'low'),
|
485
|
+
this.safeNumber (ohlcv, 'close'),
|
486
|
+
this.safeNumber (ohlcv, 'volume'),
|
487
|
+
];
|
488
|
+
}
|
489
|
+
|
490
|
+
async fetchOHLCV (symbol, timeframe = '1d', since = undefined, limit = undefined, params = {}) {
|
491
|
+
await this.loadMarkets ();
|
492
|
+
const market = this.market (symbol);
|
493
|
+
const request = {
|
494
|
+
'pair': market['id'],
|
495
|
+
};
|
496
|
+
if (limit !== undefined) {
|
497
|
+
request['last'] = limit;
|
498
|
+
}
|
499
|
+
const response = await this.graphGetOhlcs (this.extend (request, params));
|
500
|
+
return this.parseOHLCVs (response, market, timeframe, since, limit);
|
501
|
+
}
|
502
|
+
|
503
|
+
async createOrder (symbol, type, side, amount, price = undefined, params = {}) {
|
504
|
+
await this.loadMarkets ();
|
505
|
+
const market = this.market (symbol);
|
506
|
+
const request = {
|
507
|
+
'orderType': side,
|
508
|
+
'orderMethod': type,
|
509
|
+
'pairSymbol': market['id'],
|
510
|
+
'quantity': this.amountToPrecision (symbol, amount),
|
511
|
+
};
|
512
|
+
if (type !== 'market') {
|
513
|
+
request['price'] = this.priceToPrecision (symbol, price);
|
514
|
+
}
|
515
|
+
if ('clientOrderId' in params) {
|
516
|
+
request['newClientOrderId'] = params['clientOrderId'];
|
517
|
+
} else if (!('newClientOrderId' in params)) {
|
518
|
+
request['newClientOrderId'] = this.uuid ();
|
519
|
+
}
|
520
|
+
const response = await this.privatePostOrder (this.extend (request, params));
|
521
|
+
const data = this.safeValue (response, 'data');
|
522
|
+
return this.parseOrder (data, market);
|
523
|
+
}
|
524
|
+
|
525
|
+
async cancelOrder (id, symbol = undefined, params = {}) {
|
526
|
+
const request = {
|
527
|
+
'id': id,
|
528
|
+
};
|
529
|
+
return await this.privateDeleteOrder (this.extend (request, params));
|
530
|
+
}
|
531
|
+
|
532
|
+
async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
533
|
+
await this.loadMarkets ();
|
534
|
+
const request = {};
|
535
|
+
let market = undefined;
|
536
|
+
if (symbol !== undefined) {
|
537
|
+
market = this.market (symbol);
|
538
|
+
request['pairSymbol'] = market['id'];
|
539
|
+
}
|
540
|
+
const response = await this.privateGetOpenOrders (this.extend (request, params));
|
541
|
+
const data = this.safeValue (response, 'data');
|
542
|
+
const bids = this.safeValue (data, 'bids', []);
|
543
|
+
const asks = this.safeValue (data, 'asks', []);
|
544
|
+
return this.parseOrders (this.arrayConcat (bids, asks), market, since, limit);
|
545
|
+
}
|
546
|
+
|
547
|
+
async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
548
|
+
await this.loadMarkets ();
|
549
|
+
const market = this.market (symbol);
|
550
|
+
const request = {
|
551
|
+
'pairSymbol': market['id'],
|
552
|
+
};
|
553
|
+
if (limit !== undefined) {
|
554
|
+
// default 100 max 1000
|
555
|
+
request['last'] = limit;
|
556
|
+
}
|
557
|
+
if (since !== undefined) {
|
558
|
+
request['startTime'] = Math.floor (since / 1000);
|
559
|
+
}
|
560
|
+
const response = await this.privateGetAllOrders (this.extend (request, params));
|
561
|
+
// {
|
562
|
+
// "data": [
|
563
|
+
// {
|
564
|
+
// "id": "2606012912",
|
565
|
+
// "price": "55000",
|
566
|
+
// "amount": "0.0003",
|
567
|
+
// "quantity": "0.0003",
|
568
|
+
// "stopPrice": "0",
|
569
|
+
// "pairSymbol": "BTCUSDT",
|
570
|
+
// "pairSymbolNormalized": "BTC_USDT",
|
571
|
+
// "type": "buy",
|
572
|
+
// "method": "limit",
|
573
|
+
// "orderClientId": "2ed187bd-59a8-4875-a212-1b793963b85c",
|
574
|
+
// "time": "1618913189253",
|
575
|
+
// "updateTime": "1618913189253",
|
576
|
+
// "status": "Untouched",
|
577
|
+
// "leftAmount": "0.0003000000000000"
|
578
|
+
// }
|
579
|
+
// ]
|
580
|
+
// }
|
581
|
+
const data = this.safeValue (response, 'data');
|
582
|
+
return this.parseOrders (data, market, since, limit);
|
583
|
+
}
|
584
|
+
|
585
|
+
parseOrderStatus (status) {
|
586
|
+
const statuses = {
|
587
|
+
'Untouched': 'open',
|
588
|
+
'Partial': 'open',
|
589
|
+
'Canceled': 'canceled',
|
590
|
+
'Closed': 'closed',
|
591
|
+
};
|
592
|
+
return this.safeString (statuses, status, status);
|
593
|
+
}
|
594
|
+
|
595
|
+
parseOrder (order, market) {
|
596
|
+
//
|
597
|
+
// fetchOrders / fetchOpenOrders
|
598
|
+
// {
|
599
|
+
// "id": 2605984008,
|
600
|
+
// "price": "55000",
|
601
|
+
// "amount": "0.00050000",
|
602
|
+
// "quantity": "0.00050000",
|
603
|
+
// "stopPrice": "0",
|
604
|
+
// "pairSymbol": "BTCUSDT",
|
605
|
+
// "pairSymbolNormalized": "BTC_USDT",
|
606
|
+
// "type": "buy",
|
607
|
+
// "method": "limit",
|
608
|
+
// "orderClientId": "f479bdb6-0965-4f03-95b5-daeb7aa5a3a5",
|
609
|
+
// "time": 0,
|
610
|
+
// "updateTime": 1618913083543,
|
611
|
+
// "status": "Untouched",
|
612
|
+
// "leftAmount": "0.00050000"
|
613
|
+
// }
|
614
|
+
//
|
615
|
+
// createOrder
|
616
|
+
// {
|
617
|
+
// "id": "2606935102",
|
618
|
+
// "quantity": "0.0002",
|
619
|
+
// "price": "56000",
|
620
|
+
// "stopPrice": null,
|
621
|
+
// "newOrderClientId": "98e5c491-7ed9-462b-9666-93553180fb28",
|
622
|
+
// "type": "buy",
|
623
|
+
// "method": "limit",
|
624
|
+
// "pairSymbol": "BTCUSDT",
|
625
|
+
// "pairSymbolNormalized": "BTC_USDT",
|
626
|
+
// "datetime": "1618916479523"
|
627
|
+
// }
|
628
|
+
//
|
629
|
+
const id = this.safeString (order, 'id');
|
630
|
+
const price = this.safeString (order, 'price');
|
631
|
+
const amountString = this.safeString2 (order, 'amount', 'quantity');
|
632
|
+
const amount = Precise.stringAbs (amountString);
|
633
|
+
const remaining = this.safeString (order, 'leftAmount');
|
634
|
+
const marketId = this.safeNumber (order, 'pairSymbol');
|
635
|
+
const symbol = this.safeSymbol (marketId, market);
|
636
|
+
const side = this.safeString (order, 'type');
|
637
|
+
const type = this.safeString (order, 'method');
|
638
|
+
const clientOrderId = this.safeString (order, 'orderClientId');
|
639
|
+
const timestamp = this.safeInteger2 (order, 'updateTime', 'datetime');
|
640
|
+
const rawStatus = this.safeString (order, 'status');
|
641
|
+
const status = this.parseOrderStatus (rawStatus);
|
642
|
+
return this.safeOrder ({
|
643
|
+
'info': order,
|
644
|
+
'id': id,
|
645
|
+
'price': price,
|
646
|
+
'amount': amount,
|
647
|
+
'remaining': remaining,
|
648
|
+
'filled': undefined,
|
649
|
+
'cost': undefined,
|
650
|
+
'average': undefined,
|
651
|
+
'status': status,
|
652
|
+
'side': side,
|
653
|
+
'type': type,
|
654
|
+
'clientOrderId': clientOrderId,
|
655
|
+
'timestamp': timestamp,
|
656
|
+
'datetime': this.iso8601 (timestamp),
|
657
|
+
'symbol': symbol,
|
658
|
+
'fee': undefined,
|
659
|
+
}, market);
|
660
|
+
}
|
661
|
+
|
662
|
+
async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
663
|
+
await this.loadMarkets ();
|
664
|
+
let market = undefined;
|
665
|
+
if (symbol !== undefined) {
|
666
|
+
market = this.market (symbol);
|
667
|
+
}
|
668
|
+
const response = await this.privateGetUsersTransactionsTrade ();
|
669
|
+
//
|
670
|
+
// {
|
671
|
+
// "data": [
|
672
|
+
// {
|
673
|
+
// "price": "56000",
|
674
|
+
// "numeratorSymbol": "BTC",
|
675
|
+
// "denominatorSymbol": "USDT",
|
676
|
+
// "orderType": "buy",
|
677
|
+
// "orderId": "2606935102",
|
678
|
+
// "id": "320874372",
|
679
|
+
// "timestamp": "1618916479593",
|
680
|
+
// "amount": "0.00020000",
|
681
|
+
// "fee": "0",
|
682
|
+
// "tax": "0"
|
683
|
+
// }
|
684
|
+
// ],
|
685
|
+
// "success": true,
|
686
|
+
// "message": "SUCCESS",
|
687
|
+
// "code": "0"
|
688
|
+
// }
|
689
|
+
//
|
690
|
+
const data = this.safeValue (response, 'data');
|
691
|
+
return this.parseTrades (data, market, since, limit);
|
692
|
+
}
|
693
|
+
|
694
|
+
nonce () {
|
695
|
+
return this.milliseconds ();
|
696
|
+
}
|
697
|
+
|
698
|
+
sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
699
|
+
if (this.id === 'btctrader') {
|
700
|
+
throw new ExchangeError (this.id + ' is an abstract base API for BTCExchange, BTCTurk');
|
701
|
+
}
|
702
|
+
let url = this.urls['api'][api] + '/' + path;
|
703
|
+
if ((method === 'GET') || (method === 'DELETE')) {
|
704
|
+
if (Object.keys (params).length) {
|
705
|
+
url += '?' + this.urlencode (params);
|
706
|
+
}
|
707
|
+
} else {
|
708
|
+
body = this.json (params);
|
709
|
+
}
|
710
|
+
if (api === 'private') {
|
711
|
+
this.checkRequiredCredentials ();
|
712
|
+
const nonce = this.nonce ().toString ();
|
713
|
+
const secret = this.base64ToBinary (this.secret);
|
714
|
+
const auth = this.apiKey + nonce;
|
715
|
+
headers = {
|
716
|
+
'X-PCK': this.apiKey,
|
717
|
+
'X-Stamp': nonce,
|
718
|
+
'X-Signature': this.hmac (this.encode (auth), secret, 'sha256', 'base64'),
|
719
|
+
'Content-Type': 'application/json',
|
720
|
+
};
|
721
|
+
}
|
722
|
+
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
723
|
+
}
|
724
|
+
|
725
|
+
handleErrors (code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
726
|
+
const errorCode = this.safeString (response, 'code', '0');
|
727
|
+
const message = this.safeString (response, 'message');
|
728
|
+
const output = (message === undefined) ? body : message;
|
729
|
+
this.throwExactlyMatchedException (this.exceptions['exact'], message, this.id + ' ' + output);
|
730
|
+
if (errorCode !== '0') {
|
731
|
+
throw new ExchangeError (this.id + ' ' + output);
|
732
|
+
}
|
733
|
+
}
|
734
|
+
};
|