def withdraw(self, code, amount, address, tag=None, params={}): self.check_address(address) if self.is_fiat(code): raise NotSupported(self.id + ' fiat withdraw() for ' + code + ' is not implemented yet') name = self.get_currency_name(code) request = { 'amount': amount, 'address': address, } v1 = (code == 'BTC') method = 'v1' if v1 else 'private' # v1 or v2 method += 'Post' + self.capitalize(name) + 'Withdrawal' query = params if code == 'XRP': if tag is not None: request['destination_tag'] = tag query = self.omit(params, 'destination_tag') else: raise ExchangeError( self.id + ' withdraw() requires a destination_tag param for ' + code) response = getattr(self, method)(self.extend(request, query)) return { 'info': response, 'id': response['id'], }
async def fetch_ticker(self, symbol, params={}): if symbol != 'BTC/JPY': raise NotSupported(self.id + ' fetchTicker() supports BTC/JPY only') ticker = await self.publicGetTicker(params) timestamp = ticker['timestamp'] * 1000 last = float(ticker['last']) return { 'symbol': symbol, 'timestamp': timestamp, 'datetime': self.iso8601(timestamp), 'high': float(ticker['high']), 'low': float(ticker['low']), 'bid': float(ticker['bid']), 'bidVolume': None, 'ask': float(ticker['ask']), 'askVolume': None, 'vwap': None, 'open': None, 'close': last, 'last': last, 'previousClose': None, 'change': None, 'percentage': None, 'average': None, 'baseVolume': float(ticker['volume']), 'quoteVolume': None, 'info': ticker, }
async def deposit(self, currency, amount, address, params={}): await self.load_markets() request = { 'currency': currency, 'amount': amount, } method = 'privatePostDeposits' if 'payment_method_id' in params: # deposit from a payment_method, like a bank account method += 'PaymentMethod' elif 'coinbase_account_id' in params: # deposit into GDAX account from a Coinbase account method += 'CoinbaseAccount' else: # deposit methodotherwise we did not receive a supported deposit location # relevant docs link for the Googlers # https://docs.gdax.com/#deposits raise NotSupported( self.id + ' deposit() requires one of `coinbase_account_id` or `payment_method_id` extra params' ) response = await getattr(self, method)(self.extend(request, params)) if not response: raise ExchangeError(self.id + ' deposit() error: ' + self.json(response)) return { 'info': response, 'id': response['id'], }
async def create_order(self, symbol, type, side, amount, price=None, params={}): raise NotSupported(self.id + ' createOrder not implemented yet')
def fetch_closed_orders(self, symbol=None, since=None, limit=None, params={}): self.load_markets() method = 'privatePostArchivedOrdersPair' if symbol is None: raise NotSupported(self.id + ' fetchClosedOrders requires a symbol argument') market = self.market(symbol) request = {'pair': market['id']} response = getattr(self, method)(self.extend(request, params)) return self.parse_orders(response, market, since, limit)
def fetch_orders(self, symbol=None, since=None, limit=None, params={}): if not symbol: raise NotSupported(self.id + ': fetchOrders requires a `symbol` parameter.') self.load_markets() market = self.market(symbol) request = self.prepare_history_request(market, since, limit) response = self.privatePostOrderHistory(self.extend(request, params)) return self.parse_orders(response['orders'], market)
async def fetch_open_orders(self, symbol=None, since=None, limit=None, params={}): if not symbol: raise NotSupported(self.id + ' fetchOpenOrders requires a symbol param') await self.load_markets() market = self.market(symbol) orders = await self.privatePostIdOpenOrders({ 'id': market['id'], }) for i in range(0, len(orders)): # Coinfloor open orders would always be limit orders orders[i] = self.extend(orders[i], {'status': 'open'}) return self.parse_orders(orders, market, since, limit)
def fetch_trades(self, symbol, since=None, limit=None, params={}): if symbol != 'BTC/JPY': raise NotSupported(self.id + ' fetchTrades() supports BTC/JPY only') market = self.market(symbol) response = self.publicGetTrades(self.extend({ 'pair': market['id'], }, params)) if 'success' in response: if response['success']: if response['data'] is not None: return self.parse_trades(response['data'], market, since, limit) raise ExchangeError(self.id + ' ' + self.json(response))
async def fetch_my_trades(self, symbol=None, since=None, limit=None, params={}): if not symbol: raise NotSupported( self.id + ': fetchMyTrades requires a `symbol` parameter.') await self.load_markets() market = self.market(symbol) request = self.prepare_history_request(market, since, limit) response = await self.privatePostOrderTradeHistory( self.extend(request, params)) return self.parse_my_trades(response['trades'], market)
def withdraw(self, currency, amount, address, tag=None, params={}): self.check_address(address) self.load_markets() if currency != 'BTC': # they did not document other types... raise NotSupported(self.id + ' currently supports BTC withdrawals only, until they document other currencies...') response = self.privatePostWithdraw(self.extend({ 'currency': currency.lower(), 'amount': float(amount), 'account': address, 'payment_method': 'bitcoin', # they did not document other types... }, params)) return { 'info': response, 'id': response['message_id'], }
def get_currency_name(self, currency): names = { 'AID': 'aid', 'AVT': 'aventus', # #1811 'BAT': 'bat', 'BCH': 'bcash', # undocumented 'BTC': 'bitcoin', 'BTG': 'bgold', 'DASH': 'dash', 'DATA': 'datacoin', 'EDO': 'eidoo', # #1811 'ELF': 'elf', 'EOS': 'eos', 'ETC': 'ethereumc', 'ETH': 'ethereum', 'FUN': 'fun', 'GNT': 'golem', 'IOTA': 'iota', 'LTC': 'litecoin', 'MANA': 'mna', 'NEO': 'neo', # #1811 'OMG': 'omisego', 'OMNI': 'mastercoin', 'QASH': 'qash', 'QTUM': 'qtum', # #1811 'RCN': 'rcn', 'REP': 'rep', 'RLC': 'rlc', 'SAN': 'santiment', 'SNGLS': 'sng', 'SNT': 'status', 'SPANK': 'spk', 'TNB': 'tnb', 'TRX': 'trx', 'USD': 'wire', 'USDT': 'tetheruso', # undocumented 'XMR': 'monero', 'XRP': 'ripple', 'YOYOW': 'yoyow', 'ZEC': 'zcash', 'ZRX': 'zrx', } if currency in names: return names[currency] raise NotSupported(self.id + ' ' + currency + ' not supported for withdrawal')
def fetch_deposit_address(self, code, params={}): if code == 'XRP': # https://github.com/anyex/anyex/pull/2327#issuecomment-375204856 raise NotSupported(self.id + ' fetchDepositAddress does not support XRP addresses yet(awaiting docs from CEX.io)') self.load_markets() currency = self.currency(code) request = { 'currency': currency['id'], } response = self.privatePostGetAddress(self.extend(request, params)) address = self.safe_string(response, 'data') self.check_address(address) return { 'currency': code, 'address': address, 'tag': None, 'status': 'ok', 'info': response, }
async def fetch_deposit_address(self, code, params={}): if self.is_fiat(code): raise NotSupported(self.id + ' fiat fetchDepositAddress() for ' + code + ' is not implemented yet') name = self.get_currency_name(code) v1 = (code == 'BTC') method = 'v1' if v1 else 'private' # v1 or v2 method += 'Post' + self.capitalize(name) method += 'Deposit' if v1 else '' method += 'Address' response = await getattr(self, method)(params) address = response if v1 else self.safe_string(response, 'address') tag = None if v1 else self.safe_string(response, 'destination_tag') self.check_address(address) return { 'currency': code, 'status': 'ok', 'address': address, 'tag': tag, 'info': response, }
async def fetch_ohlcv(self, symbol, timeframe='1m', since=None, limit=None, params={}): # minutes = int(timeframe / 60) # 1 minute by default # periodicity = str(minutes) # await self.load_markets() # market = self.market(symbol) # if not since: # since = self.seconds() - 86400 * 7 # last day by defulat # if not limit: # limit = 1000 # default # response = await self.privateGetQuotehistorySymbolPeriodicityBarsBid(self.extend({ # 'symbol': market['id'], # 'periodicity': periodicity, # 'timestamp': since, # 'count': limit, # }, params)) # return self.parse_ohlcvs(response['Bars'], market, timeframe, since, limit) raise NotSupported(self.id + ' fetchOHLCV is disabled by the exchange')
def fetch_trades(self, symbol): raise NotSupported(self.id + ' fetchTrades() method not implemented yet')
def sign(self, path, api='public', method='GET', params={}, headers=None, body=None): raise NotSupported(self.id + ' sign() pure method must be redefined in derived classes')
def cancel_order(self, id, symbol=None, params={}): self.load_markets() # method = 'privateDeleteUserExchangeAskCancelOrderId' # TODO fixme, have to specify order side here # return getattr(self, method)({'orderID': id}) raise NotSupported(self.id + ' cancelOrder() is not fully implemented yet')
async def fetch_order_book(self, symbol, limit=None, params={}): if symbol != 'BTC/JPY': raise NotSupported(self.id + ' fetchOrderBook() supports BTC/JPY only') orderbook = await self.publicGetOrderBooks(params) return self.parse_order_book(orderbook)
async def perform_order_book_request(self, market, limit=None, params={}): raise NotSupported(self.id + ' performOrderBookRequest not supported yet')
def withdraw(self, currency, amount, address, tag=None, params={}): raise NotSupported(self.id + ' withdraw not implemented yet')
def fetch_deposit_address(self, currency, params={}): raise NotSupported(self.id + ' fetchDepositAddress() not implemented yet.')
def fetch_order(self, id, symbol=None, params={}): raise NotSupported(self.id + ' fetchOrder is not implemented yet')
def cancel_order(self, id, symbol=None, params={}): raise NotSupported(self.id + ' cancelOrder not implemented yet')