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.
Files changed (264) hide show
  1. package/.cache/eslintcache +1 -0
  2. package/.dockerignore +6 -0
  3. package/.eslintignore +1 -0
  4. package/.gitattributes +5 -0
  5. package/.readthedocs.yaml +16 -0
  6. package/CONTRIBUTING.md +1049 -0
  7. package/LICENSE.txt +21 -0
  8. package/README.md +537 -0
  9. package/SECURITY.md +5 -0
  10. package/build/cleanup-old-tags.js +94 -0
  11. package/build/countries.js +256 -0
  12. package/build/export-exchanges.js +520 -0
  13. package/build/fs.js +51 -0
  14. package/build/transpile.js +1772 -0
  15. package/build/vss.js +78 -0
  16. package/ccxt.browser.js +7 -0
  17. package/ccxt.d.ts +692 -0
  18. package/ccxt.js +171 -0
  19. package/cleanup.sh +2 -0
  20. package/composer-install.sh +20 -0
  21. package/dist/ccxt.browser.js +208383 -0
  22. package/gource.sh +3 -0
  23. package/index.html +7 -0
  24. package/js/.eslintrc +87 -0
  25. package/js/aax.js +2686 -0
  26. package/js/ascendex.js +2584 -0
  27. package/js/base/.eslintrc.js +43 -0
  28. package/js/base/Exchange.js +2371 -0
  29. package/js/base/Precise.js +283 -0
  30. package/js/base/errorHierarchy.js +47 -0
  31. package/js/base/errors.js +55 -0
  32. package/js/base/functions/crypto.js +158 -0
  33. package/js/base/functions/encode.js +118 -0
  34. package/js/base/functions/generic.js +270 -0
  35. package/js/base/functions/misc.js +138 -0
  36. package/js/base/functions/number.js +329 -0
  37. package/js/base/functions/platform.js +38 -0
  38. package/js/base/functions/string.js +21 -0
  39. package/js/base/functions/throttle.js +79 -0
  40. package/js/base/functions/time.js +210 -0
  41. package/js/base/functions/type.js +66 -0
  42. package/js/base/functions.js +28 -0
  43. package/js/bequant.js +32 -0
  44. package/js/bibox.js +1407 -0
  45. package/js/bigone.js +1366 -0
  46. package/js/binance.js +5652 -0
  47. package/js/binancecoinm.js +46 -0
  48. package/js/binanceus.js +46 -0
  49. package/js/binanceusdm.js +49 -0
  50. package/js/bit2c.js +535 -0
  51. package/js/bitbank.js +842 -0
  52. package/js/bitbay.js +16 -0
  53. package/js/bitbns.js +1073 -0
  54. package/js/bitcoincom.js +15 -0
  55. package/js/bitfinex.js +1433 -0
  56. package/js/bitfinex2.js +2025 -0
  57. package/js/bitflyer.js +840 -0
  58. package/js/bitforex.js +614 -0
  59. package/js/bitget.js +2397 -0
  60. package/js/bithumb.js +980 -0
  61. package/js/bitmart.js +2516 -0
  62. package/js/bitmex.js +1809 -0
  63. package/js/bitopro.js +1443 -0
  64. package/js/bitpanda.js +1782 -0
  65. package/js/bitrue.js +1747 -0
  66. package/js/bitso.js +1062 -0
  67. package/js/bitstamp.js +1757 -0
  68. package/js/bitstamp1.js +343 -0
  69. package/js/bittrex.js +1876 -0
  70. package/js/bitvavo.js +1579 -0
  71. package/js/bkex.js +1233 -0
  72. package/js/bl3p.js +346 -0
  73. package/js/blockchaincom.js +969 -0
  74. package/js/btcalpha.js +680 -0
  75. package/js/btcbox.js +477 -0
  76. package/js/btcmarkets.js +1022 -0
  77. package/js/btctradeua.js +466 -0
  78. package/js/btcturk.js +734 -0
  79. package/js/buda.js +946 -0
  80. package/js/bw.js +1265 -0
  81. package/js/bybit.js +3372 -0
  82. package/js/bytetrade.js +1336 -0
  83. package/js/cdax.js +1646 -0
  84. package/js/cex.js +1410 -0
  85. package/js/coinbase.js +1342 -0
  86. package/js/coinbaseprime.js +31 -0
  87. package/js/coinbasepro.js +1466 -0
  88. package/js/coincheck.js +755 -0
  89. package/js/coinex.js +3400 -0
  90. package/js/coinfalcon.js +880 -0
  91. package/js/coinmate.js +794 -0
  92. package/js/coinone.js +816 -0
  93. package/js/coinspot.js +345 -0
  94. package/js/crex24.js +1636 -0
  95. package/js/cryptocom.js +1832 -0
  96. package/js/currencycom.js +1748 -0
  97. package/js/delta.js +1547 -0
  98. package/js/deribit.js +2148 -0
  99. package/js/digifinex.js +1585 -0
  100. package/js/eqonex.js +1660 -0
  101. package/js/exmo.js +1670 -0
  102. package/js/fairdesk.js +1231 -0
  103. package/js/flowbtc.js +35 -0
  104. package/js/fmfwio.js +34 -0
  105. package/js/ftx.js +2751 -0
  106. package/js/ftxus.js +38 -0
  107. package/js/gateio.js +4174 -0
  108. package/js/gemini.js +1397 -0
  109. package/js/hitbtc.js +1343 -0
  110. package/js/hitbtc3.js +2329 -0
  111. package/js/hollaex.js +1486 -0
  112. package/js/huobi.js +5706 -0
  113. package/js/huobijp.js +1710 -0
  114. package/js/huobipro.js +18 -0
  115. package/js/idex.js +1439 -0
  116. package/js/independentreserve.js +649 -0
  117. package/js/indodax.js +742 -0
  118. package/js/itbit.js +722 -0
  119. package/js/kraken.js +2179 -0
  120. package/js/kucoin.js +2571 -0
  121. package/js/kucoinfutures.js +1771 -0
  122. package/js/kuna.js +809 -0
  123. package/js/latoken.js +1445 -0
  124. package/js/lbank.js +760 -0
  125. package/js/liquid.js +1432 -0
  126. package/js/luno.js +873 -0
  127. package/js/lykke.js +1147 -0
  128. package/js/mercado.js +771 -0
  129. package/js/mexc.js +3151 -0
  130. package/js/ndax.js +2233 -0
  131. package/js/novadax.js +1318 -0
  132. package/js/oceanex.js +816 -0
  133. package/js/okcoin.js +3841 -0
  134. package/js/okex.js +16 -0
  135. package/js/okex5.js +16 -0
  136. package/js/okx.js +4795 -0
  137. package/js/paymium.js +498 -0
  138. package/js/phemex.js +2957 -0
  139. package/js/poloniex.js +1674 -0
  140. package/js/probit.js +1346 -0
  141. package/js/qtrade.js +1588 -0
  142. package/js/ripio.js +1061 -0
  143. package/js/static_dependencies/BN/bn.js +3526 -0
  144. package/js/static_dependencies/README.md +1 -0
  145. package/js/static_dependencies/crypto-js/crypto-js.js +5988 -0
  146. package/js/static_dependencies/elliptic/lib/elliptic/curve/base.js +375 -0
  147. package/js/static_dependencies/elliptic/lib/elliptic/curve/edwards.js +433 -0
  148. package/js/static_dependencies/elliptic/lib/elliptic/curve/index.js +8 -0
  149. package/js/static_dependencies/elliptic/lib/elliptic/curve/mont.js +180 -0
  150. package/js/static_dependencies/elliptic/lib/elliptic/curve/short.js +938 -0
  151. package/js/static_dependencies/elliptic/lib/elliptic/curves.js +204 -0
  152. package/js/static_dependencies/elliptic/lib/elliptic/ec/index.js +240 -0
  153. package/js/static_dependencies/elliptic/lib/elliptic/ec/key.js +119 -0
  154. package/js/static_dependencies/elliptic/lib/elliptic/ec/signature.js +24 -0
  155. package/js/static_dependencies/elliptic/lib/elliptic/eddsa/index.js +145 -0
  156. package/js/static_dependencies/elliptic/lib/elliptic/eddsa/key.js +100 -0
  157. package/js/static_dependencies/elliptic/lib/elliptic/eddsa/signature.js +65 -0
  158. package/js/static_dependencies/elliptic/lib/elliptic/precomputed/secp256k1.js +780 -0
  159. package/js/static_dependencies/elliptic/lib/elliptic/utils.js +214 -0
  160. package/js/static_dependencies/elliptic/lib/elliptic.js +22 -0
  161. package/js/static_dependencies/elliptic/lib/hmac-drbg/hmac-drbg.js +114 -0
  162. package/js/static_dependencies/fetch-ponyfill/fetch-node.js +39 -0
  163. package/js/static_dependencies/node-fetch/index.js +1564 -0
  164. package/js/static_dependencies/node-rsa/NodeRSA.js +223 -0
  165. package/js/static_dependencies/node-rsa/asn1/ber/errors.js +13 -0
  166. package/js/static_dependencies/node-rsa/asn1/ber/index.js +21 -0
  167. package/js/static_dependencies/node-rsa/asn1/ber/reader.js +262 -0
  168. package/js/static_dependencies/node-rsa/asn1/ber/types.js +36 -0
  169. package/js/static_dependencies/node-rsa/asn1/index.js +17 -0
  170. package/js/static_dependencies/node-rsa/encryptEngines/js.js +34 -0
  171. package/js/static_dependencies/node-rsa/formats/components.js +71 -0
  172. package/js/static_dependencies/node-rsa/formats/formats.js +31 -0
  173. package/js/static_dependencies/node-rsa/formats/pkcs1.js +148 -0
  174. package/js/static_dependencies/node-rsa/formats/pkcs8.js +187 -0
  175. package/js/static_dependencies/node-rsa/libs/jsbn.js +1252 -0
  176. package/js/static_dependencies/node-rsa/libs/rsa.js +147 -0
  177. package/js/static_dependencies/node-rsa/schemes/pkcs1.js +176 -0
  178. package/js/static_dependencies/node-rsa/schemes/schemes.js +21 -0
  179. package/js/static_dependencies/node-rsa/utils.js +98 -0
  180. package/js/static_dependencies/qs/formats.js +18 -0
  181. package/js/static_dependencies/qs/index.js +11 -0
  182. package/js/static_dependencies/qs/parse.js +242 -0
  183. package/js/static_dependencies/qs/stringify.js +269 -0
  184. package/js/static_dependencies/qs/utils.js +230 -0
  185. package/js/stex.js +1925 -0
  186. package/js/test/.eslintrc.js +42 -0
  187. package/js/test/Exchange/test.balance.js +61 -0
  188. package/js/test/Exchange/test.borrowRate.js +32 -0
  189. package/js/test/Exchange/test.currency.js +52 -0
  190. package/js/test/Exchange/test.fetchBalance.js +23 -0
  191. package/js/test/Exchange/test.fetchBorrowInterest.js +59 -0
  192. package/js/test/Exchange/test.fetchBorrowRate.js +32 -0
  193. package/js/test/Exchange/test.fetchBorrowRates.js +28 -0
  194. package/js/test/Exchange/test.fetchClosedOrders.js +32 -0
  195. package/js/test/Exchange/test.fetchCurrencies.js +35 -0
  196. package/js/test/Exchange/test.fetchDeposits.js +31 -0
  197. package/js/test/Exchange/test.fetchFundingFees.js +19 -0
  198. package/js/test/Exchange/test.fetchFundingRateHistory.js +40 -0
  199. package/js/test/Exchange/test.fetchL2OrderBook.js +23 -0
  200. package/js/test/Exchange/test.fetchLedger.js +42 -0
  201. package/js/test/Exchange/test.fetchLeverageTiers.js +33 -0
  202. package/js/test/Exchange/test.fetchMarketLeverageTiers.js +22 -0
  203. package/js/test/Exchange/test.fetchMarkets.js +33 -0
  204. package/js/test/Exchange/test.fetchMyTrades.js +42 -0
  205. package/js/test/Exchange/test.fetchOHLCV.js +46 -0
  206. package/js/test/Exchange/test.fetchOpenOrders.js +36 -0
  207. package/js/test/Exchange/test.fetchOrderBook.js +25 -0
  208. package/js/test/Exchange/test.fetchOrderBooks.js +35 -0
  209. package/js/test/Exchange/test.fetchOrders.js +41 -0
  210. package/js/test/Exchange/test.fetchPositions.js +47 -0
  211. package/js/test/Exchange/test.fetchStatus.js +35 -0
  212. package/js/test/Exchange/test.fetchTicker.js +38 -0
  213. package/js/test/Exchange/test.fetchTickers.js +49 -0
  214. package/js/test/Exchange/test.fetchTrades.js +39 -0
  215. package/js/test/Exchange/test.fetchTradingFee.js +18 -0
  216. package/js/test/Exchange/test.fetchTradingFees.js +22 -0
  217. package/js/test/Exchange/test.fetchTransactions.js +31 -0
  218. package/js/test/Exchange/test.fetchWithdrawals.js +31 -0
  219. package/js/test/Exchange/test.ledgerItem.js +46 -0
  220. package/js/test/Exchange/test.leverageTier.js +33 -0
  221. package/js/test/Exchange/test.loadMarkets.js +35 -0
  222. package/js/test/Exchange/test.market.js +129 -0
  223. package/js/test/Exchange/test.ohlcv.js +33 -0
  224. package/js/test/Exchange/test.order.js +62 -0
  225. package/js/test/Exchange/test.orderbook.js +61 -0
  226. package/js/test/Exchange/test.position.js +21 -0
  227. package/js/test/Exchange/test.throttle.js +94 -0
  228. package/js/test/Exchange/test.ticker.js +95 -0
  229. package/js/test/Exchange/test.trade.js +68 -0
  230. package/js/test/Exchange/test.tradingFee.js +34 -0
  231. package/js/test/Exchange/test.transaction.js +35 -0
  232. package/js/test/base/.eslintrc +38 -0
  233. package/js/test/base/functions/test.crypto.js +110 -0
  234. package/js/test/base/functions/test.datetime.js +62 -0
  235. package/js/test/base/functions/test.generic.js +152 -0
  236. package/js/test/base/functions/test.number.js +362 -0
  237. package/js/test/base/functions/test.time.js +56 -0
  238. package/js/test/base/functions/test.type.js +53 -0
  239. package/js/test/base/test.base.js +193 -0
  240. package/js/test/errors/test.InsufficientFunds.js +86 -0
  241. package/js/test/errors/test.InvalidNonce.js +64 -0
  242. package/js/test/errors/test.InvalidOrder.js +35 -0
  243. package/js/test/errors/test.OrderNotFound.js +39 -0
  244. package/js/test/test.js +426 -0
  245. package/js/test/test.timeout_hang.js +12 -0
  246. package/js/therock.js +1431 -0
  247. package/js/tidebit.js +632 -0
  248. package/js/tidex.js +939 -0
  249. package/js/timex.js +1283 -0
  250. package/js/upbit.js +1622 -0
  251. package/js/vcc.js +1353 -0
  252. package/js/wavesexchange.js +2185 -0
  253. package/js/wazirx.js +732 -0
  254. package/js/whitebit.js +1352 -0
  255. package/js/woo.js +1577 -0
  256. package/js/xena.js +1948 -0
  257. package/js/yobit.js +1129 -0
  258. package/js/zaif.js +647 -0
  259. package/js/zb.js +4088 -0
  260. package/js/zipmex.js +40 -0
  261. package/js/zonda.js +1497 -0
  262. package/multilang.sh +159 -0
  263. package/package.json +591 -0
  264. package/postinstall.js +103 -0
@@ -0,0 +1,649 @@
1
+ 'use strict';
2
+
3
+ // ---------------------------------------------------------------------------
4
+
5
+ const Exchange = require ('./base/Exchange');
6
+ const Precise = require ('./base/Precise');
7
+
8
+ // ---------------------------------------------------------------------------
9
+
10
+ module.exports = class independentreserve extends Exchange {
11
+ describe () {
12
+ return this.deepExtend (super.describe (), {
13
+ 'id': 'independentreserve',
14
+ 'name': 'Independent Reserve',
15
+ 'countries': [ 'AU', 'NZ' ], // Australia, New Zealand
16
+ 'rateLimit': 1000,
17
+ 'has': {
18
+ 'CORS': undefined,
19
+ 'spot': true,
20
+ 'margin': false,
21
+ 'swap': false,
22
+ 'future': false,
23
+ 'option': false,
24
+ 'addMargin': false,
25
+ 'cancelOrder': true,
26
+ 'createOrder': true,
27
+ 'createReduceOnlyOrder': false,
28
+ 'fetchBalance': true,
29
+ 'fetchBorrowRate': false,
30
+ 'fetchBorrowRateHistories': false,
31
+ 'fetchBorrowRateHistory': false,
32
+ 'fetchBorrowRates': false,
33
+ 'fetchBorrowRatesPerSymbol': false,
34
+ 'fetchClosedOrders': true,
35
+ 'fetchFundingHistory': false,
36
+ 'fetchFundingRate': false,
37
+ 'fetchFundingRateHistory': false,
38
+ 'fetchFundingRates': false,
39
+ 'fetchIndexOHLCV': false,
40
+ 'fetchLeverage': false,
41
+ 'fetchLeverageTiers': false,
42
+ 'fetchMarkets': true,
43
+ 'fetchMarkOHLCV': false,
44
+ 'fetchMyTrades': true,
45
+ 'fetchOpenOrders': true,
46
+ 'fetchOrder': true,
47
+ 'fetchOrderBook': true,
48
+ 'fetchPosition': false,
49
+ 'fetchPositions': false,
50
+ 'fetchPositionsRisk': false,
51
+ 'fetchPremiumIndexOHLCV': false,
52
+ 'fetchTicker': true,
53
+ 'fetchTrades': true,
54
+ 'fetchTradingFee': false,
55
+ 'fetchTradingFees': true,
56
+ 'reduceMargin': false,
57
+ 'setLeverage': false,
58
+ 'setMarginMode': false,
59
+ 'setPositionMode': false,
60
+ },
61
+ 'urls': {
62
+ 'logo': 'https://user-images.githubusercontent.com/51840849/87182090-1e9e9080-c2ec-11ea-8e49-563db9a38f37.jpg',
63
+ 'api': {
64
+ 'public': 'https://api.independentreserve.com/Public',
65
+ 'private': 'https://api.independentreserve.com/Private',
66
+ },
67
+ 'www': 'https://www.independentreserve.com',
68
+ 'doc': 'https://www.independentreserve.com/API',
69
+ },
70
+ 'api': {
71
+ 'public': {
72
+ 'get': [
73
+ 'GetValidPrimaryCurrencyCodes',
74
+ 'GetValidSecondaryCurrencyCodes',
75
+ 'GetValidLimitOrderTypes',
76
+ 'GetValidMarketOrderTypes',
77
+ 'GetValidOrderTypes',
78
+ 'GetValidTransactionTypes',
79
+ 'GetMarketSummary',
80
+ 'GetOrderBook',
81
+ 'GetAllOrders',
82
+ 'GetTradeHistorySummary',
83
+ 'GetRecentTrades',
84
+ 'GetFxRates',
85
+ 'GetOrderMinimumVolumes',
86
+ 'GetCryptoWithdrawalFees',
87
+ ],
88
+ },
89
+ 'private': {
90
+ 'post': [
91
+ 'GetOpenOrders',
92
+ 'GetClosedOrders',
93
+ 'GetClosedFilledOrders',
94
+ 'GetOrderDetails',
95
+ 'GetAccounts',
96
+ 'GetTransactions',
97
+ 'GetFiatBankAccounts',
98
+ 'GetDigitalCurrencyDepositAddress',
99
+ 'GetDigitalCurrencyDepositAddresses',
100
+ 'GetTrades',
101
+ 'GetBrokerageFees',
102
+ 'GetDigitalCurrencyWithdrawal',
103
+ 'PlaceLimitOrder',
104
+ 'PlaceMarketOrder',
105
+ 'CancelOrder',
106
+ 'SynchDigitalCurrencyDepositAddressWithBlockchain',
107
+ 'RequestFiatWithdrawal',
108
+ 'WithdrawFiatCurrency',
109
+ 'WithdrawDigitalCurrency',
110
+ ],
111
+ },
112
+ },
113
+ 'fees': {
114
+ 'trading': {
115
+ 'taker': 0.5 / 100,
116
+ 'maker': 0.5 / 100,
117
+ 'percentage': true,
118
+ 'tierBased': false,
119
+ },
120
+ },
121
+ 'commonCurrencies': {
122
+ 'PLA': 'PlayChip',
123
+ },
124
+ });
125
+ }
126
+
127
+ async fetchMarkets (params = {}) {
128
+ const baseCurrencies = await this.publicGetGetValidPrimaryCurrencyCodes (params);
129
+ const quoteCurrencies = await this.publicGetGetValidSecondaryCurrencyCodes (params);
130
+ const limits = await this.publicGetGetOrderMinimumVolumes (params);
131
+ //
132
+ // {
133
+ // "Xbt": 0.0001,
134
+ // "Bch": 0.001,
135
+ // "Bsv": 0.001,
136
+ // "Eth": 0.001,
137
+ // "Ltc": 0.01,
138
+ // "Xrp": 1,
139
+ // }
140
+ //
141
+ const result = [];
142
+ for (let i = 0; i < baseCurrencies.length; i++) {
143
+ const baseId = baseCurrencies[i];
144
+ const base = this.safeCurrencyCode (baseId);
145
+ const minAmount = this.safeNumber (limits, baseId);
146
+ for (let j = 0; j < quoteCurrencies.length; j++) {
147
+ const quoteId = quoteCurrencies[j];
148
+ const quote = this.safeCurrencyCode (quoteId);
149
+ const id = baseId + '/' + quoteId;
150
+ result.push ({
151
+ 'id': id,
152
+ 'symbol': base + '/' + quote,
153
+ 'base': base,
154
+ 'quote': quote,
155
+ 'settle': undefined,
156
+ 'baseId': baseId,
157
+ 'quoteId': quoteId,
158
+ 'settleId': undefined,
159
+ 'type': 'spot',
160
+ 'spot': true,
161
+ 'margin': false,
162
+ 'swap': false,
163
+ 'future': false,
164
+ 'option': false,
165
+ 'active': undefined,
166
+ 'contract': false,
167
+ 'linear': undefined,
168
+ 'inverse': undefined,
169
+ 'contractSize': undefined,
170
+ 'expiry': undefined,
171
+ 'expiryDatetime': undefined,
172
+ 'strike': undefined,
173
+ 'optionType': undefined,
174
+ 'precision': this.precision,
175
+ 'limits': {
176
+ 'leverage': {
177
+ 'min': undefined,
178
+ 'max': undefined,
179
+ },
180
+ 'amount': {
181
+ 'min': minAmount,
182
+ 'max': undefined,
183
+ },
184
+ 'price': {
185
+ 'min': undefined,
186
+ 'max': undefined,
187
+ },
188
+ 'cost': {
189
+ 'min': undefined,
190
+ 'max': undefined,
191
+ },
192
+ },
193
+ 'info': id,
194
+ });
195
+ }
196
+ }
197
+ return result;
198
+ }
199
+
200
+ parseBalance (response) {
201
+ const result = { 'info': response };
202
+ for (let i = 0; i < response.length; i++) {
203
+ const balance = response[i];
204
+ const currencyId = this.safeString (balance, 'CurrencyCode');
205
+ const code = this.safeCurrencyCode (currencyId);
206
+ const account = this.account ();
207
+ account['free'] = this.safeString (balance, 'AvailableBalance');
208
+ account['total'] = this.safeString (balance, 'TotalBalance');
209
+ result[code] = account;
210
+ }
211
+ return this.safeBalance (result);
212
+ }
213
+
214
+ async fetchBalance (params = {}) {
215
+ await this.loadMarkets ();
216
+ const response = await this.privatePostGetAccounts (params);
217
+ return this.parseBalance (response);
218
+ }
219
+
220
+ async fetchOrderBook (symbol, limit = undefined, params = {}) {
221
+ await this.loadMarkets ();
222
+ const market = this.market (symbol);
223
+ const request = {
224
+ 'primaryCurrencyCode': market['baseId'],
225
+ 'secondaryCurrencyCode': market['quoteId'],
226
+ };
227
+ const response = await this.publicGetGetOrderBook (this.extend (request, params));
228
+ const timestamp = this.parse8601 (this.safeString (response, 'CreatedTimestampUtc'));
229
+ return this.parseOrderBook (response, symbol, timestamp, 'BuyOrders', 'SellOrders', 'Price', 'Volume');
230
+ }
231
+
232
+ parseTicker (ticker, market = undefined) {
233
+ // {
234
+ // "DayHighestPrice":43489.49,
235
+ // "DayLowestPrice":41998.32,
236
+ // "DayAvgPrice":42743.9,
237
+ // "DayVolumeXbt":44.54515625000,
238
+ // "DayVolumeXbtInSecondaryCurrrency":0.12209818,
239
+ // "CurrentLowestOfferPrice":43619.64,
240
+ // "CurrentHighestBidPrice":43153.58,
241
+ // "LastPrice":43378.43,
242
+ // "PrimaryCurrencyCode":"Xbt",
243
+ // "SecondaryCurrencyCode":"Usd",
244
+ // "CreatedTimestampUtc":"2022-01-14T22:52:29.5029223Z"
245
+ // }
246
+ const timestamp = this.parse8601 (this.safeString (ticker, 'CreatedTimestampUtc'));
247
+ const baseId = this.safeString (ticker, 'PrimaryCurrencyCode');
248
+ const quoteId = this.safeString (ticker, 'SecondaryCurrencyCode');
249
+ let defaultMarketId = undefined;
250
+ if ((baseId !== undefined) && (quoteId !== undefined)) {
251
+ defaultMarketId = baseId + '/' + quoteId;
252
+ }
253
+ market = this.safeMarket (defaultMarketId, market, '/');
254
+ const symbol = market['symbol'];
255
+ const last = this.safeString (ticker, 'LastPrice');
256
+ return this.safeTicker ({
257
+ 'symbol': symbol,
258
+ 'timestamp': timestamp,
259
+ 'datetime': this.iso8601 (timestamp),
260
+ 'high': this.safeString (ticker, 'DayHighestPrice'),
261
+ 'low': this.safeString (ticker, 'DayLowestPrice'),
262
+ 'bid': this.safeString (ticker, 'CurrentHighestBidPrice'),
263
+ 'bidVolume': undefined,
264
+ 'ask': this.safeString (ticker, 'CurrentLowestOfferPrice'),
265
+ 'askVolume': undefined,
266
+ 'vwap': undefined,
267
+ 'open': undefined,
268
+ 'close': last,
269
+ 'last': last,
270
+ 'previousClose': undefined,
271
+ 'change': undefined,
272
+ 'percentage': undefined,
273
+ 'average': this.safeString (ticker, 'DayAvgPrice'),
274
+ 'baseVolume': this.safeString (ticker, 'DayVolumeXbtInSecondaryCurrrency'),
275
+ 'quoteVolume': undefined,
276
+ 'info': ticker,
277
+ }, market, false);
278
+ }
279
+
280
+ async fetchTicker (symbol, params = {}) {
281
+ await this.loadMarkets ();
282
+ const market = this.market (symbol);
283
+ const request = {
284
+ 'primaryCurrencyCode': market['baseId'],
285
+ 'secondaryCurrencyCode': market['quoteId'],
286
+ };
287
+ const response = await this.publicGetGetMarketSummary (this.extend (request, params));
288
+ // {
289
+ // "DayHighestPrice":43489.49,
290
+ // "DayLowestPrice":41998.32,
291
+ // "DayAvgPrice":42743.9,
292
+ // "DayVolumeXbt":44.54515625000,
293
+ // "DayVolumeXbtInSecondaryCurrrency":0.12209818,
294
+ // "CurrentLowestOfferPrice":43619.64,
295
+ // "CurrentHighestBidPrice":43153.58,
296
+ // "LastPrice":43378.43,
297
+ // "PrimaryCurrencyCode":"Xbt",
298
+ // "SecondaryCurrencyCode":"Usd",
299
+ // "CreatedTimestampUtc":"2022-01-14T22:52:29.5029223Z"
300
+ // }
301
+ return this.parseTicker (response, market);
302
+ }
303
+
304
+ parseOrder (order, market = undefined) {
305
+ //
306
+ // fetchOrder
307
+ //
308
+ // {
309
+ // "OrderGuid": "c7347e4c-b865-4c94-8f74-d934d4b0b177",
310
+ // "CreatedTimestampUtc": "2014-09-23T12:39:34.3817763Z",
311
+ // "Type": "MarketBid",
312
+ // "VolumeOrdered": 5.0,
313
+ // "VolumeFilled": 5.0,
314
+ // "Price": null,
315
+ // "AvgPrice": 100.0,
316
+ // "ReservedAmount": 0.0,
317
+ // "Status": "Filled",
318
+ // "PrimaryCurrencyCode": "Xbt",
319
+ // "SecondaryCurrencyCode": "Usd"
320
+ // }
321
+ //
322
+ // fetchOpenOrders & fetchClosedOrders
323
+ //
324
+ // {
325
+ // "OrderGuid": "b8f7ad89-e4e4-4dfe-9ea3-514d38b5edb3",
326
+ // "CreatedTimestampUtc": "2020-09-08T03:04:18.616367Z",
327
+ // "OrderType": "LimitOffer",
328
+ // "Volume": 0.0005,
329
+ // "Outstanding": 0.0005,
330
+ // "Price": 113885.83,
331
+ // "AvgPrice": 113885.83,
332
+ // "Value": 56.94,
333
+ // "Status": "Open",
334
+ // "PrimaryCurrencyCode": "Xbt",
335
+ // "SecondaryCurrencyCode": "Usd",
336
+ // "FeePercent": 0.005,
337
+ // }
338
+ //
339
+ let symbol = undefined;
340
+ const baseId = this.safeString (order, 'PrimaryCurrencyCode');
341
+ const quoteId = this.safeString (order, 'SecondaryCurrencyCode');
342
+ let base = undefined;
343
+ let quote = undefined;
344
+ if ((baseId !== undefined) && (quoteId !== undefined)) {
345
+ base = this.safeCurrencyCode (baseId);
346
+ quote = this.safeCurrencyCode (quoteId);
347
+ symbol = base + '/' + quote;
348
+ } else if (market !== undefined) {
349
+ symbol = market['symbol'];
350
+ base = market['base'];
351
+ quote = market['quote'];
352
+ }
353
+ let orderType = this.safeString2 (order, 'Type', 'OrderType');
354
+ let side = undefined;
355
+ if (orderType.indexOf ('Bid') >= 0) {
356
+ side = 'buy';
357
+ } else if (orderType.indexOf ('Offer') >= 0) {
358
+ side = 'sell';
359
+ }
360
+ if (orderType.indexOf ('Market') >= 0) {
361
+ orderType = 'market';
362
+ } else if (orderType.indexOf ('Limit') >= 0) {
363
+ orderType = 'limit';
364
+ }
365
+ const timestamp = this.parse8601 (this.safeString (order, 'CreatedTimestampUtc'));
366
+ const amount = this.safeString2 (order, 'VolumeOrdered', 'Volume');
367
+ const filled = this.safeString (order, 'VolumeFilled');
368
+ const remaining = this.safeString (order, 'Outstanding');
369
+ const feeRate = this.safeNumber (order, 'FeePercent');
370
+ let feeCost = undefined;
371
+ if (feeRate !== undefined && filled !== undefined) {
372
+ feeCost = feeRate * filled;
373
+ }
374
+ const fee = {
375
+ 'rate': feeRate,
376
+ 'cost': feeCost,
377
+ 'currency': base,
378
+ };
379
+ const id = this.safeString (order, 'OrderGuid');
380
+ const status = this.parseOrderStatus (this.safeString (order, 'Status'));
381
+ const cost = this.safeString (order, 'Value');
382
+ const average = this.safeString (order, 'AvgPrice');
383
+ const price = this.safeString (order, 'Price');
384
+ return this.safeOrder ({
385
+ 'info': order,
386
+ 'id': id,
387
+ 'clientOrderId': undefined,
388
+ 'timestamp': timestamp,
389
+ 'datetime': this.iso8601 (timestamp),
390
+ 'lastTradeTimestamp': undefined,
391
+ 'symbol': symbol,
392
+ 'type': orderType,
393
+ 'timeInForce': undefined,
394
+ 'postOnly': undefined,
395
+ 'side': side,
396
+ 'price': price,
397
+ 'stopPrice': undefined,
398
+ 'cost': cost,
399
+ 'average': average,
400
+ 'amount': amount,
401
+ 'filled': filled,
402
+ 'remaining': remaining,
403
+ 'status': status,
404
+ 'fee': fee,
405
+ 'trades': undefined,
406
+ }, market);
407
+ }
408
+
409
+ parseOrderStatus (status) {
410
+ const statuses = {
411
+ 'Open': 'open',
412
+ 'PartiallyFilled': 'open',
413
+ 'Filled': 'closed',
414
+ 'PartiallyFilledAndCancelled': 'canceled',
415
+ 'Cancelled': 'canceled',
416
+ 'PartiallyFilledAndExpired': 'canceled',
417
+ 'Expired': 'canceled',
418
+ };
419
+ return this.safeString (statuses, status, status);
420
+ }
421
+
422
+ async fetchOrder (id, symbol = undefined, params = {}) {
423
+ await this.loadMarkets ();
424
+ const response = await this.privatePostGetOrderDetails (this.extend ({
425
+ 'orderGuid': id,
426
+ }, params));
427
+ let market = undefined;
428
+ if (symbol !== undefined) {
429
+ market = this.market (symbol);
430
+ }
431
+ return this.parseOrder (response, market);
432
+ }
433
+
434
+ async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) {
435
+ await this.loadMarkets ();
436
+ const request = this.ordered ({});
437
+ let market = undefined;
438
+ if (symbol !== undefined) {
439
+ market = this.market (symbol);
440
+ request['primaryCurrencyCode'] = market['baseId'];
441
+ request['secondaryCurrencyCode'] = market['quoteId'];
442
+ }
443
+ if (limit === undefined) {
444
+ limit = 50;
445
+ }
446
+ request['pageIndex'] = 1;
447
+ request['pageSize'] = limit;
448
+ const response = await this.privatePostGetOpenOrders (this.extend (request, params));
449
+ const data = this.safeValue (response, 'Data', []);
450
+ return this.parseOrders (data, market, since, limit);
451
+ }
452
+
453
+ async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) {
454
+ await this.loadMarkets ();
455
+ const request = this.ordered ({});
456
+ let market = undefined;
457
+ if (symbol !== undefined) {
458
+ market = this.market (symbol);
459
+ request['primaryCurrencyCode'] = market['baseId'];
460
+ request['secondaryCurrencyCode'] = market['quoteId'];
461
+ }
462
+ if (limit === undefined) {
463
+ limit = 50;
464
+ }
465
+ request['pageIndex'] = 1;
466
+ request['pageSize'] = limit;
467
+ const response = await this.privatePostGetClosedOrders (this.extend (request, params));
468
+ const data = this.safeValue (response, 'Data', []);
469
+ return this.parseOrders (data, market, since, limit);
470
+ }
471
+
472
+ async fetchMyTrades (symbol = undefined, since = undefined, limit = 50, params = {}) {
473
+ await this.loadMarkets ();
474
+ const pageIndex = this.safeInteger (params, 'pageIndex', 1);
475
+ if (limit === undefined) {
476
+ limit = 50;
477
+ }
478
+ const request = this.ordered ({
479
+ 'pageIndex': pageIndex,
480
+ 'pageSize': limit,
481
+ });
482
+ const response = await this.privatePostGetTrades (this.extend (request, params));
483
+ let market = undefined;
484
+ if (symbol !== undefined) {
485
+ market = this.market (symbol);
486
+ }
487
+ return this.parseTrades (response['Data'], market, since, limit);
488
+ }
489
+
490
+ parseTrade (trade, market = undefined) {
491
+ const timestamp = this.parse8601 (trade['TradeTimestampUtc']);
492
+ const id = this.safeString (trade, 'TradeGuid');
493
+ const orderId = this.safeString (trade, 'OrderGuid');
494
+ const priceString = this.safeString2 (trade, 'Price', 'SecondaryCurrencyTradePrice');
495
+ const amountString = this.safeString2 (trade, 'VolumeTraded', 'PrimaryCurrencyAmount');
496
+ const price = this.parseNumber (priceString);
497
+ const amount = this.parseNumber (amountString);
498
+ const cost = this.parseNumber (Precise.stringMul (priceString, amountString));
499
+ const baseId = this.safeString (trade, 'PrimaryCurrencyCode');
500
+ const quoteId = this.safeString (trade, 'SecondaryCurrencyCode');
501
+ let marketId = undefined;
502
+ if ((baseId !== undefined) && (quoteId !== undefined)) {
503
+ marketId = baseId + '/' + quoteId;
504
+ }
505
+ const symbol = this.safeSymbol (marketId, market, '/');
506
+ let side = this.safeString (trade, 'OrderType');
507
+ if (side !== undefined) {
508
+ if (side.indexOf ('Bid') >= 0) {
509
+ side = 'buy';
510
+ } else if (side.indexOf ('Offer') >= 0) {
511
+ side = 'sell';
512
+ }
513
+ }
514
+ return {
515
+ 'id': id,
516
+ 'info': trade,
517
+ 'timestamp': timestamp,
518
+ 'datetime': this.iso8601 (timestamp),
519
+ 'symbol': symbol,
520
+ 'order': orderId,
521
+ 'type': undefined,
522
+ 'side': side,
523
+ 'takerOrMaker': undefined,
524
+ 'price': price,
525
+ 'amount': amount,
526
+ 'cost': cost,
527
+ 'fee': undefined,
528
+ };
529
+ }
530
+
531
+ async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) {
532
+ await this.loadMarkets ();
533
+ const market = this.market (symbol);
534
+ const request = {
535
+ 'primaryCurrencyCode': market['baseId'],
536
+ 'secondaryCurrencyCode': market['quoteId'],
537
+ 'numberOfRecentTradesToRetrieve': 50, // max = 50
538
+ };
539
+ const response = await this.publicGetGetRecentTrades (this.extend (request, params));
540
+ return this.parseTrades (response['Trades'], market, since, limit);
541
+ }
542
+
543
+ async fetchTradingFees (params = {}) {
544
+ await this.loadMarkets ();
545
+ const response = await this.privatePostGetBrokerageFees (params);
546
+ //
547
+ // [
548
+ // {
549
+ // "CurrencyCode": "Xbt",
550
+ // "Fee": 0.005
551
+ // }
552
+ // ...
553
+ // ]
554
+ //
555
+ const fees = {};
556
+ for (let i = 0; i < response.length; i++) {
557
+ const fee = response[i];
558
+ const currencyId = this.safeString (fee, 'CurrencyCode');
559
+ const code = this.safeCurrencyCode (currencyId);
560
+ const tradingFee = this.safeNumber (fee, 'Fee');
561
+ fees[code] = {
562
+ 'info': fee,
563
+ 'fee': tradingFee,
564
+ };
565
+ }
566
+ const result = {};
567
+ for (let i = 0; i < this.symbols.length; i++) {
568
+ const symbol = this.symbols[i];
569
+ const market = this.market (symbol);
570
+ const fee = this.safeValue (fees, market['base'], {});
571
+ result[symbol] = {
572
+ 'info': this.safeValue (fee, 'info'),
573
+ 'symbol': symbol,
574
+ 'maker': this.safeNumber (fee, 'fee'),
575
+ 'taker': this.safeNumber (fee, 'fee'),
576
+ 'percentage': true,
577
+ 'tierBased': true,
578
+ };
579
+ }
580
+ return result;
581
+ }
582
+
583
+ async createOrder (symbol, type, side, amount, price = undefined, params = {}) {
584
+ await this.loadMarkets ();
585
+ const market = this.market (symbol);
586
+ const capitalizedOrderType = this.capitalize (type);
587
+ const method = 'privatePostPlace' + capitalizedOrderType + 'Order';
588
+ let orderType = capitalizedOrderType;
589
+ orderType += (side === 'sell') ? 'Offer' : 'Bid';
590
+ const request = this.ordered ({
591
+ 'primaryCurrencyCode': market['baseId'],
592
+ 'secondaryCurrencyCode': market['quoteId'],
593
+ 'orderType': orderType,
594
+ });
595
+ if (type === 'limit') {
596
+ request['price'] = price;
597
+ }
598
+ request['volume'] = amount;
599
+ const response = await this[method] (this.extend (request, params));
600
+ return {
601
+ 'info': response,
602
+ 'id': response['OrderGuid'],
603
+ };
604
+ }
605
+
606
+ async cancelOrder (id, symbol = undefined, params = {}) {
607
+ await this.loadMarkets ();
608
+ const request = {
609
+ 'orderGuid': id,
610
+ };
611
+ return await this.privatePostCancelOrder (this.extend (request, params));
612
+ }
613
+
614
+ sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
615
+ let url = this.urls['api'][api] + '/' + path;
616
+ if (api === 'public') {
617
+ if (Object.keys (params).length) {
618
+ url += '?' + this.urlencode (params);
619
+ }
620
+ } else {
621
+ this.checkRequiredCredentials ();
622
+ const nonce = this.nonce ();
623
+ const auth = [
624
+ url,
625
+ 'apiKey=' + this.apiKey,
626
+ 'nonce=' + nonce.toString (),
627
+ ];
628
+ const keys = Object.keys (params);
629
+ for (let i = 0; i < keys.length; i++) {
630
+ const key = keys[i];
631
+ const value = params[key].toString ();
632
+ auth.push (key + '=' + value);
633
+ }
634
+ const message = auth.join (',');
635
+ const signature = this.hmac (this.encode (message), this.encode (this.secret));
636
+ const query = this.ordered ({});
637
+ query['apiKey'] = this.apiKey;
638
+ query['nonce'] = nonce;
639
+ query['signature'] = signature.toUpperCase ();
640
+ for (let i = 0; i < keys.length; i++) {
641
+ const key = keys[i];
642
+ query[key] = params[key];
643
+ }
644
+ body = this.json (query);
645
+ headers = { 'Content-Type': 'application/json' };
646
+ }
647
+ return { 'url': url, 'method': method, 'body': body, 'headers': headers };
648
+ }
649
+ };