예제 #1
0
 async def fetch_order_book(self, symbol, limit=None, params={}):
     if symbol != 'BTC/JPY':
         raise BadSymbol(self.id +
                         ' fetchOrderBook() supports BTC/JPY only')
     await self.load_markets()
     response = await self.publicGetOrderBooks(params)
     return self.parse_order_book(response)
예제 #2
0
 async def fetch_ticker(self, symbol, params={}):
     if symbol != 'BTC/JPY':
         raise BadSymbol(self.id + ' fetchTicker() supports BTC/JPY only')
     await self.load_markets()
     ticker = await self.publicGetTicker(params)
     timestamp = self.safe_timestamp(ticker, 'timestamp')
     last = self.safe_float(ticker, 'last')
     return {
         'symbol': symbol,
         'timestamp': timestamp,
         'datetime': self.iso8601(timestamp),
         'high': self.safe_float(ticker, 'high'),
         'low': self.safe_float(ticker, 'low'),
         'bid': self.safe_float(ticker, 'bid'),
         'bidVolume': None,
         'ask': self.safe_float(ticker, 'ask'),
         'askVolume': None,
         'vwap': None,
         'open': None,
         'close': last,
         'last': last,
         'previousClose': None,
         'change': None,
         'percentage': None,
         'average': None,
         'baseVolume': self.safe_float(ticker, 'volume'),
         'quoteVolume': None,
         'info': ticker,
     }
예제 #3
0
 def fetch_ticker(self, symbol, params={}):
     if symbol != 'BTC/JPY':
         raise BadSymbol(self.id + ' fetchTicker() supports BTC/JPY only')
     self.load_markets()
     market = self.market(symbol)
     request = {
         'pair': market['id'],
     }
     ticker = self.publicGetTicker(self.extend(request, params))
     timestamp = self.safe_timestamp(ticker, 'timestamp')
     last = self.safe_number(ticker, 'last')
     return {
         'symbol': symbol,
         'timestamp': timestamp,
         'datetime': self.iso8601(timestamp),
         'high': self.safe_number(ticker, 'high'),
         'low': self.safe_number(ticker, 'low'),
         'bid': self.safe_number(ticker, 'bid'),
         'bidVolume': None,
         'ask': self.safe_number(ticker, 'ask'),
         'askVolume': None,
         'vwap': None,
         'open': None,
         'close': last,
         'last': last,
         'previousClose': None,
         'change': None,
         'percentage': None,
         'average': None,
         'baseVolume': self.safe_number(ticker, 'volume'),
         'quoteVolume': None,
         'info': ticker,
     }
예제 #4
0
 def fetch_ticker(self, symbol):
     ohlcv = self._ohlcvs.get(symbol)
     if ohlcv is None:
         raise BadSymbol('ExchangeBackend: no prices for {}'.format(symbol))
     current_date = self._timeframe.date().floor('1T')
     row = ohlcv.loc[current_date]
     timestamp = int(current_date.value / 10**6)
     return {
         'symbol': symbol,
         'timestamp': timestamp,
         'datetime': Exchange.iso8601(timestamp),
         'high': row['high'],
         'low': row['low'],
         'bid': None,
         'bidVolume': None,
         'ask': None,
         'askVolume': None,
         'vwap': None,
         'open': row['open'],
         'close': row['close'],
         'last': None,
         'previousClose': None,
         'change': None,
         'percentage': None,
         'average': None,
         'baseVolume': None,
         'quoteVolume': None,
         'info': {},
     }
예제 #5
0
 def parse_symbol_id_joined(self, symbolId):
     # Convert by detecting and converting currencies in symbol
     symbolIdLower = symbolId.lower()
     quoteIds = self.options['symbol']['quoteIds']
     reversed = self.options['symbol']['reversed']
     method = 'startsWith' if reversed else 'endsWith'
     quoteId = None
     baseId = None
     for i in range(0, len(quoteIds)):
         if getattr(self, method)(symbolIdLower, quoteIds[i].lower()):
             quoteId = quoteIds[i]
             break
     if quoteId is None:
         raise BadSymbol(self.id + ' symbolId could not be parsed: ' +
                         symbolId)
     if not reversed:
         baseIdLength = len(symbolId) - len(quoteId)
         baseId = self.slice_string(symbolId, 0, baseIdLength)
         quoteId = self.slice_string(symbolId, baseIdLength)
     else:
         quoteId = self.slice_string(symbolId, 0, len(quoteId))
         baseId = self.slice_string(symbolId, len(quoteId))
     return {
         'baseId': baseId,
         'quoteId': quoteId,
         'base': self.safe_currency_code(baseId),
         'quote': self.safe_currency_code(quoteId),
     }
예제 #6
0
 def fetch_ticker(self, symbol, params={}):
     """
     fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
     :param str symbol: unified symbol of the market to fetch the ticker for
     :param dict params: extra parameters specific to the coincheck api endpoint
     :returns dict: a `ticker structure <https://docs.ccxt.com/en/latest/manual.html#ticker-structure>`
     """
     if symbol != 'BTC/JPY':
         raise BadSymbol(self.id + ' fetchTicker() supports BTC/JPY only')
     self.load_markets()
     market = self.market(symbol)
     request = {
         'pair': market['id'],
     }
     ticker = self.publicGetTicker(self.extend(request, params))
     #
     # {
     #     "last":4192632.0,
     #     "bid":4192496.0,
     #     "ask":4193749.0,
     #     "high":4332000.0,
     #     "low":4101047.0,
     #     "volume":2313.43191762,
     #     "timestamp":1643374115
     # }
     #
     return self.parse_ticker(ticker, market)
예제 #7
0
 def fetch_trades(self, symbol, since=None, limit=None, params={}):
     if symbol != 'BTC/USD':
         raise BadSymbol(self.id + ' ' + self.version + " fetchTrades doesn't support " + symbol + ', use it for BTC/USD only')
     self.load_markets()
     market = self.market(symbol)
     request = {
         'time': 'minute',
     }
     response = self.publicGetTransactions(self.extend(request, params))
     return self.parse_trades(response, market, since, limit)
예제 #8
0
파일: exchange.py 프로젝트: lfern/ccxt
 async def fetch_ticker(self, symbol, params={}):
     if self.has['fetchTickers']:
         tickers = await self.fetch_tickers([symbol], params)
         ticker = self.safe_value(tickers, symbol)
         if ticker is None:
             raise BadSymbol(self.id + ' fetchTickers could not find a ticker for ' + symbol)
         else:
             return ticker
     else:
         raise NotSupported(self.id + ' fetchTicker not supported yet')
예제 #9
0
 async def fetch_trades(self, symbol, since=None, limit=None, params={}):
     if symbol != 'BTC/JPY':
         raise BadSymbol(self.id + ' fetchTrades() supports BTC/JPY only')
     await self.load_markets()
     market = self.market(symbol)
     request = {
         'pair': market['id'],
     }
     if limit is not None:
         request['limit'] = limit
     response = await self.publicGetTrades(self.extend(request, params))
     data = self.safe_value(response, 'data', [])
     return self.parse_trades(data, market, since, limit)
예제 #10
0
 def fetch_trades(self, symbol, since=None, limit=None, params={}):
     """
     get the list of most recent trades for a particular symbol
     :param str symbol: unified symbol of the market to fetch trades for
     :param int|None since: timestamp in ms of the earliest trade to fetch
     :param int|None limit: the maximum amount of trades to fetch
     :param dict params: extra parameters specific to the bitstamp1 api endpoint
     :returns [dict]: a list of `trade structures <https://docs.ccxt.com/en/latest/manual.html?#public-trades>`
     """
     if symbol != 'BTC/USD':
         raise BadSymbol(self.id + ' ' + self.version + " fetchTrades doesn't support " + symbol + ', use it for BTC/USD only')
     self.load_markets()
     market = self.market(symbol)
     request = {
         'time': 'minute',
     }
     response = self.publicGetTransactions(self.extend(request, params))
     return self.parse_trades(response, market, since, limit)
예제 #11
0
 def fetch_ohlcv_dataframe(self,
                           symbol,
                           timeframe='1m',
                           since=None,
                           limit=None,
                           params={}):
     # Exchanges in the real world have different behaviour, when there is
     # no since parameter provided. (some use data from the beginning,
     # some from the end)
     # We return data from the beginning, because this is most likely not
     # what the user wants, so this will force the user to provide the
     # parameters, which will work with every exchange. This is a bug
     # prevention mechanism.
     ohlcv = self._ohlcvs.get(symbol)
     if ohlcv is None:
         raise BadSymbol('ExchangeBackend: no prices for {}'.format(symbol))
     pd_current_date = self._timeframe.date().floor('1T')
     if limit is None:
         limit = 5
     timeframe_sec = Exchange.parse_timeframe(timeframe)
     pd_timeframe = pandas.Timedelta(timeframe_sec, unit='s')
     ohlcv_start_date = ohlcv.index[0]
     if since is None:
         pd_since = ohlcv_start_date
     else:
         pd_since = pandas.Timestamp(since, unit='ms', tz='UTC')
     pd_since = pd_since.ceil(pd_timeframe)
     if pd_since < ohlcv_start_date:
         raise BadRequest('ExchangeBackend: fetch_ohlcv: no date availabe '
                          'at since')
     pd_until = pd_since + limit * pd_timeframe - pandas.Timedelta('1m')
     if pd_until >= pd_current_date + pd_timeframe:
         raise BadRequest('ExchangeBackend: fetch_ohlcv:'
                          ' since.ceil(timeframe) + limit * timeframe'
                          ' needs to be in the past')
     pd_until = min(pd_until, pd_current_date)
     data = ohlcv[pd_since:pd_until]
     return data.resample(pd_timeframe).agg({
         'open': 'first',
         'high': 'max',
         'low': 'min',
         'close': 'last',
         'volume': 'sum'
     })
예제 #12
0
 def fetch_ticker(self, symbol, params={}):
     if symbol != 'BTC/JPY':
         raise BadSymbol(self.id + ' fetchTicker() supports BTC/JPY only')
     self.load_markets()
     market = self.market(symbol)
     request = {
         'pair': market['id'],
     }
     ticker = self.publicGetTicker(self.extend(request, params))
     #
     # {
     #     "last":4192632.0,
     #     "bid":4192496.0,
     #     "ask":4193749.0,
     #     "high":4332000.0,
     #     "low":4101047.0,
     #     "volume":2313.43191762,
     #     "timestamp":1643374115
     # }
     #
     return self.parse_ticker(ticker, market)
예제 #13
0
    def fetch_open_orders(self,
                          symbol=None,
                          since=None,
                          limit=None,
                          params={}):
        if not symbol:
            raise BadSymbol('symbol is required')

        self.load_markets()

        request = dict()

        market = self.market(symbol)
        request['market'] = market['id']

        if limit:
            request['limit'] = limit

        raw_orders = self.privateV4PostOrders(self.extend(request, params))

        return self.parse_orders(raw_orders, market, since, limit)
예제 #14
0
파일: bitbns.py 프로젝트: LANSHER/ccxt-1
 def fetch_ticker(self, symbol, params={}):
     tickers = self.fetch_tickers(None, params)
     if symbol in tickers:
         return tickers[symbol]
     raise BadSymbol(self.id + ' fetchTicker() symbol ' + symbol + ' ticker not found')
예제 #15
0
파일: equos.py 프로젝트: kyting/ccxt
 def get_currency_by_code(self, code):
     currency = self.currencies[code]
     if currency is None:
         raise BadSymbol(self.id + ': code ' + code + ' is not listed')
     return currency