ccxt 3.1.60__py2.py3-none-any.whl → 4.0.3__py2.py3-none-any.whl
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.
- ccxt/__init__.py +1 -1
- ccxt/async_support/__init__.py +1 -1
- ccxt/async_support/base/exchange.py +1 -1
- ccxt/base/exchange.py +1 -1
- ccxt/pro/__init__.py +1 -1
- {ccxt-3.1.60.dist-info → ccxt-4.0.3.dist-info}/METADATA +4 -4
- {ccxt-3.1.60.dist-info → ccxt-4.0.3.dist-info}/RECORD +9 -23
- ccxt/async_support/btcex.py +0 -2519
- ccxt/async_support/buda.py +0 -1063
- ccxt/async_support/itbit.py +0 -771
- ccxt/async_support/ripio.py +0 -1102
- ccxt/async_support/stex.py +0 -2508
- ccxt/async_support/xt.py +0 -4420
- ccxt/async_support/zb.py +0 -4127
- ccxt/btcex.py +0 -2519
- ccxt/buda.py +0 -1063
- ccxt/itbit.py +0 -771
- ccxt/ripio.py +0 -1102
- ccxt/stex.py +0 -2508
- ccxt/xt.py +0 -4419
- ccxt/zb.py +0 -4126
- {ccxt-3.1.60.dist-info → ccxt-4.0.3.dist-info}/WHEEL +0 -0
- {ccxt-3.1.60.dist-info → ccxt-4.0.3.dist-info}/top_level.txt +0 -0
ccxt/itbit.py
DELETED
@@ -1,771 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
# PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
|
4
|
-
# https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
|
5
|
-
|
6
|
-
from ccxt.base.exchange import Exchange
|
7
|
-
import hashlib
|
8
|
-
from ccxt.base.types import OrderSide
|
9
|
-
from typing import Optional
|
10
|
-
from ccxt.base.errors import ExchangeError
|
11
|
-
from ccxt.base.errors import ArgumentsRequired
|
12
|
-
from ccxt.base.errors import AuthenticationError
|
13
|
-
from ccxt.base.decimal_to_precision import TICK_SIZE
|
14
|
-
from ccxt.base.precise import Precise
|
15
|
-
|
16
|
-
|
17
|
-
class itbit(Exchange):
|
18
|
-
|
19
|
-
def describe(self):
|
20
|
-
return self.deep_extend(super(itbit, self).describe(), {
|
21
|
-
'id': 'itbit',
|
22
|
-
'name': 'itBit',
|
23
|
-
'countries': ['US'],
|
24
|
-
'rateLimit': 2000,
|
25
|
-
'version': 'v1',
|
26
|
-
'has': {
|
27
|
-
'CORS': True,
|
28
|
-
'spot': True,
|
29
|
-
'margin': False,
|
30
|
-
'swap': False,
|
31
|
-
'future': False,
|
32
|
-
'option': False,
|
33
|
-
'addMargin': False,
|
34
|
-
'cancelOrder': True,
|
35
|
-
'createMarketOrder': False,
|
36
|
-
'createOrder': True,
|
37
|
-
'createReduceOnlyOrder': False,
|
38
|
-
'createStopLimitOrder': False,
|
39
|
-
'createStopMarketOrder': False,
|
40
|
-
'createStopOrder': False,
|
41
|
-
'fetchBalance': True,
|
42
|
-
'fetchBorrowRate': False,
|
43
|
-
'fetchBorrowRateHistories': False,
|
44
|
-
'fetchBorrowRateHistory': False,
|
45
|
-
'fetchBorrowRates': False,
|
46
|
-
'fetchBorrowRatesPerSymbol': False,
|
47
|
-
'fetchClosedOrders': True,
|
48
|
-
'fetchFundingHistory': False,
|
49
|
-
'fetchFundingRate': False,
|
50
|
-
'fetchFundingRateHistory': False,
|
51
|
-
'fetchFundingRates': False,
|
52
|
-
'fetchIndexOHLCV': False,
|
53
|
-
'fetchLeverage': False,
|
54
|
-
'fetchLeverageTiers': False,
|
55
|
-
'fetchMarginMode': False,
|
56
|
-
'fetchMarkOHLCV': False,
|
57
|
-
'fetchMyTrades': True,
|
58
|
-
'fetchOpenInterestHistory': False,
|
59
|
-
'fetchOpenOrders': True,
|
60
|
-
'fetchOrder': True,
|
61
|
-
'fetchOrderBook': True,
|
62
|
-
'fetchOrders': True,
|
63
|
-
'fetchPosition': False,
|
64
|
-
'fetchPositionMode': False,
|
65
|
-
'fetchPositions': False,
|
66
|
-
'fetchPositionsRisk': False,
|
67
|
-
'fetchPremiumIndexOHLCV': False,
|
68
|
-
'fetchTicker': True,
|
69
|
-
'fetchTrades': True,
|
70
|
-
'fetchTradingFee': False,
|
71
|
-
'fetchTradingFees': False,
|
72
|
-
'fetchTransactions': True,
|
73
|
-
'reduceMargin': False,
|
74
|
-
'setLeverage': False,
|
75
|
-
'setMarginMode': False,
|
76
|
-
'setPositionMode': False,
|
77
|
-
},
|
78
|
-
'urls': {
|
79
|
-
'logo': 'https://user-images.githubusercontent.com/1294454/27822159-66153620-60ad-11e7-89e7-005f6d7f3de0.jpg',
|
80
|
-
'api': {
|
81
|
-
'rest': 'https://api.itbit.com',
|
82
|
-
},
|
83
|
-
'www': 'https://www.itbit.com',
|
84
|
-
'doc': [
|
85
|
-
'https://api.itbit.com/docs',
|
86
|
-
'https://www.itbit.com/api',
|
87
|
-
],
|
88
|
-
},
|
89
|
-
'api': {
|
90
|
-
'public': {
|
91
|
-
'get': [
|
92
|
-
'markets/{symbol}/ticker',
|
93
|
-
'markets/{symbol}/order_book',
|
94
|
-
'markets/{symbol}/trades',
|
95
|
-
],
|
96
|
-
},
|
97
|
-
'private': {
|
98
|
-
'get': [
|
99
|
-
'wallets',
|
100
|
-
'wallets/{walletId}',
|
101
|
-
'wallets/{walletId}/balances/{currencyCode}',
|
102
|
-
'wallets/{walletId}/funding_history',
|
103
|
-
'wallets/{walletId}/trades',
|
104
|
-
'wallets/{walletId}/orders',
|
105
|
-
'wallets/{walletId}/orders/{id}',
|
106
|
-
],
|
107
|
-
'post': [
|
108
|
-
'wallet_transfers',
|
109
|
-
'wallets',
|
110
|
-
'wallets/{walletId}/cryptocurrency_deposits',
|
111
|
-
'wallets/{walletId}/cryptocurrency_withdrawals',
|
112
|
-
'wallets/{walletId}/orders',
|
113
|
-
'wire_withdrawal',
|
114
|
-
],
|
115
|
-
'delete': [
|
116
|
-
'wallets/{walletId}/orders/{id}',
|
117
|
-
],
|
118
|
-
},
|
119
|
-
},
|
120
|
-
'markets': {
|
121
|
-
'BTC/USD': {'id': 'XBTUSD', 'symbol': 'BTC/USD', 'base': 'BTC', 'quote': 'USD', 'baseId': 'XBT', 'quoteId': 'USD', 'type': 'spot', 'spot': True},
|
122
|
-
'BTC/SGD': {'id': 'XBTSGD', 'symbol': 'BTC/SGD', 'base': 'BTC', 'quote': 'SGD', 'baseId': 'XBT', 'quoteId': 'SGD', 'type': 'spot', 'spot': True},
|
123
|
-
'BTC/EUR': {'id': 'XBTEUR', 'symbol': 'BTC/EUR', 'base': 'BTC', 'quote': 'EUR', 'baseId': 'XBT', 'quoteId': 'EUR', 'type': 'spot', 'spot': True},
|
124
|
-
'ETH/USD': {'id': 'ETHUSD', 'symbol': 'ETH/USD', 'base': 'ETH', 'quote': 'USD', 'baseId': 'ETH', 'quoteId': 'USD', 'type': 'spot', 'spot': True},
|
125
|
-
'ETH/EUR': {'id': 'ETHEUR', 'symbol': 'ETH/EUR', 'base': 'ETH', 'quote': 'EUR', 'baseId': 'ETH', 'quoteId': 'EUR', 'type': 'spot', 'spot': True},
|
126
|
-
'ETH/SGD': {'id': 'ETHSGD', 'symbol': 'ETH/SGD', 'base': 'ETH', 'quote': 'SGD', 'baseId': 'ETH', 'quoteId': 'SGD', 'type': 'spot', 'spot': True},
|
127
|
-
'PAXGUSD': {'id': 'PAXGUSD', 'symbol': 'PAXG/USD', 'base': 'PAXG', 'quote': 'USD', 'baseId': 'PAXG', 'quoteId': 'USD', 'type': 'spot', 'spot': True},
|
128
|
-
'BCHUSD': {'id': 'BCHUSD', 'symbol': 'BCH/USD', 'base': 'BCH', 'quote': 'USD', 'baseId': 'BCH', 'quoteId': 'USD', 'type': 'spot', 'spot': True},
|
129
|
-
'LTCUSD': {'id': 'LTCUSD', 'symbol': 'LTC/USD', 'base': 'LTC', 'quote': 'USD', 'baseId': 'LTC', 'quoteId': 'USD', 'type': 'spot', 'spot': True},
|
130
|
-
},
|
131
|
-
'fees': {
|
132
|
-
'trading': {
|
133
|
-
'maker': self.parse_number('-0.0003'),
|
134
|
-
'taker': self.parse_number('0.0035'),
|
135
|
-
},
|
136
|
-
},
|
137
|
-
'commonCurrencies': {
|
138
|
-
'XBT': 'BTC',
|
139
|
-
},
|
140
|
-
'precisionMode': TICK_SIZE,
|
141
|
-
})
|
142
|
-
|
143
|
-
def fetch_order_book(self, symbol: str, limit: Optional[int] = None, params={}):
|
144
|
-
"""
|
145
|
-
fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
|
146
|
-
:param str symbol: unified symbol of the market to fetch the order book for
|
147
|
-
:param int|None limit: the maximum amount of order book entries to return
|
148
|
-
:param dict params: extra parameters specific to the itbit api endpoint
|
149
|
-
:returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
|
150
|
-
"""
|
151
|
-
self.load_markets()
|
152
|
-
market = self.market(symbol)
|
153
|
-
request = {
|
154
|
-
'symbol': market['id'],
|
155
|
-
}
|
156
|
-
orderbook = self.publicGetMarketsSymbolOrderBook(self.extend(request, params))
|
157
|
-
return self.parse_order_book(orderbook, market['symbol'])
|
158
|
-
|
159
|
-
def parse_ticker(self, ticker, market=None):
|
160
|
-
#
|
161
|
-
# {
|
162
|
-
# "pair":"XBTUSD",
|
163
|
-
# "bid":"36734.50",
|
164
|
-
# "bidAmt":"0.01000000",
|
165
|
-
# "ask":"36734.75",
|
166
|
-
# "askAmt":"0.30750480",
|
167
|
-
# "lastPrice":"36721.75",
|
168
|
-
# "lastAmt":"0.00070461",
|
169
|
-
# "volume24h":"275.50596346",
|
170
|
-
# "volumeToday":"118.19025141",
|
171
|
-
# "high24h":"37510.50",
|
172
|
-
# "low24h":"35542.75",
|
173
|
-
# "highToday":"37510.50",
|
174
|
-
# "lowToday":"36176.50",
|
175
|
-
# "openToday":"37156.50",
|
176
|
-
# "vwapToday":"37008.22463903",
|
177
|
-
# "vwap24h":"36580.27146808",
|
178
|
-
# "serverTimeUTC":"2022-01-28T14:46:32.4472864Z"
|
179
|
-
# }
|
180
|
-
#
|
181
|
-
symbol = self.safe_symbol(None, market)
|
182
|
-
serverTimeUTC = self.safe_string(ticker, 'serverTimeUTC')
|
183
|
-
if not serverTimeUTC:
|
184
|
-
raise ExchangeError(self.id + ' fetchTicker() returned a bad response: ' + self.json(ticker))
|
185
|
-
timestamp = self.parse8601(serverTimeUTC)
|
186
|
-
vwap = self.safe_string(ticker, 'vwap24h')
|
187
|
-
baseVolume = self.safe_string(ticker, 'volume24h')
|
188
|
-
quoteVolume = Precise.string_mul(baseVolume, vwap)
|
189
|
-
last = self.safe_string(ticker, 'lastPrice')
|
190
|
-
return self.safe_ticker({
|
191
|
-
'symbol': symbol,
|
192
|
-
'timestamp': timestamp,
|
193
|
-
'datetime': self.iso8601(timestamp),
|
194
|
-
'high': self.safe_string(ticker, 'high24h'),
|
195
|
-
'low': self.safe_string(ticker, 'low24h'),
|
196
|
-
'bid': self.safe_string(ticker, 'bid'),
|
197
|
-
'bidVolume': None,
|
198
|
-
'ask': self.safe_string(ticker, 'ask'),
|
199
|
-
'askVolume': None,
|
200
|
-
'vwap': vwap,
|
201
|
-
'open': self.safe_string(ticker, 'openToday'),
|
202
|
-
'close': last,
|
203
|
-
'last': last,
|
204
|
-
'previousClose': None,
|
205
|
-
'change': None,
|
206
|
-
'percentage': None,
|
207
|
-
'average': None,
|
208
|
-
'baseVolume': baseVolume,
|
209
|
-
'quoteVolume': quoteVolume,
|
210
|
-
'info': ticker,
|
211
|
-
}, market)
|
212
|
-
|
213
|
-
def fetch_ticker(self, symbol: str, params={}):
|
214
|
-
"""
|
215
|
-
fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
216
|
-
:param str symbol: unified symbol of the market to fetch the ticker for
|
217
|
-
:param dict params: extra parameters specific to the itbit api endpoint
|
218
|
-
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
|
219
|
-
"""
|
220
|
-
self.load_markets()
|
221
|
-
market = self.market(symbol)
|
222
|
-
request = {
|
223
|
-
'symbol': market['id'],
|
224
|
-
}
|
225
|
-
ticker = self.publicGetMarketsSymbolTicker(self.extend(request, params))
|
226
|
-
#
|
227
|
-
# {
|
228
|
-
# "pair":"XBTUSD",
|
229
|
-
# "bid":"36734.50",
|
230
|
-
# "bidAmt":"0.01000000",
|
231
|
-
# "ask":"36734.75",
|
232
|
-
# "askAmt":"0.30750480",
|
233
|
-
# "lastPrice":"36721.75",
|
234
|
-
# "lastAmt":"0.00070461",
|
235
|
-
# "volume24h":"275.50596346",
|
236
|
-
# "volumeToday":"118.19025141",
|
237
|
-
# "high24h":"37510.50",
|
238
|
-
# "low24h":"35542.75",
|
239
|
-
# "highToday":"37510.50",
|
240
|
-
# "lowToday":"36176.50",
|
241
|
-
# "openToday":"37156.50",
|
242
|
-
# "vwapToday":"37008.22463903",
|
243
|
-
# "vwap24h":"36580.27146808",
|
244
|
-
# "serverTimeUTC":"2022-01-28T14:46:32.4472864Z"
|
245
|
-
# }
|
246
|
-
#
|
247
|
-
return self.parse_ticker(ticker, market)
|
248
|
-
|
249
|
-
def parse_trade(self, trade, market=None):
|
250
|
-
#
|
251
|
-
# fetchTrades(public)
|
252
|
-
#
|
253
|
-
# {
|
254
|
-
# timestamp: "2015-05-22T17:45:34.7570000Z",
|
255
|
-
# matchNumber: "5CR1JEUBBM8J",
|
256
|
-
# price: "351.45000000",
|
257
|
-
# amount: "0.00010000"
|
258
|
-
# }
|
259
|
-
#
|
260
|
-
# fetchMyTrades(private)
|
261
|
-
#
|
262
|
-
# {
|
263
|
-
# "orderId": "248ffda4-83a0-4033-a5bb-8929d523f59f",
|
264
|
-
# "timestamp": "2015-05-11T14:48:01.9870000Z",
|
265
|
-
# "instrument": "XBTUSD",
|
266
|
-
# "direction": "buy", # buy or sell
|
267
|
-
# "currency1": "XBT", # base currency
|
268
|
-
# "currency1Amount": "0.00010000", # order amount in base currency
|
269
|
-
# "currency2": "USD", # quote currency
|
270
|
-
# "currency2Amount": "0.0250530000000000", # order cost in quote currency
|
271
|
-
# "rate": "250.53000000",
|
272
|
-
# "commissionPaid": "0.00000000", # net trade fee paid after using any available rebate balance
|
273
|
-
# "commissionCurrency": "USD",
|
274
|
-
# "rebatesApplied": "-0.000125265", # negative values represent amount of rebate balance used for trades removing liquidity from order book; positive values represent amount of rebate balance earned from trades adding liquidity to order book
|
275
|
-
# "rebateCurrency": "USD",
|
276
|
-
# "executionId": "23132"
|
277
|
-
# }
|
278
|
-
#
|
279
|
-
id = self.safe_string_2(trade, 'executionId', 'matchNumber')
|
280
|
-
timestamp = self.parse8601(self.safe_string(trade, 'timestamp'))
|
281
|
-
side = self.safe_string(trade, 'direction')
|
282
|
-
orderId = self.safe_string(trade, 'orderId')
|
283
|
-
feeCost = self.safe_number(trade, 'commissionPaid')
|
284
|
-
feeCurrencyId = self.safe_string(trade, 'commissionCurrency')
|
285
|
-
feeCurrency = self.safe_currency_code(feeCurrencyId)
|
286
|
-
rebatesApplied = self.safe_number(trade, 'rebatesApplied')
|
287
|
-
if rebatesApplied is not None:
|
288
|
-
rebatesApplied = -rebatesApplied
|
289
|
-
rebateCurrencyId = self.safe_string(trade, 'rebateCurrency')
|
290
|
-
rebateCurrency = self.safe_currency_code(rebateCurrencyId)
|
291
|
-
priceString = self.safe_string_2(trade, 'price', 'rate')
|
292
|
-
amountString = self.safe_string_2(trade, 'currency1Amount', 'amount')
|
293
|
-
price = self.parse_number(priceString)
|
294
|
-
amount = self.parse_number(amountString)
|
295
|
-
cost = self.parse_number(Precise.string_mul(priceString, amountString))
|
296
|
-
symbol = None
|
297
|
-
marketId = self.safe_string(trade, 'instrument')
|
298
|
-
if marketId is not None:
|
299
|
-
baseId = self.safe_string(trade, 'currency1')
|
300
|
-
quoteId = self.safe_string(trade, 'currency2')
|
301
|
-
base = self.safe_currency_code(baseId)
|
302
|
-
quote = self.safe_currency_code(quoteId)
|
303
|
-
symbol = base + '/' + quote
|
304
|
-
result = {
|
305
|
-
'info': trade,
|
306
|
-
'id': id,
|
307
|
-
'timestamp': timestamp,
|
308
|
-
'datetime': self.iso8601(timestamp),
|
309
|
-
'symbol': symbol,
|
310
|
-
'order': orderId,
|
311
|
-
'type': None,
|
312
|
-
'side': side,
|
313
|
-
'takerOrMaker': None,
|
314
|
-
'price': price,
|
315
|
-
'amount': amount,
|
316
|
-
'cost': cost,
|
317
|
-
'fee': None,
|
318
|
-
}
|
319
|
-
if feeCost is not None:
|
320
|
-
if rebatesApplied is not None:
|
321
|
-
if feeCurrency == rebateCurrency:
|
322
|
-
feeCost = self.sum(feeCost, rebatesApplied)
|
323
|
-
result['fee'] = {
|
324
|
-
'cost': feeCost,
|
325
|
-
'currency': feeCurrency,
|
326
|
-
}
|
327
|
-
else:
|
328
|
-
result['fees'] = [
|
329
|
-
{
|
330
|
-
'cost': feeCost,
|
331
|
-
'currency': feeCurrency,
|
332
|
-
},
|
333
|
-
{
|
334
|
-
'cost': rebatesApplied,
|
335
|
-
'currency': rebateCurrency,
|
336
|
-
},
|
337
|
-
]
|
338
|
-
else:
|
339
|
-
result['fee'] = {
|
340
|
-
'cost': feeCost,
|
341
|
-
'currency': feeCurrency,
|
342
|
-
}
|
343
|
-
if not ('fee' in result):
|
344
|
-
if not ('fees' in result):
|
345
|
-
result['fee'] = None
|
346
|
-
return result
|
347
|
-
|
348
|
-
def fetch_transactions(self, code: Optional[str] = None, since: Optional[int] = None, limit: Optional[int] = None, params={}):
|
349
|
-
"""
|
350
|
-
fetch history of deposits and withdrawals
|
351
|
-
:param str|None code: not used by itbit fetchTransactions()
|
352
|
-
:param int|None since: not used by itbit fetchTransactions()
|
353
|
-
:param int|None limit: max number of transactions to return, default is None
|
354
|
-
:param dict params: extra parameters specific to the itbit api endpoint
|
355
|
-
:returns dict: a list of `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
|
356
|
-
"""
|
357
|
-
self.load_markets()
|
358
|
-
walletId = self.safe_string(params, 'walletId')
|
359
|
-
if walletId is None:
|
360
|
-
raise ArgumentsRequired(self.id + ' fetchTransactions() requires a walletId parameter')
|
361
|
-
request = {
|
362
|
-
'walletId': walletId,
|
363
|
-
}
|
364
|
-
if limit is not None:
|
365
|
-
request['perPage'] = limit # default 50, max 50
|
366
|
-
response = self.privateGetWalletsWalletIdFundingHistory(self.extend(request, params))
|
367
|
-
# {bankName: 'USBC(usd)',
|
368
|
-
# withdrawalId: 94740,
|
369
|
-
# holdingPeriodCompletionDate: '2018-04-16T07:57:05.9606869',
|
370
|
-
# time: '2018-04-16T07:57:05.9600000',
|
371
|
-
# currency: 'USD',
|
372
|
-
# transactionType: 'Withdrawal',
|
373
|
-
# amount: '2186.72000000',
|
374
|
-
# walletName: 'Wallet',
|
375
|
-
# status: 'completed'},
|
376
|
-
#
|
377
|
-
# {"time": "2018-01-02T19:52:22.4176503",
|
378
|
-
# "amount": "0.50000000",
|
379
|
-
# "status": "completed",
|
380
|
-
# "txnHash": "1b6fff67ed83cb9e9a38ca4976981fc047322bc088430508fe764a127d3ace95",
|
381
|
-
# "currency": "XBT",
|
382
|
-
# "walletName": "Wallet",
|
383
|
-
# "transactionType": "Deposit",
|
384
|
-
# "destinationAddress": "3AAWTH9et4e8o51YKp9qPpmujrNXKwHWNX"}
|
385
|
-
items = response['fundingHistory']
|
386
|
-
result = []
|
387
|
-
for i in range(0, len(items)):
|
388
|
-
item = items[i]
|
389
|
-
time = self.safe_string(item, 'time')
|
390
|
-
timestamp = self.parse8601(time)
|
391
|
-
currency = self.safe_string(item, 'currency')
|
392
|
-
destinationAddress = self.safe_string(item, 'destinationAddress')
|
393
|
-
txnHash = self.safe_string(item, 'txnHash')
|
394
|
-
transactionType = self.safe_string_lower(item, 'transactionType')
|
395
|
-
transactionStatus = self.safe_string(item, 'status')
|
396
|
-
status = self.parse_transfer_status(transactionStatus)
|
397
|
-
result.append({
|
398
|
-
'id': self.safe_string(item, 'withdrawalId'),
|
399
|
-
'timestamp': timestamp,
|
400
|
-
'datetime': self.iso8601(timestamp),
|
401
|
-
'currency': self.safe_currency_code(currency),
|
402
|
-
'address': destinationAddress,
|
403
|
-
'tag': None,
|
404
|
-
'txid': txnHash,
|
405
|
-
'type': transactionType,
|
406
|
-
'status': status,
|
407
|
-
'amount': self.safe_number(item, 'amount'),
|
408
|
-
'fee': None,
|
409
|
-
'info': item,
|
410
|
-
})
|
411
|
-
return result
|
412
|
-
|
413
|
-
def parse_transfer_status(self, status):
|
414
|
-
options = {
|
415
|
-
'cancelled': 'canceled',
|
416
|
-
'completed': 'ok',
|
417
|
-
}
|
418
|
-
return self.safe_string(options, status, 'pending')
|
419
|
-
|
420
|
-
def fetch_my_trades(self, symbol: Optional[str] = None, since: Optional[int] = None, limit: Optional[int] = None, params={}):
|
421
|
-
"""
|
422
|
-
fetch all trades made by the user
|
423
|
-
:param str|None symbol: unified market symbol
|
424
|
-
:param int|None since: the earliest time in ms to fetch trades for
|
425
|
-
:param int|None limit: the maximum number of trades structures to retrieve
|
426
|
-
:param dict params: extra parameters specific to the itbit api endpoint
|
427
|
-
:returns [dict]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
|
428
|
-
"""
|
429
|
-
self.load_markets()
|
430
|
-
walletId = self.safe_string(params, 'walletId')
|
431
|
-
if walletId is None:
|
432
|
-
raise ExchangeError(self.id + ' fetchMyTrades() requires a walletId parameter')
|
433
|
-
request = {
|
434
|
-
'walletId': walletId,
|
435
|
-
}
|
436
|
-
if since is not None:
|
437
|
-
request['rangeStart'] = self.ymdhms(since, 'T')
|
438
|
-
if limit is not None:
|
439
|
-
request['perPage'] = limit # default 50, max 50
|
440
|
-
response = self.privateGetWalletsWalletIdTrades(self.extend(request, params))
|
441
|
-
#
|
442
|
-
# {
|
443
|
-
# "totalNumberOfRecords": "2",
|
444
|
-
# "currentPageNumber": "1",
|
445
|
-
# "latestExecutionId": "332", # most recent execution at time of response
|
446
|
-
# "recordsPerPage": "50",
|
447
|
-
# "tradingHistory": [
|
448
|
-
# {
|
449
|
-
# "orderId": "248ffda4-83a0-4033-a5bb-8929d523f59f",
|
450
|
-
# "timestamp": "2015-05-11T14:48:01.9870000Z",
|
451
|
-
# "instrument": "XBTUSD",
|
452
|
-
# "direction": "buy", # buy or sell
|
453
|
-
# "currency1": "XBT", # base currency
|
454
|
-
# "currency1Amount": "0.00010000", # order amount in base currency
|
455
|
-
# "currency2": "USD", # quote currency
|
456
|
-
# "currency2Amount": "0.0250530000000000", # order cost in quote currency
|
457
|
-
# "rate": "250.53000000",
|
458
|
-
# "commissionPaid": "0.00000000", # net trade fee paid after using any available rebate balance
|
459
|
-
# "commissionCurrency": "USD",
|
460
|
-
# "rebatesApplied": "-0.000125265", # negative values represent amount of rebate balance used for trades removing liquidity from order book; positive values represent amount of rebate balance earned from trades adding liquidity to order book
|
461
|
-
# "rebateCurrency": "USD",
|
462
|
-
# "executionId": "23132"
|
463
|
-
# },
|
464
|
-
# ],
|
465
|
-
# }
|
466
|
-
#
|
467
|
-
trades = self.safe_value(response, 'tradingHistory', [])
|
468
|
-
market = None
|
469
|
-
if symbol is not None:
|
470
|
-
market = self.market(symbol)
|
471
|
-
return self.parse_trades(trades, market, since, limit)
|
472
|
-
|
473
|
-
def fetch_trades(self, symbol: str, since: Optional[int] = None, limit: Optional[int] = None, params={}):
|
474
|
-
"""
|
475
|
-
get the list of most recent trades for a particular symbol
|
476
|
-
:param str symbol: unified symbol of the market to fetch trades for
|
477
|
-
:param int|None since: timestamp in ms of the earliest trade to fetch
|
478
|
-
:param int|None limit: the maximum amount of trades to fetch
|
479
|
-
:param dict params: extra parameters specific to the itbit api endpoint
|
480
|
-
:returns [dict]: a list of `trade structures <https://docs.ccxt.com/en/latest/manual.html?#public-trades>`
|
481
|
-
"""
|
482
|
-
self.load_markets()
|
483
|
-
market = self.market(symbol)
|
484
|
-
request = {
|
485
|
-
'symbol': market['id'],
|
486
|
-
}
|
487
|
-
response = self.publicGetMarketsSymbolTrades(self.extend(request, params))
|
488
|
-
#
|
489
|
-
# {
|
490
|
-
# count: 3,
|
491
|
-
# recentTrades: [
|
492
|
-
# {
|
493
|
-
# timestamp: "2015-05-22T17:45:34.7570000Z",
|
494
|
-
# matchNumber: "5CR1JEUBBM8J",
|
495
|
-
# price: "351.45000000",
|
496
|
-
# amount: "0.00010000"
|
497
|
-
# },
|
498
|
-
# ]
|
499
|
-
# }
|
500
|
-
#
|
501
|
-
trades = self.safe_value(response, 'recentTrades', [])
|
502
|
-
return self.parse_trades(trades, market, since, limit)
|
503
|
-
|
504
|
-
def parse_balance(self, response):
|
505
|
-
balances = response[0]['balances']
|
506
|
-
result = {'info': response}
|
507
|
-
for i in range(0, len(balances)):
|
508
|
-
balance = balances[i]
|
509
|
-
currencyId = self.safe_string(balance, 'currency')
|
510
|
-
code = self.safe_currency_code(currencyId)
|
511
|
-
account = self.account()
|
512
|
-
account['free'] = self.safe_string(balance, 'availableBalance')
|
513
|
-
account['total'] = self.safe_string(balance, 'totalBalance')
|
514
|
-
result[code] = account
|
515
|
-
return self.safe_balance(result)
|
516
|
-
|
517
|
-
def fetch_balance(self, params={}):
|
518
|
-
"""
|
519
|
-
query for balance and get the amount of funds available for trading or funds locked in orders
|
520
|
-
:param dict params: extra parameters specific to the itbit api endpoint
|
521
|
-
:returns dict: a `balance structure <https://docs.ccxt.com/en/latest/manual.html?#balance-structure>`
|
522
|
-
"""
|
523
|
-
self.load_markets()
|
524
|
-
response = self.fetch_wallets(params)
|
525
|
-
return self.parse_balance(response)
|
526
|
-
|
527
|
-
def fetch_wallets(self, params={}):
|
528
|
-
self.load_markets()
|
529
|
-
if not self.uid:
|
530
|
-
raise AuthenticationError(self.id + ' fetchWallets() requires uid API credential')
|
531
|
-
request = {
|
532
|
-
'userId': self.uid,
|
533
|
-
}
|
534
|
-
return self.privateGetWallets(self.extend(request, params))
|
535
|
-
|
536
|
-
def fetch_wallet(self, walletId, params={}):
|
537
|
-
self.load_markets()
|
538
|
-
request = {
|
539
|
-
'walletId': walletId,
|
540
|
-
}
|
541
|
-
return self.privateGetWalletsWalletId(self.extend(request, params))
|
542
|
-
|
543
|
-
def fetch_open_orders(self, symbol: Optional[str] = None, since: Optional[int] = None, limit: Optional[int] = None, params={}):
|
544
|
-
"""
|
545
|
-
fetch all unfilled currently open orders
|
546
|
-
:param str|None symbol: unified market symbol
|
547
|
-
:param int|None since: the earliest time in ms to fetch open orders for
|
548
|
-
:param int|None limit: the maximum number of open orders structures to retrieve
|
549
|
-
:param dict params: extra parameters specific to the itbit api endpoint
|
550
|
-
:returns [dict]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
551
|
-
"""
|
552
|
-
request = {
|
553
|
-
'status': 'open',
|
554
|
-
}
|
555
|
-
return self.fetch_orders(symbol, since, limit, self.extend(request, params))
|
556
|
-
|
557
|
-
def fetch_closed_orders(self, symbol: Optional[str] = None, since: Optional[int] = None, limit: Optional[int] = None, params={}):
|
558
|
-
"""
|
559
|
-
fetches information on multiple closed orders made by the user
|
560
|
-
:param str|None symbol: unified market symbol of the market orders were made in
|
561
|
-
:param int|None since: the earliest time in ms to fetch orders for
|
562
|
-
:param int|None limit: the maximum number of orde structures to retrieve
|
563
|
-
:param dict params: extra parameters specific to the itbit api endpoint
|
564
|
-
:returns [dict]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
565
|
-
"""
|
566
|
-
request = {
|
567
|
-
'status': 'filled',
|
568
|
-
}
|
569
|
-
return self.fetch_orders(symbol, since, limit, self.extend(request, params))
|
570
|
-
|
571
|
-
def fetch_orders(self, symbol: Optional[str] = None, since: Optional[int] = None, limit: Optional[int] = None, params={}):
|
572
|
-
"""
|
573
|
-
fetches information on multiple orders made by the user
|
574
|
-
:param str|None symbol: unified market symbol of the market orders were made in
|
575
|
-
:param int|None since: the earliest time in ms to fetch orders for
|
576
|
-
:param int|None limit: the maximum number of orde structures to retrieve
|
577
|
-
:param dict params: extra parameters specific to the itbit api endpoint
|
578
|
-
:returns [dict]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
579
|
-
"""
|
580
|
-
self.load_markets()
|
581
|
-
market = None
|
582
|
-
if symbol is not None:
|
583
|
-
market = self.market(symbol)
|
584
|
-
walletIdInParams = ('walletId' in params)
|
585
|
-
if not walletIdInParams:
|
586
|
-
raise ExchangeError(self.id + ' fetchOrders() requires a walletId parameter')
|
587
|
-
walletId = params['walletId']
|
588
|
-
request = {
|
589
|
-
'walletId': walletId,
|
590
|
-
}
|
591
|
-
response = self.privateGetWalletsWalletIdOrders(self.extend(request, params))
|
592
|
-
return self.parse_orders(response, market, since, limit)
|
593
|
-
|
594
|
-
def parse_order_status(self, status):
|
595
|
-
statuses = {
|
596
|
-
'submitted': 'open', # order pending book entry
|
597
|
-
'open': 'open',
|
598
|
-
'filled': 'closed',
|
599
|
-
'cancelled': 'canceled',
|
600
|
-
'rejected': 'canceled',
|
601
|
-
}
|
602
|
-
return self.safe_string(statuses, status, status)
|
603
|
-
|
604
|
-
def parse_order(self, order, market=None):
|
605
|
-
#
|
606
|
-
# {
|
607
|
-
# "id": "13d6af57-8b0b-41e5-af30-becf0bcc574d",
|
608
|
-
# "walletId": "7e037345-1288-4c39-12fe-d0f99a475a98",
|
609
|
-
# "side": "buy",
|
610
|
-
# "instrument": "XBTUSD",
|
611
|
-
# "type": "limit",
|
612
|
-
# "currency": "XBT",
|
613
|
-
# "amount": "2.50000000",
|
614
|
-
# "displayAmount": "2.50000000",
|
615
|
-
# "price": "650.00000000",
|
616
|
-
# "volumeWeightedAveragePrice": "0.00000000",
|
617
|
-
# "amountFilled": "0.00000000",
|
618
|
-
# "createdTime": "2014-02-11T17:05:15Z",
|
619
|
-
# "status": "submitted",
|
620
|
-
# "funds": null,
|
621
|
-
# "metadata": {},
|
622
|
-
# "clientOrderIdentifier": null,
|
623
|
-
# "postOnly": "False"
|
624
|
-
# }
|
625
|
-
#
|
626
|
-
side = self.safe_string(order, 'side')
|
627
|
-
type = self.safe_string(order, 'type')
|
628
|
-
marketId = self.safe_string(order, 'instrument')
|
629
|
-
symbol = self.safe_symbol(marketId, market)
|
630
|
-
datetime = self.safe_string(order, 'createdTime')
|
631
|
-
timestamp = self.parse8601(datetime)
|
632
|
-
amount = self.safe_string(order, 'amount')
|
633
|
-
filled = self.safe_string(order, 'amountFilled')
|
634
|
-
fee = None
|
635
|
-
price = self.safe_string(order, 'price')
|
636
|
-
average = self.safe_string(order, 'volumeWeightedAveragePrice')
|
637
|
-
clientOrderId = self.safe_string(order, 'clientOrderIdentifier')
|
638
|
-
id = self.safe_string(order, 'id')
|
639
|
-
postOnlyString = self.safe_string(order, 'postOnly')
|
640
|
-
postOnly = (postOnlyString == 'True')
|
641
|
-
return self.safe_order({
|
642
|
-
'id': id,
|
643
|
-
'clientOrderId': clientOrderId,
|
644
|
-
'info': order,
|
645
|
-
'timestamp': timestamp,
|
646
|
-
'datetime': self.iso8601(timestamp),
|
647
|
-
'lastTradeTimestamp': None,
|
648
|
-
'status': self.parse_order_status(self.safe_string(order, 'status')),
|
649
|
-
'symbol': symbol,
|
650
|
-
'type': type,
|
651
|
-
'timeInForce': None,
|
652
|
-
'postOnly': postOnly,
|
653
|
-
'side': side,
|
654
|
-
'price': price,
|
655
|
-
'stopPrice': None,
|
656
|
-
'triggerPrice': None,
|
657
|
-
'cost': None,
|
658
|
-
'average': average,
|
659
|
-
'amount': amount,
|
660
|
-
'filled': filled,
|
661
|
-
'remaining': None,
|
662
|
-
'fee': fee,
|
663
|
-
# 'trades': self.parse_trades(order['trades'], market),
|
664
|
-
'trades': None,
|
665
|
-
}, market)
|
666
|
-
|
667
|
-
def nonce(self):
|
668
|
-
return self.milliseconds()
|
669
|
-
|
670
|
-
def create_order(self, symbol: str, type, side: OrderSide, amount, price=None, params={}):
|
671
|
-
"""
|
672
|
-
create a trade order
|
673
|
-
see https://api.itbit.com/docs#trading-new-order-post
|
674
|
-
:param str symbol: unified symbol of the market to create an order in
|
675
|
-
:param str type: must be 'limit'
|
676
|
-
:param str side: 'buy' or 'sell'
|
677
|
-
:param float amount: how much of currency you want to trade in units of base currency
|
678
|
-
:param float|None price: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
679
|
-
:param dict params: extra parameters specific to the itbit api endpoint
|
680
|
-
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
681
|
-
"""
|
682
|
-
self.load_markets()
|
683
|
-
if type == 'market':
|
684
|
-
raise ExchangeError(self.id + ' createOrder() allows limit orders only')
|
685
|
-
walletIdInParams = ('walletId' in params)
|
686
|
-
if not walletIdInParams:
|
687
|
-
raise ExchangeError(self.id + ' createOrder() requires a walletId parameter')
|
688
|
-
amount = str(amount)
|
689
|
-
price = str(price)
|
690
|
-
market = self.market(symbol)
|
691
|
-
request = {
|
692
|
-
'side': side,
|
693
|
-
'type': type,
|
694
|
-
'currency': market['id'].replace(market['quote'], ''),
|
695
|
-
'amount': amount,
|
696
|
-
'display': amount,
|
697
|
-
'price': price,
|
698
|
-
'instrument': market['id'],
|
699
|
-
}
|
700
|
-
response = self.privatePostWalletsWalletIdOrders(self.extend(request, params))
|
701
|
-
return self.safe_order({
|
702
|
-
'info': response,
|
703
|
-
'id': response['id'],
|
704
|
-
}, market)
|
705
|
-
|
706
|
-
def fetch_order(self, id: str, symbol: Optional[str] = None, params={}):
|
707
|
-
"""
|
708
|
-
fetches information on an order made by the user
|
709
|
-
:param str|None symbol: not used by itbit fetchOrder
|
710
|
-
:param dict params: extra parameters specific to the itbit api endpoint
|
711
|
-
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
712
|
-
"""
|
713
|
-
self.load_markets()
|
714
|
-
walletIdInParams = ('walletId' in params)
|
715
|
-
if not walletIdInParams:
|
716
|
-
raise ExchangeError(self.id + ' fetchOrder() requires a walletId parameter')
|
717
|
-
request = {
|
718
|
-
'id': id,
|
719
|
-
}
|
720
|
-
response = self.privateGetWalletsWalletIdOrdersId(self.extend(request, params))
|
721
|
-
return self.parse_order(response)
|
722
|
-
|
723
|
-
def cancel_order(self, id: str, symbol: Optional[str] = None, params={}):
|
724
|
-
"""
|
725
|
-
cancels an open order
|
726
|
-
:param str id: order id
|
727
|
-
:param str|None symbol: unified symbol of the market the order was made in
|
728
|
-
:param dict params: extra parameters specific to the itbit api endpoint
|
729
|
-
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
730
|
-
"""
|
731
|
-
walletIdInParams = ('walletId' in params)
|
732
|
-
if not walletIdInParams:
|
733
|
-
raise ExchangeError(self.id + ' cancelOrder() requires a walletId parameter')
|
734
|
-
request = {
|
735
|
-
'id': id,
|
736
|
-
}
|
737
|
-
return self.privateDeleteWalletsWalletIdOrdersId(self.extend(request, params))
|
738
|
-
|
739
|
-
def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
|
740
|
-
url = self.urls['api']['rest'] + '/' + self.version + '/' + self.implode_params(path, params)
|
741
|
-
query = self.omit(params, self.extract_params(path))
|
742
|
-
if method == 'GET' and query:
|
743
|
-
url += '?' + self.urlencode(query)
|
744
|
-
if method == 'POST' and query:
|
745
|
-
body = self.json(query)
|
746
|
-
if api == 'private':
|
747
|
-
self.check_required_credentials()
|
748
|
-
nonce = str(self.nonce())
|
749
|
-
timestamp = nonce
|
750
|
-
authBody = body if (method == 'POST') else ''
|
751
|
-
auth = [method, url, authBody, nonce, timestamp]
|
752
|
-
message = nonce + self.json(auth) # .replace('\\/', '/')
|
753
|
-
hash = self.hash(self.encode(message), 'sha256', 'binary')
|
754
|
-
binaryUrl = self.encode(url)
|
755
|
-
binhash = self.binary_concat(binaryUrl, hash)
|
756
|
-
signature = self.hmac(binhash, self.encode(self.secret), hashlib.sha512, 'base64')
|
757
|
-
headers = {
|
758
|
-
'Authorization': self.apiKey + ':' + signature,
|
759
|
-
'Content-Type': 'application/json',
|
760
|
-
'X-Auth-Timestamp': timestamp,
|
761
|
-
'X-Auth-Nonce': nonce,
|
762
|
-
}
|
763
|
-
return {'url': url, 'method': method, 'body': body, 'headers': headers}
|
764
|
-
|
765
|
-
def handle_errors(self, httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody):
|
766
|
-
if response is None:
|
767
|
-
return None
|
768
|
-
code = self.safe_string(response, 'code')
|
769
|
-
if code is not None:
|
770
|
-
raise ExchangeError(self.id + ' ' + self.json(response))
|
771
|
-
return None
|