diff --git a/docs/source/readers/crypto.rst b/docs/source/readers/crypto.rst new file mode 100644 index 00000000..eeb991f5 --- /dev/null +++ b/docs/source/readers/crypto.rst @@ -0,0 +1,8 @@ +Cryptocurrency Data Reader +-------------------------- + +.. py:module:: pandas_datareader.crypto + +.. autoclass:: CryptoReader + :members: + :inherited-members: read \ No newline at end of file diff --git a/docs/source/readers/index.rst b/docs/source/readers/index.rst index 310f4175..129be57b 100644 --- a/docs/source/readers/index.rst +++ b/docs/source/readers/index.rst @@ -22,3 +22,4 @@ Data Readers tsp world-bank yahoo + crypto diff --git a/docs/source/remote_data.rst b/docs/source/remote_data.rst index 70793d62..5e6ab3c0 100644 --- a/docs/source/remote_data.rst +++ b/docs/source/remote_data.rst @@ -44,6 +44,7 @@ Currently the following sources are supported: - :ref:`Tiingo` - :ref:`World Bank` - :ref:`Yahoo Finance` + - :ref:`Cryptocurrency Data` It should be noted, that various sources support different kinds of data, so not all sources implement the same methods and the data elements returned might also differ. @@ -762,3 +763,106 @@ The following endpoints are available: dividends = web.DataReader('IBM', 'yahoo-dividends', start, end) dividends.head() + + +.. _remote_data.crypto: + +Cryptocurrency Data +=================== + +Access historical data feed from the most popular and liquid exchanges, data aggregating platforms, and return OHLCV candles. +Platforms such as ``Coingecko`` or ``Coinpaprika`` return in addition the global turnover volume and market capitalization. + +The ``CryptoReader`` offers helpful methods to print all supported exchanges/platforms and their listed +currency-pairs: + +.. ipython:: python + + from pandas_datareader.crypto import CryptoReader + CryptoReader.get_all_exchanges() + + ['50x', + 'alterdice', + ...] + +And, if an exchange is selected but the supported cryptocurrency pairs are unknown: + +.. ipython:: python + + Reader = CryptoReader(exchange_name="coinbase") + Reader.get_currency_pairs() + + Exchange Base Quote + 0 COINBASE SUPER USDT + 1 COINBASE COMP USD + 2 COINBASE COVAL USD + 3 COINBASE GTC USD + 4 COINBASE ATOM BTC + .. ... ... ... + 399 COINBASE TRB BTC + 400 COINBASE GRT USD + 401 COINBASE BICO USD + 402 COINBASE FET USD + 403 COINBASE ORN USD + +The CryptoReader class takes the following arguments: + +* ``symbols`` - the currency-pair of interest +* ``exchange_name`` - the name of the exchange or platform +* ``start`` - start date +* ``end`` - end date +* ``interval`` - the candle interval (e.g. "minutes", "hours", "days") +* ``**kwargs`` - Additional arguments passes to the parent classes + +There are several ways to retrieve cryptocurrency data, with identical arguments: + +.. ipython:: python + + import pandas_datareader.data as web + web.DataReader(...) + + import pandas_datareader as pdr + pdr.get_data_crypto(...) + + from pandas_datareader.crypto import CryptoReader + Reader = CryptoReader(...) + Reader.read() + +.. ipython:: python + + import pandas_datareader.data as web + + df = web.DataReader("btc-usd", "coinbase") + df.head() + open high low close volume + time + 2015-07-20 23:59:59+00:00 277.98 280.00 277.37 280.00 782.883420 + 2015-07-21 23:59:59+00:00 279.96 281.27 276.85 277.32 4943.559434 + 2015-07-22 23:59:59+00:00 277.33 278.54 275.01 277.89 4687.909383 + 2015-07-23 23:59:59+00:00 277.96 279.75 276.28 277.39 5306.919575 + 2015-07-24 23:59:59+00:00 277.23 291.52 276.43 289.12 7362.469083 + +Additionally, the ``CryptoReader`` can be used directly: + +.. ipython:: python + + from pandas_datareader.crypto import CryptoReader + + reader = CryptoReader("eth-usd", "coinbase", interval="minutes", start="2021-10-01", end="2021-10-02") + df = reader.read() + print(df) + + open high low close volume + time + 2021-10-01 00:00:59+00:00 3001.14 3001.42 2998.49 2999.89 100.564601 + 2021-10-01 00:01:59+00:00 2999.67 3005.99 2999.67 3005.99 91.007463 + 2021-10-01 00:02:59+00:00 3006.00 3015.14 3001.83 3014.67 494.276213 + 2021-10-01 00:03:59+00:00 3015.13 3020.19 3011.47 3020.19 174.329287 + 2021-10-01 00:04:59+00:00 3019.60 3026.60 3015.58 3024.96 131.651872 + ... ... ... ... ... + 2021-10-01 23:55:59+00:00 3305.32 3307.15 3301.70 3306.91 49.974808 + 2021-10-01 23:56:59+00:00 3306.90 3308.94 3306.05 3307.74 24.950854 + 2021-10-01 23:57:59+00:00 3308.18 3309.99 3307.31 3309.66 28.768391 + 2021-10-01 23:58:59+00:00 3309.97 3311.25 3308.18 3311.23 131.851763 + 2021-10-01 23:59:59+00:00 3311.23 3311.72 3308.70 3311.16 72.940978 + [1444 rows x 5 columns] diff --git a/pandas_datareader/__init__.py b/pandas_datareader/__init__.py index a792a806..6c9dbdf7 100644 --- a/pandas_datareader/__init__.py +++ b/pandas_datareader/__init__.py @@ -28,6 +28,7 @@ get_records_iex, get_summary_iex, get_tops_iex, + get_data_crypto, ) PKG = os.path.dirname(__file__) @@ -62,6 +63,7 @@ "get_data_tiingo", "get_iex_data_tiingo", "get_data_alphavantage", + "get_data_crypto", "test", ] diff --git a/pandas_datareader/crypto.py b/pandas_datareader/crypto.py new file mode 100644 index 00000000..21144f53 --- /dev/null +++ b/pandas_datareader/crypto.py @@ -0,0 +1,237 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from typing import Dict, List, Union, Optional + +import warnings +from abc import ABC +from sys import stdout +import pandas as pd +import time +from datetime import datetime +import pytz +import requests.exceptions + +from pandas_datareader.crypto_utils.exchange import Exchange +from pandas_datareader.crypto_utils.utilities import get_exchange_names +from pandas_datareader.crypto_utils.utilities import sort_columns, print_timestamp +from pandas_datareader.exceptions import EmptyResponseError + + +class CryptoReader(Exchange, ABC): + """ Class to request the data from a given exchange for a given currency-pair. + The class inherits from Exchange to extract and format the request urls, + as well as to extract and format the values from the response json. + The requests are performed by the _BaseReader. + """ + + def __init__( + self, + symbols: Union[str, dict] = None, + exchange_name: str = None, + start: Union[str, datetime] = None, + end: Union[str, datetime] = None, + interval: str = "days", + **kwargs, + ): + """ Constructor. Inherits from the Exchange and _BaseReader class. + + @param symbols: Currency pair to request (i.e. BTC-USD) + @param exchange_name: String repr of the exchange name + @param start: The start time of the request, handed over to the BaseReader. + @param end: The end time of the request, handed over to the BaseReader. + @param interval: Candle interval (i.e. minutes, hours, days, weeks, months) + @param **kwargs: Additional kw-arguments for the _BaseReader class. + """ + + if not start: + start = datetime(2009, 1, 1) + + super(CryptoReader, self).__init__( + exchange_name, interval, symbols, start, end, **kwargs + ) + + def _get_data(self) -> Dict: + """ Requests the data and returns the response json. + + @return: Response json + """ + + # Extract and format the url and parameters for the request + self.param_dict = "historic_rates" + self.url_and_params = "historic_rates" + + # Perform the request + resp = self._get_response(self.url, params=self.params, headers=None) + + # Await the rate-limit to avoid ip ban. + self._await_rate_limit() + + return resp.json() + + def read(self, new_symbols: str = None) -> pd.DataFrame: + """ Requests and extracts the data. Requests may be performed iteratively + over time to collect the full time-series. + + @param new_symbols: New currency-pair to request, if they differ from + the constructor. + @return: pd.DataFrame of the returned data. + """ + + if new_symbols: + self.symbol_setter(new_symbols) + + # Check if the provided currency-pair is listed on the exchange. + if not self._check_symbols: + raise KeyError( + "The provided currency-pair is not listed on " + "'%s'. " + "Call CryptoReader.get_currency_pairs() for an overview." + % self.name.capitalize() + ) + + result = list() + mappings = list() + # Repeat until no "older" timestamp is delivered. + # Cryptocurrency exchanges often restrict the amount of + # data points returned by a single request, thus making it + # necessary to iterate backwards in time and merge the retrieved data. + while True: + # perform request and extract data. + resp = self._get_data() + try: + data, mappings = self.format_data(resp) + # Break if no data is returned + except EmptyResponseError: + break + + # or all returned data points already exist. + if result == data or all([datapoint in result for datapoint in data]): + break + + if self.interval == "minutes": + print_timestamp(list(self.symbols.values())[0]) + + # Append new data to the result list + result = result + data + + # Find the place in the mapping list for the key "time". + time_key = {v: k for k, v in enumerate(mappings)} + time_key = time_key.get("time") + + # Extract the minimum timestamp from the response for further requests. + new_time = min(item[time_key] for item in data) + + # Break if min timestamp is lower than initial start time. + if new_time.timestamp() <= self.start.timestamp(): + break + # Or continue requesting from the new timestamp. + else: + self.symbols.update({list(self.symbols.keys())[0]: new_time}) + + # Move cursor to the next line to ensure that + # new print statements are executed correctly. + stdout.write("\n") + # If there is data put it into a pd.DataFrame, + # set index and cut it to fit the initial start/end time. + if result: + result = pd.DataFrame(result, columns=mappings) + result = self._index_and_cut_dataframe(result) + + # Reset the self.end date of the _BaseReader for further requesting. + self.reset_request_start_date() + + return result + + @staticmethod + def get_all_exchanges() -> List: + """ Get all supported exchange names. + + @return: List of exchange names. + """ + + return get_exchange_names() + + def get_currency_pairs( + self, raw_data: bool = False + ) -> Optional[Union[pd.DataFrame, List]]: + """ Requests all supported currency pairs from the exchange. + + @param raw_data: Return the raw data as a list of tuples. + @return: A list of all listed currency pairs. + """ + + self.param_dict = "currency_pairs" + self.url_and_params = "currency_pairs" + try: + resp = self._get_response(self.url, params=None, headers=None) + resp = self.format_currency_pairs(resp.json()) + except (requests.exceptions.MissingSchema, Exception): + return None + + if raw_data: + return resp + + # create pd.DataFrame and apply upper case to values + data = pd.DataFrame(resp, columns=["Exchange", "Base", "Quote"]) + data = data.apply(lambda x: x.str.upper(), axis=0) + + return data + + @property + def _check_symbols(self) -> bool: + """ Checks if the specified currency-pair is listed on the exchange""" + + currency_pairs = self.get_currency_pairs(raw_data=True) + symbols = ( + self.symbols.keys() if isinstance(self.symbols, dict) else [self.symbols] + ) + + if currency_pairs is None: + warnings.warn( + "Currency-pair request is dysfunctional. " + "Check for valid symbols is skipped." + ) + return True + + return any( + [ + all( + [ + (self.name, *symbol.lower().split("/")) in currency_pairs + for symbol in symbols + ] + ), + all( + [ + (self.name, *symbol.lower().split("-")) in currency_pairs + for symbol in symbols + ] + ), + ] + ) + + def _await_rate_limit(self): + """ Sleep time in order to not violate the rate limit, + measured in requests per minute.""" + + time.sleep(self.rate_limit) + + def _index_and_cut_dataframe(self, dataframe: pd.DataFrame) -> pd.DataFrame: + """ Set index and cut data according to user specification. + + @param dataframe: Requested raw data + @return: pd.DataFrame with specified length and proper index. + """ + + # Reindex dataframe and cut it to the specified start and end dates. + dataframe.set_index("time", inplace=True) + dataframe.sort_index(inplace=True) + # Returned timestamps from the exchanges are converted into UTC + # and therefore timezone aware. Make start and end dates + # timezone aware in order to make them comparable. + dataframe = dataframe.loc[ + pytz.utc.localize(self.start) : pytz.utc.localize(self.end) + ] + + return sort_columns(dataframe) diff --git a/pandas_datareader/crypto_utils/__init__.py b/pandas_datareader/crypto_utils/__init__.py new file mode 100644 index 00000000..faa18be5 --- /dev/null +++ b/pandas_datareader/crypto_utils/__init__.py @@ -0,0 +1,2 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- diff --git a/pandas_datareader/crypto_utils/_paths.py b/pandas_datareader/crypto_utils/_paths.py new file mode 100644 index 00000000..ee30af29 --- /dev/null +++ b/pandas_datareader/crypto_utils/_paths.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +""" +This module is preparing the python path to access all modules. +""" + +import os +from pathlib import Path + +# sys.path.insert(0, os.path.dirname(__file__)) + +all_paths = { + "yaml_path": Path(os.path.dirname(os.path.realpath(__file__))).joinpath( + "resources/" + ), +} diff --git a/pandas_datareader/crypto_utils/exchange.py b/pandas_datareader/crypto_utils/exchange.py new file mode 100644 index 00000000..c9e0d3b9 --- /dev/null +++ b/pandas_datareader/crypto_utils/exchange.py @@ -0,0 +1,506 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from typing import Tuple, Any, Dict, Union, List, Optional, Iterator + +from abc import ABC +from datetime import datetime +import string +from collections import OrderedDict, deque +import itertools + +from pandas_datareader.crypto_utils.utilities import ( + yaml_loader, + replace_list_item, + split_str_to_list, +) +from pandas_datareader.crypto_utils.mapping import extract_mappings +from pandas_datareader.crypto_utils.mapping import convert_type +from pandas_datareader.base import _BaseReader +from pandas_datareader.exceptions import EmptyResponseError + + +class Exchange(_BaseReader, ABC): + """ Class for every exchange supported. The class extracts the request url, + fits parameters, extracts the values from the response json and + performs type-conversions.""" + + def __init__(self, exchange_name: str, interval: str = "days", *args, **kwargs): + """ Constructor. + + @param exchange_name: The exchange name. + @param interval: The candle interval. + @param args: Additional ordered arguments for the _BaseReader. + @param kwargs: Additional keyword arguments for the _BaseReader. + """ + + super(Exchange, self).__init__(timeout=10, *args, **kwargs) + self.name = exchange_name + self.yaml_file = yaml_loader(self.name) + self.interval: str = interval + self.rate_limit = self.get_rate_limit() + self.args = args + self.kwargs = kwargs + self._param_dict = None + self._url_and_params = None + + self.symbol_setter(self.symbols) + + @property + def param_dict(self) -> Optional[Dict]: + """ Returns a dict of parameters. + + @return: Dict of parameters + """ + + return self._param_dict + + @property + def url_and_params(self) -> Optional[Dict]: + """ Returns a dict of FORMATTED url and parameters. + + @return: Dict of url and parameters + """ + + return self._url_and_params + + @property + def url(self) -> str: + """ Returns the formatted url. + + @return: String of the formatted url. + """ + + return self._url_and_params.get("url") + + @property + def params(self) -> Dict: + """ Returns the formatted parameters. + + @return: Dict of all formatted parameters. + """ + + return self._url_and_params.get("params") + + @url_and_params.setter + def url_and_params(self, request_type): + """ Formats the request url, inserts the currency-pair representation and/or + extracts the parameters specified for the exchange and request. + + @param request_type: The request type. Default: "historic_rates". + Possible: "historic_rates", "currency_pairs". + @return Tuple of formatted url and formatted parameters. + """ + + currency_pair = list(self.symbols.keys())[0] if self.symbols else " / " + url = self.param_dict.get(request_type).get("url") + pair_template = self.param_dict.get(request_type).get("pair_template") + pair_formatted = self.apply_currency_pair_format(currency_pair) + parameters = self.param_dict.get(request_type).get("params") + + parameters.update( + { + key: parameters[key][currency_pair] + for key, val in parameters.items() + if isinstance(val, dict) + } + ) + + if not pair_template and request_type == "currency_pairs": + self._url_and_params = {"url": url, "params": parameters} + return + + # Case 1: Currency-Pairs in request parameters: eg. www.test.com?market=BTC-USD + if "alias" in pair_template.keys() and pair_template["alias"]: + parameters[pair_template["alias"]] = pair_formatted + # Case 2: Currency-Pairs directly in URL: eg. www.test.com/BTC-USD + elif pair_formatted: + parameters.update({"currency_pair": pair_formatted}) + + else: + self._url_and_params = {"url": url, "params": parameters} + return + + variables = [ + item[1] for item in string.Formatter().parse(url) if item[1] is not None + ] + url_formatted = url.format(**parameters) + # Drop params who are filled directly into the url + parameters = {k: v for k, v in parameters.items() if k not in variables} + + self._url_and_params = {"url": url_formatted, "params": parameters} + + @param_dict.setter + def param_dict(self, request_type: str): + """ Extracts the request url from the yaml-file and implements the parameters. + + @param request_type: Request name, default: "historic_rates". + Possible: "historic_rates", "currency_pairs". + @return: Dict of the extracted url and parameters. + """ + + request_dict = self.yaml_file.get("requests").get(request_type).get("request") + request_parameters = dict() + request_parameters["url"] = self.yaml_file.get( + "api_url", "" + ) + request_dict.get("template", "") + request_parameters["pair_template"] = request_dict.get("pair_template", None) + urls = dict() + parameter = dict() + parameters = request_dict.get("params", False) + + if not parameters: + request_parameters["params"] = {} + urls[request_type] = request_parameters + self._param_dict = urls + return + + mapping: dict = { + "allowed": self._allowed, + "function": self._function, + "default": self._default, + "type": self._type_con, + } + + # enumerate mapping dict to sort parameter values accordingly, + # i.e. {"allowed": 0, "function": 1, ...} + mapping_index = {val: key for key, val in enumerate(mapping.keys())} + + for param, options in parameters.items(): + # - Kick out all option keys which are not in the mapping dict + # or where required: False. + # - Sort the dict options according to the mapping-keys to ensure + # the right order of function calls. + # - Otherwise a (valid) specified value might be overwritten + # by the default value. + options = {k: v for k, v in options.items() if k in mapping.keys()} + options = OrderedDict( + sorted(options.items(), key=lambda x: mapping_index.get(x[0])) + ) + + if not parameters[param].get("required", True): + continue + # Iterate over the functions and fill the params dict with values. + # Kwargs are needed only partially. + kwargs = {"has_value": None, "currency_pairs": self.symbols} + for key, val in options.items(): + kwargs.update({"has_value": parameter.get(param, None)}) + parameter[param] = mapping.get(key)(val, **kwargs) + + request_parameters["params"] = parameter + urls[request_type] = request_parameters + self._param_dict = urls + + def _allowed(self, val: dict, **_: dict) -> Any: + """ Extract the configured value from all allowed values. + If there is no match, return str "default". + + @param val: dict of allowed key, value pairs. + @param _: unused additional arguments needed in other methods. + @return: value if key in dict, else None. + """ + + if isinstance(self.interval, dict): + value = None + else: + value = val.get(self.interval, None) + + if not bool(value): + all_intervals = { + "minutes": 1, + "hours": 2, + "days": 3, + "weeks": 4, + "months": 5, + } + self.interval = {v: k for k, v in val.items() if all_intervals.get(k)} + return value + + def _function(self, val: str, **kwargs: dict) -> Dict[str, datetime]: + """ Execute function for all currency-pairs. Function returns the first + timestamp, or datetime.now() if none exists. + + @param val: contains the function name as string. + @param kwargs: Contains the last timestamp. + @return: The currency-pair with the respective timestamp to continue requesting. + """ + + if val == "last_timestamp": + return { + cp: self._get_first_timestamp(last_ts) + for cp, last_ts in kwargs.get("currency_pairs").items() + } + + def _default(self, val: str, **kwargs: dict) -> Optional[str]: + """ Returns the default value if kwargs value (the parameter) is None. + + @param val: Default value. + @param kwargs: Parameter value. If None, return default value. + @return: Default value as a string. + """ + + default_val = ( + val if not bool(kwargs.get("has_value")) else kwargs.get("has_value") + ) + if isinstance(self.interval, dict): + self.interval = self.interval.get(default_val, None) + + return default_val if self.interval else None + + def _type_con(self, val: Any, **kwargs: dict) -> Any: + """ Performs type conversions. + + @param val: The conversion values specified under "type". + @param kwargs: The value to be converted. + @return: Converted value. + """ + + param_value = kwargs.get("has_value", None) + conv_params = val + + # to avoid conversion when only a type declaration was done. + # If a parameter is of type "int". + if isinstance(conv_params, str) or len(conv_params) < 2: + return param_value + + # replace the key "interval" with the interval specified + # in the configuration file. + conv_params = [self.interval if x == "interval" else x for x in conv_params] + + # return {cp: convert_type(param_value[cp], deque(conv_params)) + # for cp in currency_pairs} + # Check if the above line works. + # The older version needed both if statements below. + if isinstance(param_value, dict): + return { + cp: convert_type(param_value[cp], deque(conv_params)) + for cp in kwargs.get("currency_pairs") + } + elif isinstance(conv_params, list): + return convert_type(param_value, deque(conv_params)) + + def _get_first_timestamp(self, last_ts: datetime) -> datetime: + """ Returns the timestamp to continue requesting with. + + @param last_ts: The oldest timestamp from the previous request + @return: The latest timestamp. + """ + + if last_ts: + return last_ts + + if self.end.timestamp() > datetime.utcnow().timestamp(): + return datetime.utcnow() + else: + return self.end + + def format_data( + self, responses: Union[Dict, List] + ) -> Tuple[Optional[List], Optional[List]]: + """ Extracts and formats the response data, according to the + mapping keys and path. Data is then ordered and returned as a tuple. + + @param responses: The response json + @return: Tuple of extracted and formatted data and a list of the + mapping keys in the same order. + """ + + if not responses: + raise EmptyResponseError + + results = list() + mappings = extract_mappings(self.name, self.yaml_file.get("requests")).get( + "historic_rates" + ) + mapping_keys = [mapping.key for mapping in mappings] + + # creating dict where key is the name of the mapping which holds an empty list + temp_results = dict( + zip((key for key in mapping_keys), itertools.repeat([], len(mappings))) + ) + + try: + for mapping in mappings: + if "interval" in mapping.types: + mapping.types = replace_list_item( + mapping.types, "interval", self.interval + ) + + temp_results[mapping.key] = mapping.extract_value(responses) + + if isinstance(temp_results[mapping.key], str): + # Bugfix: if value is a single string, it is an iterable, + # and the string will be split in every letter. + # Therefore it is put into a list. + temp_results[mapping.key] = [temp_results[mapping.key]] + + except Exception: + print("Error extracting values from response.") + return None, None + + else: + # CHANGE: One filed invalid -> all fields invalid. + # Changed this in order to avoid responses kicked out just because + # of one invalid field. The response will be filtered out + # in the DB-Handler if the primary-keys are missing anyways. + if all( + value is None and not isinstance(value, datetime) + for value in list(temp_results.values()) + ): + return None, None + + # asserting that the extracted lists for each mapping are + # having the same length + assert (len(results[0]) == len(result) for result in temp_results) + + len_results = { + key: len(value) + for key, value in temp_results.items() + if hasattr(value, "__iter__") + } + len_results = max(len_results.values()) if bool(len_results) else 1 + + # update new keys only if not already exists to prevent overwriting! + # temp_results = {"time": time, **temp_results} + result = [ + v if hasattr(v, "__iter__") else itertools.repeat(v, len_results) + for k, v in temp_results.items() + ] + + result = list(itertools.zip_longest(*result)) + + return result, list(temp_results.keys()) + + def format_currency_pairs( + self, response: Tuple[str, dict] + ) -> Optional[Iterator[Tuple[str, str, str]]]: + """ + Extracts the currency-pairs of out of the given json-response + that was collected from the Rest-API of this exchange. + + Process is similar to @see{self.format_ticker()}. + + @param response: Raw json-response from the Rest-API of this exchange + that needs be formatted. + @return: Iterator containing tuples of the following structure: + (self.name, name of base currency, name of quote currency) + """ + + results = {"currency_pair_first": [], "currency_pair_second": []} + mappings = extract_mappings(self.name, self.yaml_file.get("requests")).get( + "currency_pairs" + ) + + for mapping in mappings: + results[mapping.key] = mapping.extract_value(response) + + if isinstance(results[mapping.key], str): + # If the result is only one currency, it will be split + # into every letter. To avoid this, put it into a list: + results[mapping.key] = [results[mapping.key]] + results[mapping.key] = [item.lower() for item in results[mapping.key]] + + # Check if all dict values do have the same length + values = list(results.values()) + # Get the max length from all dict values + len_results = { + key: len(value) + for key, value in results.items() + if hasattr(value, "__iter__") + } + len_results = max(len_results.values()) if bool(len_results) else 1 + + if not all(len(value) == len_results for value in values): + # Update all dict values with equal length + results.update( + { + k: itertools.repeat(*v, len_results) + for k, v in results.items() + if len(v) == 1 + } + ) + + return list( + itertools.zip_longest( + itertools.repeat(self.name, len_results), + results["currency_pair_first"], + results["currency_pair_second"], + ) + ) + + def reset_request_start_date(self): + """ Reset the end date for the symbols in order to be able to restart + a request from the end date.""" + + key = list(self.symbols.keys())[0] + self.symbols.update({key: self.end}) + + def get_rate_limit(self) -> Union[int, float]: + """ Calculates the rate-limit of an exchange. + + @return: The rate limit, i.e. time to "sleep" to not violate the + limit in seconds. + """ + if self.yaml_file.get("rate_limit"): + if self.yaml_file["rate_limit"]["max"] <= 0: + rate_limit = 0 + else: + rate_limit = ( + self.yaml_file["rate_limit"]["unit"] + / self.yaml_file["rate_limit"]["max"] + ) + else: + rate_limit = 0 + + return rate_limit + + def apply_currency_pair_format(self, currency_pair: str) -> str: + """ Helper method that applies the format described in the yaml + for the specific request on the given currency-pair. + + @param currency_pair: String repr of the currency-pair + @return: String of the formatted currency-pair. + Example: BTC and ETH -> "btc_eth" + """ + try: + first, second = currency_pair.split("/") + + except ValueError: + try: + first, second = currency_pair.split("-") + + except ValueError as e: + raise Exception( + "Base and quote currency are indistinguishable." + " Symbols must be split by either '/' or '-'." + " Hyphenated currencies must be split by '/'," + " i.e.: 'btc-bitcoin/usd'." + " The currently provided symbols are: '%s'" % currency_pair + ) from e + + request_url_and_params = ( + self.yaml_file.get("requests").get("historic_rates").get("request") + ) + pair_template_dict = request_url_and_params["pair_template"] + pair_template = pair_template_dict["template"] + + formatted_string: str = pair_template.format(first=first, second=second) + + if pair_template_dict["lower_case"]: + formatted_string = formatted_string.lower() + else: + formatted_string = formatted_string.upper() + + return formatted_string + + def symbol_setter(self, new_symbols: Union[str, dict]): + """ Prepare the symbols and transform them from a string into a dict. + + @param new_symbols: String repr of the new symbols, seperated by hyphen. + """ + + if isinstance(new_symbols, str): + new_symbols = split_str_to_list(new_symbols) + # Create a new dict with new symbols as keys and + # the end timestamp as values. + self.symbols = dict.fromkeys(new_symbols, self.end) diff --git a/pandas_datareader/crypto_utils/mapping.py b/pandas_datareader/crypto_utils/mapping.py new file mode 100644 index 00000000..2f52f6f1 --- /dev/null +++ b/pandas_datareader/crypto_utils/mapping.py @@ -0,0 +1,351 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +""" +Module to find, extract and convert values from the exchange responses. + +Classes: + - Mapping +Functions: + - convert_type + - extract_mappings + - is_scalar +""" + +from collections import deque +from collections.abc import Iterable +from typing import Any, List, Dict, Deque, Tuple + +from pandas_datareader.crypto_utils.utilities import TYPE_CONVERSIONS + + +def convert_type(value: Any, types_queue: Deque[str]) -> Any: + """ Converts the value via type conversions. + + Helper method to convert the given value via a queue of type conversions. + + @param value: The value to get converted to another type. + @type value: Any + @param types_queue: The queue of type conversion instructions. + @type types_queue: deque + + @return: The converted value. + @rtype: Any + """ + current_type = types_queue.popleft() + + result = value + + while types_queue: + next_type = types_queue.popleft() + + types_tuple = (current_type, next_type) + + if "continue" in types_tuple: + continue + + conversion = TYPE_CONVERSIONS[types_tuple] + + params = list() + + for _ in range(conversion["params"]): + params.append(types_queue.popleft()) + + # Change here to avoid "None" as result value in the params when no + # value to convert is needed (i.e. when methods are called with + # ("none", ...). + # if not result and isinstance(result, (str, list)): + try: + if result is None: + result = conversion["function"](*params) + else: + result = conversion["function"](result, *params) + + current_type = next_type + except Exception: + return None + + return result + + +class Mapping: + """ Class representing mapping data and logic. + + Class representing mapping data und further functionality provided + with methods. + + Attributes: + key: + String being the keyword indicating one or several + database table columns. See "database_column_mapping" + in "config.yaml". + path: + An ordered list of keys used for traversal through the + response dict with the intention of returning the value wanted + for the database. + types: + An ordered sequence of types and + additional parameters (if necessary). Is used to conduct + type conversions within the method "extract_value()". + """ + + def __init__(self, key: str, path: List[str], types: List[str]): + """ Constructor of Mapping. + + Constructor method for constructing method objects. + + @param key: String being the keyword indicating one or several + database table columns. See "database_column_mapping" + in "config.yaml". + @type key: str + @param path: An ordered list of keys used for traversal through the + response dict with the intention of returning the value wanted + for the database. + @type path: list + @param types: An ordered sequence of types and + additional parameters (if necessary). Is used to conduct + type conversions within the method "extract_value()". + @type types: list + """ + self.key = key + self.path = path + self.types = types + + def traverse_path( + self, + response: Dict[str, Any], + path_queue: Deque[str], + currency_pair_info: Tuple[str, str, str] = None, + ) -> Any: + """ Traverses the path on a response. + + Helper method for traversing the path on the given response dict (subset). + + @param response: The response dict (subset). + @type response: dict + @param path_queue: The queue of path traversal instructions. + @type path_queue: deque + @param currency_pair_info: The formatted String of a currency pair. + For special case that the key of a dictionary + is the formatted currency pair string. + @type currency_pair_info: tuple[str, str, str] + + @return: The traversed response dict. + @rtype: Optional[dict] + """ + path_element = path_queue.popleft() + + if path_element == "dict_key": + # Special case to extract value from "dict_key" + traversed = list(response.keys()) + elif path_element == "dict_values": + # Special case to extract value from "dict_values" + traversed = list(response.values()) + elif path_element == "list_key": + # Special case with the currency_pair prior to a list + traversed = list(response.keys()) + elif path_element == "list_values": + traversed = list(response.values()) + elif path_element == []: + # Case to extract multiple values from a single list ["USD","BTC",...] + traversed = response + elif path_element == "currency_pair" and currency_pair_info[2] is not None: + traversed = response[currency_pair_info[2]] + elif is_scalar(response): + return None + else: # Special case for kraken. + if isinstance(response, dict) and path_element not in response.keys(): + return None + else: + traversed = response[path_element] + + return traversed + + def extract_value( + self, + response: Any, + path_queue: Deque[str] = None, + types_queue: Deque[str] = None, + iterate: bool = True, + currency_pair_info: Tuple[str, str, str] = (None, None, None), + ) -> Any: + """ Extracts the value specified by "self.path". + + Extracts the value specified by the path sequence and converts it + using the "types" specified. + + @param response: The response dict (JSON) returned by an API request. + @type response: Collection + @param path_queue: The queue of path traversal instructions. + @type path_queue: deque + @param types_queue: The queue of type conversion instructions. + @type types_queue: deque + @param iterate: Whether still an auto-iteration is possible. + @type iterate: bool + @param currency_pair_info: The formatted String of a currency pair. + @type currency_pair_info: tuple[str, str, str] + + @return: The value specified by "path_queue" and converted + using "types_queue". + Can be a list of values which get extracted iteratively from + the response. + @rtype: Any + """ + + if path_queue is None: + path_queue = deque(self.path) + + if types_queue is None: + types_queue = deque(self.types) + + if not response: + return None + + if not path_queue: + # Check if clause for first + # and second currency can be deleted! + if types_queue[0] == "first_currency": + return currency_pair_info[0] + elif types_queue[0] == "second_currency": + return currency_pair_info[1] + return convert_type(None, types_queue) + + while path_queue: + + if iterate and isinstance(response, list): + # Iterate through list of results + result = list() + + # special case for bitfinex + if len(response) == 1: + response = response[0] + continue # because instance of response has to be checked + + for item in response: + + if is_scalar(item): + return self.extract_value( + response, path_queue, types_queue, iterate=False + ) + + result.append( + self.extract_value(item, deque(path_queue), deque(types_queue)) + ) + + return result + + elif is_scalar(response): + # Return converted scalar value + return convert_type(response, types_queue) + + # Special case for Bitz to handle empty dicts/lists. + elif not response: + return None + + else: + # Traverse path + response = self.traverse_path( + response, path_queue, currency_pair_info=currency_pair_info + ) + + if ( + types_queue and response is not None + ): # None to allow to change 0 to boolean. + + if isinstance(response, list): + + result = list() + + for item in response: + result.append(convert_type(item, deque(types_queue))) + + # for dict_key special_case aka. + # test_extract_value_list_containing_dict_where_key_is_value() + # in test_mapping.py + if len(result) == 1: + result = result[0] + + response = result + + else: + response = convert_type(response, types_queue) + + return response + + def __str__(self) -> str: + """String representation of a Mapping""" + string_path = list() + + for item in self.path: + string_path.append(str(item)) + + return " / ".join(string_path) + " -> " + str(self.key) + + +def extract_mappings( + exchange_name: str, requests: Dict[str, Any] +) -> Dict[str, List[Mapping]]: + """ Helper-Method which should be only called by the constructor. + Extracts out of a given exchange .yaml-requests-section for each + request the necessary mappings so the values can be extracted from + the response for said request. + + The key-value in the dictionary is the same as the key for the request. + i.e. behind 'ticker' are all the mappings stored which are necessary for + extracting the values out of a ticker-response. + + If there is no mapping specified in the .yaml for a value which is contained + by the response, the value will not be extracted later on because there won't + be a Mapping-object for said value. + + @param exchange_name: str + String representation of the exchange name. + @param requests: Dict[str: List[Mapping]] + Requests-section from a exchange.yaml as dictionary. + Method does not check if dictionary contains viable information. + + @return: + Dictionary with the following structure: + {'request_name': List[Mapping]} + """ + + response_mappings = dict() + if requests: + for request in requests: + request_mapping = requests[request] + + if "mapping" in request_mapping.keys(): + mapping = request_mapping["mapping"] + mapping_list = list() + + try: + for entry in mapping: + mapping_list.append( + Mapping(entry["key"], entry["path"], entry["type"]) + ) + except KeyError: + print( + f"Error loading mappings of {exchange_name} " + f"in {request}: {entry}" + ) + break + + response_mappings[request] = mapping_list + + return response_mappings + + +def is_scalar(value: Any) -> bool: + """ Indicates whether a value is a scalar or not. + + Convenience function returning a bool whether the provided value + is a single value or not. Strings count as scalar although they are iterable. + + @param value: The value to evaluate concerning whether it is a single value + or multiple values (iterable). + @type value: Any + + @return: Bool indicating whether the provided value is a single value or not. + @rtype: bool + """ + return isinstance(value, str) or not isinstance(value, Iterable) diff --git a/pandas_datareader/crypto_utils/resources/50x.yaml b/pandas_datareader/crypto_utils/resources/50x.yaml new file mode 100644 index 00000000..17ca9306 --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/50x.yaml @@ -0,0 +1,312 @@ +# Tickers don't work as they only return the first currency. The second, with the type conversion (none, constant) +# does not work yet. + +name: 50x +exchange: true + +rate_limit: null # no rate limit +# max: null +# unit: null + +api_url: https://rates.50x.com/ + +requests: + currency_pairs: + request: + template: market + pair_template: null + params: + base: + default: USDT + + response: + type: dict + values: + currency_pair: + type: dict + values: + vol: + type: str + rate: + type: str + + mapping: + - key: currency_pair_first + path: + - dict_key + type: + - str + - key: currency_pair_second + path: [] + type: + - none + - constant + - "USDT" + +# tickers: +# request: +# template: market +# pair_template: null +# params: +# base: +# default: "USDT" +# response: +# type: dict +# values: +# currency_pair: +# type: dict +# values: +# vol: +# type: str +# rate: +# type: str +# +# mapping: +# - key: currency_pair_first +# path: +# - dict_key +# type: +# - str +# - key: currency_pair_second +# path: [] +# type: +# - none +# - constant +# - "USDT" +# - key: last_price +# path: +# - dict_values +# - rate +# type: +# - str +# - float +# - key: time +# path: [] +# type: +# - none +# - now +# - key: daily_volume +# path: +# - dict_values +# - vol +# type: +# - str +# - float + + historic_rates: + request: + template: chart + pair_template: + template: "{first}/{second}" + lower_case: false + alias: pair + params: + period: + allowed: + minutes: M1 + hours: H1 + days: D + weeks: W + default: D + end: + function: last_timestamp + type: + - datetime + - timestamp +# start: +# function: last_timestamp +# type: +# - datetime +# - timedelta +# - interval +# - 100 + response: + type: list + values: + type: dict + values: + vol: + type: float + high: + type: float + low: + type: float + open: + type: float + close: + type: float + date: + type: int + + mapping: + - key: time + path: + - date + type: + - float + - from_timestamp + - 0 + - key: open + path: + - open + type: + - float + - key: high + path: + - high + type: + - float + - key: low + path: + - low + type: + - float + - key: close + path: + - close + type: + - float + - key: volume + path: + - vol + type: + - float + + + trades: + request: + template: last_trades/ + pair_template: + template: "{first}/{second}" + lower_case: false + alias: pair + params: null + + response: + type: list + values: + type: dict + values: + a: + type: int + bs: + type: str + ts: + type: float + rate: + type: float + vol1: + type: float + vol2: + type: float + + mapping: + - key: time + path: + - ts + type: + - float + - from_timestamp + - 0 + - key: id + path: + - ts + type: + - float + - int + - key: direction + path: + - bs + type: + - value + - map + - b + - buy + - s + - sell + - key: price + path: + - rate + type: + - float + - key: amount + path: + - vol1 + type: + - float + + order_books: + request: + template: orderbook/ + pair_template: + template: "{first}/{second}" + lower_case: false + alias: pair + params: null + + response: + type: dict + values: + bid: + type: list + values: + type: list + values: + 0: + type: int + 1: + type: int + 2: + type: int + ask: + type: list + values: + type: list + values: + 0: + type: int + 1: + type: int + 2: + type: int + + mapping: + - key: time + path: [] + type: + - none + - now + - key: id + path: [] + type: + - none + - now_timestamp + - key: position + path: [] + type: + - none + - range + - key: bids_amount + path: + - bid + - 1 + type: + - float + - key: bids_price + path: + - bid + - 0 + type: + - float + - key: asks_amount + path: + - ask + - 1 + type: + - float + - key: asks_price + path: + - ask + - 0 + type: + - float \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/alterdice.yaml b/pandas_datareader/crypto_utils/resources/alterdice.yaml new file mode 100644 index 00000000..ad4ec9c2 --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/alterdice.yaml @@ -0,0 +1,305 @@ +name: alterdice +exchange: true + +rate_limit: null + +api_url: "" + +requests: + currency_pairs: + request: + template: https://api.alterdice.com/v1/public/symbols + pair_template: null + params: null + + response: + type: dict + values: + data: + type: list + values: + type: dict + values: + id: + type: int + base: + type: str + quote: + type: str + + mapping: + - key: currency_pair_first + path: + - data + - base + type: + - str + - key: currency_pair_second + path: + - data + - quote + type: + - str + + tickers: + request: + template: https://api.alterdice.com/v1/public/ticker + pair_template: + template: "{first}{second}" + lower_case: false + alias: pair + params: null + response: + type: dict + values: + data: + type: list + values: + type: dict + values: + last: + type: str + volume_24H: + type: str + + mapping: + - key: last_price + path: + - data + - last + type: + - str + - float + - key: time + path: [] + type: + - none + - now + - key: daily_volume + path: + - data + - volume_24H + type: + - str + - float + + historic_rates: + request: + template: https://socket.alterdice.com/graph/hist + pair_template: + template: "{first}{second}" + lower_case: false + alias: t + params: + r: + allowed: + hours: 60 + days: D + weeks: W + default: D + end: + function: last_timestamp + type: + - datetime + - timestamp + limit: + default: 1000 + response: + type: list + values: + type: dict + values: + low: # + type: int + high: + type: int + volume: + type: int + time: + type: int + open: + type: int + close: + type: int + + mapping: + - key: time + path: + - time + type: + - float + - from_timestamp + - 0 + - key: open + path: + - open + type: + - int + - div + - 100000000 + - key: high + path: + - high + type: + - int + - div + - 100000000 + - key: low + path: + - low + type: + - int + - div + - 100000000 + - key: close + path: + - close + type: + - int + - div + - 100000000 + - key: volume + path: + - volume + type: + - int + - div + - 100000000 + + + trades: + request: + template: https://api.alterdice.com/v1/public/trades + pair_template: + template: "{first}{second}" + lower_case: false + alias: pair + params: null + + response: + type: dict + values: + data: + type: list + values: + type: dict + values: + volume: + type: float + price: + type: float + timestamp: + type: int + type: + type: str + mapping: + - key: time + path: + - data + - timestamp + type: + - float + - from_timestamp + - 0 + - key: id + path: + - data + - timestamp + type: + - int + - key: direction + path: + - data + - type + type: + - str + - key: price + path: + - data + - price + type: + - float + - key: amount + path: + - data + - volume + type: + - float + + order_books: + request: + template: https://api.alterdice.com/v1/public/book + pair_template: + template: "{first}{second}" + lower_case: false + alias: pair + params: null + + response: + type: dict + values: + data: + type: dict + buy: + type: list + values: + type: dict + values: + volume: + type: float + rate: + type: float + sell: + type: list + values: + type: dict + values: + volume: + type: float + rate: + type: float + + mapping: + - key: time + path: [] + type: + - none + - now + - key: id + path: [] + type: + - none + - now_timestamp + - key: position + path: [] + type: + - none + - range + - key: bids_amount + path: + - data + - buy + - volume + type: + - float + - key: bids_price + path: + - data + - buy + - rate + type: + - float + - key: asks_amount + path: + - data + - sell + - volume + type: + - float + - key: asks_price + path: + - data + - sell + - rate + type: + - float \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/ascendex.yaml b/pandas_datareader/crypto_utils/resources/ascendex.yaml new file mode 100644 index 00000000..d85ed847 --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/ascendex.yaml @@ -0,0 +1,401 @@ +name: ascendex +exchange: true + +rate_limit: null + +api_url: https://ascendex.com/api/pro/v1/ + +requests: + currency_pairs: + request: + template: products + pair_template: null + params: null + + response: + type: dict + values: + data: + type: list + values: + type: dict + values: + baseAsset: + type: str + quoteAsset: + type: str + + mapping: + - key: currency_pair_first + path: + - data + - baseAsset + type: + - str + - key: currency_pair_second + path: + - data + - quoteAsset + type: + - str + + tickers: + request: + template: ticker + pair_template: null + params: null + response: + type: dict + values: + data: + type: list + values: + type: dict + values: + symbol: + type: str + volume: + type: str + ask: + type: list + values: + 0: + type: str + bids: + type: list + values: + 0: + type: str + + + mapping: + - key: currency_pair_first + path: + - data + - symbol + type: + - str + - split + - "/" + - 0 + - key: currency_pair_second + path: + - data + - symbol + type: + - str + - split + - "/" + - 1 + - key: time + path: [] + type: + - none + - now + - key: best_bid + path: + - data + - bid + - 0 + type: + - str + - float + - key: best_ask + path: + - data + - ask + - 0 + type: + - str + - float + - key: daily_volume + path: + - data + - volume + type: + - str + - float + + historic_rates: + request: + template: barhist + pair_template: + template: "{first}/{second}" + lower_case: false + alias: symbol + params: + interval: + allowed: + minutes: 1 + hours: 60 + days: 1d + weeks: 1w + months: 1m + default: 1d + to: + function: last_timestamp + type: + - datetime + - timestampms +# from: +# function: last_timestamp +# type: +# - datatime +# - timedeltams +# - interval +# - 500 + n: + default: 20 + response: + type: dict + values: + data: + type: list + values: + type: dict + values: + data: + type: dict + values: + c: + type: str + h: + type: str + i: + type: str + l: + type: str + o: + type: str + v: + type: str + ts: + type: int + + mapping: + - key: time + path: + - data + - data + - ts + type: + - float + - from_timestamp + - 1 + - key: open + path: + - data + - data + - o + type: + - str + - float + - key: high + path: + - data + - data + - h + type: + - str + - float + - key: low + path: + - data + - data + - l + type: + - str + - float + - key: close + path: + - data + - data + - c + type: + - str + - float + - key: volume + path: + - data + - data + - v + type: + - str + - float + + trades: + request: + template: trades + pair_template: + template: "{first}/{second}" + lower_case: false + alias: symbol + params: + n: + default: 100 + + response: + type: dict + values: + data: + type: dict + values: + data: + type: list + values: + type: dict + values: + seqnum: + type: int + p: + type: str + q: + type: str + ts: + type: int + bm: + type: bool + + mapping: + - key: time + path: + - data + - data + - ts + type: + - float + - from_timestamp + - 1 + - key: id + path: + - data + - data + - seqnum + type: + - int + - key: direction + path: + - data + - data + - bm + type: + - value + - map + - true + - sell + - false + - buy + - key: price + path: + - data + - data + - p + type: + - str + - float + - key: amount + path: + - data + - data + - q + type: + - str + - float + + order_books: + request: + template: depth + pair_template: + template: "{first}/{second}" + lower_case: false + alias: symbol + params: null + + response: + type: dict + values: + data: + type: dict + data: + type: dict + seqnum: + type: int + ts: + type: int + asks: + type: list + values: + type: list + values: + 0: # p + type: str + 1: #qty + type: str + bids: + type: list + values: + type: list + values: + 0: # p + type: str + 1: #qty + type: str + + mapping: + - key: time + path: + - data + - data + - ts + type: + - float + - from_timestamp + - 1 + - key: id + path: + - data + - data + - seqnum + type: + - int + - key: position + path: [] + type: + - none + - range + - key: bids_amount + path: + - data + - data + - bids + - 1 + type: + - str + - float + - key: bids_price + path: + - data + - data + - bids + - 0 + type: + - str + - float + - key: asks_amount + path: + - data + - data + - asks + - 1 + type: + - str + - float + - key: asks_price + path: + - data + - data + - asks + - 0 + type: + - str + - float \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/b2bx.yaml b/pandas_datareader/crypto_utils/resources/b2bx.yaml new file mode 100644 index 00000000..e4b15805 --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/b2bx.yaml @@ -0,0 +1,333 @@ +name: b2bx +exchange: true + +rate_limit: + max: 120 + unit: 60 + +api_url: "" + +requests: + currency_pairs: + request: + template: https://b2t-api-cmc-b2bx.flexprotect.org/marketdata/cmc/v1/ticker + pair_template: null + params: null + + response: + type: dict + values: + currency_pair: + type: dict + values: + base_name: + type: str + quote_name: + type: str + last_price: + type: str + base_volume: + type: str + quote_volume: + type: str + + + mapping: + - key: currency_pair_first + path: + - dict_values + - base_name + type: + - str + - key: currency_pair_second + path: + - dict_values + - quote_name + type: + - str + + + tickers: + request: + template: https://cmc-gate.b2bx.exchange/marketdata/cmc/v1/ticker + pair_template: null + params: null + response: + type: dict + values: + currency_pair: + type: dict + values: + last_price: + type: str + base_volume: + type: str + quote_volume: + type: str + + mapping: + - key: currency_pair_first + path: + - dict_key + type: + - str + - split + - "_" + - 0 + - key: currency_pair_second + path: + - dict_key + type: + - str + - split + - "_" + - 1 + - key: last_price + path: + - dict_values + - last_price + type: + - str + - float + - key: time + path: [] + type: + - none + - now + - key: daily_volume + path: + - dict_values + - base_volume + type: + - str + - float + + historic_rates: + request: + template: https://b2t-api-b2bx.flexprotect.org/marketdata/instruments/{currency_pair}/history + pair_template: + template: "{first}_{second}" + lower_case: true + params: + endDate: + function: last_timestamp + type: + - datetime + - format + - "%Y-%m-%dT%H:%M:%S" + startDate: + function: last_timestamp + type: + - datetime + - timedelta + - interval + - 1000 + - from_timestamp + - 0 + - "%Y-%m-%dT%H:%M:%S" + count: + default: 1000 #max + type: + allowed: + minutes: 1m + hours: 1h + days: 1d + weeks: 1w + months: 1M + default: 1d + response: + type: dict + values: + data: + type: list + values: + type: dict + values: + start: + type: str + end: + type: str + open: + type: float + high: + type: float + low: + type: float + close: + type: float + volume: + type: float + quoteVolume: + type: float + + mapping: + - key: time + path: + - data + - start + type: + - str + - dateparser + - key: open + path: + - data + - open + type: + - float + - key: high + path: + - data + - high + type: + - float + - key: low + path: + - data + - low + type: + - float + - key: close + path: + - data + - close + type: + - float + - key: volume + path: + - data + - volume + type: + - float + + + trades: + request: + template: https://b2t-api-cmc-b2bx.flexprotect.org/marketdata/cmc/v1/trades/{currency_pair} + pair_template: + template: "{first}_{second}" + lower_case: true + params: null + + response: + type: list + values: + type: dict + values: + tradeID: + type: str + price: + type: str + base_volume: + type: str + quote_volume: + type: str + trade_timestamp: + type: str + type: + type: str + mapping: + - key: time + path: + - trade_timestamp + type: + - str + - float + - from_timestamp + - 0 + - key: id + path: + - tradeID + type: + - str + - int + - key: direction + path: + - type + type: + - str + - key: price + path: + - price + type: + - str + - float + - key: amount + path: + - base_volume + type: + - str + - float + + order_books: + request: + template: https://b2t-api-b2bx.flexprotect.org/marketdata/instruments/{currency_pair}/depth + pair_template: + template: "{first}_{second}" + lower_case: true + params: null + + response: + type: dict + values: + bids: + type: list + values: + type: dict + values: + amount: + type: float + price: + type: float + asks: + type: list + values: + type: dict + values: + amount: + type: float + price: + type: float + version: + type: int + + + mapping: + - key: time + path: [] + type: + - none + - now + - key: id + path: + - version + type: + - int + - key: position + path: [] + type: + - none + - range + - key: bids_amount + path: + - bids + - amount + type: + - float + - key: bids_price + path: + - bids + - price + type: + - float + - key: asks_amount + path: + - asks + - amount + type: + - float + - key: asks_price + path: + - asks + - price + type: + - float \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/bankcex.yaml b/pandas_datareader/crypto_utils/resources/bankcex.yaml new file mode 100644 index 00000000..da663b2d --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/bankcex.yaml @@ -0,0 +1,356 @@ +name: bankcex +exchange: true + +rate_limit: + max: 300 + unit: 60 + +api_url: https://api.bankcex.com/api/v1/ + +requests: + currency_pairs: + request: + template: exchangeInfo + pair_template: null + params: null + + response: + type: dict + values: + rate_limits: + type: list + symbols: + type: list + values: + type: dict + values: + baseAsset: + type: str + quoteAsset: + type: str + + + mapping: + - key: currency_pair_first + path: + - symbols + - baseAsset + type: + - str + - key: currency_pair_second + path: + - symbols + - quoteAsset + type: + - str + + tickers: + request: + template: returnTicker + pair_template: null + params: null + response: + type: dict + values: + currency_pair: + type: dict + values: + symbol: + type: str + last: + type: float + highestBid: + type: float + lowestAsk: + type: float + quoteVolume: + type: float + baseVolume: + type: float + + + mapping: + - key: currency_pair_first + path: + - dict_key + type: + - str + - split + - "_" + - 0 + - key: currency_pair_second + path: + - dict_key + type: + - str + - split + - "_" + - 1 + - key: last_price + path: + - dict_values + - last + type: + - float + - key: time + path: [] + type: + - none + - now + - key: best_bid + path: + - dict_values + - highestBid + type: + - float + - key: best_ask + path: + - dict_values + - lowestAsk + type: + - float + - key: daily_volume + path: + - dict_values + - baseVolume + type: + - float + + historic_rates: + request: + template: klines + pair_template: + template: "{first}{second}" + lower_case: false + alias: symbol + params: + limit: + max: 100 + default: 100 + interval: + allowed: + minutes: 1m + hours: 1h + days: 1d + weeks: 1w + default: 1d +# startTime: # not necessary +# function: last_timestamp +# type: +# - datetime +# - timedeltams +# - interval +# - 1000 + endTime: + function: last_timestamp + type: + - datetime + - timestampms + response: + type: list + values: + type: list + values: + 0: # open time + type: int + 1: # open + type: str + 2: # high + type: str + 3: # low + type: str + 4: # close + type: str + 5: # volume + type: str + 6: # close time + type: int + 7: # quote volume + type: str + 8: # number of trades + type: str + + mapping: + - key: time + path: + - 6 + type: + - float + - from_timestamp + - 1 + - key: open + path: + - 1 + type: + - str + - float + - key: high + path: + - 2 + type: + - str + - float + - key: low + path: + - 3 + type: + - str + - float + - key: close + path: + - 4 + type: + - str + - float + - key: volume + path: + - 5 + type: + - str + - float + + + trades: + request: + template: trades + pair_template: + template: "{first}{second}" + lower_case: false + alias: symbol + params: + limit: + default: 500 + + response: + type: list + values: + type: dict + values: + id: + type: str + price: + type: str + qty: + type: str + time: + type: int + isBuyerMaker: + type: bool + isBestMatch: + type: bool + + mapping: + - key: time + path: + - time + type: + - float + - from_timestamp + - 1 + - key: id + path: + - id + type: + - str + - key: direction + path: + - isBuyerMaker + type: + - value + - map + - true + - sell + - false + - buy + - key: price + path: + - price + type: + - str + - float + - key: amount + path: + - qty + type: + - str + - float + + order_books: + request: + template: depth + pair_template: + template: "{first}{second}" + lower_case: false + alias: symbol + params: + limit: + max: 1000 + default: 100 + response: + type: dict + values: + lastUpdateId: + type: str + bids: + type: list + values: + type: list + values: + 0: #price + type: str + 1: # qty + type: str + asks: + type: list + values: + type: list + values: + 0: #price + type: str + 1: # qty + type: str + + mapping: + - key: time + path: [] + type: + - none + - now + - key: id + path: [] + type: + - none + - now_timestamp + - key: position + path: [] + type: + - none + - range + - key: bids_amount + path: + - bids + - 1 + type: + - str + - float + - key: bids_price + path: + - bids + - 0 + type: + - str + - float + - key: asks_amount + path: + - asks + - 1 + type: + - str + - float + - key: asks_price + path: + - asks + - 0 + type: + - str + - float \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/bequant.yaml b/pandas_datareader/crypto_utils/resources/bequant.yaml new file mode 100644 index 00000000..996552ec --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/bequant.yaml @@ -0,0 +1,374 @@ +name: bequant +exchange: true + +rate_limit: + max: 6000 + unit: 60 + +api_url: https://api.bequant.io/api/2/public/ + +requests: + currency_pairs: + request: + template: symbol + pair_template: null + params: null + + response: + type: list + values: + type: dict + values: + baseCurrency: + type: str + quoteCurrency: + type: str + + mapping: + - key: currency_pair_first + path: + - baseCurrency + type: + - str + - key: currency_pair_second + path: + - quoteCurrency + type: + - str + + tickers: + request: + template: ticker + pair_template: + template: "{first}{second}" + lower_case: false + alias: symbols + params: null + response: + type: list + values: + type: dict + values: + ask: + type: str + bid: + type: str + last: + type: str + volume: + type: str + volumeQuote: + type: str + timestamp: + type: str + + mapping: + - key: last_price + path: + - last + type: + - str + - float + - key: time + path: + - timestamp + type: + - str + - dateparser + - key: best_bid + path: + - bid + type: + - str + - float + - key: best_ask + path: + - ask + type: + - str + - float + - key: daily_volume + path: + - volume + type: + - str + - float + + historic_rates: + request: + template: candles + pair_template: + template: "{first}{second}" + lower_case: false + alias: symbols + params: + period: + allowed: + minutes: M1 + hours: H1 + days: D1 + weeks: D7 + months: 1M + default: D1 + + till: + function: last_timestamp + type: + - datetime + - format + - "%Y-%m-%dT%H:%M:%S.%fZ" + from: + function: last_timestamp + type: + - datetime + - timedelta + - interval + - 1000 + - from_timestamp + - 0 + - "%Y-%m-%dT%H:%M:%S.%fZ" + sort: + default: DESC + limit: + max: 1000 + default: 1000 + + response: + type: dict + values: + currency_pair: + type: list + values: + type: dict + values: + timestamp: + type: str + open: + type: str + close: + type: str + min: + type: str + max: + type: str + volumeQuote: + type: str + volume: + type: str + + mapping: + - key: time + path: + - list_values + - timestamp + type: + - str + - dateparser + - key: open + path: + - list_values + - open + type: + - str + - float + - key: high + path: + - list_values + - max + type: + - str + - float + - key: low + path: + - list_values + - min + type: + - str + - float + - key: close + path: + - list_values + - close + type: + - str + - float + - key: volume + path: + - list_values + - volume + type: + - str + - float + + trades: + request: + template: trades + pair_template: + template: "{first}{second}" + lower_case: false + alias: symbols + params: +# from: +# function: last_timestamp +# type: +# - datetime +# - timestamp +# till: +# function: last_timestamp +# type: +# - datetime +# - timedelta +# - interval +# - 1000 +# sort: +# default: DESC + limit: + max: 1000 + default: 500 + response: + type: dict + values: + currency_pair: + type: list + values: + type: dict + values: + id: + type: int + price: + type: str + quantity: + type: str + side: + type: str + timestamp: + type: str + + mapping: + - key: time + path: + - list_values + - timestamp + type: + - str + - dateparser + - key: id + path: + - list_values + - id + type: + - int + - key: direction + path: + - list_values + - side + type: + - str + - key: price + path: + - list_values + - price + type: + - str + - float + - key: amount + path: + - list_values + - quantity + type: + - str + - float + + order_books: + request: + template: orderbook + pair_template: + template: "{first}{second}" + lower_case: false + alias: symbols + params: + limit: + default: 100 + + response: + type: dict + values: + currency_pair: + type: dict + values: + timestamp: + type: str + batchingTime: + type: str + ask: + type: list + values: + type: dict + values: + price: + type: str + size: + type: str + bid: + type: list + values: + type: dict + values: + price: + type: str + size: + type: str + + mapping: + - key: time + path: + - dict_values + - timestamp + type: + - str + - dateparser + - key: id + path: + - dict_values + - timestamp + type: + - str + - dateparser + - totimestamp + - key: position + path: [] + type: + - none + - range + - key: bids_amount + path: + - dict_values + - bid + - size + type: + - str + - float + - key: bids_price + path: + - dict_values + - bid + - price + type: + - str + - float + - key: asks_amount + path: + - dict_values + - ask + - size + type: + - str + - float + - key: asks_price + path: + - dict_values + - ask + - price + type: + - str + - float \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/bibox.yaml b/pandas_datareader/crypto_utils/resources/bibox.yaml new file mode 100644 index 00000000..ce282e2f --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/bibox.yaml @@ -0,0 +1,416 @@ +name: bibox +exchange: true +api_url: https://api.bibox.com/v1/mdata +rate_limit: null +requests: + + tickers: + request: + template: "" + pair_template: null + params: + cmd: + type: str + default: marketAll + response: + type: dict + values: + + type: list + values: + result: + type: dict + values: + + buy: + type: int + high: + type: int + last: + type: float + low: + type: int + sell: + type: int + vol24H: + type: float + last_cny: + type: int + last_usd: + type: int + cmd: + type: str + mapping: + - key: time + path: [] + type: + - none + - now + - key: currency_pair_first + path: + - result + - coin_symbol + type: + - str + - key: currency_pair_second + path: + - result + - currency_symbol + type: + - str + - key: daily_volume + path: + - result + - vol24H + type: + - str + - float + - key: last_price + path: + - result + - last + type: + - str + - float + + currency_pairs: + request: + template: "" + pair_template: null + params: + cmd: + type: str + default: pairList + response: + type: dict + values: + result: + type: list + values: + type: dict + values: + id: + type: int + pair: # e.g. BIX_BTC + type: str + is_hide: + type: int + cmd: + type: str + ver: + type: str + mapping: + - key: currency_pair_first + path: + - result + - pair + type: + - str + - split + - "_" + - 0 + - key: currency_pair_second + path: + - result + - pair + type: + - str + - split + - "_" + - 1 + + historic_rates: + request: + template: "" + pair_template: # pairs, example: BIX_BTC + template: "{first}_{second}" + lower_case: false + alias: pair + params: + cmd: + type: str + default: kline + period: # k line period + allowed: + minutes: 1min + hours: 1hour + days: day + weeks: week + default: day + size: # how many, 1-1000, if not passed will return 1000 + type: int + default: 1000 + response: + type: dict + values: + result: + type: list + values: + type: dict + values: + time: + type: + - float + - from_timestamp + - 0 + open: + type: + - str + - float + high: + type: + - str + - float + low: + type: + - str + - float + close: + type: + - str + - float + vol: + type: + - str + - int + cmd: + type: str + ver: + type: str + mapping: + - key: time + path: + - result + - time + type: + - float + - from_timestamp + - 1 + - key: open + path: + - result + - open + type: + - str + - float + - key: high + path: + - result + - high + type: + - str + - float + - key: low + path: + - result + - low + type: + - str + - float + - key: close + path: + - result + - close + type: + - str + - float + - key: volume + path: + - result + - vol + type: + - str + - float + + order_books: + request: + template: "" + pair_template: # pairs, example: BIX_BTC + template: "{first}_{second}" + lower_case: false + alias: pair + params: + cmd: + type: str + default: depth + size: # how many, 1-200, if not passed will return 200 + type: int + default: 200 + response: + type: dict + values: + result: + type: dict + values: + update_time: + type: + - float + - from_timestamp + - 0 + asks: + type: list + values: + type: dict + values: + price: + type: + - str + - float + volume: + type: + - str + - float + bids: + type: list + values: + type: dict + values: + price: + type: + - str + - float + volume: + type: + - str + - float + pair: + type: str + cmd: + type: str + ver: + type: str + mapping: + - key: time + path: + - result + - update_time + type: + - float + - from_timestamp + - 1 + - key: asks_price + path: + - result + - asks + - price + type: + - str + - float + - key: asks_amount + path: + - result + - asks + - volume + type: + - str + - float + - key: bids_price + path: + - result + - bids + - price + type: + - str + - float + - key: bids_amount + path: + - result + - bids + - volume + type: + - str + - float + - key: id + path: + - result + - update_time + type: + - int + - key: position + path: [] + type: + - none + - range + + trades: + request: + template: "" + pair_template: # pairs, example: BIX_BTC + template: "{first}_{second}" + lower_case: false + alias: pair + params: + cmd: + type: str + default: deals + size: # how many, 1-200, if not passed will return 200 + type: int + default: 200 + response: + type: dict + values: + result: + type: list + values: + type: dict + values: + id: + type: int + pair: + type: str + price: + type: + - str + amount: + type: + - str + time: + type: + - str + side: # transaction side, 1-bid, 2-ask + type: int + cmd: + type: str + mapping: + - key: price + path: + - result + - price + type: + - str + - float + - key: amount + path: + - result + - amount + type: + - str + - float + - key: time + path: + - result + - time + type: + - str + - float + - from_timestamp + - 1 + - key: direction + path: + - result + - side + type: + - value + - map + - 1 + - buy + - 2 + - sell + - key: id + path: + - result + - time + type: + - str + - int + diff --git a/pandas_datareader/crypto_utils/resources/bidesk.yaml b/pandas_datareader/crypto_utils/resources/bidesk.yaml new file mode 100644 index 00000000..e722bc0a --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/bidesk.yaml @@ -0,0 +1,304 @@ +name: bidesk +is_exchange: true + +api_url: https://api.bidesk.com/ +rate_limit: + max: 1500 + unit: 60 + +requests: + currency_pairs: + request: + template: openapi/v1/brokerInfo + pair_template: null + params: null + + response: + type: dict + values: + symbols: + type: list + values: + type: dict + values: + baseAsset: + type: str + quoteAsset: + type: str + + mapping: + - key: currency_pair_first + path: + - symbols + - baseAsset + type: + - str + - key: currency_pair_second + path: + - symbols + - quoteAsset + type: + - str + + tickers: + request: + template: openapi/quote/v1/ticker/price + pair_template: + template: "{first}{second}" + lower_case: false + alias: symbol + params: null + + response: + type: dict + values: + symbol: + type: str + price: + type: str + mapping: + - key: time + path: [] + type: + - none + - now + - key: last_price + path: + - price + type: + - str + - float + + order_books: + request: + template: openapi/quote/v1/depth + pair_template: + template: "{first}{second}" + lower_case: false + alias: symbol + params: + limit: + type: int + max: 1000 + default: 50 + response: + type: dict + values: + time: + type: int + bids: + type: list + values: + type: list + 0: #price + type: str + 1: #qty + type: str + asks: + type: list + values: + type: list + 0: + type: str + 1: + type: str + mapping: + - key: time + path: + - time + type: + - float + - from_timestamp + - 1 + - key: id + path: + - time + type: + - int + - key: position + path: [] + type: + - none + - range + - key: bids_price + path: + - bids + - 0 + type: + - str + - float + - key: bids_amount + path: + - bids + - 1 + type: + - str + - float + - key: asks_price + path: + - asks + - 0 + type: + - str + - float + - key: asks_amount + path: + - asks + - 1 + type: + - str + - float + + trades: + request: + template: openapi/quote/v1/trades + pair_template: + template: "{first}{second}" + lower_case: false + alias: symbol + params: + limit: + type: int + max: 1000 + default: 500 + response: + type: list + value: + type: dict + values: + price: + type: str + qty: + typ: str + time: + type: int + isBuyerMaker: + type: bool + mapping: + - key: time + path: + - time + type: + - float + - from_timestamp + - 1 + - key: direction + path: + - isBuyerMaker + type: + - value + - map + - True + - sell + - False + - buy + - key: id + path: + - time + type: + - int + - key: price + path: + - price + type: + - str + - float + - key: amount + path: + - qty + type: + - str + - float + + historic_rates: + request: + template: openapi/quote/v1/klines + pair_template: + template: "{first}{second}" + lower_case: false + alias: symbol + params: + interval: + allowed: + minutes: 1m + hours: 1h + days: 1d + weeks: 1w + months: 1M + default: 1d + limit: + type: int + max: 1000 + default: 1000 + endTime: + function: last_timestamp + type: + - datetime + - timestampms + + response: + type: list + values: + type: list + values: + 0: #timestamp + type: int + 1: #open + type: str + 2: #high + type: str + 3: #low + type: str + 4: #close + type: str + 5: #volume + type: str + 6: #close time + type: int + 7: # quote Asset volume + type: str + 8: # number of trades + type: int + 9: # taker buy base asset volume + type: str + 10: # taker buy quote asset volume + type: str + + mapping: + - key: time + path: + - 0 + type: + - float + - from_timestamp + - 1 + - key: open + path: + - 1 + type: + - str + - float + - key: high + path: + - 2 + type: + - str + - float + - key: low + path: + - 3 + type: + - str + - float + - key: close + path: + - 4 + type: + - str + - float + - key: volume + path: + - 5 + type: + - str + - float \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/bigone.yaml b/pandas_datareader/crypto_utils/resources/bigone.yaml new file mode 100644 index 00000000..a621a096 --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/bigone.yaml @@ -0,0 +1,341 @@ +name: bigone +exchange: true + +rate_limit: + max: 3000 + unit: 60 + +api_url: https://big.one/api/v3/ + +requests: + currency_pairs: + request: + template: asset_pairs + pair_template: null + params: null + + response: + type: dict + values: + data: + type: list + values: + type: dict + values: + name: + type: str + + mapping: + - key: currency_pair_first + path: + - data + - name + type: + - str + - split + - "-" + - 0 + - key: currency_pair_second + path: + - data + - name + type: + - str + - split + - "-" + - 1 + + tickers: + request: + template: asset_pairs/{currency_pair}/ticker + pair_template: + template: "{first}-{second}" + lower_case: false + params: null + response: + type: dict + values: + data: + type: dict + values: + bid: + type: dict + values: + price: + type: str + ask: + type: dict + values: + price: + type: str + volume: + type: str + + mapping: + - key: time + path: [] + type: + - none + - now + - key: best_bid + path: + - data + - bid + - price + type: + - str + - float + - key: best_ask + path: + - data + - ask + - price + type: + - str + - float + - key: daily_volume + path: + - data + - volume + type: + - str + - float + + historic_rates: + request: + template: asset_pairs/{currency_pair}/candles + pair_template: + template: "{first}-{second}" + lower_case: false + params: + period: + allowed: + minutes: min1 + hours: hour1 + days: day1 + weeks: week1 + months: months1 + default: day1 + time: + function: last_timestamp + type: + - datetime + - format + - "%Y-%m-%dT%H:%M:%S.%fZ" + limit: + max: 500 + default: 500 + response: + type: dict + values: + type: list + values: + type: dict + values: + close: + type: str + high: + type: str + low: + type: str + open: + type: str + volume: + type: str + time: + type: str + + mapping: + - key: time + path: + - data + - time + type: + - str + - dateparser + - key: open + path: + - data + - open + type: + - str + - float + - key: high + path: + - data + - high + type: + - str + - float + - key: low + path: + - data + - low + type: + - str + - float + - key: close + path: + - data + - close + type: + - str + - float + - key: volume + path: + - data + - volume + type: + - str + - float + + + trades: + request: + template: asset_pairs/{currency_pair}/trades + pair_template: + template: "{first}-{second}" + lower_case: false + params: null + + response: + type: dict + values: + type: list + values: + type: dict + values: + id: + type: int + price: + type: str + amount: + type: str + taker_side: + type: str + created_at: + type: str + mapping: + - key: time + path: + - data + - created_at + type: + - str + - dateparser + - key: id + path: + - data + - id + type: + - int + - key: direction + path: + - data + - taker_side + type: + - value + - map + - ASK + - sell + - BID + - buy + - key: price + path: + - data + - price + type: + - str + - float + - key: amount + path: + - data + - amount + type: + - str + - float + + order_books: + request: + template: asset_pairs/{currency_pair}/depth + pair_template: + template: "{first}-{second}" + lower_case: false + params: + limit: + max: 200 + default: 50 + + response: + type: dict + values: + data: + type: dict + values: + bids: + type: list + values: + type: dict + values: + price: + type: str + quantity: + type: str + asks: + type: list + values: + type: dict + values: + price: + type: str + quantity: + type: str + + mapping: + - key: time + path: [] + type: + - none + - now + - key: id + path: [] + type: + - none + - now_timestamp + - key: position + path: [] + type: + - none + - range + - key: bids_amount + path: + - data + - bids + - quantity + type: + - str + - float + - key: bids_price + path: + - data + - bids + - price + type: + - str + - float + - key: asks_amount + path: + - data + - asks + - quantity + type: + - str + - float + - key: asks_price + path: + - data + - asks + - price + type: + - str + - float \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/binance.yaml b/pandas_datareader/crypto_utils/resources/binance.yaml new file mode 100644 index 00000000..6b33b19d --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/binance.yaml @@ -0,0 +1,388 @@ +name: binance +exchange: true +api_url: https://api.binance.com/api/ +rate_limit: + max: 1200 + unit: 60 +requests: + currency_pairs: + request: + template: v1/exchangeInfo + pair_template: null + params: null + response: + type: dict + values: + timezone: + type: str # "UTC" + serverTime: + type: + - float + - from_timestamp + - 1 + rateLimits: + type: list + exchangeFilters: + type: list + symbols: + type: list + values: + type: dict + values: + symbol: # i.e. "ETHBTC" + type: str + status: # i.e. "TRADING" + type: str + baseAsset: # i.e. ETH + type: str + baseAssetPrecision: + type: int + quoteAsset: # i.e. "BTC" + type: str + quotePrecision: + type: int + orderTypes: + type: list + icebergAllowed: + type: bool + filters: + type: list + mapping: + - key: currency_pair_first + path: + - symbols + - baseAsset + type: + - str + - key: currency_pair_second + path: + - symbols + - quoteAsset + type: + - str + + tickers: + request: + template: v3/ticker/bookTicker + pair_template: # e.g. BNBBTC + template: "{first}{second}" + lower_case: false + alias: symbol + params: null + response: + type: dict + values: + symbol: + type: str + bidPrice: + type: + - str + - float + bidQty: + type: + - str + - float + askPrice: + type: + - str + - float + askQty: + type: + - str + - float + mapping: + - key: time + path: [] + type: + - none + - now + - key: best_bid + path: + - bidPrice + type: + - str + - float + - key: best_ask + path: + - askPrice + type: + - str + - float + + order_books: + request: + template: v3/depth + pair_template: # e.g. BNBBTC + template: "{first}{second}" + lower_case: false + alias: symbol + params: + limit: + max: 100 + default: 50 + + response: + type: dict + values: + lastUpdateId: + type: int + bids: + type: list + values: + type: list + values: + 0: # price + type: + - str + - float + 1: # quantity + type: + - str + - float + asks: + type: list + values: + type: list + values: + 0: # price + type: + - str + - float + 1: # quantity + type: + - str + - float + mapping: + - key: time + path: [] + type: + - none + - now + + - key: id + path: + - lastUpdateId + type: + - str + + - key: position + path: [] + type: + - none + - range + - key: bids_price + path: + - bids + - 0 + type: + - str + - float + - key: bids_amount + path: + - bids + - 1 + type: + - str + - float + - key: asks_price + path: + - asks + - 0 + type: + - str + - float + - key: asks_amount + path: + - asks + - 1 + type: + - str + - float + + trades: + request: + template: v1/trades + pair_template: # e.g. BNBBTC + template: "{first}{second}" + lower_case: false + alias: symbol + params: + limit: + max: 1000 + default: 500 + weight: 1 + response: + type: list + values: + type: dict + values: + id: + type: int + price: + type: + - str + - float + qty: + type: + - str + - float + time: + type: + - float + - from_timestamp + - 1 + isBuyerMaker: + type: bool + isBestMatch: + type: bool + mapping: + - key: id + path: + - id + type: + - int + - key: price + path: + - price + type: + - str + - float + - key: amount + path: + - qty + type: + - str + - float + - key: time + path: + - time + type: + - float + - from_timestamp + - 1 + - key: direction + path: + - isBuyerMaker + type: + - value + - map + - True + - sell + - False + - buy + + historic_rates: + request: + template: v1/klines + pair_template: # e.g. BNBBTC + template: "{first}{second}" + lower_case: false + alias: symbol + params: + interval: + allowed: + minutes: 1m + hours: 1h + days: 1d + weeks: 1w + months: 1M + default: 1d + startTime: + required: false + endTime: + function: last_timestamp + type: + - datetime + - timestampms + limit: + max: 1000 + default: 1000 + response: + type: list + values: + type: list + values: + 0: # Open time + type: + - float + - from_timestamp + - 1 + 1: # open + type: + - str + - float + 2: # high + type: + - str + - float + 3: # low + type: + - str + - float + 4: # close + type: + - str + - float + 5: # volume + type: + - str + - float + 6: # close time + type: + - float + - from_timestamp + - 1 + 7: # Quote asset volume + type: + - str + - float + 8: # Number of trades + type: int + 9: # Taker buy base asset volume + type: + - str + - float + 10: # Taker buy quote asset volume + type: + - str + - float + 11: # ignore + type: ignore + mapping: + - key: open + path: + - 1 + type: + - str + - float + - key: high + path: + - 2 + type: + - str + - float + - key: low + path: + - 3 + type: + - str + - float + - key: close + path: + - 4 + type: + - str + - float + - key: volume + path: + - 5 + type: + - str + - float + - key: time + path: + - 6 + type: + - float + - from_timestamp + - 1 diff --git a/pandas_datareader/crypto_utils/resources/bitbay.yaml b/pandas_datareader/crypto_utils/resources/bitbay.yaml new file mode 100644 index 00000000..6e725ee3 --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/bitbay.yaml @@ -0,0 +1,384 @@ +name: bitbay +exchange: true + +api_url: https://api.bitbay.net/rest/trading/ +rate_limit: + max: 60 + unit: 60 + +requests: + currency_pairs: + request: + template: ticker + pair_template: null + params: null + response: + type: dict + values: + items: + type: dict + values: + currency_pair: + type: dict + + mapping: + - key: currency_pair_first + path: + - items + - dict_key + type: + - str + - split + - "-" + - 0 + - key: currency_pair_second + path: + - items + - dict_key + type: + - str + - split + - "-" + - 1 + + tickers: + request: + template: ticker + pair_template: null + params: null + response: + type: dict + values: + items: + type: dict + values: + currency_pair: + type: dict + values: + market: + type: dict + values: + time: + type: str + highestBid: + type: str + lowestAsk: + type: str + rate: + type: str + + mapping: + - key: currency_pair_first + path: + - items + - dict_key + type: + - str + - split + - "-" + - 0 + - key: currency_pair_second + path: + - items + - dict_key + type: + - str + - split + - "-" + - 1 + - key: time + path: + - items + - dict_values + - time + type: + - str + - float + - from_timestamp + - 1 + - key: last_price + path: + - items + - dict_values + - rate + type: + - str + - float + - key: best_bid + path: + - items + - dict_values + - highestBid + type: + - str + - float + - key: best_ask + path: + - items + - dict_values + - lowestAsk + type: + - str + - float + + + trades: + request: + template: transactions/{currency_pair} + pair_template: + template: "{first}-{second}" + lower_case: false + params: + limit: + type: int + max: 300 + default: 300 + response: + type: dict + values: + items: + type: list + values: + type: dict + values: + id: + type: str + t: + type: str + a: + type: str + r: + type: str + ty: + type: str + + mapping: + - key: time + path: + - items + - t + type: + - str + - float + - from_timestamp + - 1 + - key: id + path: + - items + - id + type: + - str + - key: price + path: + - items + - r + type: + - str + - float + - key: amount + path: + - items + - a + type: + - str + - float + - key: direction + path: + - items + - ty + type: + - str + + + order_books: + request: + template: orderbook-limited/{currency_pair}/50 #change limit 50 here + pair_template: + template: "{first}-{second}" + lower_case: false + params: null + response: + type: dict + values: + sell: + type: list + values: + type: dict + values: + ra: + type: str + ca: + type: str + sa: + type: str + pa: + type: str + co: + type: int + buy: + type: list + values: + type: dict + values: + ra: + type: str + ca: + type: str + sa: + type: str + pa: + type: str + co: + type: int + timestamp: + type: str + seqNo: + type: str + + mapping: + - key: time + path: + - timestamp + type: + - str + - float + - from_timestamp + - 1 + - key: id + path: + - seqNo + type: + - str + - int + - key: position + path: [] + type: + - none + - range + - key: bids_price + path: + - buy + - ra + type: + - str + - float + - key: bids_amount + path: + - buy + - ca + type: + - str + - float + - key: asks_price + path: + - sell + - ra + type: + - str + - float + - key: asks_amount + path: + - sell + - ca + type: + - str + - float + + historic_rates: + request: + template: candle/history/{currency_pair}/{frequency} + pair_template: + template: "{first}-{second}" + lower_case: false + params: + to: + type: + - none + - now_timestampms + from: + function: last_timestamp + type: + - datetime + - timedeltams + - interval + - 2000 + + frequency: + allowed: + minutes: 60 + hours: 3600 + days: 86400 + weeks: 604800 + response: + type: dict + values: + items: + type: list + values: + type: list + values: + 0: + type: str + 1: + type: dict + values: + o: + type: str + c: + type: str + h: + type: str + l: + type: str + v: + type: str + mapping: + - key: time + path: + - items + - 0 + type: + - str + - float + - from_timestamp + - 1 + - key: open + path: + - items + - 1 + - o + type: + - str + - float + - key: high + path: + - items + - 1 + - h + type: + - str + - float + - key: low + path: + - items + - 1 + - l + type: + - str + - float + - key: close + path: + - items + - 1 + - c + type: + - str + - float + - key: volume + path: + - items + - 1 + - v + type: + - str + - float diff --git a/pandas_datareader/crypto_utils/resources/bitfinex.yaml b/pandas_datareader/crypto_utils/resources/bitfinex.yaml new file mode 100644 index 00000000..8c3f78cb --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/bitfinex.yaml @@ -0,0 +1,365 @@ +name: bitfinex + # v1: +#api_url: https://api-pub.bitfinex.com/ +#api_url: https://api.bitfinex.com/ +api_url: '' + +rate_limit: + max: 90 + unit: 60 + +requests: + currency_pairs: + request: + template: https://api.bitfinex.com/v1/symbols_details + pair_template: null + params: null + response: + type: list + values: + type: dict + values: + pair: + type: str + mapping: + - key: currency_pair_first + path: + - pair + type: + - str + - split_at_del_or_index + - ':' + - 3 + - 0 + + - key: currency_pair_second + path: + - pair + type: + - str + - split_at_del_or_index + - ':' + - 3 + - 1 + + + tickers: + request: + template: https://api.bitfinex.com/v1/pubticker/{currency_pair} + pair_template: # i.e. tBTCUSD + template: "{first}{second}" + lower_case: false + params: null + response: + type: dict + values: + mid: + type: str + bid: + type: str + ask: + type: str + last_price: + type: str + low: + type: str + high: + type: str + volume: + type: str + timestamp: + type: str + mapping: # for trading pairs (ex. tBTCUSD) + - key: time + path: + - timestamp + type: + - str + - float + - from_timestamp + - 0 + - key: best_bid + path: + - bid + type: + - str + - float + - key: best_ask + path: + - ask + type: + - str + - float + - key: last_price + path: + - last_price + type: + - str + - float + - key: daily_volume + path: + - volume + type: + - str + - float + + trades: + request: + template: https://api.bitfinex.com/v1/trades/{currency_pair} + pair_template: # i.e. tBTCUSD + template: "{first}{second}" + lower_case: false + params: + limit_trades: # Number of records + default: 999 # max: 10000 + start: # Millisecond start time + required: false + end: # Millisecond end time + required: false + sort: # if = 1 it sorts results returned with old > new + default: -1 + response: + type: list + values: + type: dict + values: + # template on trading pairs (ex. tBTCUSD) + timestamp: # ID + type: int + tid: # MTS: millisecond time stamp + type: + - int + price: # Price: How much was bought (positive) or sold (negative). + type: float + amount: # Amount: Price at which the trade was executed + type: float + exchange: # Exchange Name + type: str + type: # Direction (i.e. Sell/Buy) + type: str + # template on funding currencies (ex. fUSD) + + mapping: # for trading pairs (ex. tBTCUSD) + - key: time + path: + - timestamp + type: + - float + - from_timestamp + - 0 + - key: id + path: + - tid + type: + - int + - key: amount + path: + - amount + type: + - float + - key: price + path: + - price + type: + - float + - key: direction + path: + - type + type: + - str + + order_books: + request: + template: https://api.bitfinex.com/v1/book/{currency_pair} + pair_template: # i.e. tBTCUSD + template: "{first}{second}" + lower_case: false + params: + group: # Level of price aggregation (P0, P1, P2, P3, P4, R0) + type: str + default: 1 + limit_bids: # Number of price points ("25", "100") + type: int + default: 50 + limit_asks: # Number of price points ("25", "100") + type: int + default: 50 + response: + type: dict + values: + bids: + type: list + values: + type: dict + values: + price: + type: str + amount: + type: str + timestamp: + type: str + asks: + type: list + values: + type: dict + values: + price: + type: str + amount: + type: str + timestamp: + type: str + + mapping: # for trading pairs (ex. tBTCUSD), if AMOUNT > 0 then bid else ask. + - key: id + path: + - bids + - timestamp + type: + - str + - float + - int + - key: position + path: [] + type: + - none + - range + - key: time + path: + - bids + - timestamp + type: + - str + - float + - from_timestamp + - 0 + + - key: asks_price + path: + - asks + - price + type: + - str + - float + - key: asks_amount + path: + - asks + - amount + type: + - str + - float + + - key: bids_price + path: + - bids + - price + type: + - str + - float + - key: bids_amount + path: + - bids + - amount + type: + - str + - float + + + historic_rates: + request: + template: https://api-pub.bitfinex.com/v2/candles/trade:{frequency}:{currency_pair}/hist + pair_template: # i.e. tBTCUSD + template: "t{first}{second}" + lower_case: false + params: + limit: # Number of candles requested + default: 10000 # max + start: # Filter start (ms) + required: false + end: # Filter end (ms) + function: last_timestamp + type: + - datetime + - timestampms + sort: # if = 1 it sorts results returned with old > new + required: false + + frequency: + allowed: + minutes: 1m + hours: 1h + days: 1D + weeks: 7D + months: 1M + default: 1D + + response: + type: list + values: + # response with Section = "last" + - 0: # MTS: millisecond time stamp + type: + - float + - from_timestamp + - 1 + 1: # OPEN: First execution during the time frame + type: float + 2: # CLOSE: Last execution during the time frame + type: float + 3: # HIGH: Highest execution during the time frame + type: float + 4: # LOW: Lowest execution during the timeframe + type: float + 5: # VOLUME: Quantity of symbol traded within the timeframe + type: float + # response with Section = "hist" + - type: list + values: + 0: # MTS: millisecond time stamp + type: + - float + - from_timestamp + - 1 + 1: # OPEN: First execution during the time frame + type: float + 2: # CLOSE: Last execution during the time frame + type: float + 3: # HIGH: Highest execution during the time frame + type: float + 4: # LOW: Lowest execution during the timeframe + type: float + 5: # VOLUME: Quantity of symbol traded within the timeframe + type: float + mapping: # for trading pairs (ex. tBTCUSD) + - key: time + path: + - 0 + type: + - float + - from_timestamp + - 1 + - key: open + path: + - 1 + type: + - float + - key: close + path: + - 2 + type: + - float + - key: high + path: + - 3 + type: + - float + - key: low + path: + - 4 + type: + - float + - key: volume + path: + - 5 + type: + - float diff --git a/pandas_datareader/crypto_utils/resources/bitforex.yaml b/pandas_datareader/crypto_utils/resources/bitforex.yaml new file mode 100644 index 00000000..4a66f2a2 --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/bitforex.yaml @@ -0,0 +1,335 @@ +name: bitforex +exchange: true + +rate_limit: null + +api_url: https://api.bitforex.com/api/v1/market/ + +requests: + currency_pairs: + request: + template: symbols + pair_template: null + params: null + + response: + type: list + values: + data: + type: list + values: + type: dict + values: + symbol: + type: str + + mapping: + - key: currency_pair_first + path: + - data + - symbol + type: + - str + - split + - "-" + - 2 + - key: currency_pair_second + path: + - data + - symbol + type: + - str + - split + - "-" + - 1 + + tickers: + request: + template: ticker + pair_template: + template: "coin-{second}-{first}" + alias: symbol + lower_case: true + params: null + response: + type: dict + values: + data: + type: dict + values: + buy: + type: float + date: + type: int + last: + type: float + sell: + type: float + vol: + type: float + mapping: + - key: last_price + path: + - data + - last + type: + - float + - key: time + path: + - data + - date + type: + - float + - from_timestamp + - 1 + - key: best_bid + path: + - data + - buy + type: + - float + - key: best_ask + path: + - data + - sell + type: + - float + - key: daily_volume + path: + - data + - vol + type: + - float + + historic_rates: + request: + template: kline + pair_template: + template: "coin-{second}-{first}" + lower_case: true + alias: symbol + params: + size: + max: 600 + default: 600 + ktype: + allowed: + minutes: 1min + hours: 1hour + days: 1day + weeks: 1week + months: 1month + default: 1day + + response: + type: dict + values: + data: + type: list + values: + type: dict + values: + close: + type: float + open: + type: float + high: + type: float + low: + type: float + time: + type: float + vol: + type: float + + mapping: + - key: time + path: + - data + - time + type: + - float + - from_timestamp + - 1 + - key: open + path: + - data + - open + type: + - float + - key: high + path: + - data + - high + type: + - float + - key: low + path: + - data + - low + type: + - float + - key: close + path: + - data + - close + type: + - float + - key: volume + path: + - data + - vol + type: + - float + + + trades: + request: + template: trades + pair_template: + template: "coin-{second}-{first}" + lower_case: true + alias: symbol + params: + size: + max: 600 + default: 200 + + response: + type: dict + values: + data: + type: list + values: + type: dict + values: + amount: + type: float + direction: + type: int + price: + type: float + tid: + type: int + time: + type: int + + mapping: + - key: time + path: + - data + - time + type: + - float + - from_timestamp + - 1 + - key: id + path: + - data + - tid + type: + - int + - key: direction + path: + - direction + type: + - value + - map + - 1 + - buy + - 2 + - sell + - key: price + path: + - data + - price + type: + - float + - key: amount + path: + - data + - amount + type: + - float + + order_books: + request: + template: depth + pair_template: + template: "coin-{second}-{first}" + lower_case: true + alias: symbol + params: + size: + max: 200 + default: 50 + + response: + type: dict + values: + data: + type: dict + values: + asks: + type: list + values: + type: dict + values: + amount: + type: float + price: + type: float + bids: + type: list + values: + type: dict + values: + amount: + type: float + price: + type: float + + mapping: + - key: time + path: [] + type: + - none + - now + - key: id + path: [] + type: + - none + - now_timestamp + - key: position + path: [] + type: + - none + - range + - key: bids_amount + path: + - data + - bids + - amount + type: + - float + - key: bids_price + path: + - data + - bids + - price + type: + - float + - key: asks_amount + path: + - data + - asks + - amount + type: + - float + - key: asks_price + path: + - data + - asks + - price + type: + - float \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/bithumb.yaml b/pandas_datareader/crypto_utils/resources/bithumb.yaml new file mode 100644 index 00000000..592a98ec --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/bithumb.yaml @@ -0,0 +1,420 @@ +name: bithumb +exchange: true +api_url: https://global-openapi.bithumb.pro/openapi/v1/ +rate_limit: + max: 20 + unit: 1 +requests: + + currency_pairs: + request: + template: spot/ticker + pair_template: null + params: + symbol: + type: str + default: ALL + response: + response: + type: dict + values: + data: + type: list + values: + type: dict + values: + p: # dict_key + type: dict + ver: + type: str + vol: + type: str + c: + type: str + s: + type: str + t: + type: str + v: + type: str + h: + type: str + l: + type: str + lev: + type: str + code: + type: str + msg: + type: str + timestamp: + type: int + startTime: + type: null + + mapping: + - key: currency_pair_first + path: + - data + - s + type: + - str + - split + - "-" + - 0 + - key: currency_pair_second + path: + - data + - s + type: + - str + - split + - "-" + - 1 + + tickers: + request: + template: spot/ticker + pair_template: null + params: + symbol: + type: str + default: ALL + response: + response: + type: dict + values: + data: + type: list + values: + type: dict + values: + p: # dict_key + type: dict + ver: + type: str + vol: + type: str + c: + type: str + s: + type: str + t: + type: str + v: + type: str + h: + type: str + l: + type: str + lev: + type: str + code: + type: str + msg: + type: str + timestamp: + type: int + startTime: + type: null + mapping: + - key: time + path: + - timestamp + type: + - float + - from_timestamp + - 1 + - key: currency_pair_first + path: + - data + - s + type: + - str + - split + - "-" + - 0 + - key: currency_pair_second + path: + - data + - s + type: + - str + - split + - "-" + - 1 + - key: last_price + path: + - data + - h + type: + - str + - float + - key: daily_volume + path: + - data + - v + type: + - str + - float + + order_books: + request: + template: spot/orderBook + pair_template: # e.g. BTC + template: "{first}-{second}" + alias: symbol + lower_case: false + params: null + response: + type: dict + values: + data: + type: dict + values: + symbol: + type: str + b: + type: list + values: + type: list + values: + 0: + type: str + 1: + type: str + s: + type: list + values: + type: list + values: + 0: + type: str + 1: + type: str + code: + type: str + msg: + type: str + timestamp: + type: int + startTime: + type: null + ver: + type: str + + mapping: + - key: time + path: + - timestamp + type: + - float + - from_timestamp + - 1 + - key: bids_price + path: + - data + - b + - 0 + type: + - str + - float + - key: bids_amount + path: + - data + - b + - 1 + type: + - str + - float + - key: asks_amount + path: + - data + - s + - 1 + type: + - str + - float + - key: asks_price + path: + - data + - s + - 0 + type: + - str + - float + - key: id + path: + - data + - ver + type: + - str + - int + - key: position + path: [] + type: + - none + - range + + trades: + request: + template: spot/trades + pair_template: # e.g. BTC + template: "{first}-{second}" + alias: symbol + lower_case: false + params: null + response: + type: dict + values: + data: + type: list + values: + type: dict + values: + p: + type: str + ver: + type: str + s: + type: str + t: + type: str + v: + type: str + mapping: + - key: time + path: + - data + - t + type: + - str + - float + - from_timestamp + - 0 + - key: id + path: + - data + - ver + type: + - str + - int + - key: amount + path: + - data + - v + type: + - str + - float + - key: price + path: + - data + - p + type: + - str + - float + - key: direction + path: + - data + - s + type: + - str + + historic_rates: + request: + template: spot/kline + pair_template: + template: "{first}-{second}" + alias: symbol + lower_case: false + params: + type: + allowed: + minutes: m1 + hours: h1 + days: d1 + weeks: w1 + months: M1 + default: m1 + start: + function: last_timestamp + type: + - datetime + - timedelta + - interval + - 1000 + end: + function: last_timestamp + type: + - datetime + - timestamp + + response: + type: dict + values: + data: + type: list + values: + type: dict + values: + c: + type: str + s: + type: str + t: + type: str + v: + type: str + h: + type: str + time: + type: str + l: + type: str + o: + type: str + mapping: + - key: time + path: + - data + - time + type: + - str + - float + - from_timestamp + - 0 + - key: open + path: + - data + - o + type: + - str + - float + - key: high + path: + - data + - h + type: + - str + - float + - key: low + path: + - data + - l + type: + - str + - float + - key: close + path: + - data + - c + type: + - str + - float + - key: volume + path: + - data + - v + type: + - str + - float diff --git a/pandas_datareader/crypto_utils/resources/bitmart.yaml b/pandas_datareader/crypto_utils/resources/bitmart.yaml new file mode 100644 index 00000000..744bccac --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/bitmart.yaml @@ -0,0 +1,409 @@ +name: bitmart +exchange: true +api_url: https://api-cloud.bitmart.com/spot/v1/ +rate_limit: + max: 600 # 3-90 + unit: 60 +requests: + + currency_pairs: + request: + template: symbols + pair_template: null + params: null + response: + type: dict + values: + data: + type: dict + values: + symbols: + type: list + values: + type: str + mapping: + - key: currency_pair_first + path: + - data + - symbols + type: + - str + - split + - "_" + - 0 + - key: currency_pair_second + path: + - data + - symbols + type: + - str + - split + - "_" + - 1 + + + tickers: + request: + template: ticker + pair_template: null + params: null + response: + type: dict + values: + data: + type: dict + values: + tickers: + type: list + values: + type: dict + values: + symbol: + type: str + last_price: + type: str + quote_volume: + type: str + base_volume: + type: str + best_ask: + type: str + best_bid: + type: str + mapping: + - key: time + path: [] + type: + - none + - now + - key: currency_pair_first + path: + - data + - tickers + - symbol + type: + - str + - split + - "_" + - 0 + - key: currency_pair_second + path: + - data + - tickers + - symbol + type: + - str + - split + - "_" + - 1 + + - key: last_price + path: + - data + - tickers + - last_price + type: + - str + - float + - key: best_ask + path: + - data + - tickers + - best_ask + type: + - str + - float + - key: best_bid + path: + - data + - tickers + - best_bid + type: + - str + - float + - key: daily_volume + path: + - data + - tickers + - base_volume + type: + - str + - float + + + historic_rates: + request: + template: symbols/kline + pair_template: # e.g. BMX_ETH + template: "{first}_{second}" + lower_case: false + alias: symbol + params: + step: # in minutes + allowed: + minutes: 1 + hours: 60 + days: 1440 + weeks: 10080 + months: 43200 + default: 1440 # 1d + + from: + function: last_timestamp + type: + - datetime + - timedelta + - interval + - 500 + to: # in milliseconds + function: last_timestamp + type: + - datetime + - timestamp + + response: + type: dict + values: + data: + type: dict + values: + klines: + type: list + values: + type: dict + values: + last_price: + type: str + timestamp: + type: int + volume: + type: str + open: + type: str + close: + type: str + high: + type: str + low: + type: str + mapping: + - key: time + path: + - data + - klines + - timestamp + type: + - float + - from_timestamp + - 0 + - key: open + path: + - data + - klines + - open + type: + - str + - float + - key: high + path: + - data + - klines + - high + type: + - str + - float + - key: low + path: + - data + - klines + - low + type: + - str + - float + - key: close + path: + - data + - klines + - close + type: + - str + - float + - key: volume + path: + - data + - klines + - volume + type: + - str + - float + + order_books: + request: + template: symbols/book + pair_template: # e.g. BMX_ETH + template: "{first}_{second}" + lower_case: false + alias: symbol + params: + precision: # Price precision whose range is defined in symbol details + type: int + required: false + size: + type: int + max: 200 + default: 50 + + response: + type: dict + values: + trace: + type: str + data: + type: dict + values: + buya: + type: list + values: + type: dict + values: + amount: + type: str + total: + type: str + price: + type: str + count: + type: str + sells: + type: list + values: + type: dict + values: + amount: + type: str + total: + type: str + price: + type: str + count: + type: str + + mapping: + - key: time + path: [] + type: + - none + - now + - key: id + path: [] + type: + - none + - now_timestamp + - key: position + path: [] + type: + - none + - range + - key: bids_amount + path: + - data + - buys + - amount + type: + - str + - float + - key: bids_price + path: + - data + - buys + - price + type: + - str + - float + - key: asks_amount + path: + - data + - sells + - amount + type: + - str + - float + - key: asks_price + path: + - data + - sells + - price + type: + - str + - float + + trades: + request: + template: symbols/trades + pair_template: # e.g. BMX_ETH + template: "{first}_{second}" + lower_case: false + alias: symbol + params: null + response: + type: dict + values: + data: + type: dict + values: + trades: + type: list + values: + type: dict + values: + amount: + type: str + order_time: + type: str + price: + type: str + count: + type: str + type: + type: str + mapping: + - key: amount + path: + - data + - trades + - amount + type: + - str + - float + - key: id + path: + - data + - trades + - order_time + type: + - str + - int + - key: time + path: + - data + - trades + - order_time + type: + - float + - from_timestamp + - 1 + - key: price + path: + - data + - trades + - price + type: + - str + - float + - key: direction + path: + - data + - trades + - type + type: + - str diff --git a/pandas_datareader/crypto_utils/resources/bitopro.yaml b/pandas_datareader/crypto_utils/resources/bitopro.yaml new file mode 100644 index 00000000..fbf9c46c --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/bitopro.yaml @@ -0,0 +1,345 @@ +name: bitopro +exchange: true + +rate_limit: + max: 600 + unit: 60 + +api_url: https://api.bitopro.com/v3/ + +requests: + currency_pairs: + request: + template: provisioning/trading-pairs + pair_template: null + params: null + + response: + type: dict + values: + data: + type: list + values: + type: dict + values: + base: + type: str + quote: + type: str + + mapping: + - key: currency_pair_first + path: + - data + - base + type: + - str + - key: currency_pair_second + path: + - data + - quote + type: + - str + + tickers: + request: + template: tickers + pair_template: null + params: null + response: + type: dict + values: + data: + type: list + values: + type: dict + values: + pair: + type: str + lastPrice: + type: str + volume24hr: + type: str + + mapping: + - key: currency_pair_first + path: + - data + - pair + type: + - str + - split + - "_" + - 0 + - key: currency_pair_second + path: + - data + - pair + type: + - str + - split + - "_" + - 1 + - key: last_price + path: + - data + - lastPrice + type: + - str + - float + - key: time + path: [] + type: + - none + - now + - key: daily_volume + path: + - data + - volume24hr + type: + - str + - float + + historic_rates: + request: + template: trading-history/{currency_pair} + pair_template: + template: "{first}_{second}" + lower_case: true + params: + resolution: + allowed: + minutes: 1m + hours: 1h + days: 1d + weeks: 1w + month: 1M + default: 1d + to: + function: last_timestamp + type: + - datetime + - timestamp + from: + function: last_timestamp + type: + - datetime + - timedelta + - interval + - 300 + + response: + type: dict + values: + data: + type: list + values: + type: dict + values: + timestamp: + type: int + open: + type: str + high: + type: str + low: + type: str + close: + type: str + volume: + type: str + + mapping: + - key: time + path: + - data + - timestamp + type: + - float + - from_timestamp + - 1 + - key: open + path: + - data + - open + type: + - str + - float + - key: high + path: + - data + - high + type: + - str + - float + - key: low + path: + - data + - low + type: + - str + - float + - key: close + path: + - data + - close + type: + - str + - float + - key: volume + path: + - data + - volume + type: + - str + - float + + + trades: + request: + template: trades/{currency_pair} + pair_template: + template: "{first}_{second}" + lower_case: true + params: null + + response: + type: dict + values: + data: + type: list + values: + type: dict + values: + timestamp: + type: int + isBuyer: + type: str + price: + type: str + amount: + type: str + mapping: + - key: time + path: + - data + - timestamp + type: + - float + - from_timestamp + - 0 + - key: id + path: + - data + - timestamp + type: + - int + - key: direction + path: + - data + - isBuyer + type: + - value + - map + - true + - sell + - false + - buy + - key: price + path: + - data + - price + type: + - str + - float + - key: amount + path: + - data + - amount + type: + - str + - float + + order_books: + request: + template: order-book/{currency_pair} + pair_template: + template: "{first}_{second}" + lower_case: true + params: + limit: + default: 20 + + response: + type: dict + values: + asks: + type: list + values: + type: dict + values: + amount: + type: str + count: + type: int + price: + type: str + total: + type: str + bids: + type: list + values: + type: dict + values: + amount: + type: str + count: + type: int + price: + type: str + total: + type: str + mapping: + - key: time + path: [] + type: + - none + - now + - key: id + path: [] + type: + - none + - now_timestamp + - key: position + path: [] + type: + - none + - range + - key: bids_amount + path: + - bids + - amount + type: + - str + - float + - key: bids_price + path: + - bids + - price + type: + - str + - float + - key: asks_amount + path: + - asks + - amount + type: + - str + - float + - key: asks_price + path: + - asks + - price + type: + - str + - float \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/bitstamp.yaml b/pandas_datareader/crypto_utils/resources/bitstamp.yaml new file mode 100644 index 00000000..5ee1f5b0 --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/bitstamp.yaml @@ -0,0 +1,401 @@ +name: bitstamp +exchange: true +api_url: https://www.bitstamp.net/api/v2/ +rate_limit: + max: 60 + unit: 60 +requests: + currency_pairs: + request: + template: trading-pairs-info/ + values: null + params: null + response: + type: list + values: + type: dict + values: + base_decimals: + type: int + minimum_order: + type: str + name: # e.g. LTC/USD + type: str + counter_decimals: + type: int + trading: + type: str + url_symbol: # e.g. ltcusd + type: str + description: # e.g. Litecoin / U.S. dollar + type: str + mapping: + - key: currency_pair_first + path: + - name + - 0 + type: + - str + - split + - "/" + - 0 + - key: currency_pair_second + path: + - name + - 1 + type: + - str + - split + - "/" + - 1 + + tickers: + request: + template: ticker/{currency_pair}/ + pair_template: # e.g. btcusd + template: "{first}{second}" + lower_case: true + params: null + response: + type: dict + values: + last: + type: + - str + - float + high: + type: + - str + - float + low: + type: + - str + - float + vwap: + type: + - str + - float + volume: + type: + - str + - float + bid: + type: + - str + - float + ask: + type: + - str + - float + timestamp: + type: + - str + - float + - from_timestamp + - 0 + open: + type: + - str + - float + mapping: + - key: last_price + path: + - last + type: + - str + - float + - key: daily_volume + path: + - volume + type: + - str + - float + - key: best_bid + path: + - bid + type: + - str + - float + - key: best_ask + path: + - ask + type: + - str + - float + - key: time + path: + - timestamp + type: + - str + - float + - from_timestamp + - 0 + + historic_rates: + request: + template: ohlc/{currency_pair}/ + pair_template: + template: '{first}{second}' + lower_case: true + params: + step: + type: int + allowed: + minutes: 60 + hours: 3600 + days: 86400 + weeks: 259200 + default: 86400 + limit: + type: int + default: 1000 #limit between 1 and 1000 + end: + function: last_timestamp + type: + - datetime + - timestamp + response: + type: dict + values: + data: + type: dict + values: + pair: + - str + ohlc: + type: list + values: + high: + - str + - float + timestamp: + - str + - float + - from_timestamp + - 0 + volume: + - str + - float + low: + - str + - float + open: + - str + - float + close: + - str + - float + mapping: + - key: open + path: + - data + - ohlc + - open + type: + - str + - float + - key: close + path: + - data + - ohlc + - close + type: + - str + - float + - key: high + path: + - data + - ohlc + - high + type: + - str + - float + - key: low + path: + - data + - ohlc + - low + type: + - str + - float + - key: volume + path: + - data + - ohlc + - volume + type: + - str + - float + - key: time + path: + - data + - ohlc + - timestamp + type: + - str + - float + - from_timestamp + - 0 + + order_books: + request: + template: order_book/{currency_pair} + pair_template: # e.g. btcusd + template: "{first}{second}" + lower_case: true + params: + group: + type: int + default: 1 + response: + type: dict + values: + timestamp: + type: + - str + - float + - from_timestamp + - 0 + bids: + type: list + values: + type: list + values: + 0: # price + type: + - str + - float + 1: # amount + type: + - str + - float + asks: + type: list + values: + type: list + values: + 0: # price + type: + - str + - float + 1: # amount + type: + - str + - float + mapping: + - key: time + path: + - timestamp + type: + - str + - float + - from_timestamp + - 0 + - key: bids_price + path: + - bids + - 0 + type: + - str + - float + - key: bids_amount + path: + - bids + - 1 + type: + - str + - float + - key: asks_price + path: + - asks + - 0 + type: + - str + - float + - key: asks_amount + path: + - asks + - 1 + type: + - str + - float + - key: id + path: + - timestamp + type: + - str + - int + - key: position + path: [] + type: + - none + - range + + trades: + request: + template: transactions/{currency_pair} + pair_template: # e.g. btcusd + template: "{first}{second}" + lower_case: true + params: + time: + type: str + default: hour + response: + type: list + values: + type: dict + values: + date: + type: + - str + tid: + type: + - str + price: + type: + - str + amount: + type: + - str + type: # 0 (buy) or 1 (sell). + type: + - int + mapping: + - key: time + path: + - date + type: + - str + - float + - from_timestamp + - 0 + - key: price + path: + - price + type: + - str + - float + - key: amount + path: + - amount + type: + - str + - float + - key: direction + path: + - type + type: + - value + - map + - "0" + - buy + - "1" + - sell + - key: id + path: + - tid + type: + - str + - int + diff --git a/pandas_datareader/crypto_utils/resources/bittrex.yaml b/pandas_datareader/crypto_utils/resources/bittrex.yaml new file mode 100644 index 00000000..411eecf7 --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/bittrex.yaml @@ -0,0 +1,310 @@ +name: bittrex +exchange: true +api_docs: https://bittrex.github.io/api/v3 +api_url: https://api.bittrex.com/v3/ +rate_limit: null +requests: + currency_pairs: + request: + template: markets + pair_template: null + params: null + response: + type: list + values: + type: dict + values: + symbol: + type: str + baseCurrencySymbol: + type: str + quoteCurrencySymbol: + type: str + mapping: + - key: currency_pair_first + path: + - baseCurrencySymbol + type: + - str + - key: currency_pair_second + path: + - quoteCurrencySymbol + type: + - str + + tickers: + request: + template: markets/tickers + pair_template: null + params: null + response: + type: list + values: + type: dict + values: + symbol: + type: + - str + lastTradeRate: + type: + - str + - float + bidRate: + type: + - str + - float + askRate: + type: + - str + - float + mapping: + - key: currency_pair_first + path: + - symbol + type: + - str + - split + - '-' + - 0 + - key: currency_pair_second + path: + - symbol + type: + - str + - split + - '-' + - 1 + - key: time + path: [] + type: + - none + - now + - key: last_price + path: + - lastTradeRate + type: + - str + - float + - key: best_bid + path: + - bidRate + type: + - str + - float + - key: best_ask + path: + - askRate + type: + - str + - float + + order_books: + request: + template: markets/{currency_pair}/orderbook + pair_template: + template: "{first}-{second}" + lower_case: false + params: + depth: + type: int + max: 500 + default: 25 + response: + type: dict + values: + bid: + type: list + values: + type: dict + values: + quantity: + type: str + rate: + type: str + ask: + type: list + values: + type: dict + values: + quantity: + type: str + rate: + type: str + mapping: + - key: time + path: [] + type: + - none + - now + - key: id + path: [] + type: + - none + - now_timestamp + - key: position + path: [] + type: + - none + - range + - key: bids_price + path: + - bid + - rate + type: + - str + - float + - key: bids_amount + path: + - bid + - quantity + type: + - str + - float + - key: asks_price + path: + - ask + - rate + type: + - str + - float + - key: asks_amount + path: + - ask + - quantity + type: + - str + - float + + trades: + request: + template: markets/{currency_pair}/trades + pair_template: + template: "{first}-{second}" + lower_case: true + params: null + response: + type: list + values: + type: dict + values: + id: + type: str + executedAt: + type: str + quantity: + type: str + rate: + type: str + takerSide: + type: str + + mapping: + - key: time + path: + - executedAt + type: + - str + - dateparser + - key: id + path: + - id + type: + - str + - key: price + path: + - rate + type: + - str + - float + - key: amount + path: + - quantity + type: + - str + - float + - key: direction + path: + - takerSide + type: + - str + + historic_rates: + request: + template: markets/{currency_pair}/candles/{frequency}/historical/{from} + pair_template: + template: "{first}-{second}" + lower_case: false + alias: null + params: + frequency: + allowed: + minutes: MINUTE_1 + default: MINUTE_1 + + from: + function: last_timestamp + type: + - datetime + - timedelta + - interval + - 1440 + - from_timestamp + - 0 + - "%Y/%m/%d" + + response: + type: list + values: + type: dict + values: + startsAt: + type: str + open: + type: str + high: + type: str + low: + type: str + close: + type: str + volume: + type: str + quoteVolume: + type: str + mapping: + - key: time + path: + - startsAt + type: + - str + - dateparser + - key: open + path: + - open + type: + - str + - float + - key: high + path: + - high + type: + - str + - float + - key: low + path: + - low + type: + - str + - float + - key: close + path: + - close + type: + - str + - float + - key: volume + path: + - quoteVolume + type: + - str + - float \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/bitvavo.yaml b/pandas_datareader/crypto_utils/resources/bitvavo.yaml new file mode 100644 index 00000000..af5d0e49 --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/bitvavo.yaml @@ -0,0 +1,301 @@ +name: bitvavo +exchange: true +rate_limit: + max: 1000 + unit: 60 + +api_url: https://api.bitvavo.com/v2 + +requests: + currency_pairs: + request: + template: /markets + pair_template: null + params: null + response: + type: list + values: + type: dict + values: + markets: + type: str + base: + type: str + quote: + type: str + mapping: + - key: currency_pair_first + path: + - base + type: + - str + - key: currency_pair_second + path: + - quote + type: + - str + + tickers: + request: + template: /ticker/price + pair_template: null + params: null + + response: + type: list + values: + type: dict + values: + market: + type: str + price: + type: str + mapping: + - key: currency_pair_first + path: + - market + type: + - str + - split + - "-" + - 0 + - key: currency_pair_second + path: + - market + type: + - str + - split + - "-" + - 1 + - key: last_price + path: + - price + type: + - str + - float + + + historic_rates: + request: + template: /{currency_pair}/candles + pair_template: + template: "{first}-{second}" + lower_case: false + params: + limit: + default: 1440 + start: + function: last_timestamp + type: + - datetime + - timedeltams + - interval + - 1400 + end: + function: last_timestamp + type: + - datetime + - timestampms + interval: + allowed: + minutes: 1m + hours: 1h + days: 1d + default: 1d + + response: + type: list + values: + type: list + values: + 0: #time + type: int + 1: # open + type: str + 2: # high + type: str + 3: # low + type: str + 4: # close + type: str + 5: # volume + type: str + + mapping: + - key: time + path: + - 0 + type: + - float + - from_timestamp + - 1 + - key: open + path: + - 1 + type: + - str + - float + - key: high + path: + - 2 + type: + - str + - float + - key: low + path: + - 3 + type: + - str + - float + - key: close + path: + - 4 + type: + - str + - float + - key: volume + path: + - 5 + type: + - str + - float + + trades: + request: + template: /{currency_pair}/trades + pair_template: + template: "{first}-{second}" + lower_case: false + params: + limit: + type: int + default: 500 + + response: + type: list + values: + type: dict + values: + id: + type: str + timestamp: + type: int + amount: + type: str + price: + type: str + side: + type: str + + mapping: + - key: id + path: + - id + type: + - str + - key: time + path: + - timestamp + type: + - float + - from_timestamp + - 1 + - key: direction + path: + - side + type: + - str + - key: amount + path: + - amount + type: + - str + - float + - key: price + path: + - price + type: + - str + - float + + order_books: + request: + template: /{currency_pair}/book + pair_template: + template: "{first}-{second}" + lower_case: false + params: + depth: + type: int + default: 50 + + response: + type: dict + values: + market: + type: str + nonce: + type: int + bids: + type: list + values: + type: list + values: + 0: + type: str + 1: + type: str + sells: + type: list + values: + type: list + values: + 0: # price + type: str + 1: # qty + type: str + + mapping: + - key: id + path: + - nonce + type: + - int + - key: position + path: [] + type: + - none + - range + - key: time + path: [] + type: + - none + - now + - key: bids_amount + path: + - bids + - 1 + type: + - str + - float + - key: bids_price + path: + - bids + - 0 + type: + - str + - float + - key: asks_amount + path: + - asks + - 1 + type: + - str + - float + - key: asks_price + path: + - asks + - 0 + type: + - str + - float \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/bitwell.yaml b/pandas_datareader/crypto_utils/resources/bitwell.yaml new file mode 100644 index 00000000..17444213 --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/bitwell.yaml @@ -0,0 +1,338 @@ +name: bitwell +exchange: true +rate_limit: null + +api_url: https://openapi.bitwellex.com + +requests: + currency_pairs: + request: + template: /pub/openapi/v1/symbol/spot/all + pair_template: null + params: null + + response: + type: dict + values: + data: + type: list + values: + type: dict + values: + base_asset: + type: str + quote_asset: + type: str + + mapping: + - key: currency_pair_first + path: + - data + - quote_asset + type: + - str + - key: currency_pair_second + path: + - data + - base_asset + type: + - str + + tickers: + request: + template: /pub/openapi/v1/hq/quote + pair_template: + template: "{first}_{second}" + lower_case: false + alias: symbol + params: null + response: + type: dict + values: + data: + type: list + values: + type: dict + values: + time: + type: int + highest_bid: + type: float + lowest_ask: + type: float + trade: + type: float + volume_24: + type: float + mapping: + - key: time + path: + - data + - time + type: + - float + - from_timestamp + - 2 + - key: best_bid + path: + - data + - highest_bid + type: + - float + - key: best_ask + path: + - data + - lowest_ask + type: + - float + - key: last_price + path: + - data + - trade + type: + - float + - key: daily_volume + path: + - data + - volume_24 + type: + - float + + + + historic_rates: + request: + template: /pub/openapi/v1/hq/kline + pair_template: + template: "{first}_{second}" + lower_case: false + alias: symbol + params: + type: + allowed: + minutes: 3 + hours: 2 + days: 1 + default: 1 #day + num: + type: int + max: 2880 + default: 2000 + ts: + function: last_timestamp + type: + - datetime + - timestamp + response: + type: dict + values: + data: + type: list + values: + type: dict + values: + time: + type: int + open: + type: float + high: + type: float + low: + type: float + close: + type: float + volume: + type: float + mapping: + - key: time + path: + - data + - time + type: + - float + - from_timestamp + - 0 + - key: open + path: + - data + - open + type: + - float + - key: high + path: + - data + - high + type: + - float + - key: low + path: + - data + - low + type: + - float + - key: close + path: + - data + - close + type: + - float + - key: volume + path: + - data + - volume + type: + - float + + + order_books: + request: + template: /pub/openapi/v1/hq/orderbook + pair_template: + template: "{first}_{second}" + lower_case: false + alias: symbol + params: null + + response: + type: dict + values: + data: + type: dict + values: + ask: + type: list + values: + type: list + values: + 0: + type: float + 1: + type: float + bid: + type: list + values: + type: list + values: + 0: + type: float + 1: + type: float + sn: + type: int + time: + type: int + + mapping: + - key: id + path: + - data + - sn + type: + - int + - key: time + path: + - data + - time + type: + - float + - from_timestamp + - 2 + - key: position + path: [] + type: + - none + - range + - key: bids_amount + path: + - data + - bid + - 1 + type: + - float + - key: asks_amount + path: + - data + - ask + - 1 + type: + - float + - key: bids_price + path: + - data + - bid + - 0 + type: + - float + - key: asks_price + path: + - data + - ask + - 0 + type: + - float + + trades: + request: + template: /pub/openapi/v1/hq/transaction + pair_template: + template: "{first}_{second}" + lower_case: false + alias: symbol + params: null + + response: + type: dict + values: + data: + type: list + values: + type: dict + values: + time_us: + type: int + price: + type: float + amount: + type: float + volume: + type: float + direction: + type: int + mapping: + - key: id + path: + - data + - sn + type: + - int + - key: time + path: + - data + - time_us + type: + - float + - from_timestamp + - 2 + - key: price + path: + - data + - price + type: + - float + - key: amount + path: + - data + - volume + type: + - float + - key: direction + path: + - data + - direction + type: + - value + - map + - 1 + - sell + - 2 + - buy \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/bkex.yaml b/pandas_datareader/crypto_utils/resources/bkex.yaml new file mode 100644 index 00000000..3c878d2b --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/bkex.yaml @@ -0,0 +1,356 @@ +name: bkex +exchange: true +api_url: https://api.bkex.cc + +requests: + currency_pairs: + request: + template: /v2/common/symbols + pair_template: null + params: null + response: + type: dict + values: + msg: + type: str + code: + type: str + data: + type: list + values: + type: dict + values: + coinTypes: + type: list + values: + type: dict + values: + symbol: + type: str + mapping: + - key: currency_pair_first + path: + - data + - symbol + type: + - str + - split + - "_" + - 0 + - key: currency_pair_second + path: + - data + - symbol + type: + - str + - split + - "_" + - 1 + + tickers: + request: + template: /v2/q/ticker/price + pair_template: + template: "{first}_{second}" + lower_case: false + alias: pair + params: null + response: + type: dict + values: + code: + type: int + data: + type: list + values: + type: dict + values: + price: + type: float + symbol: + type: str + mapping: + - key: currency_pair_first + path: + - data + - symbol + type: + - str + - split + - "_" + - 0 + - key: currency_pair_second + path: + - data + - symbol + type: + - str + - split + - "_" + - 1 + - key: last_price + path: + - data + - price + type: + - float + - key: time + path: [] + type: + - none + - now + + historic_rates: + request: + template: /v2/q/kline + pair_template: + template: "{first}_{second}" + lower_case: false + alias: symbol + params: + period: + allowed: + minutes: 1m + hours: 1h + days: 1d + weeks: 1w + default: 1d + size: + default: 1000 + to: + function: last_timestamp + type: + - datetime + - timestampms + from: + function: last_timestamp + type: + - datetime + - timedeltams + - interval + - 1000 + + + response: + type: dict + values: + msg: + type: str + code: + type: str + data: + type: list + values: + type: dict + values: + ts: # timestamp ms + type: int + close: # closing price + type: float + open: # opening price + type: float + hhigh: # highest price + type: float + low: # lowest price + type: float + volume: #base amount + type: float + mapping: + - key: time + path: + - data + - ts + type: + - float + - from_timestamp + - 1 + - key: low + path: + - data + - low + type: + - float + - key: high + path: + - data + - high + type: + - float + - key: open + path: + - data + - open + type: + - float + - key: close + path: + - data + - close + type: + - float + - key: volume + path: + - data + - volume + type: + - float + + order_books: + request: + template: /v2/q/depth + pair_template: + template: "{first}_{second}" + lower_case: false + alias: symbol + params: + depth: + type: + - int + default: 50 + preicion: + type: int + default: 4 + response: + type: dict + values: + msg: + type: str + code: + type: str + data: + type: dict + values: + bid: + type: list + values: + type: list + values: + 0: # price + type: float + 1: # quantity + type: float + ask: + type: list + values: + type: list + values: + 0: # price + type: float + 1: # quantity + type: float + + mapping: + - key: time + path: [] + type: + - none + - now + - key: id + path: [] + type: + - none + - now_timestamp + - key: position + path: [] + type: + - none + - range + - key: bids_price + path: + - data + - bid + - 0 + type: + - float + - key: bids_amount + path: + - data + - bid + - 1 + type: + - float + - key: asks_price + path: + - data + - ask + - 0 + type: + - float + - key: asks_amount + path: + - data + - ask + - 1 + type: + - float + + trades: + request: + template: /v2/q/deals + pair_template: + template: "{first}_{second}" + lower_case: false + alias: symbol + params: + size: + type: + - int + default: 50 + response: + type: dict + values: + msg: + type: str + code: + type: str + data: + type: list + values: + type: dict + values: + ts: + type: int + price: + type: float + volume: + type: float + direction: + type: str + mapping: + - key: time + path: + - data + - ts + type: + - float + - from_timestamp + - 1 + - key: id + path: + - data + - ts + type: + - int + - key: direction + path: + - data + - direction + type: + - value + - map + - B + - buy + - S + - sell + - key: price + path: + - data + - price + type: + - float + - key: amount + path: + - data + - volume + type: + - float \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/bleutrade.yaml b/pandas_datareader/crypto_utils/resources/bleutrade.yaml new file mode 100644 index 00000000..9ebc6bb9 --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/bleutrade.yaml @@ -0,0 +1,369 @@ +#API Dokumentation nicht auffindbar. Historic Rates flexibeler Timestamp nicht implementiert. +name: bleutrade +exchange: true +api_url: https://bleutrade.com/api/v3/ +rate_limit: null + +requests: + currency_pairs: + request: + template: public/getmarkets + pair_template: null + params: null + response: + type: dict + values: + success: + type: bool + message: + type: str + result: + type: list + values: + type: dict + values: + MarketName: + type: str # e.g. ETH_BTC + MarketAsset: # e.g. ETH + type: str + BaseAsset: # e.g. BTC + type: str + MarketAssetLong: # e.g. Ethereum + type: str + BaseAssetLong: # e.g. Bitcoin + type: str + IsActive: + type: bool + MinTradeSize: + type: float + InfoMassage: + type: str + mapping: + - key: currency_pair_first + path: + - result + - MarketAsset + type: + - str + - key: currency_pair_second + path: + - result + - BaseAsset + type: + - str + + + tickers: + request: + template: public/getticker + pair_template: + template: "{first}_{second}" + lower_case: false + alias: market + params: null + response: + type: dict + values: + success: + type: bool + message: + type: str + result: + type: list + values: + type: dict + values: + Market: + type: str + Bid: + type: float + Ask: + type: float + Last: + type: float + mapping: + - key: time + path: [] + type: + - none + - now + - key: last_price + path: + - result + - Last + type: + - float + - key: best_bid + path: + - result + - Bid + type: + - float + - key: best_ask + path: + - result + - Ask + type: + - float + + order_books: + request: + template: public/getorderbook + pair_template: # e.g. ETH_BTC + template: "{first}_{second}" + lower_case: false + alias: market + params: + type: + type: str + default: ALL + depth: + type: int + default: 20 + response: + type: dict + values: + success: + type: bool + message: + type: str + result: + type: dict + values: + buy: + type: list + values: + type: dict + values: + Quantity: + type: float + Rate: + type: float + sell: + type: list + values: + type: dict + values: + Quantity: + type: float + Rate: + type: float + mapping: + - key: time + path: [] + type: + - none + - now + - key: id + path: [] + type: + - none + - now_timestamp + - key: position + path: [] + type: + - none + - range + - key: bids_price + path: + - result + - buy + - Rate + type: + - float + - key: bids_amount + path: + - result + - buy + - Quantity + type: + - float + - key: asks_price + path: + - result + - sell + - Rate + type: + - float + - key: asks_amount + path: + - result + - sell + - Quantity + type: + - float + + trades: + request: + template: public/getmarkethistory + pair_template: # e.g. ETH_BTC + template: "{first}_{second}" + lower_case: false + alias: market + params: + count: + type: int + max: 200 + default: 20 + response: + type: dict + values: + success: + type: bool + message: + type: str + result: + type: list + values: + type: dict + values: + TradeID: + type: int + TimeStamp: + type: + - str + Quantity: + type: float + Price: + type: float + BaseVolumne: + type: float + OrderType: + type: str + Total: + type: float + + mapping: + - key: time + path: + - result + - TimeStamp + type: + - str + - dateparser + - key: id + path: + - result + - TradeID + type: + - int + - key: amount + path: + - result + - Quantity + type: + - float + - key: price + path: + - result + - Price + type: + - float + - key: direction + path: + - result + - OrderType + type: + - str + + historic_rates: + request: + template: public/getcandles + pair_template: # e.g. ETH_BTC + template: "{first}_{second}" + lower_case: false + alias: market + params: + period: + type: str + allowed: +# minutes: 1m #raises an error + hours: 1h + days: 1d + weeks: 1w + default: 1d + response: + type: dict + values: + success: + type: bool + message: + type: str + result: + type: list + values: + type: dict + values: + TimeStamp: + type: + - str + - strptime + - "%Y-%m-%d %H:%M:%S" + Open: + type: + - str + - float + High: + type: + - str + - float + Low: + type: + - str + - float + Close: + type: + - str + - float + Volume: + type: + - str + - float + BaseVolume: + type: + - str + - float + mapping: + - key: time + path: + - result + - TimeStamp + type: + - str + - strptime + - "%Y-%m-%d %H:%M:%S" + - key: open + path: + - result + - Open + type: + - str + - float + - key: high + path: + - result + - High + type: + - str + - float + - key: low + path: + - result + - Low + type: + - str + - float + - key: close + path: + - result + - Close + type: + - str + - float + - key: volume + path: + - result + - Volume + type: + - str + - float diff --git a/pandas_datareader/crypto_utils/resources/btc-alpha.yaml b/pandas_datareader/crypto_utils/resources/btc-alpha.yaml new file mode 100644 index 00000000..6ff788c2 --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/btc-alpha.yaml @@ -0,0 +1,253 @@ +name: btc-alpha +api_docs: https://btc-alpha.github.io/api-docs/ +rate_limit: null + +api_url: https://btc-alpha.com/api/ + +requests: + currency_pairs: + request: + template: v1/pairs/ + pair_template: null + params: null + response: + type: list + values: + type: dict + values: + currency1: + type: str + currency2: + type: str + mapping: + - key: currency_pair_first + path: + - currency1 + type: + - str + - key: currency_pair_second + path: + - currency2 + type: + - str + + historic_rates: + request: + template: charts/{currency_pair}/{frequency}/chart + pair_template: + template: "{first}_{second}" + lower_case: false + params: + limit: + max: 720 + default: 720 + until: + function: last_timestamp + type: + - datetime + - timestamp + frequency: + allowed: + minutes: 5 + hours: 60 + days: D + default: D + + response: + type: list + values: + type: dict + values: + time: + type: int + open: + type: float + high: + type: float + low: + type: float + close: + type: float + volume: + type: float + + mapping: + - key: time + path: + - time + type: + - float + - from_timestamp + - 0 + - key: open + path: + - open + type: + - float + - key: high + path: + - high + type: + - float + - key: low + path: + - low + type: + - float + - key: close + path: + - close + type: + - float + - key: volume + path: + - volume + type: + - float + + + trades: + request: + template: v1/exchanges + pair_template: + template: "{first}_{second}" + lower_case: false + alias: pair + params: + limit: + type: int + default: 100 + + response: + type: list + values: + type: dict + values: + id: + type: int + timestamp: + type: float + price: + type: str + amount: + type: str + type: + type: str + + mapping: + - key: time + path: + - timestamp + type: + - float + - from_timestamp + - 0 + - key: id + path: + - id + type: + - int + - key: direction + path: + - type + type: + - str + - key: price + path: + - price + type: + - str + - float + - key: amount + path: + - amount + type: + - str + - float + + order_books: + request: + template: v1/orderbook/{currency_pair} + pair_template: + template: "{first}_{second}" + lower_case: false + params: + group: + type: int + default: 1 # group by price + limit_asks: + type: int + default: 50 + limit_bids: + type: int + default: 50 + response: + type: dict + values: + sell: + type: list + values: + type: dict + values: + price: + type: float + id: # id and timestamp only if group=1 + type: int + amount: + type: float + timestamp: + type: float + buy: + type: list + values: + type: dict + values: + price: + type: float + id: + type: int + amount: + type: float + timestamp: + type: float + + mapping: + - key: time + path: [] + type: + - none + - now + - key: id + path: [] + type: + - none + - now_timestamp + - key: position + path: [] + type: + - none + - range + - key: bids_amount + path: + - buy + - amount + type: + - float + - key: bids_price + path: + - buy + - price + type: + - float + - key: asks_amount + path: + - sell + - amount + type: + - float + - key: asks_price + path: + - sell + - price + type: + - float \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/btc_turk.yaml b/pandas_datareader/crypto_utils/resources/btc_turk.yaml new file mode 100644 index 00000000..112ab64f --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/btc_turk.yaml @@ -0,0 +1,389 @@ +name: btc_turk +is_exchange: true + +api_url: "" #Base Api url changes. Complete URL therefore in templates +rate_limit: + max: 60 + unit: 60 + +requests: + currency_pairs: + request: + template: https://api.btcturk.com/api/v2/ticker + pair_template: null + params: null + response: + type: dict + values: + data: + type: dict + values: + type: list + values: + pair: + type: str + pairNormalized: + type: str + timestamp: + type: int + last: + type: float + high: + type: float + low: + type: float + bid: + type: float + ask: + type: float + open: + type: float + volume: + type: float + + mapping: + - key: currency_pair_first + path: + - data + - pairNormalized + type: + - str + - split + - "_" + - 0 + - key: currency_pair_second + path: + - data + - pairNormalized + type: + - str + - split + - "_" + - 1 + + tickers: + request: + template: https://api.btcturk.com/api/v2/ticker + pair_template: null + params: null + response: + type: dict + values: + data: + type: dict + values: + type: list + values: + pair: + type: str + pairNormalized: + type: str + timestamp: + type: int + last: + type: float + high: + type: float + low: + type: float + bid: + type: float + ask: + type: float + open: + type: float + volume: + type: float + mapping: + - key: currency_pair_first + path: + - data + - pairNormalized + type: + - str + - split + - "_" + - 0 + - key: currency_pair_second + path: + - data + - pairNormalized + type: + - str + - split + - "_" + - 1 + - key: time + path: + - data + - timestamp + type: + - float + - from_timestamp + - 1 + - key: best_bid + path: + - data + - bid + type: + - float + - key: daily_volume + path: + - data + - volume + type: + - float + - key: best_ask + path: + - data + - ask + type: + - float + - key: last_price + path: + - data + - last + type: + - float + + order_books: + request: + template: https://api.btcturk.com/api/v2/orderbook + pair_template: # e.g. BTCTRY + template: "{first}{second}" + lower_case: false + alias: pairSymbol + params: + limit: + type: int + default: 100 #max 1000 + response: + type: dict + values: + data: + type: dict + values: + timestamp: + type: int + bids: + type: list + values: + type: list + values: + 0: #price + type: str + 1: # qty + type: str + asks: + type: list + values: + type: list + values: + 0: + type: str + 1: + type: str + + mapping: + - key: time + path: + - data + - timestamp + type: + - float + - from_timestamp + - 1 + - key: id + path: + - data + - timestamp + type: + - int + - key: position + path: [] + type: + - none + - range + - key: bids_price + path: + - data + - bids + - 0 + type: + - str + - float + - key: bids_amount + path: + - data + - bids + - 1 + type: + - str + - float + - key: asks_price + path: + - data + - asks + - 0 + type: + - str + - float + - key: asks_amount + path: + - data + - asks + - 1 + type: + - str + - float + + trades: + request: + template: https://api.btcturk.com/api/v2/trades + pair_template: # e.g. BTCTRY + template: "{first}{second}" + lower_case: false + alias: pairSymbol + params: + last: + type: int + max: 50 + default: 50 + response: + type: dict + values: + data: + type: list + values: + type: dict + values: + pair: + type: str + pairNormalized: + type: str + date: + type: int + tid: + type: str + price: + type: float + amount: + type: float + side: + type: str + + + mapping: + - key: time + path: + - data + - date + type: + - float + - from_timestamp + - 1 + - key: id + path: + - data + - tid + type: + - str + - int + - key: direction + path: + - data + - side + type: + - str + - key: price + path: + - data + - price + type: + - str + - float + - key: amount + path: + - data + - amount + type: + - str + - float + + historic_rates: # no hint which currency pair is meant + request: + template: https://graph-api.btcturk.com/v1/ohlcs + pair_template: + template: "{first}_{second}" + lower_case: false + alias: pair + params: + to: # from and to params are available. But API returns every data point by default. + function: last_timestamp + type: + - datetime + - timestamp + from: + function: last_timestamp + type: + - datetime + - timedelta + - interval + - 1000 + + response: + type: list + values: + type: dict + values: + time: + type: int + open: + type: float + high: + type: float + low: + type: float + close: + type: float + volume: + type: float + average: + type: float + dailyChangeAmount: + type: float + dailyChangePercentage: + type: float + mapping: + - key: time + path: + - time + type: + - float + - from_timestamp + - 0 + - key: open + path: + - open + type: + - float + - key: high + path: + - high + type: + - float + - key: low + path: + - low + type: + - float + - key: close + path: + - close + type: + - float + - key: volume + path: + - volume + type: + - float diff --git a/pandas_datareader/crypto_utils/resources/btse.yaml b/pandas_datareader/crypto_utils/resources/btse.yaml new file mode 100644 index 00000000..094e1af6 --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/btse.yaml @@ -0,0 +1,331 @@ +name: btse +exchange: true + +rate_limit: + max: 900 + unit: 60 + +api_url: https://api.btse.com/spot/ + +requests: + currency_pairs: + request: + template: api/v3.2/market_summary + pair_template: null + params: null + + response: + type: list + values: + type: dict + values: + symbol: + type: str + base: + type: str + quote: + type: str + mapping: + - key: currency_pair_first + path: + - base + type: + - str + - key: currency_pair_second + path: + - quote + type: + - str + + tickers: + request: + template: api/v3.2/market_summary + pair_template: null + params: null + response: + type: list + values: + type: dict + values: + symbol: + type: str + base: + type: str + quote: + type: str + last: + type: float + lowestAsk: + type: float + highestBid: + type: float + volume: + type: float + + mapping: + - key: currency_pair_first + path: + - base + type: + - str + - key: currency_pair_second + path: + - quote + type: + - str + - key: last_price + path: + - last + type: + - float + - key: time + path: [] + type: + - none + - now + - key: best_bid + path: + - highestBid + type: + - float + - key: best_ask + path: + - lowestAsk + type: + - float + - key: daily_volume + path: + - volume + type: + - float + + historic_rates: + request: + template: api/v3.2/ohlcv + pair_template: + template: "{first}-{second}" + lower_case: false + alias: symbol + params: + resolution: + allowed: + minutes: 1 + hours: 60 + days: 1440 + weeks: 10080 + months: 43200 + default: 1440 + start: + function: last_timestamp + type: + - datetime + - timedelta + - interval + - 200 + end: + function: last_timestamp + type: + - datetime + - timestamp + response: + type: list + values: + type: list + values: + 0: #time + type: int + 1: #open + type: float + 2: #high + type: float + 3: #low + type: float + 4: #close + type: float + 5: #volume + type: float + mapping: + - key: time + path: + - 0 + type: + - float + - from_timestamp + - 0 + - key: open + path: + - 1 + type: + - float + - key: high + path: + - 2 + type: + - float + - key: low + path: + - 3 + type: + - float + - key: close + path: + - 4 + type: + - float + - key: volume + path: + - 5 + type: + - float + + + trades: + request: + template: api/v3.2/trades + pair_template: + template: "{first}-{second}" + lower_case: false + alias: symbol + params: +# startTime: +# function: last_timestamp +# type: +# - timestamp +# - timedelta +# - interval +# - 200 +# - datetime +# endTime: +# function: last_timestamp +# type: +# - timestmap +# - datetime + count: + default: 300 + + response: + type: list + values: + type: dict + values: + price: + type: float + size: + type: float + side: + type: str + serialId: + type: int + timestamp: + type: int + + mapping: + - key: time + path: + - timestamp + type: + - float + - from_timestamp + - 1 + - key: id + path: + - serialId + type: + - int + - key: direction + path: + - side + type: + - str + - key: price + path: + - price + type: + - float + - key: amount + path: + - size + type: + - float + + order_books: + request: + template: api/v3.2/orderbook/L2 + pair_template: + template: "{first}-{second}" + lower_case: false + alias: symbol + params: + depth: + default: 50 + + response: + type: dict + values: + timestamp: + type: int + buyQuote: + type: list + values: + type: dict + values: + price: + type: str + size: + type: str + sellQuote: + type: list + values: + type: dict + values: + price: + type: str + size: + type: str + + mapping: + - key: time + path: + - timestamp + type: + - float + - from_timestamp + - 1 + - key: id + path: + - timestamp + type: + - int + - key: position + path: [] + type: + - none + - range + - key: bids_amount + path: + - buyQuote + - size + type: + - str + - float + - key: bids_price + path: + - buyQuote + - price + type: + - str + - float + - key: asks_amount + path: + - sellQuote + - size + type: + - str + - float + - key: asks_price + path: + - sellQuote + - price + type: + - str + - float \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/bw.yaml b/pandas_datareader/crypto_utils/resources/bw.yaml new file mode 100644 index 00000000..863744b5 --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/bw.yaml @@ -0,0 +1,420 @@ +name: bw +exchange: true +rate_limit: null +api_url: https://www.bw.com/api/ + +requests: + currency_pairs: + request: + template: data/v1/tickers + pair_template: null + params: + isUseMarketName: + type: bool + default: "True" + response: + type: dict + values: + datas: + type: dict + values: + currency_pair: + type: list + + mapping: + - key: currency_pair_first + path: + - datas + - list_key + type: + - str + - split + - "_" + - 0 + - key: currency_pair_second + path: + - datas + - list_key + type: + - str + - split + - "_" + - 1 + + tickers: + request: + template: data/v1/tickers + pair_template: null + params: + isUseMarketName: + type: bool + default: "True" + response: + type: dict + values: + datas: + type: dict + values: + currency_pair: + type: list + values: + 0: #MarketID + type: int + 1: #last + type: str + 2: #high + type: str + 3: #low + type: str + 4: #24h Volumne + type: str + 5: #24h price increase + type: str + 6: #recent 6h closing price list + type: str + 7: #buy one price + type: str + 8: #sell one price + type: str + 9: #24h turnover + type: str + mapping: + - key: time + path: [] + type: + - none + - now + - key: currency_pair_first + path: + - datas + - list_key + type: + - str + - split + - "_" + - 0 + - key: currency_pair_second + path: + - datas + - list_key + type: + - str + - split + - "_" + - 1 + - key: last_price + path: + - datas + - list_values + - 1 + type: + - str + - float + - key: daily_volume + path: + - datas + - list_values + - 4 + type: + - str + - float + - key: best_bid + path: + - datas + - list_values + - 7 + type: + - str + - float + - key: best_ask + path: + - datas + - list_values + - 8 + type: + - str + - float + + historic_rates: + request: + template: data/v1/klines + pair_template: + template: "{first}_{second}" + lower_case: false + alias: marketName + params: + dataSize: + type: int + default: 500 + type: + allowed: + minutes: 1M + hours: 1H + days: 1D + weeks: 1W + default: 1D + + response: + type: dict + values: + datas: + type: list + values: + type: list + values: + 0: #data Typ + type: str + 1: #market ID + type: int + 2: #market_name + type: str + 3: #timestamp + type: int + 4: #opening Price + type: str + 5: #highest price + type: str + 6: #lowest Price + type: str + 7: #closing Price + type: #str + 8: #volume + type: str + 9: #price_range + type: str + 10: #US Dollar Exchange Rate + type: # str + 11: # K-line Period + type: str + 12: #converted + type: bool + 13: #? + type: str + resMsg: + type: dict + values: + message: + type: str + method: + type: str + code: + type: str + + mapping: + - key: time + path: + - datas + - 3 + type: + - str + - float + - from_timestamp + - 0 + - key: open + path: + - datas + - 4 + type: + - str + - float + - key: close + path: + - datas + - 7 + type: + - str + - float + - key: low + path: + - datas + - 6 + type: + - str + - float + - key: high + path: + - datas + - 5 + type: + - str + - float + - key: volume + path: + - datas + - 8 + type: + - str + - float + + + trades: + request: + template: data/v1/trades + pair_template: + template: "{first}_{second}" + lower_case: false + alias: marketName + params: + dataSize: + type: int + max: 20 + default: 20 + response: + type: dict + values: + datas: + type: list + values: + type: list + values: + 0: #trade data + type: str + 1: # market ID + type: str + 2: # timestamp + type: str + 3: # symbol + type: str + 4: # direction + type: str + 5: # price + type: str + 6: # amount + type: str + mapping: + - key: time + path: + - datas + - 2 + type: + - str + - float + - from_timestamp + - 0 + - key: id + path: + - datas + - 2 + type: + - str + - int + - key: direction + path: + - datas + - 4 + type: + - value + - map + - bid + - sell + - ask + - buy + - key: price + path: + - datas + - 5 + type: + - str + - float + - key: amount + path: + - datas + - 6 + type: + - str + - float + + order_books: + request: + template: data/v1/entrusts + pair_template: + template: "{first}_{second}" + lower_case: false + alias: marketName + params: + dataSize: + type: int + max: 50 + default: 50 + + response: + type: dict + values: + datas: + type: dict + values: + asks: + type: list + values: + type: list + values: + 0: + type: str + 1: + type: str + bids: + type: list + values: + type: list + values: + 0: + type: str + 1: + type: str + timestamp: + type: str + mapping: + - key: time + path: + - datas + - timestamp + type: + - str + - float + - from_timestamp + - 0 + - key: id + path: + - datas + - timestamp + type: + - str + - int + - key: position + path: [] + type: + - none + - range + - key: bids_amount + path: + - datas + - bids + - 1 + type: + - str + - float + - key: bids_price + path: + - datas + - bids + - 0 + type: + - str + - float + - key: asks_amount + path: + - datas + - asks + - 1 + type: + - str + - float + - key: asks_price + path: + - datas + - asks + - 0 + type: + - str + - float + diff --git a/pandas_datareader/crypto_utils/resources/chiliz.yaml b/pandas_datareader/crypto_utils/resources/chiliz.yaml new file mode 100644 index 00000000..bd4f34a7 --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/chiliz.yaml @@ -0,0 +1,304 @@ +name: chiliz +is_exchange: true + +api_url: https://api.chiliz.net/ +rate_limit: + max: 3000 + unit: 60 + +requests: + currency_pairs: + request: + template: openapi/v1/brokerInfo + pair_template: null + params: null + + response: + type: dict + values: + symbols: + type: list + values: + type: dict + values: + baseAsset: + type: str + quoteAsset: + type: str + + mapping: + - key: currency_pair_first + path: + - symbols + - baseAsset + type: + - str + - key: currency_pair_second + path: + - symbols + - quoteAsset + type: + - str + + tickers: + request: + template: openapi/quote/v1/ticker/price + pair_template: + template: "{first}{second}" + lower_case: false + alias: symbol + params: null + + response: + type: dict + values: + symbol: + type: str + price: + type: str + mapping: + - key: time + path: [] + type: + - none + - now + - key: last_price + path: + - price + type: + - str + - float + + order_books: + request: + template: openapi/quote/v1/depth + pair_template: + template: "{first}{second}" + lower_case: false + alias: symbol + params: + limit: + type: int + max: 100 + default: 100 + response: + type: dict + values: + time: + type: int + bids: + type: list + values: + type: list + 0: #price + type: str + 1: #qty + type: str + asks: + type: list + values: + type: list + 0: + type: str + 1: + type: str + mapping: + - key: time + path: + - time + type: + - float + - from_timestamp + - 1 + - key: id + path: + - time + type: + - int + - key: position + path: [] + type: + - none + - range + - key: bids_price + path: + - bids + - 0 + type: + - str + - float + - key: bids_amount + path: + - bids + - 1 + type: + - str + - float + - key: asks_price + path: + - asks + - 0 + type: + - str + - float + - key: asks_amount + path: + - asks + - 1 + type: + - str + - float + + trades: + request: + template: openapi/quote/v1/trades + pair_template: + template: "{first}{second}" + lower_case: false + alias: symbol + params: + limit: + type: int + max: 1000 + default: 500 + response: + type: list + value: + type: dict + values: + price: + type: str + qty: + typ: str + time: + type: int + isBuyerMaker: + type: bool + mapping: + - key: time + path: + - time + type: + - float + - from_timestamp + - 1 + - key: direction + path: + - isBuyerMaker + type: + - value + - map + - True + - sell + - False + - buy + - key: id + path: + - time + type: + - int + - key: price + path: + - price + type: + - str + - float + - key: amount + path: + - qty + type: + - str + - float + + historic_rates: + request: + template: openapi/quote/v1/klines + pair_template: + template: "{first}{second}" + lower_case: false + alias: symbol + params: + interval: + allowed: + minutes: 1m + hours: 1h + days: 1d + weeks: 1w + months: 1M + default: 1d + limit: + type: int + max: 1000 + default: 1000 + endTime: + function: last_timestamp + type: + - datetime + - timestampms + + response: + type: list + values: + type: list + values: + 0: #timestamp + type: int + 1: #open + type: str + 2: #high + type: str + 3: #low + type: str + 4: #close + type: str + 5: #volume + type: str + 6: #close time + type: int + 7: # quote Asset volume + type: str + 8: # number of trades + type: int + 9: # taker buy base asset volume + type: str + 10: # taker buy quote asset volume + type: str + + mapping: + - key: time + path: + - 0 + type: + - float + - from_timestamp + - 1 + - key: open + path: + - 1 + type: + - str + - float + - key: high + path: + - 2 + type: + - str + - float + - key: low + path: + - 3 + type: + - str + - float + - key: close + path: + - 4 + type: + - str + - float + - key: volume + path: + - 5 + type: + - str + - float \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/coinbase.yaml b/pandas_datareader/crypto_utils/resources/coinbase.yaml new file mode 100644 index 00000000..75000915 --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/coinbase.yaml @@ -0,0 +1,338 @@ +name: coinbase +exchange: true +api_url: https://api.pro.coinbase.com/ +rate_limit: + max: 180 + unit: 60 +requests: + currency_pairs: + request: + template: products/ + pair_template: null + params: null + response: + type: list + values: + type: dict + values: + id: # i.e. "BTC-USD" + type: str + base_currency: # i.e. "BTC" + type: str + quote_currency: # i.e. "USD" + type: str + base_min_size: + type: + - str + base_max_size: + type: + - str + quote_increment: + type: + - str + mapping: + - key: currency_pair_first + path: + - base_currency + type: + - str + - key: currency_pair_second + path: + - quote_currency + type: + - str + + tickers: + request: + template: products/{currency_pair}/ticker + pair_template: # e.g. BTC-USD + template: "{first}-{second}" + lower_case: false + params: null + response: + type: dict + values: + trade_id: + type: int + price: + type: + - str + size: + type: + - str + bid: + type: + - str + ask: + type: + - str + volume: + type: + - str + time: + type: + - str + mapping: + + - key: last_price + path: + - price + type: + - str + - float + - key: best_bid + path: + - bid + type: + - str + - float + - key: best_ask + path: + - ask + type: + - str + - float + - key: daily_volume + path: + - volume + type: + - str + - float + - key: time + path: + - time + type: + - str + - dateparser + + + order_books: + request: + template: products/{currency_pair}/book + pair_template: # e.g. BTC-USD + template: "{first}-{second}" + lower_case: false + params: + level: + type: int + possible: + - 1 # Only the best bid and ask + - 2 # Top 50 bids and asks (aggregated) + - 3 # Full order book (non aggregated), Abuse of Level 3 via polling will cause your access to be limited or blocked. + default: 2 + response: + type: dict + values: + sequence: + type: + - int + bids: + type: list + values: + type: list + values: + 0: # price + type: + - str + 1: # size + type: + - str + 2: # num-orders + type: int + asks: + type: list + values: + type: list + values: + 0: # price + type: + - str + 1: # size + type: + - str + 2: # num-orders + type: int + mapping: + - key: time + path: [] + type: + - none + - now + - key: bids_price + path: + - bids + - 0 + type: + - str + - float + - key: bids_amount + path: + - bids + - 1 + type: + - str + - float + - key: asks_price + path: + - asks + - 0 + type: + - str + - float + - key: asks_amount + path: + - asks + - 1 + type: + - str + - float + - key: position + path: [] + type: + - none + - range + - key: id + path: + - sequence + type: + - int + + + trades: + request: + template: products/{currency_pair}/trades + pair_template: # e.g. BTC-USD + template: "{first}-{second}" + lower_case: false + params: null + response: + type: list + values: + type: dict + values: + time: + type: + - str + trade_id: + type: int + price: + type: + - str + size: + type: + - str + side: + type: str + mapping: + - key: time + path: + - time + type: + - str + - dateparser + - key: price + path: + - price + type: + - str + - float + - key: amount + path: + - size + type: + - str + - float + - key: direction + path: + - side + type: + - str + - key: id + path: + - trade_id + type: + - int + + historic_rates: # Historical rates should not be polled frequently. If you need real-time information, use the trade and book endpoints along with the websocket feed. + request: + template: products/{currency_pair}/candles + pair_template: # e.g. BTC-USD + template: "{first}-{second}" + lower_case: false + params: + start: # Start time in ISO 8601 "%Y-%m-%dT%H:%M:%S.%fZ" + function: last_timestamp + type: + - datetime + - timedelta + - interval + - 300 + - from_timestamp + - 0 + - "%Y-%m-%dT%H:%M:%S.%fZ" + end: # End time in ISO 8601 + function: last_timestamp + type: + - datetime + - format + - "%Y-%m-%dT%H:%M:%S.%fZ" + granularity: # Desired timeslice in seconds + type: int + allowed: + minutes: 60 + hours: 3600 + days: 86400 + default: 86400 + response: + type: list + values: + type: list + values: + 0: # start time + type: int + 1: # low + type: float + 2: # high + type: float + 3: # open + type: float + 4: # close + type: float + 5: # volume + type: float + mapping: + - key: time + path: + - 0 + type: + - float + - from_timestamp + - 0 + - to_end + - interval + + - key: low + path: + - 1 + type: + - float + - key: high + path: + - 2 + type: + - float + - key: open + path: + - 3 + type: + - float + - key: close + path: + - 4 + type: + - float + - key: volume + path: + - 5 + type: + - float diff --git a/pandas_datareader/crypto_utils/resources/coinbene.yaml b/pandas_datareader/crypto_utils/resources/coinbene.yaml new file mode 100644 index 00000000..70621f7b --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/coinbene.yaml @@ -0,0 +1,378 @@ +name: coinbene +exchange: true +api_url: https://openapi-exchange.coinbene.com/api/exchange/v2/market/ +rate_limit: + max: 15 + unit: 1 +requests: + currency_pairs: + request: + template: tradePair/list + pair_template: null + params: null + response: + type: dict + values: + code: + type: int + data: + type: list + values: + type: dict + values: + symbol: + type: str + baseAsset: + type: str + quoteAsset: + type: str + mapping: + - key: currency_pair_first + path: + - data + - baseAsset + type: + - str + - key: currency_pair_second + path: + - data + - quoteAsset + type: + - str + + tickers: + request: + template: ticker/one + pair_template: + template: "{first}/{second}" + lower_case: false + alias: symbol + params: null + response: + type: dict + values: + code: + type: int + message: + type: str + data: + type: dict + values: + symbol: + type: str + latestPrice: + type: str + bestBid: + type: str + bestAsk: + type: str + high24h: + type: str + low24h: + type: str + volume24h: + type: str + chg24h: + type: str + chg0h: + type: str + mapping: + - key: time + path: [] + type: + - none + - now + - key: last_price + path: + - data + - latestPrice + type: + - str + - float + - key: best_bid + path: + - data + - bestBid + type: + - str + - float + - key: best_ask + path: + - data + - bestAsk + type: + - str + - float + + trades: + request: + template: trades + pair_template: + template: "{first}/{second}" + lower_case: false + alias: symbol + params: null + response: + type: dict + values: + code: + type: int + data: + type: list + values: + type: list + 0: + type: str + 1: + type: str + 2: + type: str + 3: + type: str + 4: + type: str + mapping: + - key: time + path: + - data + - 4 + type: + - str + - strptime + - "%Y-%m-%dT%H:%M:%S.%fZ" + - key: id + path: + - data + - 4 + type: + - strptime + - totimestamp + - "%Y-%m-%dT%H:%M:%S.%fZ" + - key: amount + path: + - data + - 2 + type: + - str + - float + - key: price + path: + - data + - 1 + type: + - str + - float + - key: direction + path: + - data + - 3 + type: + - str + + historic_rates: + request: + template: instruments/candles + pair_template: + template: "{first}/{second}" + lower_case: false + alias: symbol + params: + period: + allowed: + minutes: 1 + hours: 60 + days: D + weeks: W + months: M + default: D + end: + function: last_timestamp + type: + - datetime + - timestamp + response: + type: dict + values: + code: + type: int + data: + type: list + values: + type: list + values: + 0: #timestamp + type: str + 1: # open + type: str + 2: # high + type: str + 3: # low + type: str + 4: # close + type: str + 5: #volume + type: str + mapping: + - key: time + path: + - data + - 0 + type: + - str + - strptime + - "%Y-%m-%dT%H:%M:%S.%fZ" + - key: open + path: + - data + - 1 + type: + - str + - float + - key: high + path: + - data + - 2 + type: + - str + - float + - key: low + path: + - data + - 3 + type: + - str + - float + - key: close + path: + - data + - 4 + type: + - str + - float + - key: volume + path: + - data + - 5 + type: + - str + - float + + order_books: + request: + template: orderBook + pair_template: + template: "{first}/{second}" + lower_case: false + alias: symbol + params: + depth: + type: int + default: 100 + response: + type: dict + values: + code: + type: int + data: + type: dict + values: + asks: + type: list + values: + type: list + values: + 0: # Price + type: str + 1: # Size + type: str + bids: + type: list + values: + type: list + values: + 0: # Price + type: str + 1: # Size + type: str + mapping: + - key: id + path: [] + type: + - none + - now_timestamp + - key: position + path: [] + type: + - none + - range + - key: time + path: [] + type: + - none + - now + - key: bids_price + path: + - data + - bids + - 0 + type: + - str + - float + - key: bids_amount + path: + - data + - bids + - 1 + type: + - str + - float + - key: asks_amount + path: + - data + - asks + - 1 + type: + - str + - float + - key: asks_price + path: + - data + - asks + - 0 + type: + - str + - float + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pandas_datareader/crypto_utils/resources/coindcx.yaml b/pandas_datareader/crypto_utils/resources/coindcx.yaml new file mode 100644 index 00000000..8cdcbe62 --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/coindcx.yaml @@ -0,0 +1,221 @@ +# Structure of Order-Books not applicable to our program. Tickers not with single request, while CP are not separated. + +name: coindcx +exchange: true + +rate_limit: null + +api_url: "" #Base URL differs + +requests: + currency_pairs: + request: + template: https://api.coindcx.com/exchange/v1/markets_details + pair_template: null + params: null + response: + type: list + values: + type: dict + values: + base_currency_short_name: + type: str + target_currency_short_name: + type: str + + mapping: + - key: currency_pair_first + path: + - target_currency_short_name + type: + - str + - key: currency_pair_second + path: + - base_currency_short_name + type: + - str + + historic_rates: + request: + template: https://public.coindcx.com/market_data/candles + pair_template: + template: "B-{first}_{second}" + lower_case: false + alias: pair + params: + limit: + dafault: 1000 + interval: + allowed: + minutes: 1m + hours: 1h + days: 1d + weeks: 1w +# months: 1M + default: 1d + endTime: + function: last_timestamp + type: + - datetime + - timestampms + startTime: + function: last_timestamp + type: + - datetime + - timedeltams + - interval + - 1000 + response: + type: list + values: + type: dict + values: + open: + type: float + high: + type: float + low: + type: float + close: + type: float + volume: + type: float + time: + type: int + mapping: + - key: time + path: + - time + type: + - float + - from_timestamp + - 1 + - key: open + path: + - open + type: + - float + - key: high + path: + - high + type: + - float + - key: low + path: + - low + type: + - float + - key: close + path: + - close + type: + - float + - key: volume + path: + - volume + type: + - float + + trades: + request: + template: https://public.coindcx.com/market_data/trade_history + pair_template: + template: "B-{first}_{second}" + lower_case: false + alias: pair + params: + limit: + default: 100 + max: 500 + response: + type: list + values: + type: dict + values: + p: + type: float + q: + type: float + s: + type: str + T: + type: int + m: + type: str + + mapping: + - key: direction + path: + - m + type: + - value + - map + - True + - sell + - False + - buy + - key: time + path: + - T + type: + - float + - from_timestamp + - 1 + - key: id + path: + - T + type: + - int + + - key: price + path: + - p + type: + - float + - key: amount + path: + - q + type: + - float +# +# order_books: +# request: +# template: /market_data/orderbook +# pair_template: +# template: "B{first}_{second}" +# lower_case: false +# alias: pair +# params: null +# +# response: +# type: dict +# values: +# bids: +# type: dict +# values: +# +# +# mapping: +# - key: time +# path: +# type: +# - key: id +# path: +# type: +# - key: position +# path: [] +# type: +# - none +# - range +# - key: bids_amount +# path: +# type: +# - key: bids_price +# path: +# type: +# - key: asks_amount +# path: +# type: +# - key: asks_price +# path: +# type: \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/coinegg.yaml b/pandas_datareader/crypto_utils/resources/coinegg.yaml new file mode 100644 index 00000000..ef9d0b34 --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/coinegg.yaml @@ -0,0 +1,310 @@ +name: coinegg +exchange: true + +rate_limit: + max: 3000 + unit: 60 + +api_url: https://api.coinegg.fun/ + +requests: + currency_pairs: + request: + template: openapi/v1/brokerInfo + pair_template: null + params: null + + response: + type: dict + values: + symbols: + type: list + values: + type: dict + values: + baseAsset: + type: str + quoteAsset: + type: str + + mapping: + - key: currency_pair_first + path: + - symbols + - baseAsset + type: + - str + - key: currency_pair_second + path: + - symbols + - quoteAsset + type: + - str + + tickers: + request: + template: openapi/quote/v1/ticker/price + pair_template: + template: "{first}{second}" + lower_case: false + alias: sybmol + params: null + response: + type: dict + values: + symbol: + type: str + price: + type: str + + mapping: + - key: last_price + path: + - price + type: + - str + - float + - key: time + path: [] + type: + - none + - now + + historic_rates: + request: + template: openapi/quote/v1/klines + pair_template: + template: "{first}{second}" + lower_case: false + alias: symbol + params: + interval: + allowed: + minutes: 1m +# hours: 1h + days: 1d + weeks: 1w + months: 1M + default: 1d + endTime: + function: last_timestamp + type: + - datetime + - timestampms +# startTime: #not required with endTime and limit parameter +# function: last_timestamp +# type: +# - datetime +# - timedeltams +# - interval +# - 100 + limit: + type: + - int + default: 1000 + + response: + type: list + values: + type: list + values: + 0: #open time + type: int + 1: #open + type: str + 2: # high + type: str + 3: # low + type: str + 4: # close + type: str + 5: # vol + type: str + 6: # close time + type: int + 7: # quote_vol + type: str + + mapping: + - key: time + path: + - 0 + type: + - float + - from_timestamp + - 1 + - to_end + - interval + - key: open + path: + - 1 + type: + - str + - float + - key: high + path: + - 2 + type: + - str + - float + - key: low + path: + - 3 + type: + - str + - float + - key: close + path: + - 4 + type: + - str + - float + - key: volume + path: + - 5 + type: + - str + - float + + + trades: + request: + template: openapi/quote/v1/trades + pair_template: + template: "{first}{second}" + lower_case: false + alias: symbol + params: + limit: + default: 500 #max: 1000 + + response: + type: list + values: + type: dict + values: + price: + type: str + time: + type: int + qty: + type: str + isBuyerMaker: + type: bool + + mapping: + - key: time + path: + - time + type: + - float + - from_timestamp + - 1 + - key: id + path: + - time + type: + - int + - key: direction + path: + - isBuyerMaker + type: + - value + - map + - true + - sell + - false + - buy + - key: price + path: + - price + type: + - str + - float + - key: amount + path: + - qty + type: + - str + - float + + order_books: + request: + template: openapi/quote/v1/depth + pair_template: + template: "{first}{second}" + lower_case: false + alias: symbol + params: + limit: + default: 50 + + response: + type: dict + values: + time: + type: int + bids: + type: list + values: + type: list + values: + 0: + type: str + 1: + type: str + asks: + type: list + values: + type: list + values: + 0: #price + type: str + 1: #qty + type: str + + mapping: + - key: time + path: + - time + type: + - float + - from_timestamp + - 1 + - key: id + path: + - time + type: + - int + - key: position + path: [] + type: + - none + - range + - key: bids_amount + path: + - bids + - 1 + type: + - str + - float + - key: bids_price + path: + - bids + - 0 + type: + - str + - float + - key: asks_amount + path: + - asks + - 1 + type: + - str + - float + - key: asks_price + path: + - asks + - 0 + type: + - str float \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/coinex.yaml b/pandas_datareader/crypto_utils/resources/coinex.yaml new file mode 100644 index 00000000..98ada1fe --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/coinex.yaml @@ -0,0 +1,411 @@ +name: coinex +terms: + terms_url: https://www.coinex.com/service + permission: false + search_targets: + - tag: div + class: article-body-inner +api_url: https://api.coinex.com/v1/ + +rate_limit: null # 20 times per second per IP (for Trading and Account API); no limit on Market API +requests: + currency_pairs: + request: + template: market/info + pair_template: null + params: null + response: + type: dict + values: + code: + type: int + data: + type: dict + values: + currency_pair: + type: dict + values: + name: + type: str + pricing_name: + type: str + trading_name: + type: str + mapping: + - key: currency_pair_first + path: + - data + - dict_values + - trading_name + type: + - str + - key: currency_pair_second + path: + - data + - dict_values + - pricing_name + type: + - str + + tickers: + request: + template: market/ticker + pair_template: + template: "{first}{second}" + lower_case: false + alias: market + params: null + response: + type: dict + values: + code: + type: int + data: + type: dict + values: + date: + type: int + ticker: + type: dict + values: + vol: + type: str + low: + type: str + open: + type: str + high: + type: str + last: + type: str + buy: + type: str + buy_amount: + type: str + sell: + type: str + sell_amount: + type: str + message: + type: str + mapping: + - key: time + path: [] + type: + - none + - now + - key: best_bid + path: + - data + - ticker + - buy + type: + - str + - float + - key: last_price + path: + - data + - ticker + - last + type: + - str + - float + - key: best_ask + path: + - data + - ticker + - sell + type: + - str + - float + - key: daily_volume + path: + - data + - ticker + - vol + type: + - str + - float +# + order_books: + request: + template: market/depth + pair_template: # e.g. BTCBCH + template: "{first}{second}" + lower_case: false + alias: market + params: + merge: + type: float + required: true + default: "0" + limit: + type: int + default: 50 + response: + type: dict + values: + code: + type: int + data: + type: dict + values: + last: + type: + - str + asks: + type: list + values: + type: list + values: + 0: # Order price + type: + - str + 1: # Order amount + type: + - str + bids: + type: list + values: + type: list + values: + 0: # Order price + type: + - str + 1: # Order amount + type: + - str + message: + type: str + mapping: + - key: time + path: + - data + - time + type: + - float + - from_timestamp + - 1 + - key: id + path: + - data + - time + type: + - int + - key: position + path: [] + type: + - none + - range + - key: asks_price + path: + - data + - asks + - 0 + type: + - str + - float + - key: asks_amount + path: + - data + - asks + - 1 + type: + - str + - float + - key: bids_price + path: + - data + - bids + - 0 + type: + - str + - float + - key: bids_amount + path: + - data + - bids + - 1 + type: + - str + - float + + trades: + request: + template: market/deals + pair_template: # e.g. BTCBCH + template: "{first}{second}" + lower_case: false + alias: market + params: + last_id: # Transaction history id, send 0 to draw from the latest record. + type: int + default: "0" + limit: + type: int + default: 100 # less than 1,000 + response: + type: dict + values: + code: + type: int + data: + type: list + values: + type: dict + values: + amount: + type: + - str + - float + date: + type: + - int + date_ms: + type: + - int + id: + type: int + price: + type: + - str + - float + type: + type: str + message: + type: str + mapping: + - key: id + path: + - data + - id + type: + - int + - key: amount + path: + - data + - amount + type: + - str + - float + - key: time + path: + - data + - date + type: + - float + - from_timestamp + - 0 + - key: price + path: + - data + - price + type: + - str + - float + - key: direction + path: + - data + - type + type: + - str + + historic_rates: + request: + template: market/kline + pair_template: # e.g. BTCBCH + template: "{first}{second}" + lower_case: false + alias: market + params: + type: + type: str + allowed: + minutes: 1min + hours: 1hour + days: 1day + weeks: 1week + default: 1day + limit: # Less than or equal to 1000 + type: int + max: 1000 + default: 1000 + response: + type: dict + values: + code: + type: int + data: + type: list + values: + type: list + values: + 0: # Time + type: + - int + 1: # open + type: + - str + 2: # close + type: + - str + 3: # highest + type: + - str + 4: # lowest + type: + - str + 5: # volume + type: + - str + 6: # amount + type: + - str + 7: # market + type: str + message: + type: str + mapping: + - key: time + path: + - data + - 0 + type: + - float + - from_timestamp + - 0 + - key: open + path: + - data + - 1 + type: + - str + - float + - key: close + path: + - data + - 2 + type: + - str + - float + - key: high + path: + - data + - 3 + type: + - str + - float + - key: low + path: + - data + - 4 + type: + - str + - float + - key: volume + path: + - data + - 5 + type: + - str + - float diff --git a/pandas_datareader/crypto_utils/resources/coinfield.yaml b/pandas_datareader/crypto_utils/resources/coinfield.yaml new file mode 100644 index 00000000..546f3fc1 --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/coinfield.yaml @@ -0,0 +1,348 @@ +name: coinfield +exchange: true + +rate_limit: null + +api_url: https://api.coinfield.com/v1/ + +requests: + currency_pairs: + request: + template: markets + pair_template: null + params: null + + response: + type: dict + values: + markets: + type: list + values: + type: dict + values: + id: + type: str + name: + type: str + + mapping: + - key: currency_pair_first + path: + - markets + - name + type: + - str + - split + - "/" + - 0 + - key: currency_pair_second + path: + - markets + - name + type: + - str + - split + - "/" + - 1 + + tickers: + request: + template: tickers/{currency_pair} + pair_template: + template: "{first}{second}" + lower_case: true + params: null + response: + type: dict + values: + markets: + type: list + values: + type: dict + values: + timestamp: + type: str + bid: + type: float + ask: + type: float + vol: + type: float + last: + type: float + + mapping: + - key: last_price + path: + - markets + - last + type: + - float + - key: time + path: [] + type: + - none + - now + - key: best_bid + path: + - markets + - bid + type: + - float + - key: best_ask + path: + - markets + - ask + type: + - float + - key: daily_volume + path: + - markets + - vol + type: + - float + + historic_rates: + request: + template: ohlc/{currency_pair} + pair_template: + template: "{first}{second}" + lower_case: true + params: + limit: + default: 400 + period: + allowed: + minutes: 1 + hours: 60 + days: 1440 + weeks: 10080 + default: 1440 + to: + function: last_timestamp + type: + - datetime + - timestamp + from: + function: last_timestamp + type: + - datetime + - timedelta + - interval + - 400 + response: + type: dict + values: + ohlc: + type: list + values: + type: dict + values: + ts: + type: str + o: + type: str + h: + type: str + l: + type: str + c: + type: str + v: + type: str + + mapping: + - key: time + path: + - ohlc + - ts + type: + - str + - dateparser + - key: open + path: + - ohlc + - o + type: + - str + - float + - key: high + path: + - ohlc + - h + type: + - str + - float + - key: low + path: + - ohlc + - l + type: + - str + - float + - key: close + path: + - ohlc + - c + type: + - str + - float + - key: volume + path: + - ohlc + - v + type: + - str + - float + + + trades: + request: + template: trades/{currency_pair} + pair_template: + template: "{first}{second}" + lower_case: true + params: + limit: + default: 200 + + response: + type: dict + values: + trades_hash: + type: str + trades: + type: list + values: + type: dict + values: + id: + type: int + price: + type: str + volume: + type: str + total_value: + type: str + timestamp: + type: str + + + mapping: + - key: time + path: + - trades + - timestamp + type: + - str + - dateparser + - key: id + path: + - trades + - id + type: + - int +# - key: direction +# path: +# type: + - key: price + path: + - trades + - price + type: + - str + - float + - key: amount + path: + - trades + - volume + type: + - str + - float + + order_books: + request: + template: orderbook/{currency_pair} + pair_template: + template: "{first}{second}" + lower_case: true + params: + limit: + default: 50 + + response: + type: dict + values: + asks_hash: + type: str + bids: + type: list + values: + type: dict + values: + id: + type: int + price: + type: str + volume: + type: str + timestamp: + type: str + asks: + type: list + values: + type: dict + values: + id: + type: int + price: + type: str + volume: + type: str + timestamp: + type: str + + mapping: + - key: time + path: [] + type: + - none + - now + - key: id + path: [] + type: + - none + - now_timestamp + - key: position + path: [] + type: + - none + - range + - key: bids_amount + path: + - bids + - volume + type: + - str + - float + - key: bids_price + path: + - bids + - price + type: + - str + - float + - key: asks_amount + path: + - asks + - volume + type: + - str + - float + - key: asks_price + path: + - asks + - price + type: + - str + - float \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/coingecko.yaml b/pandas_datareader/crypto_utils/resources/coingecko.yaml new file mode 100644 index 00000000..7ea0a9f9 --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/coingecko.yaml @@ -0,0 +1,120 @@ +name: coingecko +exchange: false +api_url: https://api.coingecko.com/api/v3/ +#api_url: https://api.coingecko.com/api/v2/ +rate_limit: + max: 50 + unit: 60 + +requests: + currency_pairs: + request: + template: coins/list + pair_template: null + params: null + + response: + type: list + values: + type: dict + values: + id: + type: str + symbol: + type: str + name: + type: str + + mapping: + - key: currency_pair_first + path: + - id + type: + - str + - key: currency_pair_second + path: [] + type: + - none + - constant + - USD + + historic_rates: + request: + template: coins/{currency_pair}/market_chart + pair_template: + template: "{first}" + lower_case: true + params: + vs_currency: + type: str + default: USD + days: + type: int + default: max + interval: + allowed: + days: daily + default: daily + + response: + type: dict + values: + prices: + type: list + values: + type: list + values: + 0: + type: int + 1: + type: float + market_caps: + type: list + values: + type: list + values: + 0: + type: int + 1: + type: float + total_volumes: + type: list + values: + type: list + values: + 0: + type: int + 1: + type: float + + mapping: + - key: time + path: + - prices + - 0 + type: + - float + - from_timestamp + - 1 + - to_end + - interval + - key: close + path: + - prices + - 1 + type: + - float + - key: volume + path: + - total_volumes + - 1 + type: + - float + - key: market_cap + path: + - market_caps + - 1 + type: + - float + + diff --git a/pandas_datareader/crypto_utils/resources/coinhe.yaml b/pandas_datareader/crypto_utils/resources/coinhe.yaml new file mode 100644 index 00000000..8a06582e --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/coinhe.yaml @@ -0,0 +1,333 @@ +name: coinhe +exchange: true + +rate_limit: null + +api_url: https://api.coinhe.io/v1/ + +requests: + currency_pairs: + request: + template: market-summary/ + pair_template: null + params: null + + response: + type: list + values: + tyoe: dict + values: + currency_pair: + type: dict + + mapping: + - key: currency_pair_first + path: + - dict_key + type: + - str + - split + - "_" + - 1 + - key: currency_pair_second + path: + - dict_key + type: + - str + - split + - "_" + - 0 + + tickers: + request: + template: market-summary/ + pair_template: null + params: null + response: + type: list + values: + tyoe: dict + values: + currency_pair: + type: dict + values: + lastUpdateTimestamp: + type: int + LastPrice: + type: float + highestBid: + type: float + lowestAsk: + type: float + baseVolume24g: + type: float + quoteVolume24h: + type: float + + mapping: + - key: currency_pair_first + path: + - dict_key + type: + - str + - split + - "_" + - 1 + - key: currency_pair_second + path: + - dict_key + type: + - str + - split + - "_" + - 0 + - key: last_price + path: + - dict_values + - LastPrice + type: + - float + - key: time + path: + - dict_values + - lastUpdateTimestamp + type: + - float + - from_timestamp + - 0 + - key: best_bid + path: + - dict_values + - highestBid + type: + - float + - key: best_ask + path: + - dict_values + - lowestAsk + type: + - float + - key: daily_volume + path: + - dict_values + - baseVolume24h + type: + - float + - key: daily_base_volume + path: + - dict_values + - quoteVolume24h + type: + - float + + historic_rates: + request: + template: candlestick-v2 + pair_template: + template: "{second}_{first}" + lower_case: false + alias: pair + params: + interval: + allowed: + minutes: 5m + days: 1d + default: 5m + timestamp: + function: last_timestamp + type: + - datetime + - timestamp + response: + type: list + values: + type: dict + values: + close: + type: str + high: + type: str + open: + type: str + low: + type: str + volume: + type: str + timestamp: + type: int + + mapping: + - key: time + path: + - timestamp + type: + - float + - from_timestamp + - 0 + - key: open + path: + - open + type: + - str + - float + - key: high + path: + - high + type: + - str + - float + - key: low + path: + - low + type: + - str + - float + - key: close + path: + - close + type: + - str + - float + - key: volume + path: + - volume + type: + - str + - float + + + trades: + request: + template: trades/{currency_pair} + pair_template: + template: "{second}_{first}" + lower_case: false +# alias: + params: null + + response: + type: list + values: + type: dict + values: + tradeID: + type: int + price: + type: float + base_volume: + type: float + quote_volume: + type: float + trade_timestamp: + type: int + type: + type: str + + mapping: + - key: time + path: + - trade_timestamp + type: + - float + - from_timestamp + - 0 + - key: id + path: + - tradeID + type: + - int + - key: direction + path: + - type + type: + - str + - key: price + path: + - price + type: + - float + - key: amount + path: + - quote_volume # pair is quoted indirectly + type: + - float + + order_books: + request: + template: orderbook/{currency_pair} + pair_template: + template: "{second}_{first}" + lower_case: false +# alias: + params: null + + response: + type: dict + values: + timestamp: + type: int + bids: + type: list + values: + type: list + values: + 0: #price + type: str + 1: #qty + type: str + asks: + type: list + values: + type: list + values: + 0: #price + type: str + 1: #qty + type: str + + mapping: + - key: time + path: + - timestamp + type: + - float + - from_timestamp + - 0 + - key: id + path: + - timestamp + type: + - int + - key: position + path: [] + type: + - none + - range + - key: bids_amount + path: + - bids + - 1 + type: + - str + - float + - key: bids_price + path: + - bids + - 0 + type: + - str + - float + - key: asks_amount + path: + - asks + - 1 + type: + - str + - float + - key: asks_price + path: + - asks + - 0 + type: + - str + - float \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/coinjar.yaml b/pandas_datareader/crypto_utils/resources/coinjar.yaml new file mode 100644 index 00000000..380202ea --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/coinjar.yaml @@ -0,0 +1,310 @@ +name: coinjar +exchange: true + +rate_limit: null + +api_url: "" + +requests: + currency_pairs: + request: + template: https://api.exchange.coinjar.com/products + pair_template: null + params: null + + response: + type: list + values: + type: dict + values: + name: + type: str + + mapping: + - key: currency_pair_first + path: + - name + type: + - str + - split + - "/" + - 0 + - key: currency_pair_second + path: + - name + type: + - str + - split + - "/" + - 1 + + tickers: + request: + template: https://data.exchange.coinjar.com/products/{currency_pair}/ticker + pair_template: + template: "{first}{second}" + lower_case: false + params: null + response: + type: dict + values: + volume_24h: + type: str + last: + type: str + current_time: + type: str + bid: + type: str + ask: + type: str + + mapping: + - key: last_price + path: + - last + type: + - str + - float + - key: time + path: + - current_time + type: + - str + - dateparser + - key: best_bid + path: + - bid + type: + - str + - float + - key: best_ask + path: + - ask + type: + - str + - float + - key: daily_volume + path: + - volume_24h + type: + - str + - float + + historic_rates: + request: + template: https://data.exchange.coinjar.com/products/{currency_pair}/candles + pair_template: + template: "{first}{second}" + lower_case: false + params: + before: + function: last_timestamp + type: + - datetime + - timestamp + after: + function: last_timestamp + type: + - datetime + - timedelta + - interval + - 300 + interval: + allowed: + minutes: 1m + hours: 1h + days: 1d + weeks: 1w + months: 1M + default: 1d + + response: + type: list + values: + type: list + values: + 0: #time + type: str + 1: #open + type: str + 2: #high + type: str + 3: #low + type: str + 4: #close + type: str + 5: #vol + type: str + + mapping: + - key: time + path: + - 0 + type: + - str + - dateparser + - key: open + path: + - 1 + type: + - str + - float + - key: high + path: + - 2 + type: + - str + - float + - key: low + path: + - 3 + type: + - str + - float + - key: close + path: + - 4 + type: + - str + - float + - key: volume + path: + - 5 + type: + - str + - float + + + trades: + request: + template: https://data.exchange.coinjar.com/products/{currency_pair}/trades + pair_template: + template: "{first}{second}" + lower_case: false + params: + limit: + default: 200 + + response: + type: list + values: + type: dict + values: + value: + type: str + timestamp: + type: str + tid: + type: int + taker_side: + type: str + size: + type: str + price: + type: str + + mapping: + - key: time + path: + - timestamp + type: + - str + - dateparser + - key: id + path: + - tid + type: + - int + - key: direction + path: + - taker_side + type: + - str + - key: price + path: + - price + type: + - str + - float + - key: amount + path: + - size + type: + - str + - float + + order_books: + request: + template: https://data.exchange.coinjar.com/products/{currency_pair}/book + pair_template: + template: "{first}{second}" + lower_case: false + params: + level: + default: 2 + response: + type: dict + values: + bids: + type: list + values: + type: list + values: + 0: # price + type: str + 1: # qty + type: str + asks: + type: list + values: + type: list + values: + 0: # price + type: str + 1: # qty + type: str + mapping: + - key: time + path: [] + type: + - none + - now + - key: id + path: [] + type: + - none + - now_timestamp + - key: position + path: [] + type: + - none + - range + - key: bids_amount + path: + - bids + - 1 + type: + - str + - float + - key: bids_price + path: + - bids + - 0 + type: + - str + - float + - key: asks_amount + path: + - asks + - 1 + type: + - str + - float + - key: asks_price + path: + - asks + - 0 + type: + - str + - float \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/coinlist.yaml b/pandas_datareader/crypto_utils/resources/coinlist.yaml new file mode 100644 index 00000000..1da79c76 --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/coinlist.yaml @@ -0,0 +1,288 @@ +name: coinlist +exchange: true + +rate_limit: + max: 200 + unit: 60 + +api_url: http://trade-api.coinlist.co/v1/ + +requests: + currency_pairs: + request: + template: symbols + pair_template: null + params: null + + response: + type: list + values: + symbols: + type: list + values: + type: dict + values: + symbol: + type: str + base_currency: + type: str + quote_currency: + type: str + + mapping: + - key: currency_pair_first + path: + - symbols + - base_currency + type: + - str + - key: currency_pair_second + path: + - symbols + - quote_currency + type: + - str + + tickers: + request: + template: symbols/summary + pair_template: null + params: null + response: + type: dict + values: + currency_pair: + type: dict + values: + last_price: + type: str + lowest_ask: + type: str + highest_bid: + type: str + volume_base_24h: + type: str + volume_quote_24h: + type: str + + mapping: + - key: currency_pair_first + path: + - dict_key + type: + - str + - split + - "-" + - 0 + - key: currency_pair_second + path: + - dict_key + type: + - str + - split + - "-" + - 1 + - key: last_price + path: + - dict_values + - last_price + type: + - str + - float + - key: time + path: [] + type: + - none + - now + - key: best_bid + path: + - dict_values + - highest_bid + type: + - str + - float + - key: best_ask + path: + - dict_values + - lowest_ask + type: + - str + - float + - key: daily_volume + path: + - dict_values + - volume_base_24h + type: + - str + - float + + historic_rates: + request: + template: symbols/{currency_pair}/candles + pair_template: + template: "{first}-{second}" + lower_case: false + params: + granularity: + allowed: + minutes: 1m + hours: 30m + default: 30m +# start_time: +# function: last_timestamp +# type: +# - datetime +# - timedelta +# - interval +# - 300 +# - format +# - "%Y-%m%dT%H:%M:%S.%fZ" + end_time: + function: last_timestamp + type: + - datetime + - format + - "%Y-%m-%dT%H:%M:%S.%fZ" + response: + type: dict + values: + candles: + type: list + values: + type: list + values: + 0: #time + type: str + 1: #open + type: str + 2: #high + type: str + 3: # low + type: str + 4: #close + type: str + 5: #volume + type: str + mapping: + - key: time + path: + - candles + - 0 + type: + - str + - dateparser + - key: open + path: + - candles + - 1 + type: + - str + - float + - key: high + path: + - candles + - 2 + type: + - str + - float + - key: low + path: + - candles + - 3 + type: + - str + - float + - key: close + path: + - candles + - 4 + type: + - str + - float + - key: volume + path: + - candles + - 5 + type: + - str + - float + + order_books: + request: + template: symbols/{currency_pair}/book + pair_template: + template: "{first}-{second}" + lower_case: false + params: null + + response: + type: dict + values: + call_time: + type: str + after_auction_code: + type: str + bids: + type: list + values: + type: list + values: + 0: + type: str + 1: + type: str + asks: + type: list + values: + type: list + values: + 0: #price + type: str + 1: #qty + type: str + + mapping: + - key: time + path: + - call_time + type: + - str + - dateparser + - key: id + path: [] + type: + - none + - now_timestamp + - key: position + path: [] + type: + - none + - range + - key: bids_amount + path: + - bids + - 1 + type: + - str + - float + - key: bids_price + path: + - bids + - 0 + type: + - str + - float + - key: asks_amount + path: + - asks + - 1 + type: + - str + - float + - key: asks_price + path: + - asks + - 0 + type: + - str + - float \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/coinpaprika.yaml b/pandas_datareader/crypto_utils/resources/coinpaprika.yaml new file mode 100644 index 00000000..523e89d4 --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/coinpaprika.yaml @@ -0,0 +1,225 @@ +name: coinpaprika +exchange: false + +rate_limit: + max: 600 + unit: 60 + +api_url: https://api.coinpaprika.com/v1/ + +requests: + currency_pairs: + request: + template: coins + pair_template: null + params: null + + response: + type: list + values: + type: dict + values: + id: + type: str + name: + type: str + symbol: + type: str + + + mapping: + - key: currency_pair_first + path: + - id + type: + - str + - key: currency_pair_second + path: [] + type: + - none + - constant + - 'USD' + +# pair_infos: +# request: +# template: coins/{currency_pair} +# pair_template: +# template: "{first}" +# lower_case: true +# params: null +# response: +# type: dict +# values: +# first_data_at: +# type: str +# last_data_at: +# type: str +# mapping: +# - key: start +# path: +# - first_data_at +# type: +# - str +# - dateparser +# - key: end +# path: +# - last_data_at +# type: +# - str +# - dateparser +## + historic_rates: + request: + template: tickers/{currency_pair}/historical + pair_template: + template: "{first}" + lower_case: true + params: + start: + function: last_timestamp + type: + - datetime + - timedelta + - interval + - 5000 + end: + function: last_timestamp + type: + - datetime + - timestamp + limit: + default: 5000 # max! + interval: + allowed: + minutes: 5m + hours: 1h + days: 1d + weeks: 7d + months: 30d + default: 1d + + response: + type: list + values: + type: dict + values: + timestamp: + type: str + price: + type: float + volume_24h: + type: float + market_cap: + type: float + + mapping: + - key: time + path: + - timestamp + type: + - str + - dateparser + - key: close + path: + - price + type: + - float + - key: volume + path: + - volume_24h + type: + - float + - key: market_cap + path: + - market_cap + type: + - float + + +# sentiments: +# request: +# template: tickers/{currency_pair}/historical +# pair_template: +# template: "{first}" +# lower_case: true +# params: +# +# historic_rates: +# request: +# template: coins/{currency_pair}/ohlcv/historical +# pair_template: +# template: "{first}" +# lower_case: true +# params: +# start: +# function: last_timestamp +# type: +# - datetime +# - timedelta +# - interval +# - 366 +# limit: +# default: 366 # max value +# quote: +# default: usd # or 'btc' +# +# response: +# type: list +# values: +# type: dict +# values: +# time_open: +# type: str +# time_close: +# type: str +# open: +# type: float +# high: +# type: float +# low: +# type: float +# close: +# type: float +# volume: +# type: float +# market_cap: +# type: float +# +# +# mapping: +# - key: time +# path: +# - time_close +# type: +# - str +# - dateparser +# - key: open +# path: +# - open +# type: +# - float +# - key: high +# path: +# - high +# type: +# - float +# - key: low +# path: +# - low +# type: +# - float +# - key: close +# path: +# - close +# type: +# - float +# - key: volume +# path: +# - volume +# type: +# - float +# - key: market_cap +# path: +# - market_cap +# type: +# - float \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/coinsbit.yaml b/pandas_datareader/crypto_utils/resources/coinsbit.yaml new file mode 100644 index 00000000..41928331 --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/coinsbit.yaml @@ -0,0 +1,325 @@ +name: coinsbit +exchange: true + +rate_limit: null +api_url: https://coinsbit.io/api/v1/public/ + +requests: + currency_pairs: + request: + template: markets + pair_template: null + params: null + + response: + type: dict + values: + result: + type: list + values: + type: dict + values: + name: + type: str + stock: + type: str + money: + type: str + mapping: + - key: currency_pair_first + path: + - result + - stock + type: + - str + - key: currency_pair_second + path: + - result + - money + type: + - str + + tickers: + request: + template: tickers + pair_template: null + params: null + response: + type: dict + values: + result: + type: dict + values: + currency_pair: + type: dict + values: + at: + type: int + ticker: + type: dict + values: + bid: + type: str + ask: + type: str + last: + type: str + vol: + type: str + + mapping: + - key: currency_pair_first + path: + - result + - dict_key + type: + - str + - split + - "_" + - 0 + - key: currency_pair_second + path: + - result + - dict_key + type: + - str + - split + - "_" + - 1 + - key: time + path: + - result + - dict_values + - at + type: + - float + - from_timestamp + - 0 + - key: last + path: + - result + - dict_values + - ticker + - last + type: + - str + - float + - key: best_bid + path: + - result + - dict_values + - ticker + - bid + type: + - str + - float + - key: best_ask + path: + - result + - dict_values + - ticker + - ask + type: + - str + - float + - key: daily_volume + path: + - result + - dict_values + - ticker + - vol + type: + - str + - float + + order_books: + request: + template: depth/result + pair_template: + template: "{first}_{second}" + lower_case: false + alias: market + params: + limit: + default: 50 #max=100 + response: + type: dict + values: + asks: + type: list + values: + type: list + values: + 0: #price + type: str + 1: #qty + type: str + bids: + type: list + values: + type: list + values: + 0: + type: str + 1: + type: str + mapping: + - key: time + path: [] + type: + - none + - now + - key: id + path: [] + type: + - none + - now_timestamp + - key: position + path: [] + type: + - none + - range + - key: bids_amount + path: + - bids + - 1 + type: + - str + - float + - key: bids_price + path: + - bids + - 0 + type: + - str + - float + - key: asks_amount + path: + - asks + - 1 + type: + - str + - float + - key: asks_price + path: + - asks + - 0 + type: + - str + - float + + historic_rates: + request: + template: kline + pair_template: + template: "{first}_{second}" + lower_case: false + alias: market + params: + start: + function: last_timestamp + type: + - datetime + - timedelta + - interval + - 1000 + end: + function: last_timestamp + type: + - datetime + - timestamp + interval: + allowed: #minimum is 86400 +# minutes: 60 +# hours: 3600 + days: 86400 + weeks: 604800 + months: 18144000 + + default: 86400 # 1day + response: + type: dict + values: + result: + type: dict + values: + market: + type: str + start: + type: int + end: + type: int + interval: + type: int + kline: + type: list + values: + type: dict + values: + time: + type: int + open: + type: str + highest: + type: str + lowest: + type: str + close: + type: str + volume: + type: str + amount: + type: str + mapping: + - key: time + path: + - result + - kline + - time + type: + - float + - from_timestamp + - 0 + - key: open + path: + - result + - kline + - open + type: + - str + - float + - key: high + path: + - result + - kline + - highest + type: + - str + - float + - key: low + path: + - result + - kline + - lowest + type: + - str + - float + - key: close + path: + - result + - kline + - close + type: + - str + - key: volume + path: + - result + - kline + - volume + type: + - str + - float + + + + diff --git a/pandas_datareader/crypto_utils/resources/crex24.yaml b/pandas_datareader/crypto_utils/resources/crex24.yaml new file mode 100644 index 00000000..03fa17ff --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/crex24.yaml @@ -0,0 +1,313 @@ +name: crex24 +exchange: true +api_url: https://api.crex24.com/v2/public/ +rate_limit: null + +requests: + + currency_pairs: + request: + template: instruments + pair_template: null + params: null + response: + type: list + values: + type: dict + values: + symbol: + type: str + baseCurrency: + type: str + quoteCurrency: + type: str + + + mapping: + - key: currency_pair_first + path: + - baseCurrency + type: + - str + - key: currency_pair_second + path: + - quoteCurrency + type: + - str + + tickers: + request: + template: tickers + pair_template: null + params: null + + response: + type: list + values: + type: dict + values: + instrument: + type: str + last: + type: float + percentChange: + type: float + low: + type: float + high: + type: float + baseVolume: + type: float + quoteVolume: + type: float + volumeInBtc: + type: float + volumeInUsd: + type: float + ask: + type: float + bid: + type: float + timestamp: + type: str + + mapping: + - key: time + path: + - timestamp + type: + - str + - dateparser + - key: currency_pair_first + path: + - instrument + type: + - str + - split + - "-" + - 0 + - key: currency_pair_second + path: + - instrument + type: + - str + - split + - "-" + - 1 + - key: last_price + path: + - last + type: + - float + - key: best_ask + path: + - ask + type: + - float + - key: best_bid + path: + - bid + type: + - float + - key: daily_volume + path: + - baseVolume + type: + - float + + historic_rates: + request: + template: ohlcv + pair_template: + template: "{first}-{second}" + lower_case: false + alias: instrument + params: + granularity: + allowed: + minutes: 1m + hours: 1h + days: 1d + weeks: 1w + default: 1d + limit: + type: int + default: 1000 #between 1-1000, if not specified, default is 100. + response: + type: list + values: + type: dict + values: + timestamp: + type: str + open: + type: float + high: + type: float + low: + type: float + close: + type: float + volume: + type: float + mapping: + - key: time + path: + - timestamp + type: + - str + - dateparser + - key: open + path: + - open + type: + - float + - key: high + path: + - high + type: + - float + - key: low + path: + - low + type: + - float + - key: close + path: + - close + type: + - float + - key: volume + path: + - volume + type: + - float + + trades: + request: + template: recentTrades + pair_template: + template: "{first}-{second}" + lower_case: false + alias: instrument + params: + limit: + type: int + default: 1000 + + response: + type: list + values: + type: dict + values: + timestamp: + type: str + price: + type: float + volume: + type: float + side: + type: float + mapping: + - key: id + path: + - timestamp + type: + - str + - dateparser + - totimestamp + - key: time + path: + - timestamp + type: + - str + - dateparser + - key: direction + path: + - side + type: + - str + - key: price + path: + - price + type: + - float + - key: amount + path: + - volume + type: + - float + + + order_books: + request: + template: orderBook + pair_template: + template: "{first}-{second}" + lower_case: false + alias: instrument + params: + limit: + type: int + default: 50 + response: + type: dict + values: + buyLevels: + type: list + values: + type: dict + values: + price: + type: float + volume: + type: float + sellLevels: + type: list + values: + type: dict + values: + price: + type: float + volume: + type: float + mapping: + - key: id + path: [] + type: + - none + - now_timestamp + - key: time + path: [] + type: + - none + - now + - key: position + path: [] + type: + - none + - now + - key: bids_amount + path: + - buyLevels + - volume + type: + - float + - key: bids_price + path: + - buyLevels + - price + type: + - float + - key: asks_amount + path: + - sellLevels + - volume + type: + - float + - key: asks_price + path: + - sellLevels + - price + type: + - float \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/crosstower.yaml b/pandas_datareader/crypto_utils/resources/crosstower.yaml new file mode 100644 index 00000000..9e48e226 --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/crosstower.yaml @@ -0,0 +1,364 @@ +name: crosstower +exchange: true + +rate_limit: + max: 6000 + unit: 60 + +api_url: https://api.crosstower.com/api/2/ + +requests: + currency_pairs: + request: + template: public/symbol + pair_template: null + params: null + + response: + type: list + values: + type: dict + values: + baseCurrency: + type: str + quoteCurrency: + type: str + + mapping: + - key: currency_pair_first + path: + - baseCurrency + type: + - str + - key: currency_pair_second + path: + - quoteCurrency + type: + - str + + tickers: + request: + template: public/ticker + pair_template: + template: "{first}{second}" + lower_case: false + alias: symbols + params: null + response: + type: list + values: + type: dict + values: + ask: + type: str + bid: + type: str + last: + type: str + volume: + type: str + timestamp: + type: str + volumeQuote: + type: str + + mapping: + - key: last_price + path: + - last + type: + - str + - float + - key: time + path: + - timestamp + type: + - str + - dateparser + - key: best_bid + path: + - bid + type: + - str + - float + - key: best_ask + path: + - ask + type: + - str + - float + - key: daily_volume + path: + - volumeQuote + type: + - str + - float + + historic_rates: + request: + template: public/candles + pair_template: + template: "{first}{second}" + lower_case: false + alias: symbols + params: + period: + allowed: + minutes: M1 + hours: H1 + days: D1 + weeks: W1 + months: 1M + sort: + default: DESC +# from: +# function: last_timestamp +# type: +# - datetime +# - timedelta +# - interval +# - 1000 +# - fromtimestamp +# - "%Y-%m-%dT%H:%M:%S.%fZ" + till: + function: last_timestamp + type: + - datetime + - format + - "%Y-%m-%dT%H:%M:%S.%fZ" + limit: + default: 1000 + response: + type: dict + values: + currency_pair: + type: list + values: + type: dict + values: + timestamp: + type: str + open: + type: str + max: + type: str + min: + type: str + close: + type: str + volume: + type: str + volumeQuote: + type: str + + mapping: + - key: time + path: + - dict_values + - timestamp + type: + - str + - dateparser + - key: open + path: + - dict_values + - open + type: + - str + - float + - key: high + path: + - dict_values + - max + type: + - str + - float + - key: low + path: + - dict_values + - min + type: + - str + - float + - key: close + path: + - dict_values + - close + type: + - str + - float + - key: volume + path: + - dict_values + - volume + type: + - str + - float + + trades: + request: + template: public/trades + pair_template: + template: "{first}{second}" + lower_case: false + alias: symbols + params: +# from: +# function: last_timestamp +# type: +# - datetime +# - timedelta +# - interval +# - 1000 +# - fromtimestamp +# - "%Y-%m-%dT%H:%M:%S.%fZ" +# till: +# function: last_timestamp +# type: +# - datetime +# - format +# - "%Y-%m-%dT%H:%M:%S.%fZ" + limit: + default: 1000 + max: 1000 + + response: + type: dict + values: + currency_pair: + type: list + values: + type: dict + values: + timestamp: + type: str + id: + type: int + price: + type: str + quantity: + type: str + side: + type: str + + mapping: + - key: time + path: + - dict_values + - timestamp + type: + - str + - dateparser + - key: id + path: + - dict_values + - id + type: + - int + - key: direction + path: + - dict_values + - side + type: + - str + - key: price + path: + - dict_values + - price + type: + - str + - float + - key: amount + path: + - dict_values + - quantity + type: + - str + - float + + order_books: + request: + template: public/orderbook + pair_template: + template: "{first}{second}" + lower_case: false + alias: symbols + params: + limit: + default: 50 + max: 0 # to see complete order-book + + response: + type: dict + values: + currency_pair: + type: dict + values: + ask: + type: list + values: + type: dict + price: + type: str + size: + type: str + sell: + type: list + values: + type: dict + price: + type: str + size: + type: str + timestamp: + type: str + mapping: + - key: time + path: + - dict_values + - timestamp + type: + - str + - dateparser + - key: id + path: [] + type: + - none + - now_timestampms + - key: position + path: [] + type: + - none + - range + - key: bids_amount + path: + - dict_values + - bid + - size + type: + - str + - float + - key: bids_price + path: + - dict_values + - bid + - price + type: + - str + - float + - key: asks_amount + path: + - dict_values + - ask + - size + type: + - str + - float + - key: asks_price + path: + - dict_values + - ask + - price + type: + - str + - float \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/crypto.com.yaml b/pandas_datareader/crypto_utils/resources/crypto.com.yaml new file mode 100644 index 00000000..701cfb34 --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/crypto.com.yaml @@ -0,0 +1,392 @@ +name: crypto.com +exchange: true +rate_limit: + max: 6000 + unit: 60 + +api_url: https://uat-api.3ona.co/v2/ + +requests: + currency_pairs: + request: + template: public/get-instruments + pair_template: null + params: null + + response: + type: dict + values: + result: + type: dict + values: + instruments: + type: list + values: + type: dict + values: + instrument_name: + type: str + quote_currency: + type: str + base_currency: + type: str + mapping: + - key: currency_pair_first + path: + - result + - instruments + - base_currency + type: + - str + - key: currency_pair_second + path: + - result + - instruments + - quote_currency + type: + - str + + tickers: + request: + template: public/get-ticker + pair_template: null + params: null + response: + type: dict + values: + result: + type: dict + values: + data: + type: list + values: + i: + type: str + b: + type: float + k: + type: float + a: + type: float + t: + type: int + v: + type: float + mapping: + - key: currency_pair_first + path: + - result + - data + - i + type: + - str + - split + - "_" + - 0 + - key: currency_pair_second + path: + - result + - data + - i + type: + - str + - split + - "_" + - 1 + - key: time + path: + - result + - data + - t + type: + - float + - from_timestamp + - 1 + - key: last_price + path: + - result + - data + - a + type: + - float + - key: best_bid + path: + - result + - data + - b + type: + - float + - key: best_ask + path: + - result + - data + - k + type: + - float + - key: daily_volume + path: + - result + - data + - v + type: + - float + + trades: + request: + template: public/get-trades + pair_template: + template: "{first}_{second}" + lower_case: false + alias: instrument_name + params: null + + response: + type: dict + values: + result: + type: dict + values: + instrument_name: + type: str + data: + type: list + values: + type: dict + values: + dataTime: + type: int + d: #trade id + type: int + s: #side + type: str + p: #price + type: float + q: #quantity + type: float + t: #time + type: int + i: + type: str + mapping: + - key: time + path: + - result + - data + - t + type: + - float + - from_timestamp + - 1 + - key: id + path: + - result + - data + - d + type: + - int + - key: direction + path: + - result + - data + - s + type: + - str + - key: price + path: + - result + - data + - p + type: + - float + - key: amount + path: + - result + - data + - q + type: + - float + + order_books: + request: + template: public/get-book + pair_template: + template: "{first}_{second}" + lower_case: false + alias: instrument_name + params: + depth: + type: int + max: 150 + default: 50 + response: + type: dict + values: + result: + type: dict + values: + data: + type: list + values: + type: dict + values: + bids: + type: list + values: + type: list + values: + 0: #price + type: float + 1: #qty + type: float + asks: + type: list + values: + type: list + values: + 0: #price + type: float + 1: #qty + type: float + t: #timestamp + type: int + mapping: + - key: time + path: + - result + - data + - t + type: + - float + - from_timestamp + - 1 + - key: id + path: + - result + - data + - t + type: + - int + - key: position + path: [] + type: + - none + - range + - key: bids_price + path: + - result + - data + - bids + - 0 + type: + - float + - key: bids_amount + path: + - result + - data + - bids + - 1 + type: + - float + - key: asks_price + path: + - result + - data + - asks + - 0 + type: + - float + - key: asks_amount + path: + - result + - data + - asks + - 1 + type: + - float + + historic_rates: + request: + template: public/get-candlestick + pair_template: + template: "{first}_{second}" + lower_case: false + alias: instrument_name + params: + timeframe: + allowed: +# minutes: 1M +# hours: 1H + days: 1D + weeks: 1W +# months: 1M + default: 1D + limit: + default: 100 + + response: + type: dict + values: + result: + type: data + values: + type: list + values: + type: dict + values: + t: + type: int + o: + type: float + h: + type: float + l: + type: float + c: + type: float + v: + type: float + mapping: + - key: time + path: + - result + - data + - t + type: + - float + - from_timestamp + - 1 + - key: open + path: + - result + - data + - o + type: + - float + - key: high + path: + - result + - data + - h + type: + - float + - key: low + path: + - result + - data + - l + type: + - float + - key: close + path: + - result + - data + - c + type: + - float + - key: volume + path: + - result + - data + - v + type: + - float diff --git a/pandas_datareader/crypto_utils/resources/currency.com.yaml b/pandas_datareader/crypto_utils/resources/currency.com.yaml new file mode 100644 index 00000000..b1f26370 --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/currency.com.yaml @@ -0,0 +1,320 @@ +name: currency.com +exchange: true +api_url: https://marketcap.backend.currency.com/api/v1/ + +rate_limit: null + +requests: + currency_pairs: + request: + template: ticker + pair_template: null + params: null + + response: + type: dict + values: + currency_pair: + type: dict + values: + base_currency: + type: str + quote_currency: + type: str + mapping: + - key: currency_pair_first + path: + - dict_values + - base_currency + type: + - str + - key: currency_pair_second + path: + - dict_values + - quote_currency + type: + - str + + tickers: + request: + template: ticker + pair_template: null + params: null + + response: + type: dict + values: + currency_pair: + type: dict + values: + base_currency: + type: str + quote_currency: + type: str + last_price: + type: float + base_volume: + type: float + lowest_ask_price: + type: float + highest_bid_price: + type: float + mapping: + - key: currency_pair_first + path: + - dict_values + - base_currency + type: + - str + - key: currency_pair_second + path: + - dict_values + - quote_currency + type: + - str + - key: time + path: [] + type: + - none + - now + - key: last_price + path: + - dict_values + - last_price + type: + - float + - key: best_bid + path: + - dict_values + - highest_bid + type: + - float + - key: best_ask + path: + - dict_values + - lowest_ask + type: + - float + - key: daily_volume + path: + - dict_values + - base_volume + type: + - float + + order_books: + request: + template: orderbook + pair_template: + template: "{first}/{second}" + lower_case: false + alias: symbol + params: + depth: + default: 50 + + response: + type: dict + values: + timestamp: + type: int + asks: + type: list + values: + type: list + values: + 0: # price + type: float + 1: # qty + type: float + bids: + type: list + values: + type: list + values: + 0: # price + type: float + 1: # qty + type: float + + mapping: + - key: id + path: + - timestamp + type: + - int + - key: time + path: + - timestamp + type: + - float + - from_timestamp + - 1 + - key: position + path: [] + type: + - none + - range + - key: bids_price + path: + - bids + - 0 + type: + - float + - key: bids_amount + path: + - bids + - 1 + type: + - float + - key: asks_price + path: + - asks + - 0 + type: + - float + - key: asks_amount + path: + - asks + - 1 + type: + - float + + historic_rates: + request: + template: candles + pair_template: + template: "{first}/{second}" + lower_case: false + alias: symbol + params: + interval: + allowed: + minutes: M1 + hours: H1 + days: D1 + weeks: W1 + default: D1 + limit: + default: 1000 + endTime: + function: last_timestamp + type: + - datetime + - timestampms + startTime: + function: last_timestamp + type: + - datetime + - timedeltams + - interval + - 1000 + + response: + type: list + values: + type: list + values: + 0: + type: int + 1: + type: str + 2: + type: str + 3: + type: str + 4: + type: str + mapping: + - key: time + path: + - [] + - 0 + type: + - float + - from_timestamp + - 1 + - key: open + path: + - [] + - 1 + type: + - str + - float + - key: high + path: + - [] + - 2 + type: + - str + - float + - key: low + path: + - [] + - 3 + type: + - str + - float + - key: close + path: + - [] + - 4 + type: + - str + - float + + trades: + request: + template: trades + pair_template: + template: "{first}/{second}" + lower_case: false + alias: symbol + params: null + + response: + type: list + values: + type: dict + values: + tradeID: + type: int + price: + type: float + base_volume: + type: float + quote_volume: + type: float + trade_timestamp: + type: float + type: + type: str + + mapping: + - key: id + path: + - tradeID + type: + - int + - key: time + path: + - trade_timestamp + type: + - float + - from_timestamp + - 0 + - key: direction + path: + - type + type: + - str + - key: price + path: + - price + type: + - float + - key: amount + path: + - base_volume + type: + - float \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/deepcoin.yaml b/pandas_datareader/crypto_utils/resources/deepcoin.yaml new file mode 100644 index 00000000..82e5270f --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/deepcoin.yaml @@ -0,0 +1,211 @@ +name: deepcoin +exchange: true + +rate_limit: null + +api_url: https://api-w.deepcoin.pro + +requests: + currency_pairs: + request: + template: /query/v1.0/Instrument + pair_template: null + params: + ProductGroup: + default: Spot + + response: + type: dict + values: + data: + type: list + values: + type: dict + values: + InsturmentID: + type: str + + mapping: + - key: currency_pair_first + path: + - data + - InstrumentID + type: + - str + - split + - "/" + - 0 + - key: currency_pair_second + path: + - data + - InstrumentID + type: + - str + - split + - "/" + - 1 + + tickers: + request: + template: /query/v1.0/MarketData + pair_template: null + params: + ProductGroup: + default: Spot + + response: + type: dict + values: + data: + type: list + values: + type: dict + values: + InstrumentID: + type: str + UpdateTime: + type: int + LastPrice: + type: float + BidPrice1: + type: float + AskPrice1: + type: float + Turnover: + type: float + Volume: + type: float + + mapping: + - key: currency_pair_first + path: + - data + - InstrumentID + type: + - str + - split + - "/" + - 0 + - key: currency_pair_second + path: + - data + - InstrumentID + type: + - str + - split + - "/" + - 1 + - key: last_price + path: + - data + - LastPrice + type: + - float + - key: time + path: + - data + - UpdateTime + type: + - float + - from_timestamp + - 0 + - key: best_bid + path: + - data + - BidPrice1 + type: + - float + - key: best_ask + path: + - data + - AskPrice1 + type: + - float + - key: daily_volume + path: + - data + - Turnover + type: + - float + + historic_rates: + request: + template: /query/v1.0/KLine + pair_template: + template: "{first}{second}" + lower_case: false + alias: InstrumentID + params: + Type: + allowed: + minutes: 1m + hours: 1h + days: 1d + weeks: 1w + months: 1o + default: 1d + Count: + max: 2000 + default: 200 + StartDatetime: + function: last_timestamp + type: + - datetime + - timedelta + - interval + - 200 + response: + type: list + values: + type: dict + values: + BeginTime: + type: int + UpdateTime: + type: int + OpenPrice: + type: float + ClosePrice: + type: float + HighestPrice: + type: float + LowestPrice: + type: float + Volume: + type: float + Turnover: + type: float + + mapping: + - key: time + path: + - UpdateTime + type: + - float + - from_timestamp + - 0 + - key: open + path: + - ClosePrice + type: + - float + - key: high + path: + - HighestPrice + type: + - float + - key: low + path: + - LowestPrice + type: + - float + - key: close + path: + - ClosePrice + type: + - float + - key: volume + path: + - Turnover + type: + - float diff --git a/pandas_datareader/crypto_utils/resources/dex-trade.yaml b/pandas_datareader/crypto_utils/resources/dex-trade.yaml new file mode 100644 index 00000000..a28b224d --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/dex-trade.yaml @@ -0,0 +1,310 @@ +name: dex-trade +exchange: true + +rate_limit: null + +api_url: "" + +requests: + currency_pairs: + request: + template: https://api.dex-trade.com/v1/public/symbols + pair_template: null + params: null + + response: + type: dict + values: + data: + type: list + values: + type: dict + values: + base: + type: str + quote: + type: str + id: + type: int + + mapping: + - key: currency_pair_first + path: + - data + - base + type: + - str + - key: currency_pair_second + path: + - data + - quote + type: + - str + + tickers: + request: + template: https://api.dex-trade.com/v1/public/ticker + pair_template: + template: "{first}{second}" + lower_case: false + alias: pair + params: null + response: + type: dict + values: + data: + type: dict + values: + last: + type: str + volume_24H: + type: str + + mapping: + - key: last_price + path: + - data + - last + type: + - str + - float + - key: time + path: [] + type: + - none + - now + - key: daily_volume + path: + - data + - volume_24H + type: + - str + - float + + historic_rates: + request: + template: https://socket.dex-trade.com/graph/hist + pair_template: + template: "{first}{second}" + lower_case: false + alias: t + params: + r: + allowed: + minutes: 1 + hours: 60 + days: D + weeks: W + default: D + end: + function: last_timestamp + type: + - datetime + - timestamp + limit: + default: 1000 + + response: + type: list + values: + type: dict + values: + low: + type: float + high: + type: float + volume: + type: float + time: + type: float + open: + type: float + close: + type: float + + + mapping: + - key: time + path: + - time + type: + - float + - from_timestamp + - 0 + - key: open + path: + - open + type: + - int + - div + - 100000000 + - key: high + path: + - high + type: + - int + - div + - 100000000 + - key: low + path: + - low + type: + - int + - div + - 100000000 + - key: close + path: + - close + type: + - int + - div + - 100000000 + - key: volume + path: + - volume + type: + - int + - div + - 100000000 + + trades: + request: + template: https://api.dex-trade.com/v1/public/trades + pair_template: + template: "{first}{second}" + lower_case: false + alias: pair + params: null + + response: + type: dict + values: + data: + type: list + values: + type: dict + values: + volume: + type: float + rate: + type: float + price: + type: float + timestamp: + type: int + type: + type: str + + mapping: + - key: time + path: + - data + - timestamp + type: + - float + - from_timestamp + - 0 + - key: id + path: + - data + - timestamp + type: + - int + - key: direction + path: + - data + - type + type: + - str + - key: price + path: + - data + - rate + type: + - float + - key: amount + path: + - data + - volume + type: + - float + + order_books: + request: + template: https://api.dex-trade.com/v1/public/book + pair_template: + template: "{first}{second}" + lower_case: false + alias: pair + params: null + + response: + type: dict + values: + buy: + type: list + values: + type: dict + values: + volume: + type: float + count: + type: float + rate: + type: float + sell: + type: list + values: + type: dict + values: + volume: + type: float + count: + type: float + rate: + type: float + + mapping: + - key: time + path: [] + type: + - none + - now + - key: id + path: [] + type: + - none + - now_timestamp + - key: position + path: [] + type: + - none + - range + - key: bids_amount + path: + - data + - buy + - volume + type: + - float + - key: bids_price + path: + - data + - buy + - rate + type: + - flot + - key: asks_amount + path: + - data + - sell + - volume + type: + - float + - key: asks_price + path: + - data + - sell + - rate + type: + - float \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/digifinex.yaml b/pandas_datareader/crypto_utils/resources/digifinex.yaml new file mode 100644 index 00000000..1f80bf12 --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/digifinex.yaml @@ -0,0 +1,291 @@ +name: digifinex +exchange: true +api_doc: https://docs.digifinex.com/en-ww/v3/#market-data +rate_limit: null +api_url: https://openapi.digifinex.vip/v3/ + +requests: + currency_pairs: + request: + template: markets + pair_template: null + params: null + response: + type: dict + values: + data: + type: list + values: + type: dict + values: + volume_precision: + type: int + price_precision: + type: int + market: + type: str + min_amount: + type: int + min_volume: + type: float + mapping: + - key: currency_pair_first + path: + - data + - market + type: + - str + - splitupper + - "_" + - 0 + - key: currency_pair_second + path: + - data + - market + type: + - str + - splitupper + - "_" + - 1 + + tickers: + request: + template: ticker + pair_template: null + params: null + response: + type: dict + values: + ticker: + type: list + values: + type: dict + values: + vol: + type: float + change: + type: float + base_vol: + type: float + sell: + type: float + last: + type: float + symbol: + type: str + low: + type: float + buy: + type: float + high: + type: float + date: + type: int + code: + type: bool + + mapping: + - key: time + path: [] + type: + - none + - now + - key: currency_pair_first + path: + - ticker + - symbol + type: + - str + - splitupper + - "_" + - 0 + - key: currency_pair_second + path: + - ticker + - symbol + type: + - str + - splitupper + - "_" + - 1 + - key: last_price + path: + - ticker + - last + type: + - float + - key: best_bid + path: + - ticker + - buy + type: + - float + - key: best_ask + path: + - ticker + - sell + type: + - float + - key: daily_volume + path: + - ticker + - vol + type: + - float + + historic_rates: + request: + template: kline + pair_template: + template: "{first}_{second}" + lower_case: true + alias: symbol + params: + period: + allowed: + minutes: 1 + hours: 60 + days: 1D + weeks: 1W + default: 1D + start_time: + function: last_timestamp + type: + - datetime + - timedelta + - interval + - 1000 + end_time: + function: last_timestamp + type: + - datetime + - timestamp + + response: + type: dict + values: + code: + type: dict + data: + type: list + values: + type: list + values: + 0: # timestamp + type: int + 1: # volume + type: float + 2: # close + type: float + 3: # high + type: float + 4: # low + type: float + 5: # open + type: float + mapping: + - key: time + path: + - data + - [] + - 0 + type: + - float + - from_timestamp + - 0 + - key: volume + path: + - data + - [] + - 1 + type: + - float + - key: close + path: + - data + - [] + - 2 + type: + - float + - key: high + path: + - data + - [] + - 3 + type: + - float + - key: low + path: + - data + - [] + - 4 + type: + - float + - key: open + path: + - data + - [] + - 4 + type: + - float + +# trades: +# request: +# template: trades +# pair_template: +# template: "{first}_{second}" +# lower_case: true +# alias: symbol +# params: +# limit: #between 100-500 +# type: int +# default: 100 +# response: +# type: dict +# values: +# data: +# type: list +# values: +# type: dict +# values: +# date: +# type: int +# id: +# type: int +# amount: +# type: float +# type: +# type: str +# price: +# type: float +# mapping: +# - key: trade_time +# path: +# - data +# - date +# type: +# - int +# - fromtimestamp +# - key: trade_amount +# path: +# - data +# - amount +# type: +# - float +# - key: trade_last_price +# path: +# - data +# - price +# type: +# - int +# - key: trade_side +# path: +# - data +# - type +# type: +# - str +# +# order_book: +# request: +# response: +# mapping: \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/exrates.yaml b/pandas_datareader/crypto_utils/resources/exrates.yaml new file mode 100644 index 00000000..af1c2475 --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/exrates.yaml @@ -0,0 +1,318 @@ +name: exrates +exchange: true +api_url: '' +api_docs: https://docs.exrates.me/ +rate_limit: + max: 10 + unit: 60 + +requests: + currency_pairs: + request: + template: https://api.exrates.me/v1/public/symbols + pair_template: null + params: null + response: + type: dict + values: + data: + type: list + values: + type: dict + values: + id: + type: int + base: + type: str + quote: + type: str + mapping: + - key: currency_pair_first + path: + - data + - base + type: + - str + - key: currency_pair_second + path: + - data + - quote + type: + - str + + tickers: + request: + template: https://api.exrates.me/v1/public/ticker + pair_template: + template: "{first}{second}" + lower_case: false + alias: pair + params: null + response: + type: dict + values: + status: + type: boolean + data: + type: dict + values: + id: + type: int + pair: + type: str + last: + type: str + open: + type: str + close: + type: str + high: + type: str + low: + type: str + volume_24H: + type: str + mapping: + - key: time + path: [] + type: + - none + - now + - key: price + path: + - data + - last + type: + - str + - float + - key: daily_volume + path: + - data + - volume_24H + type: + - str + - float + + trades: + request: + template: https://api.exrates.me/v1/public/trades + pair_template: + template: "{first}{second}" + lower_case: false + alias: pair + params: null + + response: + type: dict + values: + data: + type: list + values: + type: dict + values: + volume: + type: float + rate: + type: float + price: + type: float + timestamp: + type: int + type: + type: str + + mapping: + - key: id + path: + - data + - timestamp + type: + - int + - key: time + path: + - data + - timestamp + type: + - float + - from_timestamp + - 0 + - key: direction + path: + - data + - type + type: + - str + - key: price + path: + - data + - rate + type: + - float + - key: amount + path: + - data + - volume + type: + - float + + order_books: + request: + template: https://api.exrates.me/v1/public/book + pair_template: + template: "{first}{second}" + lower_case: false + alias: pair + params: null + + response: + type: dict + values: + data: + type: dict + values: + buy: + type: list + values: + type: dict + values: + volume: + type: float + count: + type: int + rate: + type: float + sell: + type: list + values: + type: dict + values: + volume: + type: float + count: + type: int + rate: + type: float + mapping: + - key: id + path: [] + type: + - none + - now_timestamp + - key: position + path: [] + type: + - none + - range + - key: bids_price + path: + - data + - buy + - rate + type: + - float + - key: bids_amount + path: + - data + - buy + - volume + type: + - float + - key: asks_price + path: + - data + - sell + - rate + type: + - float + - key: asks_amount + path: + - data + - sell + - volume + type: + - float + + historic_rates: + request: + template: https://socket.exrates.me/graph/hist + pair_template: + template: "{first}{second}" + lower_case: false + alias: t + params: + end: + function: last_timestamp + type: + - datetime + - timestamp + r: + allowed: + minutes: 1 + hours: 60 + days: D + weeks: W + default: D + limit: + type: int + default: 500 + + response: + type: list + values: + type: dict + values: + low: + type: int + high: + type: int + volume: + type: int + time: + type: int + close: + type: int + open: + type: int + mapping: + - key: open + path: + - open + type: + - int + - div + - 100000000 + - key: high + path: + - high + type: + - int + - div + - 100000000 + - key: low + path: + - low + type: + - int + - div + - 100000000 + - key: close + path: + - close + type: + - int + - div + - 100000000 + - key: volume + path: + - volume + type: + - int + - div + - 100000000 + - key: time + path: + - time + type: + - float + - from_timestamp + - 0 diff --git a/pandas_datareader/crypto_utils/resources/ftx.yaml b/pandas_datareader/crypto_utils/resources/ftx.yaml new file mode 100644 index 00000000..dd98c2aa --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/ftx.yaml @@ -0,0 +1,384 @@ +name: ftx +is_exchange: true +api_docs: https://docs.ftx.com/#rest-api +api_url: https://ftx.com/api/ +# +rate_limit: + max: 1800 + unit: 60 + +requests: + currency_pairs: + request: + template: markets + pair_template: null + params: null + + response: + type: dict + values: + success: + type: boolean + result: + type: list + values: + type: dict + values: + name: + type: str + baseCurrency: + type: str + quoteCurrency: + type: str + type: + type: str + underlying: + type: str + enabled: + type: boolean + ask: + type: float + bid: + type: float + last: + type: float + postOnly: + type: boolean + priceIncrement: + type: float + sizeIncrement: + type: float + restricted: + type: boolean + + mapping: + - key: currency_pair_first + path: + - result + - baseCurrency + type: + - str + - key: currency_pair_second + path: + - result + - quoteCurrency + type: + - str + + tickers: + request: + template: markets + pair_template: null + params: null + + response: + type: dict + values: + success: + type: boolean + result: + type: list + values: + type: dict + values: + name: + type: str + baseCurrency: + type: str + quoteCurrency: + type: str + type: + type: str + underlying: + type: str + enabled: + type: boolean + ask: + type: float + bid: + type: float + last: + type: float + postOnly: + type: boolean + priceIncrement: + type: float + sizeIncrement: + type: float + restricted: + type: boolean + + mapping: + - key: currency_pair_first + path: + - result + - baseCurrency + type: + - str + - key: currency_pair_second + path: + - result + - quoteCurrency + type: + - str + - key: time + path: [] + type: + - none + - now + - key: last + path: + - result + - last + type: + - float + - key: best_ask + path: + - result + - ask + type: + - float + - key: best_bid + path: + - result + - bid + type: + - float + + historic_rates: + request: + template: markets/{currency_pair}/candles + pair_template: + template: "{first}_{second}" + alias: null + lower_case: false + params: + resolution: + allowed: + seconds: 15 + minutes: 60 + hours: 3600 + days: 86400 + default: 86400 #daily + limit: + type: int + default: 5000 + end_time: + function: last_timestamp + type: + - datetime + - timestamp + + response: + type: dict + values: + success: + type: boolean + result: + type: list + values: + type: dict + values: + close: + type: float + high: + type: float + low: + type: float + open: + type: float + startTime: + type: str + time: + type: int + volume: + type: float + mapping: + - key: time + path: + - result + - time + type: + - float + - from_timestamp + - 1 + - key: open + path: + - result + - open + type: + - float + - key: high + path: + - result + - high + type: + - float + - key: low + path: + - result + - low + type: + - float + - key: close + path: + - result + - close + type: + - float + - key: volume + path: + - result + - volume + type: + - float + + trades: + request: + template: markets/{currency_pair}/trades + pair_template: + template: "{first}_{second}" + alias: null + lower_case: false + params: + limit: + type: int + default: 100 + + response: + type: dict + values: + success: + type: boolean + result: + type: list + values: + type: dict + values: + id: + type: int + liquidation: + type: boolean + price: + type: float + side: + type: str + size: + type: float + time: + type: str + mapping: + - key: time + path: + - result + - time + type: + - str + - strptime + - "%Y-%m-%dT%H:%M:%S.%f+00:00" + - key: id + path: + - result + - id + type: + - int + - key: direction + path: + - result + - side + type: + - str + - key: price + path: + - result + - price + type: + - float + - key: amount + path: + - result + - size + type: + - float + + order_books: + request: + template: markets/{currency_pair}/orderbook + pair_template: + template: "{first}_{second}" + alias: null + lower_case: false + params: + depth: + type: int + default: 200 + + response: + type: dict + values: + success: + type: bool + result: + type: dict + values: + asks: + type: list + values: + type: list + 0: + type: float + 1: + type: float + bids: + type: list + values: + type: list + 0: + type: float + 1: + type: float + + mapping: + - key: id + path: [] + type: + - none + - now_timestamp + - key: position + path: [] + type: + - none + - range + - key: time + path: [] + type: + - none + - now + - key: bids_price + path: + - result + - bids + - 0 + type: + - float + - key: bids_amount + path: + - result + - bids + - 1 + type: + - float + - key: asks_price + path: + - result + - asks + - 0 + type: + - float + - key: asks_amount + path: + - result + - asks + - 1 + type: + - float diff --git a/pandas_datareader/crypto_utils/resources/gateio.yaml b/pandas_datareader/crypto_utils/resources/gateio.yaml new file mode 100644 index 00000000..1c6956e2 --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/gateio.yaml @@ -0,0 +1,362 @@ +name: gateio +exchange: true +api_url: https://api.gateio.ws/api/v4/spot/ +rate_limit: null + +requests: + currency_pairs: + request: + template: currency_pairs + pair_template: null + params: null + response: + type: list + values: + type: dict + values: + id: + type: str + base: + type: str + quote: + type: str + fee: + type: str + min_base_amount: + type: str + min_quote_amount: + type: str + amount_precision: + type: str + precision: + type: int + trade_status: + type: str + mapping: + - key: currency_pair_first + path: + - base + type: + - str + - key: currency_pair_second + path: + - quote + type: + - str + + tickers: + request: + template: tickers + pair_template: null + params: null + response: + type: list + values: + type: dict + values: + currency_pair: + type: str + last: + type: str + lowest_ask: + type: str + highest_bid: + type: str + change_percentage: + type: str + base_volume: + type: str + quote_volume: + type: str + high_24h: + type: str + low_24h: + type: str + mapping: + - key: currency_pair_first + path: + - currency_pair + type: + - str + - split + - "_" + - 0 + - key: currency_pair_second + path: + - currency_pair + type: + - str + - split + - "_" + - 1 + - key: time + path: [] + type: + - none + - now + - key: last_price + path: + - last + type: + - str + - float + - key: best_bid + path: + - highest_bid + type: + - str + - float + - key: best_ask + path: + - lowest_ask + type: + - str + - float + - key: daily_volume + path: + - quote_volume + type: + - str + - float +# + order_books: + request: + template: order_book + pair_template: + template: "{first}_{second}" + alias: currency_pair + lower_case: true + params: + interval: + type: int + default: "0" + limit: + type: int + default: 30 + + response: + type: dict + values: + asks: + type: list + values: + type: list + values: + 0: # price + type: + - str + 1: # size + type: + - str + bids: + type: list + values: + type: list + values: + 0: + type: + - str + 1: + type: + - str + mapping: + - key: time + path: [] + type: + - none + - now + - key: asks_price + path: + - asks + - 0 + type: + - str + - float + - key: asks_amount + path: + - asks + - 1 + type: + - str + - float + - key: bids_price + path: + - bids + - 0 + type: + - str + - float + - key: bids_amount + path: + - bids + - 1 + type: + - str + - float + - key: id + path: [] + type: + - none + - now_timestamp + - key: position + path: [] + type: + - none + - range + + trades: + request: + template: trades + pair_template: + template: "{first}_{second}" + alias: currency_pair + lower_case: true + params: + limit: + type: int + default: 200 + last_id: + type: int + required: false + response: + type: list + values: + type: dict + values: + id: + type: str + create_time: + type: str + side: + type: str + role: + type: str + amount: + type: str + price: + type: str + order_id: + type: str + fee: + type: str + fee_currency: + type: str + point_fee: + type: str + gt_fee: + type: str + + mapping: + - key: time + path: + - create_time + type: + - str + - float + - from_timestamp + - 0 + - key: amount + path: + - amount + type: + - str + - float + - key: direction + path: + - side + type: + - str + - key: price + path: + - price + type: + - str + - float + - key: id + path: + - id + type: + - str + - int + + + historic_rates: + request: + template: candlesticks + pair_template: + template: "{first}_{second}" + alias: currency_pair + lower_case: true + params: + limit: + type: int + default: 1000 + interval: + allowed: + minutes: 1m + hours: 1h + days: 1d + weeks: 1w + default: 1d + to: + function: last_timestamp + type: + - datetime + - timestamp + response: + type: list + values: + type: list + values: + 0: + type: str + 1: + type: str + 2: + type: str + 3: + type: str + 4: + type: str + 5: + type: str + 6: + type: str + mapping: + - key: time + path: + - 0 + type: + - str + - float + - from_timestamp + - 0 + - key: volume + path: + - 1 + type: + - str + - float + - key: close + path: + - 2 + type: + - str + - float + - key: high + path: + - 3 + type: + - str + - float + - key: low + path: + - 4 + type: + - str + - float + - key: open + path: + - 5 + type: + - str \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/gemini.yaml b/pandas_datareader/crypto_utils/resources/gemini.yaml new file mode 100644 index 00000000..04d6b9f4 --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/gemini.yaml @@ -0,0 +1,320 @@ +# The extraction of the currency_pairs relies on the fact, that every quote_currency is only 3 digits long. +# However this may change in future. + +name: gemini +exchange: true +api_docs: https://docs.gemini.com/rest-api/ +api_url: https://api.gemini.com/ +rate_limit: # For public API entry points, we limit requests to 120 requests per minute, and recommend that you do not exceed 1 request per second. + max: 120 # recommended: 60 + unit: 60 + +requests: + currency_pairs: + request: + template: v1/symbols + pair_template: null + params: null + response: + type: list + values: # each available currency pair, i.e. "btcusd" + type: str + mapping: # split Methode is not save + - key: currency_pair_first + path: + - [] + type: + - str + - slice + - 0 + - -3 + - key: currency_pair_second + path: + - [] + type: + - str + - slice + - -3 + - + + tickers: + request: + template: v1/pricefeed + pair_template: null + params: null + response: + type: list + values: + type: dict + values: + pair: + type: str + price: + type: str + percentageChange24h: + type: str + + mapping: + - key: currency_pair_first + path: + - pair + type: + - str + - slice + - 0 + - -3 + - key: currency_pair_second + path: + - pair + type: + - str + - slice + - -3 + - + - key: last_price + path: + - price + type: + - str + - float + - key: time + path: [] + type: + - none + - now + + order_books: + request: + template: v1/book/{currency_pair} + pair_template: # e.g. btcusd + template: "{first}{second}" + lower_case: true + params: + limit_bids: # Optional. Limit the number of bids (offers to buy) returned. Default is 50. May be 0 to return the full order book on this side. + type: int + default: 50 + limit_asks: # Optional. Limit the number of asks (offers to sell) returned. Default is 50. May be 0 to return the full order book on this side. + type: int + default: 50 + response: + type: dict + values: + bids: # The bids currently on the book. These are offers to buy at a given price + type: list + values: + type: dict + values: + amount: # The total quantity remaining at the price + type: + - str + price: # The price + type: + - str + timestamp: # DO NOT USE - this field is included for compatibility reasons only and is just populated with a dummy value. + type: + - str + asks: # The asks currently on the book. These are offers to sell at a given price + type: list + values: + type: dict + values: + amount: # The total quantity remaining at the price + type: + - str + price: # The price + type: + - str + timestamp: # DO NOT USE - this field is included for compatibility reasons only and is just populated with a dummy value. + type: + - str + mapping: + - key: time + path: + - bids + - timestamp + type: + - str + - float + - from_timestamp + - 0 + - key: id + path: + - bids + - timestamp + type: + - str + - int + - key: position + path: [] + type: + - none + - range + - key: bids_amount + path: + - bids + - amount + type: + - str + - float + - key: bids_price + path: + - bids + - price + type: + - str + - float + - key: asks_amount + path: + - asks + - amount + type: + - str + - float + - key: asks_price + path: + - asks + - price + type: + - str + - float + + trades: # This public API endpoint is limited to retrieving seven calendar days of data. + request: + template: v1/trades/{currency_pair} + pair_template: # e.g. btcusd + template: "{first}{second}" + lower_case: true + params: + since: # Optional. Only return trades after this timestamp. If not present, will show the most recent trades. + required: false + limit_trades: # Optional. The maximum number of trades to return. The default is 50. + type: int + default: 50 + include_breaks: # Optional. Whether to display broken trades. False by default. Can be '1' or 'true' to activate + type: bool + required: false + response: + type: list + values: + type: dict + values: + timestamp: # The time that the trade was executed + type: + - int + timestampms: # The time that the trade was executed in milliseconds + type: + - int + tid: # The trade ID number + type: + - int + price: # The price the trade was executed at + type: + - str + amount: # The amount that was traded + type: + - str + exchange: # Will always be "gemini" + type: str + type: + type: str + allowed: + - buy # buy means that an ask was removed from the book by an incoming buy order + - sell # sell means that a bid was removed from the book by an incoming sell order + - auction # auction indicates a bulk trade from an auction + - block # block indicates a block trade + broken: + type: bool # Whether the trade was broken or not. Broken trades will not be displayed by default; use the include_breaks to display them. + mapping: + - key: time + path: + - timestamp + type: + - float + - from_timestamp + - 0 + - key: id + path: + - tid + type: + - int + - key: price + path: + - price + type: + - str + - float + - key: amount + path: + - amount + type: + - str + - float + - key: direction + path: + - type + type: + - str + + historic_rates: + request: + template: v2/candles/{currency_pair}/{frequency} + pair_template: + template: "{first}{second}" + lower_case: true + params: + frequency: + allowed: + minutes: 1m + hours: 1hr + days: 1day + default: 1day + response: + type: list + values: + type: list + values: + 0: # timestamp + type: int + 1: # open + type: float + 2: # high + type: float + 3: # low + type: float + 4: # close + type: float + 5: # volume + type: float + mapping: + - key: time + path: + - 0 + type: + - float + - from_timestamp + - 1 + - key: open + path: + - 1 + type: + - float + - key: high + path: + - 2 + type: + - float + - key: low + path: + - 3 + type: + - float + - key: close + path: + - 4 + type: + - float + - key: volume + path: + - 5 + type: + - float \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/gopax.yaml b/pandas_datareader/crypto_utils/resources/gopax.yaml new file mode 100644 index 00000000..fa835fff --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/gopax.yaml @@ -0,0 +1,301 @@ +name: gopax +exchange: true + +rate_limit: + max: 1200 + unit: 60 + +api_url: https://api.gopax.co.kr + +requests: + currency_pairs: + request: + template: /trading-pairs + pair_template: null + params: null + + response: + type: list + values: + type: dict + values: + baseAsset: + type: str + quoteAsset: + type: str + + mapping: + - key: currency_pair_first + path: + - baseAsset + type: + - str + - key: currency_pair_second + path: + - quoteAsset + type: + - str + + tickers: + request: + template: /trading-pairs/{currency_pair}/ticker + pair_template: + template: "{first}-{second}" + lower_case: false + params: null + response: + type: dict + values: + price: + type: float + ask: + type: float + bid: + type: float + volume: + type: float + time: + type: str + + mapping: + - key: last_price + path: + - price + type: + - float + - key: time + path: + - time + type: + - str + - dateparser + - key: best_bid + path: + - bid + type: + - float + - key: best_ask + path: + - ask + type: + - float + - key: daily_volume + path: + - volume + type: + - float + + historic_rates: + request: + template: /trading-pairs/{currency_pair}/candles + pair_template: + template: "{first}-{second}" + lower_case: false + params: + interval: + allowed: + minutes: 1 + hours: 60 + days: 1440 + default: 1440 # e.g. 1 day + start: + default: 1 # better as intervals up to 5000 can lead to zero new prices and the program exits. +# function: last_timestamp +# type: +# - datetime +# - timedeltams +# - interval +# - 5000 + end: + function: last_timestamp + type: + - datetime + - timestampms + + response: + type: list + values: + type: list + values: + 0: #time + type: int + 1: #open + type: float + 2: #high + type: float + 3: #low + type: float + 4: #close + type: float + 5: #volume + type: float + + mapping: + - key: time + path: + - [] + - 0 + type: + - float + - from_timestamp + - 1 + - key: open + path: + - [] + - 1 + type: + - float + - key: high + path: + - [] + - 2 + type: + - float + - key: low + path: + - [] + - 3 + type: + - float + - key: close + path: + - [] + - 4 + type: + - float + - key: volume + path: + - [] + - 5 + type: + - float + + + trades: + request: + template: /trading-pairs/{currency_pair}/trades + pair_template: + template: "{first}-{second}" + lower_case: false + params: null + + response: + type: list + values: + type: dict + values: + date: + type: int + id: + type: int + price: + type: float + amount: + type: float + side: + type: str + + mapping: + - key: time + path: + - date + type: + - float + - from_timestamp + - 0 + - key: id + path: + - id + type: + - int + - key: direction + path: + - side + type: + - str + - key: price + path: + - price + type: + - float + - key: amount + path: + - amount + type: + - float + + order_books: + request: + template: /trading-pairs/{currency_pair}/book + pair_template: + template: "{first}-{second}" + lower_case: false + params: + level: + type: int + default: 2 + + response: + type: dict + values: + sequence: + type: int + bid: + type: list + values: + type: list + values: + 1: #price + type: float + 2: #quantity + type: float + ask: + type: list + values: + type: list + values: + 1: #price + type: float + 2: #quantity + type: float + + mapping: + - key: time + path: [] + type: + - none + - now + - key: id + path: + - sequence + type: + - int + - key: position + path: [] + type: + - none + - range + - key: bids_amount + path: + - bid + - 2 + type: + - float + - key: bids_price + path: + - bid + - 1 + type: + - float + - key: asks_amount + path: + - ask + - 2 + type: + - float + - key: asks_price + path: + - ask + - 1 + type: + - float \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/hbtc.yaml b/pandas_datareader/crypto_utils/resources/hbtc.yaml new file mode 100644 index 00000000..88ba65b5 --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/hbtc.yaml @@ -0,0 +1,305 @@ +name: hbtc +is_exchange: true + +rate_limit: null +api_url: https://api.bhex.com/ + +requests: + currency_pairs: + request: + template: openapi/v1/pairs + pair_template: null + params: null + + response: + type: list + values: + type: dict + values: + symbol: + type: str + quoteToke: + type: str + baseToken: + type: str + mapping: + - key: currency_pair_first + path: + - baseToken + type: + - str + - key: currency_pair_second + path: + - quoteToken + type: + - str + + tickers: + request: + template: openapi/quote/v1/ticker/price + pair_template: + template: "{first}{second}" + lower_case: false + alias: symbol + params: null + response: + type: dict + values: + price: + type: str + mapping: + - key: time + path: [] + type: + - none + - now + - key: last_price + path: + - price + type: + - str + - float + + + order_books: + request: + template: openapi/quote/v1/depth/merged + pair_template: + template: "{first}{second}" + lower_case: false + alias: symbol + params: + limit: + type: int + default: 40 + response: + type: dict + values: + time: + type: int + bids: + type: list + values: + type: list + values: + 0: #price + type: str + 1: #quantity + type: str + asks: + type: list + values: + type: list + values: + 0: #price + type: str + 1: #quantity + type: str + + mapping: + - key: time + path: + - time + type: + - float + - from_timestamp + - 1 + - key: id + path: + - time + type: + - int + - key: position + path: [] + type: + - none + - range + - key: bids_price + path: + - bids + - 0 + type: + - str + - float + - key: bids_amount + path: + - bids + - 1 + type: + - str + - float + - key: asks_price + path: + - asks + - 0 + type: + - str + - float + - key: asks_amount + path: + - asks + - 1 + type: + - str + - float + + trades: + request: + template: openapi/quote/v1/trades + pair_template: + template: "{first}{second}" + lower_case: false + alias: symbol + params: + limit: + type: int + max: 1000 + default: 500 + response: + type: list + values: + type: dict + values: + price: + type: str + time: + type: int + qty: + type: str + isBuyerMaker: + type: bool + mapping: + - key: time + path: + - time + type: + - float + - from_timestamp + - 1 + - key: id + path: + - time + type: + - int + - key: direction + path: + - isBuyerMaker + type: + - value + - map + - true + - sell + - false + - buy + - key: price + path: + - price + type: + - str + - float + - key: amount + path: + - qty + type: + - str + - float + + historic_rates: + request: + template: openapi/quote/v1/klines + pair_template: + template: "{first}{second}" + lower_case: false + alias: symbol + params: + startTime: + type: int + required: false + endTime: + function: last_timestamp + type: + - datetime + - timestampms + limit: + type: int + max: 1000 + default: 1000 + interval: + allowed: + minutes: 1m + hours: 1h + days: 1d + weeks: 1w + months: 1M + default: 1d + response: + type: list + values: + type: list + values: + 0: #open time + type: int + 1: # open + type: str + 2: #high + type: str + 3: #low + type: str + 4: #close + type: str + 5: #volume + type: str + 6: # close time + type: str + 7: # quote asset volume + type: str + 8: # numb. trades + type: str + 9: # taker buy base asset volume + type: str + 10: # taker buy quote asset volume + type: str + 11: + type: str + + mapping: + - key: time + path: + - 0 + type: + - float + - from_timestamp + - 1 + - key: open + path: + - 1 + type: + - str + - float + - key: high + path: + - 2 + type: + - str + - float + - key: low + path: + - 3 + type: + - str + - float + - key: close + path: + - 4 + type: + - str + - float + - key: volume + path: + - 5 + type: + - str + - float + + + diff --git a/pandas_datareader/crypto_utils/resources/hitbtc.yaml b/pandas_datareader/crypto_utils/resources/hitbtc.yaml new file mode 100644 index 00000000..a6905592 --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/hitbtc.yaml @@ -0,0 +1,393 @@ +name: hitbtc +exchange: true +api_docs: https://api.hitbtc.com/#market-data +api_url: https://api.hitbtc.com/api/2/ +rate_limit: + max: 100 + unit: 1 +requests: + currency_pairs: + request: + template: public/symbol/ + pair_template: null + params: null + response: + type: list + values: + type: dict + values: + id: # Symbol identifier. In the future, the description will simply use the symbol, i.e. "ETHBTC" + type: str + baseCurrency: # i.e. "ETH" + type: str + quoteCurrency: # i.e. "BTC" + type: str + quantityIncrement: + type: + - str + - float + tickSize: + type: + - str + - float + takeLiquidityRate: # Default fee rate + type: + - str + - float + provideLiquidityRate: # Default fee rate for market making trades + type: + - str + - float + feeCurrency: # i.e. "BTC" + type: str + mapping: + - key: currency_pair_first + path: + - baseCurrency + type: + - str + - key: currency_pair_second + path: + - quoteCurrency + type: + - str + + tickers: + request: + template: public/ticker/{currency_pair} + pair_template: # i.e. ETHBTC + template: "{first}{second}" + lower_case: false + params: null + response: + type: list + values: + type: dict + values: + ask: # Best ask price + type: + - str + - float + bid: # Best bid price + type: + - str + - float + last: # Last trade price + type: + - str + - float + open: # Last trade price 24 hours ago + type: + - str + - float + low: # Lowest trade price within 24 hours + type: + - str + - float + high: # Highest trade price within 24 hours + type: + - str + - float + volume: # Total trading amount within 24 hours in base currency + type: + - str + - float + volumeQuote: # Total trading amount within 24 hours in quote currency + type: + - str + - float + timestamp: # Last update or refresh ticker timestamp + type: + - str + symbol: + type: str + mapping: + - key: best_ask + path: + - ask + type: + - str + - float + - key: best_bid + path: + - bid + type: + - str + - float + - key: last_price + path: + - last + type: + - str + - float + - key: daily_volume + path: + - volume + type: + - str + - float + - key: time + path: + - timestamp + type: + - str + - dateparser + + trades: + request: + template: public/trades/{currency_pair} + pair_template: # i.e. ETHBTC + template: "{first}{second}" + lower_case: false + params: + sort: + type: str + default: DESC + by: # Filtration definition. Accepted values: id, timestamp. Default timestamp + type: str + default: timestamp + required: false + from: # Number or Datetime + required: false + till: # Number or Datetime + required: false + limit: + type: int + required: false + offset: + type: int + required: false + response: + type: list + values: + type: dict + values: + id: + type: int + price: + type: + - str + - float + quantity: + type: + - str + - float + side: # Trade side "sell" or "buy" + type: str + timestamp: + type: + - str + mapping: + - key: price + path: + - price + type: + - str + - float + - key: amount + path: + - quantity + type: + - str + - float + - key: direction + path: + - side + type: + - str + - key: ime + path: + - timestamp + type: + - str + - dateparser + - key: id + path: + - id + type: + - int + + order_books: + request: + template: public/orderbook/{currency_pair} + pair_template: # i.e. ETHBTC + template: "{first}{second}" + lower_case: false + params: + limit: # Limit of orderbook levels. Set 0 to view full orderbook levels + type: int + default: 100 + response: + type: dict + values: + ask: + type: list + values: + type: dict + values: + price: # Price level + type: + - str + size: # Total volume of orders with the specified price + type: + - str + bid: + type: list + values: + type: dict + values: + price: # Price level + type: + - str + size: # Total volume of orders with the specified price + type: + - str + mapping: + - key: book_time + path: [] + type: + - none + - now + - key: id + path: [] + type: + - none + - now_timestamp + - key: position + path: [] + type: + - none + - range + - key: asks_price + path: + - ask + - price + type: + - str + - float + - key: asks_amount + path: + - ask + - size + type: + - str + - float + - key: bids_price + path: + - bid + - price + type: + - str + - float + - key: bids_amount + path: + - bid + - size + type: + - str + - float + + historic_rates: + request: + template: public/candles/{currency_pair} + pair_template: # i.e. ETHBTC + template: "{first}{second}" + lower_case: false + params: + period: + type: str + allowed: + minutes: M1 +# hours: H1 + days: D1 + weeks: D7 + months: 1M + default: D1 + sort: + type: str + default: ASC + from: + function: last_timestamp + type: + - datetime + - timedelta + - interval + - 1000 + - from_timestamp + - 0 + - "%Y-%m-%dT%H:%M:%S.%fZ" + till: + function: last_timestamp + type: + - datetime + - format + - "%Y-%m-%dT%H:%M:%S.%fZ" + limit: # Limit of candles, default 100. + type: int + default: 1000 + offset: + type: int + required: false + response: # Result contain candles only with non zero volume. (No trades - no candles) + type: list + values: + type: dict + values: + timestamp: + type: + - str + open: # Open price + type: + - str + close: # Close price + type: + - str + min: # Min price + type: + - str + max: # Max price + type: + - str + volume: # Volume in base currency + type: + - str + volumeQuote: # Volume in quote currency + type: + - str + mapping: + - key: time + path: + - timestamp + type: + - str + - dateparser + - key: open + path: + - open + type: + - str + - float + - key: close + path: + - close + type: + - str + - float + - key: low + path: + - min + type: + - str + - float + - key: high + path: + - max + type: + - str + - float + - key: volume + path: + - volume + type: + - str + - float diff --git a/pandas_datareader/crypto_utils/resources/hoo.yaml b/pandas_datareader/crypto_utils/resources/hoo.yaml new file mode 100644 index 00000000..d9723730 --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/hoo.yaml @@ -0,0 +1,341 @@ +name: hoo +exchange: true +api_docs: https://hoo.com/docs-en +rate_limit: + max: 300 + unit: 60 + +api_url: https://api.hoolgd.com/open/v1/ + +requests: + currency_pairs: + request: + template: tickers/market + pair_template: null + params: null + + response: + type: dict + values: + data: + type: list + values: + type: dict + values: + price: + type: str + symbol: + type: str + volume: + type: str + + mapping: + - key: currency_pair_first + path: + - data + - symbol + type: + - str + - split + - "-" + - 0 + - key: currency_pair_second + path: + - data + - symbol + type: + - str + - split + - "-" + - 1 + + tickers: + request: + template: tickers/market + pair_template: null + params: null + response: + type: dict + values: + data: + type: list + values: + type: dict + values: + price: + type: str + symbol: + type: str + volume: + type: str + + mapping: + - key: currency_pair_first + path: + - data + - symbol + type: + - str + - split + - "-" + - 0 + - key: currency_pair_second + path: + - data + - symbol + type: + - str + - split + - "-" + - 1 + - key: time + path: [] + type: + - none + - now + - key: daily_volume + path: + - data + - volume + type: + - str + - float + - key: last_price + path: + - data + - price + type: + - str + - float + + historic_rates: + request: + template: kline/market + pair_template: + template: "{first}-{second}" + lower_case: false + alias: symbol + params: + type: + allowed: + minutes: 1Min + hours: 1Hour + days: 1Day + weeks: 1Week + default: 1Day + response: + type: dict + values: + data: + type: list + values: + type: dict + values: + open: + type: str + high: + type: str + low: + type: str + close: + type: str + time: + type: int + volume: + type: str + mapping: + - key: time + path: + - data + - time + type: + - float + - from_timestamp + - 0 + - key: open + path: + - data + - open + type: + - str + - float + - key: high + path: + - data + - high + type: + - str + - float + - key: low + path: + - data + - low + type: + - str + - float + - key: close + path: + - data + - close + type: + - str + - float + - key: volume + path: + - data + - volume + type: + - str + - float + + trades: + request: + template: trade/market + pair_template: + template: "{first}-{second}" + lower_case: false + alias: symbol + params: null + + response: + type: dict + values: + data: + type: list + values: + type: dict + values: + amount: + type: str + price: + type: str + time: + type: int + side: + type: str + volume: + type: str + + mapping: + - key: time + path: + - data + - time + type: + - float + - from_timestamp + - 1 + - key: id + path: + - data + - time + type: + - int + - key: direction + path: + - data + - side + type: + - value + - map + - -1 + - buy + - 1 + - sell + - key: price + path: + - data + - price + type: + - str + - float + - key: amount + path: + - data + - volume + type: + - str + - float + + order_books: + request: + template: depth/market + pair_template: + template: "{first}-{second}" + lower_case: false + alias: symbol + params: null + + response: + type: dict + values: + data: + type: dict + values: + bids: + type: list + values: + type: dict + values: + price: + type: str + quantity: + type: str + asks: + type: list + values: + type: dict + values: + price: + type: str + quantity: + type: str + + mapping: + - key: time + path: [] + type: + - none + - now + - key: id + path: [] + type: + - none + - now_timestamp + - key: position + path: [] + type: + - none + - range + - key: bids_amount + path: + - data + - bids + - quantity + type: + - str + - float + - key: bids_price + path: + - data + - bids + - price + type: + - str + - float + - key: asks_amount + path: + - data + - asks + - quantity + type: + - str + - float + - key: asks_price + path: + - data + - asks + - price + type: + - str + - float \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/huobi.yaml b/pandas_datareader/crypto_utils/resources/huobi.yaml new file mode 100644 index 00000000..274acc47 --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/huobi.yaml @@ -0,0 +1,423 @@ +name: huobi +exchange: true +api_docs: https://huobiapi.github.io/docs/spot/v1/en/ +api_url: https://api.huobi.pro/ +rate_limit: + max: 100 + unit: 10 +requests: + currency_pairs: + request: + template: v1/common/symbols + pair_template: null + params: null + response: + type: dict + values: + status: + type: str + data: + type: list + values: + type: dict + values: + base-currency: + type: str + quote-currency: + type: str + price-precision: + type: int + amoint_precision: + type: int + symbol-partition: + type: str + symbol: + type: str + state: + type: str + value-precision: + type: int + min-order-amt: + type: float + max-oder-amt: + type: float + min-order-value: + type: float + laverage-ratio: + type: int + mapping: + - key: currency_pair_first + path: + - data + - base-currency + type: + - str + - upper + - key: currency_pair_second + path: + - data + - quote-currency + type: + - str + - upper + + historic_rates: + request: + template: market/history/kline + pair_template: # i.e. BTC_CQ + template: "{first}{second}" + lower_case: true + alias: symbol + params: + period: + type: str + allowed: + minutes: 1min + hours: 60min + days: 1day + weeks: 1week + months: 1mon + default: 1day + size: + type: int + min: 1 + max: 2000 + default: 2000 + response: + type: dict + values: + status: + type: str + allowed: + - ok + - error + ch: # channel format, i.e. "market.btcusdt.kline.1day" + type: str + ts: # timestamp in millisecond + type: + - int + data: + type: list + values: + type: dict + values: + id: + type: int + amount: + type: float + count: + type: int + open: + type: float + close: + type: float + low: + type: float + high: + type: float + vol: + type: float + mapping: + - key: time + path: + - data + - id + type: + - float + - from_timestamp + - 0 + - key: open + path: + - data + - open + type: + - float + - key: close + path: + - data + - close + type: + - float + - key: low + path: + - data + - low + type: + - float + - key: high + path: + - data + - high + type: + - float + - key: volume + path: + - data + - vol + type: + - float + + tickers: + request: + template: market/detail/merged + pair_template: # i.e. BTC_CQ + template: "{first}{second}" + lower_case: true + alias: symbol + params: null + response: + type: dict + values: + status: + type: str + ch: # channel format, i.e. "market.btcusdt.kline.1day" + type: str + ts: # timestamp in millisecond + type: + - int + tick: + type: dict + values: + amount: + type: float + open: # daily Kline, opening price + type: float + close: # daily Kline, closing price + type: float + high: # daily Kline,the maxmum price + type: float + id: + type: int + count: + type: int + low: # daily Kline, the minimum price + type: float + version: + type: int + ask: + type: list + values: + 0: + type: float + 1: + type: float + bid: + type: list + values: + 0: # price + type: float + 1: # size + type: float + vol: + type: float + mapping: + - key: time + path: + - ts + type: + - float + - from_timestamp + - 1 + - key: daily_volume + path: + - tick + - vol + type: + - float + - key: best_ask + path: + - tick + - ask + - 0 + type: + - float + - key: best_bid + path: + - tick + - bid + - 0 + type: + - float + + order_books: + request: + template: market/depth + pair_template: # i.e. BTC_CQ + template: "{first}{second}" + lower_case: true + alias: symbol + params: + type: + type: str + default: step0 #aggregation level (step5 -->max. aggregation) + response: + type: dict + values: + status: + type: str + ch: + type: str + ts: # timestamp in millisecond + type: + - int + tick: # Depth + type: dict + values: + id: + type: int + ts: + type: + - int + bids: + type: list + values: + type: list + values: + 0: # price + type: int + 1: # amount + type: float + asks: + type: list + values: + type: list + values: + 0: # price + type: int + 1: # amount + type: float + mapping: + - key: time + path: + - tick + - ts + type: + - float + - from_timestamp + - 1 + - key: bids_price + path: + - tick + - bids + - 0 + type: + - int + - key: bids_amount + path: + - tick + - bids + - 1 + type: + - float + - key: asks_price + path: + - tick + - asks + - 0 + type: + - int + - key: asks_amount + path: + - tick + - asks + - 1 + type: + - float + - key: id + path: + - tick + - version + type: + - int + - key: position + path: [] + type: + - none + - range + +# Probleme mit der resoponse. Die können wir nicht mappen, da manchmal zu einem Zeitpunkt mehrere Trades zurückkommen. +# trades: +# request: +# template: market/history/trade +# pair_template: # i.e. BTC_CQ +# template: "{first}{second}" +# alias: symbol +# lower_case: true +# params: +# size: +# type: int +# default: 5 +# response: +# type: dict +# values: +# status: +# type: str +# ch: +# type: str +# ts: +# type: int +# data: +# type: list +# values: +# type: dict +# values: +# id: +# type: int +# ts: # timestamp +# type: int +# data: +# type: list +# values: +# type: dict +# values: +# id: +# type: int +# ts: +# type: int +# trade-id: +# type: int +# amount: +# type: float +# price: +# type: +# - int +# direction: +# type: str +# +# mapping: +# - key: price +# path: +# - data +# - data +# - price +# type: +# - float +# - key: amount +# path: +# - data +# - data +# - amount +# type: +# - float +# - key: direction +# path: +# - data +# - data +# - direction +# type: +# - str +# - key: time +# path: +# - data +# - data +# - ts +# type: +# - int +# - Afrom_timestamp +# - key: id +# path: +# - data +# - data +# - trade-id +# type: +# - int \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/huobi_korea.yaml b/pandas_datareader/crypto_utils/resources/huobi_korea.yaml new file mode 100644 index 00000000..48c89493 --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/huobi_korea.yaml @@ -0,0 +1,424 @@ +name: huobi_korea +exchange: true +api_url: https://api-cloud.huobi.co.kr/ +rate_limit: + max: 100 + unit: 10 +requests: + currency_pairs: + request: + template: v1/common/symbols + pair_template: null + params: null + response: + type: dict + values: + status: + type: str + data: + type: list + values: + type: dict + values: + base-currency: + type: str + quote-currency: + type: str + price-precision: + type: int + amoint_precision: + type: int + symbol-partition: + type: str + symbol: + type: str + state: + type: str + value-precision: + type: int + min-order-amt: + type: float + max-oder-amt: + type: float + min-order-value: + type: float + laverage-ratio: + type: int + mapping: + - key: currency_pair_first + path: + - data + - base-currency + type: + - str + - upper + - key: currency_pair_second + path: + - data + - quote-currency + type: + - str + - upper + + + + historic_rates: + request: + template: market/history/kline + pair_template: # i.e. BTC_CQ + template: "{first}{second}" + lower_case: true + alias: symbol + params: + period: + type: str + allowed: + minutes: 1min + hours: 60min + days: 1day + weeks: 1week + months: 1mon + default: 1day + size: + type: int + min: 1 + max: 2000 + default: 2000 + response: + type: dict + values: + status: + type: str + allowed: + - ok + - error + ch: # channel format, i.e. "market.btcusdt.kline.1day" + type: str + ts: # timestamp in millisecond + type: + - int + data: + type: list + values: + type: dict + values: + id: + type: int + amount: + type: float + count: + type: int + open: + type: float + close: + type: float + low: + type: float + high: + type: float + vol: + type: float + mapping: + - key: time + path: + - data + - id + type: + - float + - from_timestamp + - 0 + - key: open + path: + - data + - open + type: + - float + - key: close + path: + - data + - close + type: + - float + - key: low + path: + - data + - low + type: + - float + - key: high + path: + - data + - high + type: + - float + - key: volume + path: + - data + - vol + type: + - float + + tickers: + request: + template: market/detail/merged + pair_template: # i.e. BTC_CQ + template: "{first}{second}" + lower_case: true + alias: symbol + params: null + response: + type: dict + values: + status: + type: str + ch: # channel format, i.e. "market.btcusdt.kline.1day" + type: str + ts: # timestamp in millisecond + type: + - int + tick: + type: dict + values: + amount: + type: float + open: # daily Kline, opening price + type: float + close: # daily Kline, closing price + type: float + high: # daily Kline,the maxmum price + type: float + id: + type: int + count: + type: int + low: # daily Kline, the minimum price + type: float + version: + type: int + ask: + type: list + values: + 0: + type: float + 1: + type: float + bid: + type: list + values: + 0: # price + type: float + 1: # size + type: float + vol: + type: float + mapping: + - key: time + path: + - ts + type: + - float + - from_timestamp + - 1 + - key: daily_volume + path: + - tick + - vol + type: + - float + - key: best_ask + path: + - tick + - ask + - 0 + type: + - float + - key: best_bid + path: + - tick + - bid + - 0 + type: + - float + + order_books: + request: + template: market/depth + pair_template: # i.e. BTC_CQ + template: "{first}{second}" + lower_case: true + alias: symbol + params: + type: + type: str + default: step0 #aggregation level (step5 -->max. aggregation) + response: + type: dict + values: + status: + type: str + ch: + type: str + ts: # timestamp in millisecond + type: + - int + tick: # Depth + type: dict + values: + id: + type: int + ts: + type: + - int + bids: + type: list + values: + type: list + values: + 0: # price + type: int + 1: # amount + type: float + asks: + type: list + values: + type: list + values: + 0: # price + type: int + 1: # amount + type: float + mapping: + - key: time + path: + - tick + - ts + type: + - float + - from_timestamp + - 1 + - key: bids_price + path: + - tick + - bids + - 0 + type: + - int + - key: bids_amount + path: + - tick + - bids + - 1 + type: + - float + - key: asks_price + path: + - tick + - asks + - 0 + type: + - int + - key: asks_amount + path: + - tick + - asks + - 1 + type: + - float + - key: id + path: + - tick + - version + type: + - int + - key: position + path: [] + type: + - none + - range + +# Probleme mit der resoponse. Die können wir nicht mappen, da manchmal zu einem Zeitpunkt mehrere Trades zurückkommen. +# trades: +# request: +# template: market/history/trade +# pair_template: # i.e. BTC_CQ +# template: "{first}{second}" +# alias: symbol +# lower_case: true +# params: +# size: +# type: int +# default: 5 +# response: +# type: dict +# values: +# status: +# type: str +# ch: +# type: str +# ts: +# type: int +# data: +# type: list +# values: +# type: dict +# values: +# id: +# type: int +# ts: # timestamp +# type: int +# data: +# type: list +# values: +# type: dict +# values: +# id: +# type: int +# ts: +# type: int +# trade-id: +# type: int +# amount: +# type: float +# price: +# type: +# - int +# direction: +# type: str +# +# mapping: +# - key: price +# path: +# - data +# - data +# - price +# type: +# - float +# - key: amount +# path: +# - data +# - data +# - amount +# type: +# - float +# - key: direction +# path: +# - data +# - data +# - direction +# type: +# - str +# - key: time +# path: +# - data +# - data +# - ts +# type: +# - int +# - Afrom_timestamp +# - key: id +# path: +# - data +# - data +# - trade-id +# type: +# - int \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/idex.yaml b/pandas_datareader/crypto_utils/resources/idex.yaml new file mode 100644 index 00000000..741a0e3a --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/idex.yaml @@ -0,0 +1,336 @@ +name: idex +exchange: true +api_docs: https://docs.idex.io/#introduction +api_url: https://api.idex.io/ +rate_limit: + max: 300 + unit: 60 +requests: + currency_pairs: + request: + template: v1/markets + pair_template: null + params: null + response: + type: list + values: + type: dict + values: + baseAsset: + type: str + quoteAsset: + type: str + mapping: + - key: currency_pair_first + path: + - baseAsset + type: + - str + - key: currency_pair_second + path: + - quoteAsset + type: + - str + + + tickers: + request: + template: v1/tickers + pair_template: null + params: null + response: + type: list + values: + type: dict + values: + baseAsset: + type: str + quoteAsset: + type: str + baseVolume: + type: str + quoteVolume: + type: str + ask: + type: str + bid: + type: str + time: + type: int + + mapping: + - key: currency_pair_first + path: + - market + type: + - str + - split + - "-" + - 0 + - key: currency_pair_second + path: + - market + type: + - str + - split + - "-" + - 1 + - key: time + path: + - time + type: + - float + - from_timestamp + - 1 + - key: best_ask + path: + - bid + type: + - str + - float + - key: best_bid + path: + - bid + type: + - str + - float + + order_books: + request: + template: v1/orderbook + pair_template: # e.g. ETH_SAN + template: "{first}-{second}" + lower_case: false + alias: market + params: + level: + type: int + default: 2 + limit: + type: int + default: 50 + + response: + type: dict + values: + sequence: + type: int + asks: + type: list + values: + type: list + values: + 0: #price + type: + - str + 1: #quantity + type: + - str + bids: + type: list + values: + type: list + values: + 0: #price + type: + - str + 1: #quantity + type: + - str + mapping: + - key: position + path: [] + type: + - none + - range + - key: id + path: + - sequence + type: + - int + - key: time + path: [] + type: + - none + - now + - key: asks_price + path: + - asks + - 0 + type: + - str + - float + - key: asks_amount + path: + - asks + - 1 + type: + - str + - float + - key: bids_price + path: + - bids + - 0 + type: + - str + - float + - key: bids_amount + path: + - bids + - 1 + type: + - str + - float + + trades: + request: + template: v1/trades + pair_template: # e.g. ETH_SAN + template: "{first}-{second}" + lower_case: false + alias: market + params: + limit: + type: int + max: 1000 + default: 200 + response: + type: list + values: + type: dict + values: + fillId: + type: str + quantity: + type: str + price: + type: str + time: + type: int + makerSide: + type: str + sequence: + type: int + mapping: + - key: time + path: + - time + type: + - float + - from_timestamp + - 1 + - key: id + path: + - sequence + type: + - int + - key: amount + path: + - quantity + type: + - str + - float + - key: direction + path: + - makerSide + type: + - value + - map + - sell + - buy + - buy + - sell + - key: price + path: + - price + type: + - str + - float + + historic_rates: + request: + template: v1/candles + pair_template: # e.g. ETH_SAN + template: "{first}-{second}" + lower_case: false + alias: market + params: + interval: + allowed: + minutes: 1m + hours: 1h + days: 1d + default: 1d + limit: + max: 1000 + default: 1000 + end: + function: last_timestamp + type: + - datetime + - timestampms +# start: +# function: last_timestamp +# type: +# - datetime +# - timedeltams +# - interval +# - 1000 + + response: + type: list + values: + type: dict + values: + market: + type: str + start: + type: int + open: + type: str + high: + type: str + low: + type: str + close: + type: str + volume: + type: str + mapping: + - key: time + path: + - start + type: + - float + - from_timestamp + - 1 + - key: open + path: + - open + type: + - str + - float + - key: high + path: + - high + type: + - str + - float + - key: low + path: + - low + type: + - str + - float + - key: close + path: + - close + type: + - str + - float + - key: volume + path: + - volume + type: + - str + - float \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/kucoin.yaml b/pandas_datareader/crypto_utils/resources/kucoin.yaml new file mode 100644 index 00000000..2a51a4bd --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/kucoin.yaml @@ -0,0 +1,432 @@ +name: kucoin +exchange: true +api_url: https://api.kucoin.com/api/v1/ +rate_limit: + max: 30 + unit: 60 +requests: + currency_pairs: + request: + template: symbols + pair_template: null + params: null + response: + type: dict + values: + code: + type: + - str + - int + data: + type: list + values: + symbol: + type: str + name: + type: str + baseCurrency: + type: str + quoteCurrency: + type: str + baseMinSize: + type: float + quoteMinSize: + type: int + baseMaxSize: + type: int + quoteMaxSize: + type: float + baseIncrement: + type: float + quoteIncrement: + type: float + priceIncrement: + type: float + feeCurrency: + type: str + enableTrading: + type: bool + mapping: + - key: currency_pair_first + path: + - data + - symbol + type: + - str + - split + - "-" + - 0 + - key: currency_pair_second + path: + - data + - symbol + type: + - str + - split + - "-" + - 1 + + tickers: + request: + template: market/allTickers + pair_template: null + params: null + response: + type: dict + values: + code: + type: int + data: + type: dict + values: + ticker: + type: list + values: + type: dict + values: + symbol: # e.g. KCS + type: str + high: + type: float + vol: + type: float + last: + type: float + low: + type: float + buy: + type: float + sell: + type: float + changePrice: + type: float + averagePrice: + type: float + changeRate: + type: float + volValue: + type: float + time: + type: int + mapping: + - key: time + path: + - data + - time + type: + - float + - from_timestamp + - 1 + - key: currency_pair_first + path: + - data + - ticker + - symbol + type: + - str + - split + - "-" + - 0 + - key: currency_pair_second + path: + - data + - ticker + - symbol + type: + - str + - split + - "-" + - 1 + - key: last_price + path: + - data + - ticker + - last + type: + - float + - key: best_bid + path: + - data + - ticker + - buy + type: + - float + - key: best_ask + path: + - data + - ticker + - sell + type: + - float + - key: daily_volume + path: + - data + - ticker + - volValue + type: + - float + + historic_rates: + request: + template: market/candles + pair_template: # e.g. KCS-BTC + template: "{first}-{second}" + lower_case: false + alias: symbol + params: + startAt: + function: last_timestamp + type: + - datetime + - timedelta + - interval + - 1000 + endAt: + function: last_timestamp + type: + - datetime + - timestamp + type: + allowed: + minutes: 1min + hours: 1hour + days: 1day + weeks: 1week + default: 1day + + response: + type: dict + values: + code: + type: str + data: + type: list + values: + type: list + values: + 0: # timestamp + type: + - str + 1: # open + type: + - str + 2: # close + type: + - str + 3: # high + type: + - str + 4: # low + type: + - str + 5: # volume + type: + - str + 6: # amount + type: + - str + mapping: + - key: time + path: + - data + - 0 + type: + - str + - float + - from_timestamp + - 0 + - key: open + path: + - data + - 1 + type: + - str + - float + - key: close + path: + - data + - 2 + type: + - str + - float + - key: high + path: + - data + - 3 + type: + - str + - float + - key: low + path: + - data + - 4 + type: + - str + - float + - key: volume + path: + - data + - 5 + type: + - str + - float + + + order_books: + request: + template: market/orderbook/level2_20 + pair_template: # e.g. KCS-BTC + template: "{first}-{second}" + lower_case: false + alias: symbol + params: null + response: + type: dict + values: + code: + type: str + data: + type: dict + values: + time: + type: int + sequence: + type: str + bids: + type: list + values: + type: list + values: + 0: + type: str + 1: + type: str + asks: + type: list + values: + type: list + values: + 0: + type: str + 1: + type: str + mapping: + - key: asks_price + path: + - data + - asks + - 0 + type: + - str + - float + - key: asks_amount + path: + - data + - asks + - 1 + type: + - str + - float + - key: bids_price + path: + - data + - bids + - 0 + type: + - str + - float + - key: bids_amount + path: + - data + - bids + - 1 + type: + - str + - float + - key: time + path: + - data + - time + type: + - float + - from_timestamp + - 1 + - key: id + path: + - data + - sequence + type: + - str + - int + - key: position + path: [] + type: + - none + - range + + trades: + request: + template: market/histories + pair_template: + template: "{first}-{second}" + alias: symbol + lower_case: false + params: null + + response: + type: dict + values: + code: + type: str + data: + type: list + values: + type: dict + values: + sequence: + type: str + price: + type: str + size: + type: str + side: + type: str + time: + type: int + mapping: + - key: time + path: + - data + - time + type: + - float + - from_timestamp + - 3 + - key: price + path: + - data + - price + type: + - str + - float + - key: amount + path: + - data + - size + type: + - str + - float + - key: direction + path: + - data + - side + type: + - str + - key: id + path: + - data + - sequence + type: + - str + - int + diff --git a/pandas_datareader/crypto_utils/resources/lbank.yaml b/pandas_datareader/crypto_utils/resources/lbank.yaml new file mode 100644 index 00000000..6b109afd --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/lbank.yaml @@ -0,0 +1,333 @@ +name: lbank +exchange: true +api_docs: https://github.com/LBank-exchange/lbank-official-api-docs/tree/master/API-For-Spot-EN +api_url: https://api.lbkex.com/v1/ +rate_limit: null + +requests: + tickers: + request: + template: ticker.do + pair_template: null + params: + symbol: + type: str + default: all + response: + type: list + values: + type: dict + values: + symbol: + type: str + ticker: + type: dict + values: + change: + type: float + high: + type: float + latest: + type: float + low: + type: float + turnover: + type: float + vol: + type: float + timestamp: + type: + - int + mapping: + - key: time + path: [] + type: + - none + - now + - key: currency_pair_first + path: + - symbol + type: + - str + - splitupper + - "_" + - 0 + - key: currency_pair_second + path: + - symbol + type: + - str + - splitupper + - "_" + - 1 + - key: last_price + path: + - ticker + - latest + type: + - float + - key: last_price + path: + - ticker + - latest + type: + - float + - key: daily_volume + path: + - ticker + - vol + type: + - float + + currency_pairs: + request: + template: currencyPairs.do + pair_template: null + params: null + response: + type: list + values: # each available currency pair e.g. "bcc_eth","etc_btc"... + type: str + mapping: + - key: currency_pair_first + path: + - [] + type: + - str + - split + - "_" + - 0 + - key: currency_pair_second + path: + - [] + type: + - str + - split + - "_" + - 1 + + order_books: + request: + template: depth.do + pair_template: # e.g. eth_btc + template: "{first}_{second}" + lower_case: true + alias: symbol + params: + size: + type: int + min: 1 + max: 60 + default: 60 + merge: + type: int + default: "0" + response: + type: dict + values: + asks: + type: list + values: + type: list + values: + 0: # price + type: float + 1: # size + type: float + bids: + type: list + values: + type: list + values: + 0: # price + type: float + 1: # size + type: float + mapping: + - key: id + path: [] + type: + - none + - now_timestamp + - key: position + path: [] + type: + - none + - range + - key: time + path: [] + type: + - none + - now + - key: asks_price + path: + - asks + - 0 + type: + - str + - float + - key: asks_amount + path: + - asks + - 1 + type: + - str + - float + - key: bids_price + path: + - bids + - 0 + type: + - str + - float + - key: bids_amount + path: + - bids + - 1 + type: + - str + - float + + trades: + request: + template: trades.do + pair_template: # e.g. eth_btc + template: "{first}_{second}" + lower_case: true + alias: symbol + params: + size: + type: int + min: 1 + max: 600 + default: 200 + time: + required: false + response: + type: list + values: + type: dict + values: + date_ms: + type: + - float + - from_timestamp + - 0 + amount: + type: float + price: + type: float + type: + type: str + tid: + type: str + mapping: + - key: id + path: + - tid + type: + - str + - key: time + path: + - date_ms + type: + - float + - from_timestamp + - 1 + - key: amount + path: + - amount + type: + - float + - key: price + path: + - price + type: + - float + - key: direction + path: + - type + type: + - str + + historic_rates: + request: + template: kline.do + pair_template: # e.g. eth_btc + template: "{first}_{second}" + lower_case: true + alias: symbol + params: + size: + type: int + min: 1 + max: 2880 + default: 2000 + type: + allowed: + minutes: minute1 + hours: hour1 + days: day1 + weeks: week1 + months: month1 + default: day1 + time: + function: last_timestamp + type: + - datetime + - timedelta + - interval + - 2000 +# type: int +# default: 1325432318 #01.01.2012 + response: + type: list + values: + type: list + values: + 0: # timestamp + type: + - int + 1: # open + type: float + 2: # high + type: float + 3: # low + type: float + 4: # close + type: float + 5: # volume + type: float + mapping: + - key: time + path: + - 0 + type: + - float + - from_timestamp + - 0 + - key: open + path: + - 1 + type: + - float + - key: high + path: + - 2 + type: + - float + - key: low + path: + - 3 + type: + - float + - key: close + path: + - 4 + type: + - float + - key: volume + path: + - 5 + type: + - float diff --git a/pandas_datareader/crypto_utils/resources/maicoin.yaml b/pandas_datareader/crypto_utils/resources/maicoin.yaml new file mode 100644 index 00000000..346d5b98 --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/maicoin.yaml @@ -0,0 +1,314 @@ +name: maicoin +exchange: true +api_docs: https://max.maicoin.com/documents/api_list#!/public/getApiV2K +rate_limit: + max: 1200 + unit: 60 + +api_url: https://max-api.maicoin.com/api/v2/ + +requests: + currency_pairs: + request: + template: markets + pair_template: null + params: null + + response: + type: list + values: + type: dict + values: + base_unit: + type: str + quote_unit: + type: str + + mapping: + - key: currency_pair_first + path: + - base_unit + type: + - str + - key: currency_pair_second + path: + - quote_unit + type: + - str + + tickers: + request: + template: tickers/{currency_pair} + pair_template: + template: "{first}{second}" + lower_case: true + params: null + response: + type: dict + values: + at: + type: int + buy: + type: str + sell: + type: str + last: + type: str + vol: + type: str + + + mapping: + - key: last_price + path: + - last + type: + - str + - float + - key: time + path: + - at + type: + - float + - from_timestamp + - 0 + - key: best_bid + path: + - buy + type: + - str + - float + - key: best_ask + path: + - sell + type: + - str + - float + - key: daily_volume + path: + - vol + type: + - str + - float + + historic_rates: + request: + template: k + pair_template: + template: "{first}{second}" + lower_case: true + alias: market + params: + limit: + default: 2000 + timestamp: + function: last_timestamp + type: + - datetime + - timedelta + - interval + - 2000 + period: + allowed: + minutes: 1 + hours: 60 + days: 1440 + weeks: 10080 + default: 1440 + response: + type: list + values: + type: list + values: + 0: #time + type: int + 1: #open + type: float + 2: #high + type: float + 3: #low + type: float + 4: #close + type: float + 5: #vol + type: float + + mapping: + - key: time + path: + - 0 + type: + - float + - from_timestamp + - 0 + - key: open + path: + - 1 + type: + - float + - key: high + path: + - 2 + type: + - float + - key: low + path: + - 3 + type: + - float + - key: close + path: + - 4 + type: + - float + - key: volume + path: + - 5 + type: + - float + + + trades: + request: + template: trades + pair_template: + template: "{first}{second}" + lower_case: true + alias: market + params: + limit: + default: 200 + + response: + type: list + values: + type: dict + values: + id: + type: int + price: + type: str + volume: + type: str + created_at: + type: int + side: + type: str + + mapping: + - key: time + path: + - created_at + type: + - float + - from_timestamp + - 0 + - key: id + path: + - id + type: + - int + - key: direction + path: + - side + type: + - value + - map + - ask + - sell + - bid + - buy + - key: price + path: + - price + type: + - str + - float + - key: amount + path: + - volume + type: + - str + - float + + order_books: + request: + template: depth + pair_template: + template: "{first}{second}" + lower_case: true + alias: market + params: + limit: + default: 50 + + response: + type: dict + values: + timestamp: + type: int + asks: + type: list + values: + type: list + values: + 0: #Price + type: str + 1: # Qty + type: str + bids: + type: list + values: + type: list + values: + 0: #Price + type: str + 1: # Qty + type: str + + mapping: + - key: time + path: + - timestamp + type: + - float + - from_timestamp + - 0 + - key: id + path: + - timestamp + type: + - int + - key: position + path: [] + type: + - none + - range + - key: bids_amount + path: + - bids + - 1 + type: + - str + - float + - key: bids_price + path: + - bids + - 0 + type: + - str + - float + - key: asks_amount + path: + - asks + - 1 + type: + - str + - float + - key: asks_price + path: + - asks + - 0 + type: + - str + - float \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/mandala.yaml b/pandas_datareader/crypto_utils/resources/mandala.yaml new file mode 100644 index 00000000..3bb77dbd --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/mandala.yaml @@ -0,0 +1,329 @@ +name: mandala +exchange: true + +rate_limit: + max: 1200 + unit: 60 + +api_url: "" + +requests: + currency_pairs: + request: + template: https://trade.mandala.exchange/open/v1/common/symbols + pair_template: null + params: null + + response: + type: dict + values: + data: + type: dict + values: + list: + type: list + values: + type: dict + values: + symbol: + type: str + baseAsset: + type: str + quoteAsset: + type: str + + mapping: + - key: currency_pair_first + path: + - data + - list + - baseAsset + type: + - str + - key: currency_pair_second + path: + - data + - list + - quoteAsset + type: + - str + + order_books: + request: + template: https://api.binance.com/api/v3/depth + pair_template: # e.g. BNBBTC + template: "{first}{second}" + lower_case: false + alias: symbol + params: + limit: + max: 100 + default: 50 + + response: + type: dict + values: + lastUpdateId: + type: int + bids: + type: list + values: + type: list + values: + 0: # price + type: + - str + - float + 1: # quantity + type: + - str + - float + asks: + type: list + values: + type: list + values: + 0: # price + type: + - str + - float + 1: # quantity + type: + - str + - float + mapping: + - key: time + path: [] + type: + - none + - now + - key: id + path: + - lastUpdateId + type: + - int + + - key: position + path: [] + type: + - none + - range + - key: bids_price + path: + - bids + - 0 + type: + - str + - float + - key: bids_amount + path: + - bids + - 1 + type: + - str + - float + - key: asks_price + path: + - asks + - 0 + type: + - str + - float + - key: asks_amount + path: + - asks + - 1 + type: + - str + - float + + trades: + request: + template: https://api.binance.com/api/v1/trades + pair_template: # e.g. BNBBTC + template: "{first}{second}" + lower_case: false + alias: symbol + params: + limit: + max: 1000 + default: 500 + weight: 1 + response: + type: list + values: + type: dict + values: + id: + type: int + price: + type: + - str + - float + qty: + type: + - str + - float + time: + type: + - float + - from_timestamp + - 1 + isBuyerMaker: + type: bool + isBestMatch: + type: bool + mapping: + - key: id + path: + - id + type: + - int + - key: price + path: + - price + type: + - str + - float + - key: amount + path: + - qty + type: + - str + - float + - key: time + path: + - time + type: + - float + - from_timestamp + - 1 + - key: direction + path: + - isBuyerMaker + type: + - value + - map + - True + - sell + - False + - buy + + historic_rates: + request: + template: https://api.binance.com/api/v1/klines + pair_template: # e.g. BNBBTC + template: "{first}{second}" + lower_case: false + alias: symbol + params: + interval: + allowed: + minutes: 1m + hours: 1h + days: 1d + weeks: 1w + months: 1M + default: 1d + startTime: + required: false + endTime: + function: last_timestamp + type: + - datetime + - timestampms +# - timedeltams +# - interval +# - 1000 + limit: + max: 1000 + default: 1000 + response: + type: list + values: + type: list + values: + 0: # Open time + type: + - float + - from_timestamp + - 1 + 1: # open + type: + - str + - float + 2: # high + type: + - str + - float + 3: # low + type: + - str + - float + 4: # close + type: + - str + - float + 5: # volume + type: + - str + - float + 6: # close time + type: + - float + - from_timestamp + - 1 + 7: # Quote asset volume + type: + - str + - float + 8: # Number of trades + type: int + 9: # Taker buy base asset volume + type: + - str + - float + 10: # Taker buy quote asset volume + type: + - str + - float + 11: # ignore + type: ignore + mapping: + - key: open + path: + - 1 + type: + - str + - float + - key: high + path: + - 2 + type: + - str + - float + - key: low + path: + - 3 + type: + - str + - float + - key: close + path: + - 4 + type: + - str + - float + - key: volume + path: + - 5 + type: + - str + - float + - key: time + path: + - 6 + type: + - float + - from_timestamp + - 1 diff --git a/pandas_datareader/crypto_utils/resources/mexc.yaml b/pandas_datareader/crypto_utils/resources/mexc.yaml new file mode 100644 index 00000000..e841297e --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/mexc.yaml @@ -0,0 +1,368 @@ +name: mexc +exchange: true + +rate_limit: + max: 1200 + unit: 60 + +api_url: https://www.mexc.com + +requests: + currency_pairs: + request: + template: /open/api/v2/market/symbols + pair_template: null + params: null + + response: + type: dict + values: + data: + type: list + values: + type: dict + values: + symbol: + type: str + + mapping: + - key: currency_pair_first + path: + - data + - symbol + type: + - str + - split + - "_" + - 0 + - key: currency_pair_second + path: + - data + - symbol + type: + - str + - split + - "_" + - 1 + + tickers: + request: + template: /open/api/v2/market/ticker + pair_template: + template: "{first}_{second}" + lower_case: false + alias: symbol + params: null + response: + type: dict + values: + data: + type: list + values: + type: dict + values: + symbol: + type: str + volume: + type: str + bid: + type: str + ask: + type: str + last: + type: str + time: + type: int + + mapping: + - key: last_price + path: + - data + - last + type: + - str + - float + - key: time + path: + - data + - time + type: + - float + - from_timestamp + - 1 + - key: best_bid + path: + - data + - bid + type: + - str + - float + - key: best_ask + path: + - data + - ask + type: + - str + - float + - key: daily_volume + path: + - data + - volume + type: + - str + - float + + historic_rates: + request: + template: /open/api/v2/market/kline + pair_template: + template: "{first}_{second}" + lower_case: false + alias: symbol + params: + interval: + allowed: + minutes: 1m + hours: 60m + days: 1d + months: 1M + default: 1d + limit: + max: 1000 + default: 100 + start_time: + function: last_timestamp + type: + - datetime + - timedelta + - interval + - 100 + response: + type: dict + values: + data: + type: list + values: + type: dict + values: + 0: # time + type: int + 1: # open + type: str + 2: # close + type: str + 3: # high + type: str + 4: # low + type: str + 5: # quote_vol + type: str + 6: # base_vol + type: str + + mapping: + - key: time + path: + - data + - 0 + type: + - float + - from_timestamp + - 0 + - key: open + path: + - data + - 1 + type: + - str + - float + - key: high + path: + - data + - 3 + type: + - str + - float + - key: low + path: + - data + - 4 + type: + - str + - float + - key: close + path: + - data + - 2 + type: + - str + - float + - key: volume + path: + - data + - 6 + type: + - str + - float + + + trades: + request: + template: /open/api/v2/market/deals + pair_template: + template: "{first}_{second}" + lower_case: false + alias: symbol + params: + limit: + max: 1000 + default: 1000 + + response: + type: dict + values: + data: + type: list + values: + type: dict + values: + trade_time: # time + type: int + trade_price: # open + type: str + trade_quantity: # close + type: str + trade_type: # high + type: str + + mapping: + - key: time + path: + - data + - trade_time + type: + - float + - from_timestamp + - 1 + - key: id + path: + - data + - trade_time + type: + - float + - key: direction + path: + - data + - trade_type + type: + - value + - map + - "BID" + - "buy" + - "ASK" + - "sell" + + - key: price + path: + - data + - trade_price + type: + - str + - float + - key: amount + path: + - data + - trade_quantity + type: + - str + - float +# + order_books: + request: + template: /open/api/v2/market/depth + pair_template: + template: "{first}_{second}" + lower_case: false + alias: symbol + params: + depth: + max: 2000 + default: 50 + + response: + type: dict + values: + data: + type: dict + values: + version: + type: str + asks: + type: list + values: + type: dict + values: + price: + type: str + quantity: + type: str + bids: + type: list + values: + type: dict + values: + price: + type: str + quantity: + typs: str + + mapping: + - key: time + path: [] + type: + - none + - now + - key: id + path: + - data + - version + type: + - str + - float + - key: position + path: [] + type: + - none + - range + - key: bids_amount + path: + - data + - bids + - quantity + type: + - str + - float + - key: bids_price + path: + - data + - bids + - price + type: + - str + - float + - key: asks_amount + path: + - data + - asks + - quantity + type: + - str + - float + - key: asks_price + path: + - data + - asks + - price + type: + - str + - float \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/mexo.yaml b/pandas_datareader/crypto_utils/resources/mexo.yaml new file mode 100644 index 00000000..997d3b45 --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/mexo.yaml @@ -0,0 +1,304 @@ +name: mexo +is_exchange: true +api_docs: https://github.com/mexo-tech/Mexo-OpenApi/blob/master/doc/rest-api.md +api_url: https://api.mexo.io/ +rate_limit: + max: 1500 + unit: 60 + +requests: + currency_pairs: + request: + template: openapi/v1/brokerInfo + pair_template: null + params: null + + response: + type: dict + values: + symbols: + type: list + values: + type: dict + values: + baseAsset: + type: str + quoteAsset: + type: str + + mapping: + - key: currency_pair_first + path: + - symbols + - baseAsset + type: + - str + - key: currency_pair_second + path: + - symbols + - quoteAsset + type: + - str + + tickers: + request: + template: openapi/quote/v1/ticker/price + pair_template: + template: "{first}{second}" + lower_case: false + alias: symbol + params: null + + response: + type: dict + values: + symbol: + type: str + price: + type: str + mapping: + - key: time + path: [] + type: + - none + - now + - key: last_price + path: + - price + type: + - str + - float + + order_books: + request: + template: openapi/quote/v1/depth + pair_template: + template: "{first}{second}" + lower_case: false + alias: symbol + params: + limit: + type: int + max: 100 + default: 100 + response: + type: dict + values: + time: + type: int + bids: + type: list + values: + type: list + 0: #price + type: str + 1: #qty + type: str + asks: + type: list + values: + type: list + 0: + type: str + 1: + type: str + mapping: + - key: time + path: + - time + type: + - float + - from_timestamp + - 1 + - key: id + path: + - time + type: + - int + - key: position + path: [] + type: + - none + - range + - key: bids_price + path: + - bids + - 0 + type: + - str + - float + - key: bids_amount + path: + - bids + - 1 + type: + - str + - float + - key: asks_price + path: + - asks + - 0 + type: + - str + - float + - key: asks_amount + path: + - asks + - 1 + type: + - str + - float + + trades: + request: + template: openapi/quote/v1/trades + pair_template: + template: "{first}{second}" + lower_case: false + alias: symbol + params: + limit: + type: int + max: 1000 + default: 500 + response: + type: list + value: + type: dict + values: + price: + type: str + qty: + typ: str + time: + type: int + isBuyerMaker: + type: bool + mapping: + - key: time + path: + - time + type: + - float + - from_timestamp + - 1 + - key: direction + path: + - isBuyerMaker + type: + - value + - map + - True + - sell + - False + - buy + - key: id + path: + - time + type: + - int + - key: price + path: + - price + type: + - str + - float + - key: amount + path: + - qty + type: + - str + - float + + historic_rates: + request: + template: openapi/quote/v1/klines + pair_template: + template: "{first}{second}" + lower_case: false + alias: symbol + params: + interval: + allowed: + minutes: 1m + hours: 1h + days: 1d + weeks: 1w + months: 1M + default: 1d + limit: + type: int + max: 1000 + default: 1000 + endTime: + function: last_timestamp + type: + - datetime + - timestampms + + response: + type: list + values: + type: list + values: + 0: #timestamp + type: int + 1: #open + type: str + 2: #high + type: str + 3: #low + type: str + 4: #close + type: str + 5: #volume + type: str + 6: #close time + type: int + 7: # quote Asset volume + type: str + 8: # number of trades + type: int + 9: # taker buy base asset volume + type: str + 10: # taker buy quote asset volume + type: str + + mapping: + - key: time + path: + - 0 + type: + - float + - from_timestamp + - 1 + - key: open + path: + - 1 + type: + - str + - float + - key: high + path: + - 2 + type: + - str + - float + - key: low + path: + - 3 + type: + - str + - float + - key: close + path: + - 4 + type: + - str + - float + - key: volume + path: + - 5 + type: + - str + - float \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/nicehash.yaml b/pandas_datareader/crypto_utils/resources/nicehash.yaml new file mode 100644 index 00000000..2e5efdbc --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/nicehash.yaml @@ -0,0 +1,255 @@ +# Tickers only with no split parameter in the CP +name: nicehash +exchange: true + +rate_limit: null + +api_url: https://api2.nicehash.com/exchange/api/v2/ + +requests: + currency_pairs: + request: + template: info/status + pair_template: null + params: null + + response: + type: dict + values: + symbols: + type: list + values: + type: dict + values: + baseAsset: + type: str + quoteAsset: + type: str + + mapping: + - key: currency_pair_first + path: + - symbols + - baseAsset + type: + - str + - key: currency_pair_second + path: + - symbols + - quoteAsset + type: + - str + + + historic_rates: + request: + template: info/candlesticks + pair_template: + template: "{first}{second}" + lower_case: false + alias: market + params: + resolution: + allowed: + minutes: 1 + hours: 60 + days: 1440 + default: 1440 # daily + from: + function: last_timestamp + type: + - datetime + - timedelta + - interval + - 2000 + to: + function: last_timestamp + type: + - datetime + - timestamp + response: + type: list + values: + type: dict + values: + time: + type: int + open: + type: float + close: + type: float + high: + type: float + low: + type: float + volume: + type: float + quote_volume: + type: float + + mapping: + - key: time + path: + - time + type: + - float + - from_timestamp + - 0 + - key: open + path: + - open + type: + - float + - key: high + path: + - high + type: + - float + - key: low + path: + - low + type: + - float + - key: close + path: + - close + type: + - float + - key: volume + path: + - volume + type: + - float + + trades: + request: + template: info/trades + pair_template: + template: "{first}{second}" + lower_case: false + alias: market + params: + limit: + default: 200 + response: + type: list + values: + type: dict + values: + id: + type: str + dir: + type: str + price: + type: flaot + qty: + type: float + sndQty: + type: float + time: + type: int + + mapping: + - key: time + path: + - time + type: + - float + - from_timestamp + - 2 + - key: id + path: + - id + type: + - str + - key: direction + path: + - dir + type: + - str + - key: price + path: + - price + type: + - float + - key: amount + path: + - qty + type: + - float + + order_books: + request: + template: orderbook + pair_template: + template: "{first}{second}" + lower_case: false + alias: market + params: + limit: + default: 50 + + response: + type: dict + values: + tick: + type: int + buy: + type: list + values: + type: list + values: + 0: + type: float + 1: + type: float + sell: + type: list + values: + type: list + values: + 0: + type: float + 1: + type: float + + mapping: + - key: time + path: [] + type: + - none + - now + - key: id + path: + - tick + type: + - int + - key: position + path: [] + type: + - none + - range + - key: bids_amount + path: + - buy + - 1 + type: + - float + - key: bids_price + path: + - buy + - 0 + type: + - float + - key: asks_amount + path: + - sell + - 1 + type: + - float + - key: asks_price + path: + - sell + - 0 + type: + - float \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/nominex.yaml b/pandas_datareader/crypto_utils/resources/nominex.yaml new file mode 100644 index 00000000..b0084fe2 --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/nominex.yaml @@ -0,0 +1,225 @@ +# Cannot extract bid/sell side from orderbooks. +name: nominex +exchange: true + +rate_limit: null +api_docs: https://developer.nominex.io/#parameters +api_url: https://nominex.io/api/rest/v1/ + +requests: + currency_pairs: + request: + template: pairs + pair_template: null + params: null + + response: + type: list + values: + type: dict + values: + name: + type: str + + mapping: + - key: currency_pair_first + path: + - name + type: + - str + - split + - "/" + - 0 + - key: currency_pair_second + path: + - name + type: + - str + - split + - "/" + - 1 + + tickers: + request: + template: ticker/{currency_pair} + pair_template: + template: "{first}/{second}" + lower_case: false + params: null + response: + type: dict + values: + bid: + type: float + ask: + type: float + baseVolume: + type: float + price: + type: float + + mapping: + - key: last_price + path: + - price + type: + - float + - key: time + path: [] + type: + - none + - now + - key: best_bid + path: + - bid + type: + - float + - key: best_ask + path: + - ask + type: + - float + - key: daily_volume + path: + - baseVolume + type: + - float + + historic_rates: + request: + template: candles/{currency_pair}/{frequency} + pair_template: + template: "{first}/{second}" + lower_case: false + params: + frequency: + allowed: + minutes: TF1M + hours: TF1H + days: TF1D + weeks: TF7D + months: TF1MO + default: TF1D + limit: + default: 400 # max + end: + function: last_timestamp + type: + - datetime + - timestampms + response: + type: list + values: + type: dict + values: + timestamp: + type: int + open: + type: float + close: + type: float + high: + type: float + low: + type: float + volume: + type: float + + + mapping: + - key: time + path: + - timestamp + type: + - float + - from_timestamp + - 1 + - key: open + path: + - open + type: + - float + - key: high + path: + - high + type: + - float + - key: low + path: + - low + type: + - float + - key: close + path: + - close + type: + - float + - key: volume + path: + - volume + type: + - float + + + trades: + request: + template: trades/{currency_pair} + pair_template: + template: "{first}/{second}" + lower_case: false + params: + limit: + default: 200 # max + + response: + type: dict + values: + items: + type: list + values: + type: dict + values: + id: + type: int + timestamp: + type: int + amount: + type: float + price: + type: float + side: + type: str + + mapping: + - key: time + path: + - items + - timestamp + type: + - float + - from_timestamp + - 1 + - key: id + path: + - items + - id + type: + - int + - key: direction + path: + - items + - side + type: + - str + - key: price + path: + - items + - price + type: + - float + - key: amount + path: + - items + - amount + type: + - float diff --git a/pandas_datareader/crypto_utils/resources/oceanex.yaml b/pandas_datareader/crypto_utils/resources/oceanex.yaml new file mode 100644 index 00000000..bc7ff21f --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/oceanex.yaml @@ -0,0 +1,380 @@ +name: oceanex +exchange: true + +rate_limit: + max: 3000 + unit: 60 + +api_url: https://api.oceanex.pro/v1/ + +requests: + currency_pairs: + request: + template: markets + pair_template: null + params: null + + response: + type: dict + values: + data: + type: list + values: + type: dict + values: + name: + type: str + + mapping: + - key: currency_pair_first + path: + - data + - name + type: + - str + - split + - "/" + - 0 + - key: currency_pair_second + path: + - data + - name + type: + - str + - split + - "/" + - 1 + + tickers: + request: + template: tickers + pair_template: null + params: null + response: + type: dict + values: + data: + type: dict + values: + currency_pair: + type: dict + values: + base_unit: + type: str + quote_unit: + type: str + at: + type: int + sell: + type: str + buy: + type: str + last: + type: str + volume: + type: str + mapping: + - key: currency_pair_first + path: + - data + - dict_values + - base_unit + type: + - str + - key: currency_pair_second + path: + - data + - dict_values + - quote_unit + type: + - str + - key: last_price + path: + - data + - dict_values + - last + type: + - str + - float + - key: time + path: + - data + - dict_values + - at + type: + - float + - from_timestamp + - 0 + - key: best_bid + path: + - data + - dict_values + - buy + type: + - str + - float + - key: best_ask + path: + - data + - dict_values + - sell + type: + - str + - float + - key: daily_volume + path: + - data + - dict_values + - volume + type: + - str + - float + + historic_rates: + request: + template: k + pair_template: + template: "{first}{second}" + lower_case: true + alias: market + params: + limit: + max: null + default: 10000 + period: + allowed: + minutes: 1 + hours: 60 + days: 1440 + default: 1440 #daily + timestamp: + function: last_timestamp # data after that timestamp + type: + - datetime + - timedelta + - interval + - 10000 + response: + type: dict + values: + data: + type: list + values: + type: list + values: + 0: # timestamp + type: int + 1: #open + type: float + 2: #high + type: float + 3: #low + type: float + 4: #close + type: float + 5: #vol + type: float + + mapping: + - key: time + path: + - data + - 0 + type: + - float + - from_timestamp + - 0 + - key: open + path: + - data + - 1 + type: + - float + - key: high + path: + - data + - 2 + type: + - float + - key: low + path: + - data + - 3 + type: + - float + - key: close + path: + - data + - 4 + type: + - float + - key: volume + path: + - data + - 5 + type: + - float + + + trades: + request: + template: trades + pair_template: + template: "{first}{second}" + lower_case: true + alias: market + params: + limit: + default: 200 + + response: + type: dict + values: + data: + type: list + values: + type: dict + values: + id: + type: int + price: + type: str + volume: + type: str + side: + type: str + created_on: + type: int + + + mapping: + - key: time + path: + - data + - created_on + type: + - float + - from_timestamp + - 0 + - key: id + path: + - data + - id + type: + - int + - key: direction + path: + - data + - side + type: + - value + - map + - bid + - buy + - ask + - sell + - key: price + path: + - data + - price + type: + - str + - float + - key: amount + path: + - data + - volume + type: + - str + - float + + order_books: + request: + template: order_book + pair_template: + template: "{first}{second}" + lower_case: true + alias: market + params: + limit: + max: 300 + default: 50 + + response: + type: dict + values: + data: + type: dict + values: + timestamp: + type: int + asks: + type: list + values: + type: list + values: + 0: # price + type: str + 1: #qty + type: str + bids: + type: list + values: + type: list + values: + 0: # price + type: str + 1: #qty + type: str + mapping: + - key: time + path: + - data + - timestamp + type: + - float + - from_timestamp + - 0 + - key: id + path: + - data + - timestamp + type: + - int + - key: position + path: [] + type: + - none + - range + - key: bids_amount + path: + - data + - bids + - 1 + type: + - str + - float + - key: bids_price + path: + - data + - bids + - 0 + type: + - str + - float + - key: asks_amount + path: + - data + - asks + - 1 + type: + - str + - float + - key: asks_price + path: + - data + - asks + - 0 + type: + - str + - float \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/okcoin.yaml b/pandas_datareader/crypto_utils/resources/okcoin.yaml new file mode 100644 index 00000000..d0846e3b --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/okcoin.yaml @@ -0,0 +1,338 @@ +name: okcoin +exchange: true + +api_url: https://www.okcoin.com/api/spot/v3/ +rate_limit: + max: 360 + unit: 60 + +requests: + currency_pairs: + request: + template: instruments + pair_template: null + params: null + response: + type: list + values: + type: dict + values: + base_currency: + type: str + quote_currency: + type: str + mapping: + - key: currency_pair_first + path: + - base_currency + type: + - str + - key: currency_pair_second + path: + - quote_currency + type: + - str + + + tickers: + request: + template: instruments/ticker + pair_template: null # + params: null + response: + type: list + values: + type: dict + values: + instrument_id: + type: str + last: + type: str + bid: + type: str + ask: + type: str + base_volume_24h: + type: str + timestamp: + type: str + quote_volume_24h: + type: str + mapping: + - key: currency_pair_first + path: + - product_id + type: + - str + - split + - "-" + - 0 + - key: currency_pair_second + path: + - product_id + type: + - str + - split + - "-" + - 1 + - key: time + path: + - timestamp + type: + - str + - dateparser + - key: last_price + path: + - last + type: + - str + - float + - key: best_ask + path: + - ask + type: + - str + - float + - key: best_bid + path: + - bid + type: + - str + - float + - key: daily_volume + path: + - base_volume_24h + type: + - str + - float + + order_books: + request: + template: instruments/{currency_pair}/book + pair_template: # e.g. btc_usd + template: "{first}-{second}" + lower_case: false + params: + size: + type: int + min: 1 + max: 200 + required: false + default: 50 + merge: + type: int + possible: + - 1 + - 0.1 + required: false + response: + type: dict + values: + asks: + type: list + values: + type: list + values: + 0: # price + type: str + 1: # size + type: str + bids: + type: list + values: + type: list + values: + 0: # price + type: str + 1: # size + type: str + timestamp: + type: str + mapping: + - key: time + path: + - timestamp + type: + - str + - dateparser + - key: id + path: + - timestamp + type: + - str + - dateparser + - totimestamp + - key: position + path: [] + type: + - none + - range + - key: asks_price + path: + - asks + - 0 + type: + - str + - float + - key: asks_amount + path: + - asks + - 1 + type: + - str + - float + - key: bids_price + path: + - bids + - 0 + type: + - str + - float + - key: bids_amount + path: + - bids + - 1 + type: + - str + - float + + trades: + request: + template: instruments/{currency_pair}/trades + pair_template: # e.g. btc_usd + template: "{first}-{second}" + lower_case: false + params: + limit: + type: int + max: 100 + default: 100 + response: + type: list + values: + type: dict + values: + timestamp: + type: str + price: + type: str + size: + type: str + trade_id: + type: str + side: + type: str + mapping: + - key: time + path: + - timestamp + type: + - str + - dateparser + - key: id + path: + - timestamp + type: + - str + - dateparser + - totimestamp + - key: price + path: + - price + type: + - str + - float + - key: amount + path: + - size + type: + - str + - key: direction + path: + - side + type: + - str + + historic_rates: + request: + template: instruments/{currency_pair}/candles + pair_template: # e.g. btc_usd + template: "{first}-{second}" + lower_case: false + params: + granularity: + allowed: + minutes: 60 + hours: 3600 + days: 86400 + weeks: 604800 + default: 86400 # 1 day +# start: #returns only the last 200 entries until end or "today". +# function: last_timestamp +# type: +# - datetime +# - timedelta +# - interval +# - 1000 +# - fromtimestamp +# - "%Y-%m-%dT%H:%M:%S.%fZ" + end: + function: last_timestamp + type: + - datetime + - format + - "%Y-%m-%dT%H:%M:%S.%fZ" # e.g. 2020-11-10T16:00:00.000Z + response: + type: list + values: + type: list + values: + 0: # timestamp + type: str + 1: # open + type: str + 2: # high + type: str + 3: # low + type: str + 4: # close + type: str + 5: # volume + type: str + mapping: + - key: time + path: + - 0 + type: + - str + - dateparser + - key: open + path: + - 1 + type: + - str + - float + - key: high + path: + - 2 + type: + - str + - float + - key: low + path: + - 3 + type: + - str + - float + - key: close + path: + - 4 + type: + - str + - float + - key: volume + path: + - 5 + type: + - str + - float diff --git a/pandas_datareader/crypto_utils/resources/okex.yaml b/pandas_datareader/crypto_utils/resources/okex.yaml new file mode 100644 index 00000000..7cde4876 --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/okex.yaml @@ -0,0 +1,360 @@ +name: okex +exchange: true + +api_url: https://www.okex.com/api/spot/v3/ +rate_limit: + max: 20 + unit: 2 +requests: + currency_pairs: + request: + template: instruments + pair_template: null + params: null + + response: + type: list + values: + type: dict + values: + base_currency: + type: str + category: + type: str + instrument_id: + type: str + min_size: + type: str + quote_currency: + type: str + size_increment: + type: str + tick_size: + type: str + mapping: + - key: currency_pair_first + path: + - base_currency + type: + - str + - lower + - key: currency_pair_second + path: + - quote_currency + type: + - str + - lower + + + tickers: + request: + template: instruments/ticker + pair_template: null + params: null + response: + type: list + values: + type: dict + values: + best_ask: + type: str + best_bid: + type: str + instrument_id: + type: str + product_id: + type: str + last: + type: str + last_qty: + type: str + ask: + type: str + best_ask_size: + type: str + bid: + type: str + best_bid_size: + type: str + open: + type: str + open_24h: + type: str + high_24h: + type: str + low_24h: + type: str + base_volume_24h: + type: str + timestamp: + type: str + qutote_volume_24h: + type: str + + mapping: + - key: currency_pair_first + path: + - instrument_id + type: + - str + - split + - "-" + - 0 + - key: currency_pair_second + path: + - instrument_id + type: + - str + - split + - "-" + - 1 + - key: best_bid + path: + - best_bid + type: + - str + - float + - key: last_price + path: + - last + type: + - str + - float + - key: best_ask + path: + - best_ask + type: + - str + - float + - key: daily_volume + path: + - base_volume_24h + type: + - str + - float +# + order_books: + request: + template: instruments/{currency_pair}/book + pair_template: # e.g. btc_usd + template: "{first}-{second}" + lower_case: false + params: + size: + min: 1 + max: 200 + default: 50 + response: + type: dict + values: + asks: + type: list + values: + type: list + values: + 0: # price + type: float + 1: # size + type: float + bids: + type: list + values: + type: list + values: + 0: # price + type: float + 1: # size + type: float + mapping: + - key: time + path: [] + type: + - none + - now + - key: id + path: [] + type: + - none + - now_timestamp + - key: position + path: [] + type: + - none + - range + - key: asks_price + path: + - asks + - 0 + type: + - float + - key: asks_amount + path: + - asks + - 1 + type: + - float + - key: bids_price + path: + - bids + - 0 + type: + - float + - key: bids_amount + path: + - bids + - 1 + type: + - float + + trades: + request: + template: instruments/{currency_pair}/trades + pair_template: # e.g. btc_usd + template: "{first}-{second}" + lower_case: false + params: + limit: # get recently 60 pieces of data starting from the given tid (optional) + type: str + required: false + default: 100 + response: + type: list + values: + type: dict + values: + 0: + type: str + 1: + type: str + 2: + type: str + 3: + type: str + 4: + type: str + 5: + type: str + mapping: + - key: time + path: + - dict_values + - 1 + type: + - str + - strptime + - "%Y-%m-%dT%H:%M:%S.%fZ" + - key: price + path: + - dict_values + - 3 + type: + - str + - float + - key: amount + path: + - dict_values + - 4 + type: + - str + - float + - key: direction + path: + - dict_values + - 5 + type: + - str + - key: id + path: + - dict_values + - 2 + type: + - str + - int + + historic_rates: + request: + template: instruments/{currency_pair}/candles + pair_template: # e.g. btc_usd + template: "{first}-{second}" + lower_case: false + params: + granularity: + allowed: + minutes: 60 + hours: 3600 + days: 86400 + weeks: 604800 + default: 86400 # 1day + limit: + default: 300 + start: + function: last_timestamp + type: + - datetime + - timedelta + - interval + - 300 + - from_timestamp + - 0 + - "%Y-%m-%dT%H:%M:%S.%fZ" + end: + function: last_timestamp + type: + - datetime + - format + - "%Y-%m-%dT%H:%M:%S.%fZ" + response: + type: list + values: + type: list + values: + 0: + type: str + 1: + type: str + 2: + type: str + 3: + type: str + 4: + type: str + 5: + type: str + mapping: + - key: time + path: + - 0 + type: + - str + - strptime + - "%Y-%m-%dT%H:%M:%S.%fZ" + - key: open + path: + - 1 + type: + - str + - float + - key: high + path: + - 2 + type: + - str + - float + - key: low + path: + - 3 + type: + - str + - float + - key: close + path: + - 4 + type: + - str + - float + - key: volume + path: + - 5 + type: + - str + - float diff --git a/pandas_datareader/crypto_utils/resources/omgfin.yaml b/pandas_datareader/crypto_utils/resources/omgfin.yaml new file mode 100644 index 00000000..df32334b --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/omgfin.yaml @@ -0,0 +1,359 @@ +#HR endpoint is not really working. Frequently returning data is non-json format (status 503) which can not +# be parsed. + +name: omgfin +api_url: https://omgfin.com/api/v1/ +rate_limit: + max: 600 + unit: 60 + + +requests: + + currency_pairs: + request: + template: exchangeInfo + pair_template: null + params: null + + response: + type: dict + values: + symbols: + type: list + values: + type: dict + values: + baseAsset: + type: str + quoteAsset: + type: str + mapping: + - key: currency_pair_first + path: + - symbols + - baseAsset + type: + - str + - key: currency_pair_second + path: + - symbols + - quoteAsset + type: + - str + + tickers: + request: + template: ticker/summary + pair_template: null + params: null + response: + type: dict + values: + currency_pair: + type: dict + values: + last: + type: str + lowestAsk: + type: str + highest_bid: + type: str + percentChange: + type: str + baseVolume: + type: str + quoteVolume: + type: str + high24h: + type: str + low24h: + type: str + mapping: + - key: time + path: [] + type: + - none + - now + - key: currency_pair_first + path: + - dict_key + type: + - str + - split + - "_" + - 0 + - key: currency_pair_second + path: + - dict_key + type: + - str + - split + - "_" + - 1 + - key: last_price + path: + - dict_values + - last + type: + - str + - float + - key: best_bid + path: + - dict_values + - highestBid + type: + - str + - float + - key: best_ask + path: + - dict_values + - lowestAsk + type: + - str + - float + - key: daily_volume + path: + - dict_values + - baseVolume + type: + - str + - float + + historic_rates: + request: + template: klines + pair_template: + template: "{first}{second}" + lower_case: false + alias: symbol + params: + interval: + allowed: + minutes: 1m + hours: 1h + days: 1d + weeks: 1w + default: 1d + limit: + default: 300 # max: 300 +# startTime: +# function: last_timestamp +# type: +# - datetime +# - timedeltams +# - interval +# - 300 + endTime: + function: last_timestamp + type: + - datetime + - timestampms + response: + type: list + values: + type: dict + values: + OT: + type: int + O: + type: str + H: + type: str + L: + type: str + C: + type: str + CT: + type: int + QV: + type: str + V: + type: str + + mapping: + - key: time + path: + - CT + type: + - float + - from_timestamp + - 1 + - key: open + path: + - O + type: + - str + - float + - key: high + path: + - H + type: + - str + - float + - key: low + path: + - L + type: + - str + - float + - key: close + path: + - C + type: + - str + - float + - key: volume + path: + - V + type: + - str + - float + + + trades: + request: + template: trades/{currency_pair} + pair_template: + template: "{first}{second}" + lower_case: false + params: + limit: + max: 1000 + default: 500 + + response: + type: list + values: + type: dict + values: + id: + type: int + price: + type: str + qty: + type: str + time: + type: int + isBuyerMaker: + type: str + isBestMatch: + type: str + + mapping: + - key: time + path: + - time + type: + - float + - from_timestamp + - 1 + - key: id + path: + - id + type: + - int + - key: direction + path: + - isBuyerMaker + type: + - value + - map + - True + - sell + - False + - buy + - key: price + path: + - price + type: + - str + - float + - key: amount + path: + - qty + type: + - str + - float + + order_books: + request: + template: orderbook/{currency_pair} + pair_template: + template: "{first}{second}" + lower_case: false + params: + limit: + max: 500 + default: 50 + + response: + type: dict + values: + timestamp: + type: int + bids: + type: list + values: + type: list + values: + 0: + type: str + 1: + type: str + asks: + type: list + values: + type: list + values: + 0: + type: str + 1: + type: str + + mapping: + - key: time + path: + - timestamp + type: + - float + - from_timestamp + - 0 + - key: id + path: + - timestamp + type: + - int + - key: position + path: [] + type: + - none + - range + - key: bids_amount + path: + - bids + - 1 + type: + - str + - float + - key: bids_price + path: + - bids + - 0 + type: + - str + - float + - key: asks_amount + path: + - asks + - 1 + type: + - str + - float + - key: asks_price + path: + - asks + - 0 + type: + - str + - float \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/p2pb2b.yaml b/pandas_datareader/crypto_utils/resources/p2pb2b.yaml new file mode 100644 index 00000000..1a281aad --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/p2pb2b.yaml @@ -0,0 +1,391 @@ +name: p2pb2b +exchange: true +rate_limit: + max: 100 + unit: 60 +api_url: https://api.p2pb2b.io/api/v2/public/ + +requests: + currency_pairs: + request: + template: markets + pair_template: null + params: null + response: + type: dict + values: + result: + type: list + values: + type: dict + values: + name: + type: str + stock: + type: str + money: + type: str + mapping: + - key: currency_pair_first + path: + - result + - stock + type: + - str + - key: currency_pair_second + path: + - result + - money + type: + - str + + tickers: + request: + template: tickers + pair_template: null + params: null + response: + type: dict + values: + success: + type: bool + message: + type: str + resulst: + type: dict + values: + currency_pair: + type: dict + values: + at: + type: int + ticker: + type: dict + values: + bid: + type: float + ask: + type: float + low: + type: float + high: + type: float + last: + type: float + vol: + type: float + change: + type: float + mapping: + - key: time + path: + - result + - dict_values + - at + type: + - float + - from_timestamp + - 0 + - key: currency_pair_first + path: + - result + - dict_key + type: + - str + - split + - "_" + - 0 + - key: currency_pair_second + path: + - result + - dict_key + type: + - str + - split + - "_" + - 1 + - key: last_price + path: + - result + - dict_values + - ticker + - last + type: + - float + - key: best_bid + path: + - result + - dict_values + - ticker + - bid + type: + - float + - key: best_ask + path: + - result + - dict_values + - ticker + - ask + type: + - float + - key: daily_volume + path: + - result + - dict_values + - ticker + - vol + type: + - float + + trades: + request: + template: history + pair_template: + template: "{first}_{second}" + lower_case: false + alias: market + params: + lastId: + type: int + default: 1 + limit: + type: int + default: 100 + response: + type: dict + values: + success: + type: bool + message: + type: str + result: + type: list + values: + type: dict + values: + id: + type: int + type: + type: str + time: + type: int + amount: + type: float + price: + type: float + + mapping: + - key: time + path: + - result + - time + type: + - float + - from_timestamp + - 0 + - key: id + path: + - result + - id + type: + - int + - key: amount + path: + - result + - amount + type: + - float + - key: price + path: + - result + - price + type: + - float + - key: direction + path: + - result + - type + type: + - str + + order_books: + request: + template: depth/result + pair_template: + template: "{first}_{second}" + lower_case: false + alias: market + params: + limit: + type: int + default: 100 + interval: + default: "0" + + response: + type: dict + values: + result: + type: dict + asks: + type: list + values: + type: list + values: + 0: + type: str + 1: + type: str + bids: + type: list + values: + type: list + values: + 0: + type: str + 1: + type: str + cache_time: + type: float + current_time: + type: float + mapping: + - key: id + path: + - cache_time + type: + - float + - int + - key: time + path: + - cache_time + type: + - float + - from_timestamp + - 0 + - key: position + path: [] + type: + - none + - range + - key: bids_price + path: + - result + - bids + - 0 + type: + - str + - float + - key: bids_amount + path: + - result + - bids + - 1 + type: + - str + - float + - key: asks_price + path: + - result + - asks + - 0 + type: + - str + - float + - key: asks_amount + path: + - result + - asks + - 1 + type: + - str + - float + + historic_rates: + request: + template: market/kline + pair_template: + template: "{first}_{second}" + lower_case: false + alias: market + params: + interval: + allowed: + minutes: 1m + hours: 1h + days: 1d + default: 1d + limit: + type: int + default: 500 + + response: + type: dict + values: + result: + type: list + values: + type: dict + values: + 0: #time + type: int + 1: #open + type: str + 2: #close + type: str + 3: #high + type: str + 4: #low + type: str + 5: #volume + type: str + 6: #amount + type: str + + mapping: + - key: time + path: + - result + - 0 + type: + - float + - from_timestamp + - 0 + - key: open + path: + - result + - 1 + type: + - str + - float + - key: high + path: + - result + - 3 + type: + - str + - float + - key: low + path: + - result + - 4 + type: + - str + - float + - key: close + path: + - result + - 2 + type: + - str + - float + - key: volume + path: + - result + - 5 + type: + - str + - float + + + diff --git a/pandas_datareader/crypto_utils/resources/poloniex.yaml b/pandas_datareader/crypto_utils/resources/poloniex.yaml new file mode 100644 index 00000000..bd36eb8f --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/poloniex.yaml @@ -0,0 +1,348 @@ +name: poloniex +exchange: true +api_url: https://poloniex.com/ +rate_limit: null +requests: + currency_pairs: + request: + template: public?command=returnTicker + pair_template: null + params: null + response: + type: dict + values: + currency_pair: # variable key, each currency pair e.g. ltc_btc + type: dict + values: + last: + type: float + lowestAsk: + type: float + highestBid: + type: float + percentChange: + type: float + baseVolume: + type: float + quoteVolume: + type: float + isFrozen: + type: int + high24hr: + type: float + low24hr: + type: float + mapping: + - key: currency_pair_first + path: + - dict_key + type: + - str + - splitupper + - "_" + - 1 + - key: currency_pair_second + path: + - dict_key + type: + - str + - splitupper + - "_" + - 0 + + tickers: + request: + template: public?command=returnTicker + pair_template: null + params: null + response: + type: dict + values: + currency_pair: # variable key, each currency pair e.g. ltc_btc + type: dict + values: + last: + type: float + lowestAsk: + type: float + highestBid: + type: float + percentChange: + type: float + baseVolume: + type: float + quoteVolume: + type: float + isFrozen: + type: int + high24hr: + type: float + low24hr: + type: float + mapping: + - key: time + path: [] + type: + - none + - now + - key: currency_pair_first + path: + - dict_key + type: + - str + - splitupper + - "_" + - 1 + - key: currency_pair_second + path: + - dict_key + type: + - str + - splitupper + - "_" + - 0 + - key: last_price + path: + - dict_values + - last + type: + - float + - key: best_bid + path: + - dict_values + - highestBid + type: + - float + - key: best_ask + path: + - dict_values + - lowestAsk + type: + - float + - key: daily_volume + path: + - dict_values + - base_volume + type: + - float + + historic_rates: + request: + template: public?command=returnChartData + pair_template: + template: "{second}_{first}" + alias: currencyPair + lower_case: false + params: + start: + function: last_timestamp + type: + - datetime + - timedelta + - interval + - 1000 +# type: int +# default: 946684800 # 01.01.2000 + period: + allowed: + minutes: 300 + hours: 7200 + days: 86400 + default: 86400 #1 Day in Seconds + + response: + type: list + values: + type: dict + values: + date: + type: int + high: + type: float + low: + type: float + open: + type: float + close: + type: float + quoteVolume: + type: float + weightedAverage: + type: flaot + + mapping: + - key: time + path: + - date + type: + - float + - from_timestamp + - 0 + - key: close + path: + - close + type: + - float + - key: open + path: + - open + type: + - float + - key: high + path: + - high + type: + - float + - key: low + path: + - low + type: + - float + - key: volume + path: + - volume + type: + - float + + order_books: + request: + template: public?command=returnOrderBook + pair_template: + template: "{second}_{first}" + alias: currencyPair + lower_case: false + params: + depth: + type: int + default: 100 + + response: + type: dict + values: + ask: + type: list + values: + type: list + values: + 0: + type: str + 1: + type: float + bids: + type: list + values: + type: list + values: + 0: + type: str + 1: + type: float + is_frozen: + type: str + seq: + type: int + + mapping: + - key: time + path: [] + type: + - none + - now + - key: bids_price + path: + - bids + - 0 + type: + - str + - float + - key: bids_amount + path: + - bids + - 1 + type: + - float + - key: asks_price + path: + - asks + - 0 + type: + - str + - float + - key: asks_amount + path: + - asks + - 1 + type: + - float + - key: id + path: + - seq + type: + - int + - key: position + path: [] + type: + - none + - range + + trades: + request: + template: public?command=returnTradeHistory + pair_template: + template: "{second}_{first}" + alias: currencyPair + lower_case: false + params: null + + response: + type: list + values: + type: dict + values: + globalTradeID: + type: int + tradeID: + type: int + date: + type: str + type: + type: str + rate: + type: str + amount: + type: str + total: + type: str + orderNumber: + type: str + mapping: + - key: time + path: + - date + type: + - str + - strptime + - "%Y-%m-%d %H:%M:%S" + - key: id + path: + - tradeID + type: + - str + - int + - key: price + path: + - rate + type: + - str + - float + - key: amount + path: + - amount + type: + - str + - float + - key: direction + path: + - type + type: + - str diff --git a/pandas_datareader/crypto_utils/resources/therocktrading.yaml b/pandas_datareader/crypto_utils/resources/therocktrading.yaml new file mode 100644 index 00000000..032ada09 --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/therocktrading.yaml @@ -0,0 +1,340 @@ +name: therocktrading +exchange: true + +rate_limit: + max: 600 + unit: 60 + +api_url: https://api.therocktrading.com/v1/ + +requests: + currency_pairs: + request: + template: funds + pair_template: null + params: null + + response: + type: dict + values: + funds: + type: list + values: + type: dict + values: + base_currency: + type: str + trade_currency: + type: str + + + mapping: + - key: currency_pair_first + path: + - funds + - trade_currency + type: + - str + - key: currency_pair_second + path: + - funds + - base_currency + type: + - str + + tickers: + request: + template: funds/{currency_pair}/ticker + pair_template: + template: "{first}{second}" + lower_case: false + params: null + response: + type: dict + values: + date: + type: str + bid: + type: str + ask: + type: str + last: + type: str + volume: + type: str + traded_volume: + type: str + + mapping: + - key: last_price + path: + - last + type: + - str + - float + - key: time + path: + - date + type: + - str + - dateparser + - key: best_bid + path: + - bid + type: + - str + - float + - key: best_ask + path: + - ask + type: + - str + - float + - key: daily_volume + path: + - volume + type: + - str + - float + + historic_rates: + request: + template: funds/{currency_pair}/ohlc_statistics + pair_template: + template: "{first}{second}" + lower_case: false + params: + period: + allowed: + minutes: 1 + hours: 60 +# days: 1440 +# weeks: 10080 +# months: 43200 + default: 60 + before: + function: last_timestamp + type: + - datetime + - format + - "%Y-%m-%dT%H:%M:%S%Z" + after: + function: last_timestamp + type: + - datetime + - timedelta + - interval + - 1000 #max interval 60 DAYS! + - from_timestamp + - 0 + - "%Y-%m-%dT%H:%M:%S%Z" +# default: "2020-03-19T17:25:00.000Z" + sort: + default: DESC + response: + type: list + values: + type: dict + values: + open: + type: float + high: + type: float + low: + type: float + close: + type: float + base_volume: + type: float + trade_volume: + type: float + interval_starts_at: + type: str + interval_ends_at: + type: str + + mapping: + - key: time + path: + - interval_ends_at + type: + - str + - dateparser + - key: open + path: + - open + type: + - float + - key: high + path: + - high + type: + - float + - key: low + path: + - low + type: + - float + - key: close + path: + - close + type: + - float + - key: volume + path: + - traded_volume + type: + - float + + trades: + request: + template: funds/{currency_pair}/trades + pair_template: + template: "{first}{second}" + lower_case: false + params: +# before: +# function: last_timestamp +# type: +# - datetime +# - format +# - "%Y-%m-%dT%H:%M:%S%Z" +# after: +# function: last_timestamp +# type: +# - datetime +# - timedelta +# - interval +# - 1000 +# - fromtimestamp +# - "%Y-%m-%dT%H:%M:%S%Z" + per_page: + max: 250 + default: 250 + + response: + type: dict + values: + type: list + values: + type: dict + values: + trade_id: + type: int + amount: + type: float + price: + type: float + side: + type: str + date: + type: str + + + mapping: + - key: time + path: + - trades + - date + type: + - str + - dateparser + - key: id + path: + - trades + - id + type: + - int + - key: direction + path: + - trades + - side + type: + - str + - key: price + path: + - trades + - price + type: + - float + - key: amount + path: + - trades + - amount + type: + - float + + order_books: + request: + template: funds/{currency_pair}/orderbook + pair_template: + template: "{first}{second}" + lower_case: false + params: + limit: + default: 50 + response: + type: dict + values: + date: + type: str + asks: + type: list + values: + type: dict + values: + price: + type: float + amount: + type: float + bids: + type: list + values: + type: dict + values: + price: + type: float + amount: + type: float + + mapping: + - key: time + path: + - date + type: + - str + - dateparser + - key: id + path: [] + type: + - none + - now_timestamp + - key: position + path: [] + type: + - none + - range + - key: bids_amount + path: + - bids + - amount + type: + - float + - key: bids_price + path: + - bids + - price + type: + - float + - key: asks_amount + path: + - asks + - amount + type: + - float + - key: asks_price + path: + - asks + - price + type: + - float \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/upbit.yaml b/pandas_datareader/crypto_utils/resources/upbit.yaml new file mode 100644 index 00000000..0beb46fa --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/upbit.yaml @@ -0,0 +1,320 @@ +name: upbit +exchange: true +api_url: https://api.upbit.com/v1/ +rate_limit: null + +requests: + currency_pairs: + request: + template: market/all + pair_template: null + params: null + response: + type: list + values: + type: dict + values: + market: # e.g. KRW-BTC + type: str + korean_name: + type: str + english_name: + type: str + mapping: + - key: currency_pair_first + path: + - market + type: + - str + - split + - "-" + - 1 + - key: currency_pair_second + path: + - market + type: + - str + - split + - "-" + - 0 + + historic_rates: + request: + template: candles/{frequency} + pair_template: # e.g. KRW-BTC + template: "{second}-{first}" + lower_case: false + alias: market + params: + frequency: + allowed: + minutes: minutes/1 + hours: minutes/60 + days: days + weeks: weeks + months: months + default: days + to: + function: last_timestamp + type: + - datetime + - format + - "%Y-%m-%dT%H:%M:%S.%fZ" + count: + type: int + max: 200 + default: 200 + response: + type: list + values: + type: dict + values: + market: + type: str + candle_date_time_utc: + type: + - str + candle_date_time_kst: + type: + - str + opening_price: + type: float + high_price: + type: float + low_price: + type: float + trade_price: + type: float + timestamp: + type: + - int + candle_acc_trade_price: + type: float + candle_acc_trade_volume: + type: float + mapping: + - key: open + path: + - opening_price + type: + - float + - key: high + path: + - high_price + type: + - float + - key: low + path: + - low_price + type: + - float + - key: close + path: + - trade_price + type: + - float + - key: time + path: + - candle_date_time_utc + type: + - str + - dateparser + - key: volume + path: + - candle_acc_trade_volume + type: + - float + + trades: + request: + template: trades/ticks + pair_template: # e.g. KRW-BTC + template: "{second}-{first}" + lower_case: false + alias: market + params: + count: + type: int + default: 1000 + response: + type: list + values: + type: dict + values: + market: + type: str + trade_date_utc: + type: + - str + - strptime + - "%Y-%m-%d" + trade_time_utc: + type: + - str + - strptime + - "%H:%M:%S" + timestamp: + type: + - float + - from_timestamp + - 0 + trade_price: + type: float + trade_volume: + type: float + prev_closing_price: + type: float + change_price: + type: float + ask_bid: # ask or bid + type: str + mapping: + - key: time + path: + - timestamp + type: + - float + - from_timestamp + - 1 + - key: price + path: + - trade_price + type: + - float + - key: amount + path: + - trade_volume + type: + - float + - key: direction + path: + - ask_bid + type: + - value + - map + - ASK + - sell + - BID + - buy + - key: id + path: + - sequential_id + type: + - float + + tickers: + request: + template: ticker + pair_template: + template: "{second}-{first}" + lower_case: false + alias: markets + params: null + response: + type: list + values: + type: dict + values: + market: + type: str + trade_date: + type: str + trade_time: + type: str + trade_timestamp: + type: int + trade_price: + type: int + mapping: + - key: time + path: + - trade_timestamp + type: + - float + - from_timestamp + - 1 + - key: last_price + path: + - trade_price + type: + - float + + order_books: + request: + template: orderbook + pair_template: # e.g. KRW-BTC + template: "{second}-{first}" + lower_case: false + alias: markets + params: null + response: + type: list + values: + type: dict + values: + market: + type: str + timestamp: + type: + - float + - from_timestamp + - 0 + total_ask_size: + type: float + total_bid_size: + type: float + orderbook_units: + type: list + values: + type: dict + values: + ask_price: + type: float + bid_price: + type: float + ask_size: + type: float + bid_size: + type: float + mapping: + - key: time + path: + - timestamp + type: + - float + - from_timestamp + - 1 + - key: id + path: + - timestamp + type: + - int + - key: position + path: [] + type: + - none + - range + - key: asks_price + path: + - orderbook_units + - ask_price + type: + - float + - key: bids_price + path: + - orderbook_units + - bid_price + type: + - float + - key: asks_amount + path: + - orderbook_units + - ask_size + type: + - float + - key: bids_amount + path: + - orderbook_units + - bid_size + type: + - float diff --git a/pandas_datareader/crypto_utils/resources/vindax.yaml b/pandas_datareader/crypto_utils/resources/vindax.yaml new file mode 100644 index 00000000..2f6c7f90 --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/vindax.yaml @@ -0,0 +1,350 @@ +name: vindax +exchange: true +api_url: https://api.vindax.com/api/v1/ +rate_limit: + max: 6 + unit: 1 + +requests: + currency_pairs: + request: + template: returnTicker + pair_template: null + params: null + response: + type: dict + values: + currency_pair: + type: dict + + mapping: + - key: currency_pair_first + path: + - dict_key + type: + - str + - split + - "_" + - 0 + - key: currency_pair_second + path: + - dict_key + type: + - str + - split + - "_" + - 1 + + tickers: + request: + template: returnTicker + pair_template: null + params: null + response: + type: dict + values: + currency_pair: + type: dict + values: + quote_volume: + type: str + symbol: + type: str + percentChange: + type: float + last: + type: float + highestBid: + type: float + lowsetAsk: + type: float + baseVolume: + type: float + openTime: + type: int + closeTime: + type: int + high24hr: + type: float + low24hr: + type: float + isFrozen: + type: bool + + mapping: + - key: time + path: [] + type: + - none + - now + - key: currency_pair_first + path: + - dict_key + type: + - str + - split + - "_" + - 0 + - key: currency_pair_second + path: + - dict_key + type: + - str + - split + - "_" + - 1 + - key: last_price + path: + - dict_values + - last + type: + - float + - key: best_bid + path: + - dict_values + - highestBid + type: + - float + - key: best_ask + path: + - dict_values + - lowsetAsk + type: + - float + + + order_books: + request: + template: depth + pair_template: + template: "{first}{second}" + lower_case: false + alias: symbol + params: + limit: + type: int + max: 1000 + default: 50 + response: + type: dict + values: + lastUpdateId: + type: str + bids: + type: list + values: + type: list + values: + 0: #Price + type: float + 1: #Qty + type: float + asks: + type: list + values: + type: list + values: + 0: + type: float + 1: + type: float + mapping: + - key: id + path: [] + type: + - none + - now_timestamp + - key: time + path: [] + type: + - none + - now + - key: position + path: [] + type: + - none + - range + - key: bids_amount + path: + - bids + - 1 + type: + - float + - key: asks_amount + path: + - asks + - 1 + type: + - float + - key: bids_price + path: + - bids + - 0 + type: + - float + - key: asks_price + path: + - asks + - 0 + type: + - float + + + trades: + request: + template: trades + pair_template: + template: "{first}{second}" + lower_case: false + alias: symbol + params: + limit: + type: int + max: 500 + default: 100 + + response: + type: list + values: + type: dict + values: + id: + type: str + price: + type: str + qty: + type: str + time: + type: int + isBuyerMaker: + type: true + isBestMatch: + type: true + mapping: + - key: id + path: + - id + type: + - str + - key: direction + path: + - isBuyerMaker + type: + - value + - map + - true + - sell + - false + - buy + - key: time + path: + - time + type: + - float + - from_timestamp + - 1 + - key: price + path: + - price + type: + - str + - float + - key: amount + path: + - qty + type: + - str + - float + + + + historic_rates: + request: + template: klines + pair_template: + template: "{first}{second}" + lower_case: false + alias: symbol + params: + limit: + type: int + max: 500 + default: 1000 + interval: + allowed: + minutes: 1m + hours: 1h + days: 1d + weeks: 1w + default: 1d + endTime: + function: last_timestamp + type: + - datetime + - timestampms + + response: + type: list + values: + type: list + values: + 0: + type: int + 1: + type: str + 2: + type: str + 3: + type: str + 4: + type: str + 5: + type: str + 6: + type: str + 7: + type: str + mapping: + - key: time + path: + - [] + - 6 + type: + - float + - from_timestamp + - 1 + - key: open + path: + - [] + - 1 + type: + - str + - float + - key: high + path: + - [] + - 2 + type: + - str + - float + - key: low + path: + - [] + - 3 + type: + - str + - float + - key: close + path: + - [] + - 4 + type: + - str + - float + - key: volume + path: + - [] + - 5 + type: + - str + - float diff --git a/pandas_datareader/crypto_utils/resources/xt.yaml b/pandas_datareader/crypto_utils/resources/xt.yaml new file mode 100644 index 00000000..757a2b96 --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/xt.yaml @@ -0,0 +1,328 @@ + +name: xt +exchange: true +api_docs: https://github.com/xtpub/api-doc/blob/master/rest-api-v1-en.md +rate_limit: + max: 1000 + unit: 60 + +api_url: https://api.xt.com + +requests: + currency_pairs: + request: + template: /data/api/v1/getMarketConfig + pair_template: null + params: null + + response: + type: + type: list + values: + currency_pair: + type: dict + + mapping: + - key: currency_pair_first + path: + - dict_key + type: + - str + - split + - "_" + - 0 + - key: currency_pair_second + path: + - dict_key + type: + - str + - split + - "_" + - 1 + + tickers: + request: + template: /data/api/v1/getTickers + pair_template: null + params: null + response: + type: dict + values: + currency_pair: + type: dict + values: + price: + type: float + ask: + type: float + bid: + type: float + coinVol: + type: float + mapping: + - key: currency_pair_first + path: + - dict_key + type: + - str + - split + - "_" + - 0 + - key: currency_pair_second + path: + - dict_key + type: + - str + - split + - "_" + - 1 + - key: last_price + path: + - dict_values + - price + type: + - float + - key: time + path: [] + type: + - none + - now + - key: best_bid + path: + - dict_values + - bid + type: + - float + - key: best_ask + path: + - dict_values + - ask + type: + - float + - key: daily_volume + path: + - dict_values + - coinVol + type: + - float + + historic_rates: + request: + template: /data/api/v1/getKLine + pair_template: + template: "{first}_{second}" + lower_case: true + alias: market + params: + type: + allowed: + minutes: 1min + hours: 1hour + days: 1day + weeks: 7day + months: 30day + default: 1day + since: + function: last_timestamp + type: + - datetime + - timestamp + response: + type: dict + values: + datas: + type: list + values: + type: list + values: + 0: #time + type: int + 1: #open + type: float + 2: #high + type: float + 3: #low + type: float + 4: #close + type: float + 5: #vol + type: float + 6: #turnover + type: float + + mapping: + - key: time + path: + - datas + - 0 + type: + - float + - from_timestamp + - 0 + - key: open + path: + - datas + - 1 + type: + - float + - key: high + path: + - datas + - 2 + type: + - float + - key: low + path: + - datas + - 3 + type: + - float + - key: close + path: + - datas + - 4 + type: + - float + - key: volume + path: + - datas + - 5 + type: + - float + + + trades: + request: + template: /data/api/v1/getTrades + pair_template: + template: "{first}_{second}" + lower_case: true + alias: market + params: null + + response: + type: list + values: + type: list + values: + 0: #time + type: int + 1: #price + type: float + 2: #quantity + type: float + 3: # directoin + type: str + 4: #id + type: int + + mapping: + - key: time + path: + - [] + - 0 + type: + - float + - from_timestamp + - 1 + - key: id + path: + - [] + - 4 + type: + - int + - key: direction + path: + - [] + - 3 + type: + - value + - map + - bid + - buy + - ask + - sell + - key: price + path: + - [] + - 1 + type: + - float + - key: amount + path: + - [] + - 2 + type: + - float + + order_books: + request: + template: /data/api/v1/getDepth + pair_template: + template: "{first}_{second}" + lower_case: true + alias: market + params: null + + response: + type: dict + values: + asks: + type: list + values: + type: list + values: + 0: #price + type: float + 1: #quantity + type: float + bids: + type: list + values: + type: list + values: + 0: #price + type: float + 1: #quantity + type: float + + mapping: + - key: time + path: [] + type: + - none + - now + - key: id + path: [] + type: + - none + - now_timestamp + - key: position + path: [] + type: + - none + - range + - key: bids_amount + path: + - bids + - 1 + type: + - float + - key: bids_price + path: + - bids + - 0 + type: + - float + - key: asks_amount + path: + - asks + - 1 + type: + - float + - key: asks_price + path: + - asks + - 0 + type: + - float \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/xtheta_global.yaml b/pandas_datareader/crypto_utils/resources/xtheta_global.yaml new file mode 100644 index 00000000..c336d4ad --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/xtheta_global.yaml @@ -0,0 +1,303 @@ +name: xtheta_global +is_exchange: true + +api_url: https://api.xthetaglobal.com/ +rate_limit: + max: 1500 + unit: 60 + +requests: + currency_pairs: + request: + template: openapi/v1/brokerInfo + pair_template: null + params: null + + response: + type: dict + values: + symbols: + type: list + values: + type: dict + values: + baseAsset: + type: str + quoteAsset: + type: str + + mapping: + - key: currency_pair_first + path: + - symbols + - baseAsset + type: + - str + - key: currency_pair_second + path: + - symbols + - quoteAsset + type: + - str + + tickers: + request: + template: openapi/quote/v1/ticker/price + pair_template: + template: "{first}{second}" + lower_case: false + alias: symbol + params: null + + response: + type: dict + values: + symbol: + type: str + price: + type: str + mapping: + - key: time + path: [] + type: + - none + - now + - key: last_price + path: + - price + type: + - str + - float + + order_books: + request: + template: openapi/quote/v1/depth + pair_template: + template: "{first}{second}" + lower_case: false + alias: symbol + params: + limit: + type: int + max: 100 + default: 100 + response: + type: dict + values: + time: + type: int + bids: + type: list + values: + type: list + 0: #price + type: str + 1: #qty + type: str + asks: + type: list + values: + type: list + 0: + type: str + 1: + type: str + mapping: + - key: time + path: + - time + type: + - float + - from_timestamp + - 1 + - key: id + path: + - time + type: + - int + - key: position + path: [] + type: + - none + - range + - key: bids_price + path: + - bids + - 0 + type: + - str + - float + - key: bids_amount + path: + - bids + - 1 + type: + - str + - float + - key: asks_price + path: + - asks + - 0 + type: + - str + - float + - key: asks_amount + path: + - asks + - 1 + type: + - str + - float + + trades: + request: + template: openapi/quote/v1/trades + pair_template: + template: "{first}{second}" + lower_case: false + alias: symbol + params: + limit: + type: int + max: 1000 + default: 500 + response: + type: list + value: + type: dict + values: + price: + type: str + qty: + typ: str + time: + type: int + isBuyerMaker: + type: bool + mapping: + - key: time + path: + - time + type: + - float + - from_timestamp + - 1 + - key: direction + path: + - isBuyerMaker + type: + - value + - map + - True + - sell + - False + - buy + - key: id + path: + - time + type: + - int + - key: price + path: + - price + type: + - str + - float + - key: amount + path: + - qty + type: + - str + - float + + historic_rates: + request: + template: openapi/quote/v1/klines + pair_template: + template: "{first}{second}" + lower_case: false + alias: symbol + params: + interval: + allowed: + minutes: 1m + hours: 1h + days: 1d + weeks: 1w + default: 1d + limit: + type: int + max: 1000 + default: 1000 + endTime: + function: last_timestamp + type: + - datetime + - timestampms + + response: + type: list + values: + type: list + values: + 0: #timestamp + type: int + 1: #open + type: str + 2: #high + type: str + 3: #low + type: str + 4: #close + type: str + 5: #volume + type: str + 6: #close time + type: int + 7: # quote Asset volume + type: str + 8: # number of trades + type: int + 9: # taker buy base asset volume + type: str + 10: # taker buy quote asset volume + type: str + + mapping: + - key: time + path: + - 0 + type: + - float + - from_timestamp + - 1 + - key: open + path: + - 1 + type: + - str + - float + - key: high + path: + - 2 + type: + - str + - float + - key: low + path: + - 3 + type: + - str + - float + - key: close + path: + - 4 + type: + - str + - float + - key: volume + path: + - 5 + type: + - str + - float \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/zb.yaml b/pandas_datareader/crypto_utils/resources/zb.yaml new file mode 100644 index 00000000..dd56aa37 --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/zb.yaml @@ -0,0 +1,322 @@ +name: zb +is_exchange: true +api_docs: https://www.zb.com/en/api +api_url: http://api.zb.land/ +rate_limit: + max: 60 + unit: 60 + +requests: + currency_pairs: + request: + template: data/v1/markets + pair_template: null + params: null + + response: + type: dict + values: + currency_pair: + type: dict + values: + priceScale: + type: int + + mapping: + - key: currency_pair_first + path: + - dict_key + type: + - str + - split + - "_" + - 0 + - key: currency_pair_second + path: + - dict_key + type: + - str + - split + - "_" + - 1 + + tickers: + request: + template: data/v1/ticker + pair_template: + template: "{first}_{second}" + lower_case: true + alias: market + params: null + + response: + type: dict + values: + date: + type: int + ticker: + type: dict + values: + vol: + type: str + last: + type: str + buy: + type: str + sell: + type: str + mapping: + - key: time + path: + - date + type: + - str + - float + - from_timestamp + - 1 + - key: last_price + path: + - ticker + - last + type: + - str + - float + - key: best_ask + path: + - ticker + - sell + type: + - str + - float + - key: best_bid + path: + - ticker + - buy + type: + - str + - float + - key: daily_volume + path: + - ticker + - vol + type: + - str + - float + + + order_books: + request: + template: data/v1/depth + pair_template: + template: "{first}_{second}" + lower_case: true + alias: market + params: + size: + type: int + max: 50 + default: 50 + response: + type: dict + values: + timestamp: + type: int + bids: + type: list + values: + type: list + 0: #price + type: float + 1: #qty + type: float + asks: + type: list + values: + type: list + 0: + type: float + 1: + type: float + mapping: + - key: timestamp + path: + - timestamp + type: + - float + - from_timestamp + - 0 + - key: id + path: + - timestamp + type: + - int + - key: position + path: [] + type: + - none + - range + - key: bids_price + path: + - bids + - 0 + type: + - float + - key: bids_amount + path: + - bids + - 1 + type: + - float + - key: asks_price + path: + - asks + - 0 + type: + - float + - key: asks_amount + path: + - asks + - 1 + type: + - float + + trades: + request: + template: data/v1/trades + pair_template: + template: "{first}_{second}" + lower_case: true + alias: market + params: null + response: + type: list + value: + type: dict + values: + price: + type: str + amount: + typ: str + date: + type: int + type: + type: str + tid: + type: int + mapping: + - key: time + path: + - date + type: + - float + - from_timestamp + - 0 + - key: direction + path: + - type + type: + - str + - key: id + path: + - tid + type: + - int + - key: price + path: + - price + type: + - str + - float + - key: amount + path: + - amount + type: + - str + - float + + historic_rates: + request: + template: data/v1/kline + pair_template: + template: "{first}_{second}" + lower_case: true + alias: market + params: + type: + allowed: + minutes: 1min + days: 1day + hours: 1hour + weeks: 1week + default: 1day + since: + function: last_timestamp + type: + - datetime + - timedeltams + - interval + - 1000 + limit: + type: int + max: 1000 + default: 1000 + + + response: + type: dict + values: + data: + type: list + values: + 0: #timestamp + type: int + 1: #open + type: float + 2: #high + type: float + 3: #low + type: float + 4: #close + type: float + 5: #volume + type: float + + mapping: + - key: time + path: + - data + - 0 + type: + - float + - from_timestamp + - 1 + - key: open + path: + - data + - 1 + type: + - float + - key: high + path: + - data + - 2 + type: + - float + - key: low + path: + - data + - 3 + type: + - float + - key: close + path: + - data + - 4 + type: + - float + - key: volume + path: + - data + - 5 + type: + - float \ No newline at end of file diff --git a/pandas_datareader/crypto_utils/resources/zbg.yaml b/pandas_datareader/crypto_utils/resources/zbg.yaml new file mode 100644 index 00000000..91d05d98 --- /dev/null +++ b/pandas_datareader/crypto_utils/resources/zbg.yaml @@ -0,0 +1,405 @@ +# Trade direction is available but not certain what is meant... +name: zbg +exchange: true +api_url: https://kline.zbg.com/ + +rate_limit: + max: 1000 + unit: 60 + +requests: + currency_pairs: + request: + template: /exchange/api/v1/common/symbols + pair_template: null + params: null + + response: + type: dict + values: + datas: + type: list + values: + type: dict + values: + symbol: + type: str + base-currency: + type: str + quote-currency: + type: str + + mapping: + - key: currency_pair_first + path: + - datas + - base-currency + type: + - str + - key: currency_pair_second + path: + - datas + - quote-currency + type: + - str + + + tickers: + request: + template: api/data/v1/tickers + pair_template: null + params: + isUseMarketName: + type: str + default: "true" + response: + type: dict + values: + datas: + type: dict + values: + currency_pair: + type: list + values: + 0: #marketId + type: str + 1: #last price + type: str + 2: #highest price + type: str + 3: #lowest + type: str + 4: #24h volume + type: str + 5: #24h change + type: str + 6: # + type: str + 7: #top buying price + type: str + 8: #top selling price + type: str + 9: #24h volume in unit of buyers currency + type: str + mapping: + - key: time + path: [] + type: + - none + - now + - key: currency_pair_first + path: + - datas + - list_key + type: + - str + - split + - "_" + - 0 + - key: currency_pair_second + path: + - datas + - list_key + type: + - str + - split + - "_" + - 1 + - key: last_price + path: + - datas + - list_values + - 1 + type: + - str + - float + - key: daily_volume + path: + - datas + - list_values + - 4 + type: + - str + - float + - key: best_bid + path: + - datas + - list_values + - 7 + type: + - str + - float + - key: best_ask + path: + - datas + - list_values + - 8 + type: + - str + - float + + + historic_rates: + request: + template: api/data/v1/klines + pair_template: + template: "{first}_{second}" + lower_case: false + alias: marketName + params: + type: + allowed: + minutes: 1M + hours: 1H + days: 1D + weeks: 1W + default: 1D + dataSize: + type: int + default: 10000 + + response: + type: dict + values: + datas: + type: list + values: + type: list + values: + 0: + type: str + 1: + type: str + 2: # pair + type: str + 3: # time + type: str + 4: # open + type: str + 5: # high + type: str + 6: # low + type: str + 7: # close + type: str + 8: # base volume + type: str + 13: # quote volume + type: str + mapping: + - key: time + path: + - datas + - 3 + type: + - str + - float + - from_timestamp + - 0 + - key: open + path: + - datas + - 4 + type: + - str + - float + - key: high + path: + - datas + - 5 + type: + - str + - float + - key: low + path: + - datas + - 6 + type: + - str + - float + - key: close + path: + - datas + - 7 + type: + - str + - float + - key: volume + path: + - datas + - 8 + type: + - str + - float + + trades: + request: + template: /api/data/v1/trades + pair_template: + template: "{first}_{second}" + lower_case: false + alias: marketName + params: + dataSize: + type: int + max: 1000 + default: 1000 + + response: + type: dict + values: + datas: + type: list + values: + type: list + values: + 0: + type: str + 1: + type: str + 2: # time + type: str + 3: # pair + type: str + 4: # direction + type: str + 5: # price + type: str + 6: # qty + type: str + mapping: + - key: id + path: + - datas + - 2 + type: + - str + - int + - key: time + path: + - datas + - 2 + type: + - str + - float + - from_timestamp + - 0 + - key: price + path: + - datas + - 5 + type: + - str + - float + - key: amount + path: + - datas + - 6 + type: + - str + - float +# - key: direction # not certain what bid and ask for a direction is +# path: +# - datas +# - 4 +# type: +# - map +# - values +# - bid +# - sell +# - ask +# - buy + + order_books: + request: + template: api/data/v1/entrusts + pair_template: + template: "{first}_{second}" + lower_case: false + alias: marketName + params: + dataSize: + type: int + max: 200 + default: 50 + + response: + type: dict + values: + datas: + type: dict + values: + asks: + type: list + values: + type: list + values: + 0: + type: str + 1: + type: str + bids: + type: list + values: + type: list + values: + 0: + type: str + 1: + type: str + timestamp: + type: str + mapping: + - key: id + path: + - datas + - timestamp + type: + - str + - int + - key: position + path: [] + type: + - none + - range + - key: time + path: + - datas + - timestamp + type: + - str + - float + - from_timestamp + - 0 + - key: bids_amount + path: + - datas + - bids + - 1 + type: + - str + - float + - key: bids_price + path: + - datas + - bids + - 0 + type: + - str + - float + - key: asks_price + path: + - datas + - asks + - 0 + type: + - str + - float + - key: asks_amount + path: + - datas + - asks + - 1 + type: + - str + - float diff --git a/pandas_datareader/crypto_utils/time_helper.py b/pandas_datareader/crypto_utils/time_helper.py new file mode 100644 index 00000000..0b636625 --- /dev/null +++ b/pandas_datareader/crypto_utils/time_helper.py @@ -0,0 +1,133 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +""" +Contains helper classes to manage dates and times. + +Classes: +- TimeHelper: Used to create/convert timezone aware (UTC+0) dates and times. + +Enums: +- TimeUnit: Used to indicate the unit of timestamps. +""" + +from datetime import datetime, timezone +from enum import IntEnum + +from datetime_periods import period +from dateutil.parser import parse + + +class TimeUnit(IntEnum): + """ An enumeration to indicate the unit of timestamps.""" + + SECONDS = 0 + MILLISECONDS = 1 + MICROSECONDS = 2 + NANOSECONDS = 3 + + +class TimeHelper: + """ A helper class to create/convert dates and times. + + It ensures that all dates and times are timezone aware (UTC+0). + + freq_map is used to convert specific strings from plural into singular. + """ + + freq_map = { + "minutes": "minute", + "hours": "hour", + "days": "day", + "weeks": "week", + "months": "month", + } + + @staticmethod + def now() -> datetime: + """ Get the current datetime (UTC+0). The accuracy is limited to + milliseconds and the remaining microseconds are cleared. + + @return: The current datetime (UTC+0). + @rtype: datetime + """ + + now = datetime.now(tz=timezone.utc) + return now.replace(microsecond=now.microsecond - now.microsecond % 1000) + + @staticmethod + def now_timestamp(unit: TimeUnit = TimeUnit.SECONDS) -> float: + """ Get the timestamp of the current datetime (UTC+0). + + @param unit: The desired time unit of the timestamp. + @type unit: TimeUnit + + @return: The timestamp of the current datetime (UTC+0). + @rtype: float + """ + + return TimeHelper.to_timestamp(TimeHelper.now(), unit) + + @staticmethod + def from_string(representation: str) -> datetime: + """ Get a datetime (UTC+0) from a given representation. + + @param representation: The string that represents a datetime. + @type representation: str + + @return: The datetime (UTC+0) of the given representation. + @rtype: datetime + """ + + return parse(representation).replace(tzinfo=timezone.utc) + + @staticmethod + def from_timestamp(timestamp: float, unit: TimeUnit = TimeUnit.SECONDS) -> datetime: + """ Get a datetime (UTC+0) from a given timestamp. + + @param timestamp: The timestamp whose datetime is to be obtained. + @type timestamp: float + @param unit: The time unit in which the timestamp is given. + @type unit: TimeUnit + + @return: The datetime (UTC+0) of the given timestamp. + @rtype: datetime + """ + + timestamp_in_sec: float = timestamp / (1000 ** int(unit)) + + return datetime.fromtimestamp(timestamp_in_sec, tz=timezone.utc) + + @staticmethod + def to_timestamp(date_time: datetime, unit: TimeUnit = TimeUnit.SECONDS) -> float: + """ Convert a datetime to a timestamp. + + @param date_time: The datetime to be converted. + @type date_time: datetime + @param unit: The desired time unit of the timestamp. + @type unit: TimeUnit + + @return: The timestamp of the given datetime in the desired time unit. + @rtype: float + """ + + return date_time.replace(tzinfo=timezone.utc).timestamp() * (1000 ** int(unit)) + + @staticmethod + def start_end_conversion( + date_time: datetime, frequency: str, to_end: bool = True + ) -> datetime: + """ Returns the beginning/end of a period. + + @param date_time: The datetime object to be converted. + @type date_time: datetime + @param frequency: The underlying period frequency. + @type frequency: str + @param to_end: boolean, return end of period. Default: True + @type to_end: bool + + @return: datetime of start/end of period. + @rtype: datetime + """ + + return period(date_time, TimeHelper.freq_map[frequency])[int(to_end)] diff --git a/pandas_datareader/crypto_utils/utilities.py b/pandas_datareader/crypto_utils/utilities.py new file mode 100644 index 00000000..6a3d83ee --- /dev/null +++ b/pandas_datareader/crypto_utils/utilities.py @@ -0,0 +1,313 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +""" +Module providing several utility functions needed across the whole program. +""" + +from typing import Any, Optional, Dict, List + +import os +from sys import stdout +import calendar +import datetime +from datetime import timedelta +import dateutil.parser +import yaml +import pandas as pd + +from pandas_datareader.crypto_utils.time_helper import TimeHelper, TimeUnit +import pandas_datareader.crypto_utils._paths as _paths + +TYPE_CONVERSIONS = { + ("float", "from_timestamp"): {"function": TimeHelper.from_timestamp, "params": 1}, + ("bool", "int"): {"function": int, "params": 0}, + ("float", "int"): {"function": int, "params": 0}, + ("int", "bool"): {"function": bool, "params": 0}, + ("int", "div"): { + "function": lambda integer, div: integer / (1 * div), + "params": 1, + }, + ("any", "value"): {"function": lambda number: float(number) > 0, "params": 0}, + ("str", "bool"): { + "function": lambda string: string.lower() == "true", + "params": 0, + }, + ("str", "int"): {"function": int, "params": 0}, + ("str", "float"): {"function": float, "params": 0}, + ("str", "float_absolut"): { + "function": lambda string: abs(float(string)), + "params": 0, + }, + ("str", "floatNA"): { + "function": lambda string: float(string) if string != "N/A" else None, + "params": 0, + }, + ("str", "strptime"): { + "function": lambda string, *args: datetime.datetime.strptime(string, args[0]), + "params": 1, + }, + ("strptime_w_f", "strptime_wo_f"): { + "function": lambda string, *args: datetime.datetime.strptime( + string.split(".")[0], *args + ), + "params": 1, + }, + ("str", "split"): { + "function": lambda string, *args: string.split(args[0])[args[1]] + if args[0] in string + else None, + "params": 2, + }, + ("str", "splitupper"): { + "function": lambda string, *args: string.split(args[0])[args[1]].upper(), + "params": 2, + }, + ("str", "slice"): { + "function": lambda string, *args: string[args[0] : args[1]], + "params": 2, + }, + ("str", "upper"): {"function": lambda string: string.upper(), "params": 0}, + ("str", "lower"): {"function": lambda string: string.lower(), "params": 0}, + ("str", "dateparser"): {"function": dateutil.parser.parse, "params": 0}, + ("datetime", "strftime"): { + "function": lambda time, *args: datetime.datetime.strftime(time, args[0]), + "params": 1, + }, + ("dateparser", "totimestamp"): { + "function": lambda time: int(time.timestamp()), + "params": 0, + }, + ("datetime", "totimestamp"): { + "function": lambda time: int(time.timestamp()), + "params": 0, + }, + ("datetime", "totimestampms"): { + "function": lambda time: int(round(time.timestamp() * 1000)), + "params": 0, + }, + ("datetime", "utctotimestamp"): { + "function": lambda time: calendar.timegm(time.utctimetuple()), + "params": 0, + }, + ("strptime", "totimestamp"): { + "function": lambda string, *args: int( + datetime.datetime.timestamp(datetime.datetime.strptime(string, args[0])) + ), + "params": 1, + }, + ("none", "nowstrptime"): { + "function": lambda arg: TimeHelper.now().replace( + hour=0, minute=0, second=0, microsecond=0 + ), + "params": 0, + }, + ("none", "now"): {"function": TimeHelper.now, "params": 0}, + ("none", "now_format"): { + "function": lambda spec: format(TimeHelper.now(), spec), + "params": 1, + }, + ("none", "constant"): { # Returns the first argument + "function": lambda *args: args[0], + "params": 1, + }, + ("none", "range"): {"function": lambda: range(1), "params": 0}, + ("value", "map"): { + # translate into buy/sell. Args: {0: 'buy', 1:'sell'} and arg[0] + # is the response value (i.e. 0/1) + "function": lambda *args: {args[1]: args[2], args[3]: args[4]}[args[0]], + "params": 4, + }, + ("str", "split_at_del_or_index"): { + "function": lambda string, *args: string.split(args[0])[args[2]] + if len(string) != len(string.split(args[0])[0]) + else string[: args[1]] + if args[2] == 0 + else string[args[1] :], + "params": 3, # delimiter, index, 0 or 1 aka. left or right + }, + ("none", "now_timestamp"): { + "function": lambda: int(TimeHelper.now_timestamp()), + "params": 0, + }, + ("none", "now_timestampms"): { + "function": lambda: int(TimeHelper.now_timestamp(TimeUnit.MILLISECONDS)), + "params": 0, + }, + ("now", "timedelta"): { + "function": lambda delta: int( + TimeHelper.to_timestamp(TimeHelper.now() - timedelta(days=int(delta))) + ), + "params": 1, + }, + ("datetime", "timedelta"): { + "function": lambda time, interval, delta: int( + TimeHelper.to_timestamp(time - timedelta(**{interval: int(delta)})) + ), + "params": 2, + }, + ("utcfromtimestamp", "timedelta"): { + "function": lambda time, interval, value: TimeHelper.from_timestamp(time) + - timedelta(**{interval: value}) + if isinstance(time, int) + else dateutil.parser.parse(time) - timedelta(**{interval: value}), + "params": 2, + }, + ("datetime", "timedeltams"): { + "function": lambda time, interval, delta: int( + TimeHelper.to_timestamp(time - timedelta(**{interval: int(delta)})) + ) + * 1000, + "params": 2, + }, + ("datetime", "timestamp"): { + "function": lambda time: int(TimeHelper.to_timestamp(time)), + "params": 0, + }, + ("datetime", "timestampms"): { + "function": lambda time: int(TimeHelper.to_timestamp(time)) * 1000, + "params": 0, + }, + ("datetime", "format"): {"function": format, "params": 1}, + ("timedelta", "from_timestamp"): { + "function": lambda time, unit, spec: format( + TimeHelper.from_timestamp(time, unit), spec + ), + "params": 2, + }, + ("from_timestamp", "to_start"): { + "function": lambda time, interval: TimeHelper.start_end_conversion( + time, interval, False + ), + "params": 1, + }, + ("from_timestamp", "to_end"): { + "function": lambda time, interval: TimeHelper.start_end_conversion( + time, interval, True + ), + "params": 1, + }, +} +""" + Type Conversions used to convert extracted values from the API-Response + into the desired type ("first", "second"). The values are specified in the + .yaml-file of each exchange under the "mapping" of each method. + The function is called in the Mapping Class of utilities.py under + the method convert_types(). + + "first": + The actual type extracted from the API-Request (.json) + "second": + The desired type to convert + "function": + the actual function to apply + "params": + the number of additional parameters needed +""" + + +def yaml_loader(exchange: str) -> Dict[str, Any]: + """ + Loads, reads and returns the data of a .yaml-file specified by the param exchange. + + @param exchange: The file name to load (exchange). + @type exchange: str + + @return: Returns a dict of the loaded data from the .yaml-file. + @rtype: dict + + @raise Exception: If the .yaml file could not be evaluated for a given exchange. + """ + if not exchange: + raise ValueError("No exchange provided.") + + exchange = exchange.replace(" ", "") + + path = _paths.all_paths.get("yaml_path") + + try: + with open( + path.joinpath(".".join([exchange.lower(), "yaml"])), "r", encoding="UTF-8" + ) as file: + return yaml.load(file, Loader=yaml.FullLoader) + + except FileNotFoundError as exc: + raise ValueError( + "Exchange '%s' is not supported." % exchange.capitalize() + ) from exc + + +def get_exchange_names() -> Optional[List[str]]: + """ + Gives information about all exchange that the program will send + requests to. This means if the name of a exchange is not part of the + list that is returned, the program will not send any request to said + exchange. + + @return: Names from all the exchange, which have a .yaml-file in + the directory described in YAML_PATH. + """ + path_to_resources = _paths.all_paths.get("yaml_path") + + try: + exchanges = os.listdir(path_to_resources) + exchanges = [x.split(".yaml")[0] for x in exchanges if x.endswith(".yaml")] + exchanges.sort() + except FileNotFoundError: + print(f"YAML files not found. The path {path_to_resources} is incorrect.") + return + + return exchanges + + +def replace_list_item(replace_list: list, condition: any, value: any) -> list: + """ + Replaces a specific value from a list. + @param replace_list: The list in which the value needs to be replaced + @param condition: The value to be updated + @param value: The new value + @return: Updated list + """ + for i, item in enumerate(replace_list): + if item == condition: + replace_list[i] = value + return replace_list + + +def split_str_to_list(string: str, splitter: str = ",") -> List[str]: + """ + Splits a string into a list of string. + + @param string: A long string. + @param splitter: The splitting parameter. + + @return: List of strings. + """ + items = string.rsplit(splitter) + + # remove possible blanks from strings + return [item.replace(" ", "").lower() for item in items] + + +def sort_columns(dataframe: pd.DataFrame) -> pd.DataFrame: + """ Sort columns in OHLCV order. + + @param dataframe: Requested data with unordered columns + @return: pd.DataFrame with ordered columns + """ + + # remove columns not returned by the exchange and maintain order. + columns = ["open", "high", "low", "close", "volume", "market_cap"] + columns = sorted(set(columns).intersection(dataframe.columns), key=columns.index) + + return dataframe.loc[:, columns] + + +def print_timestamp(timestamp): + """ Prints the actual request timestamp. + + @param timestamp: The timestamp + """ + + stdout.write("Requesting from: {}\r".format(timestamp)) + stdout.flush() diff --git a/pandas_datareader/data.py b/pandas_datareader/data.py index c2d6223a..2c53ad58 100644 --- a/pandas_datareader/data.py +++ b/pandas_datareader/data.py @@ -3,7 +3,7 @@ """ # flake8: noqa - +import os import warnings from pandas.util._decorators import deprecate_kwarg @@ -38,6 +38,8 @@ from pandas_datareader.yahoo.daily import YahooDailyReader from pandas_datareader.yahoo.options import Options as YahooOptions from pandas_datareader.yahoo.quotes import YahooQuotesReader +from pandas_datareader.crypto import CryptoReader +from pandas_datareader.crypto_utils.utilities import get_exchange_names __all__ = [ "get_components_yahoo", @@ -61,6 +63,7 @@ "get_dailysummary_iex", "get_data_stooq", "DataReader", + "get_data_crypto", ] @@ -136,6 +139,10 @@ def get_sector_performance_av(*args, **kwargs): return AVSectorPerformanceReader(*args, **kwargs).read() +def get_data_crypto(*args, **kwargs): + return CryptoReader(*args, **kwargs).read() + + def get_markets_iex(*args, **kwargs): """ Returns near-real time volume data across markets segregated by tape @@ -280,6 +287,7 @@ def DataReader( pause=0.1, session=None, api_key=None, + **kwargs ): """ Imports data from a number of online sources. @@ -360,6 +368,7 @@ def DataReader( "av-intraday", "econdb", "naver", + *crypto_exchanges, ] if data_source not in expected_source: @@ -668,6 +677,18 @@ def DataReader( session=session, ).read() + elif data_source in crypto_exchanges: + return CryptoReader( + exchange_name=data_source, + symbols=name, + start=start, + end=end, + retry_count=retry_count, + pause=pause, + session=session, + **kwargs + ).read() + else: msg = "data_source=%r is not implemented" % data_source raise NotImplementedError(msg) @@ -687,3 +708,6 @@ def Options(symbol, data_source=None, session=None): return YahooOptions(symbol, session=session) else: raise NotImplementedError("currently only yahoo supported") + + +crypto_exchanges = get_exchange_names() diff --git a/pandas_datareader/exceptions.py b/pandas_datareader/exceptions.py index a186d400..bbbc01c6 100644 --- a/pandas_datareader/exceptions.py +++ b/pandas_datareader/exceptions.py @@ -16,3 +16,7 @@ class UnstableAPIWarning(Warning): class ImmediateDeprecationError(Exception): pass + + +class EmptyResponseError(Exception): + pass diff --git a/pandas_datareader/tests/test_cryptoreader.py b/pandas_datareader/tests/test_cryptoreader.py new file mode 100644 index 00000000..c6ffd7df --- /dev/null +++ b/pandas_datareader/tests/test_cryptoreader.py @@ -0,0 +1,1027 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +""" +Test module for the classes: + - CryptoReader, + - Exchange, + - Mapping. +""" +import itertools + +import pytest +import datetime +import pandas as pd + +from pandas_datareader.crypto import CryptoReader +from pandas_datareader.crypto_utils.mapping import Mapping +from pandas_datareader.crypto_utils.mapping import extract_mappings +from pandas_datareader.crypto_utils.utilities import ( + yaml_loader, + sort_columns, + replace_list_item, + split_str_to_list, +) +from pandas_datareader.exceptions import EmptyResponseError + + +class TestCryptoReader: + """ Unit tests for the CryptoReader.""" + + exchange_name = "coinbase" + symbols = "btc/usd" + CryptoReader = CryptoReader(symbols=symbols, exchange_name=exchange_name) + + def test_get_all_exchanges(self): + """ Test to return a list of all available exchanges.""" + + result = self.CryptoReader.get_all_exchanges() + + assert isinstance(result, list) + + def test_read(self): + """ Test the request from a particular exchange.""" + + result = self.CryptoReader.read() + + assert isinstance(result, pd.DataFrame) + assert not result.empty + + def test_request_new_symbol(self): + """ Test to request NEW symbols.""" + + result = self.CryptoReader.read("eth/usd") + + assert "eth/usd" in self.CryptoReader.symbols.keys() + assert isinstance(result, pd.DataFrame) + assert not result.empty + + def test_reset_request_start_date(self): + """ Test resetting the request start date.""" + + key = list(self.CryptoReader.symbols.keys())[0] + self.CryptoReader.symbols.update({key: datetime.datetime(2020, 1, 1)}) + self.CryptoReader.reset_request_start_date() + + assert ( + self.CryptoReader.symbols.get(key).date() == datetime.datetime.now().date() + ) + + def test_check_symbols(self): + """ Test checking if the provided currency-pair is listed on an exchange.""" + + with pytest.raises(KeyError): + self.CryptoReader.symbols = {" / ": datetime.datetime.today()} + self.CryptoReader.read() + + def test_check_wrong_splitting_symbol(self): + """ Test checking if the provided currency-pair is listed on an exchange.""" + + with pytest.raises(BaseException): + self.CryptoReader.symbols = {" - ": datetime.datetime.today()} + self.CryptoReader.read() + + def test_ensure_correct_column_names(self): + """ Test to ensure specific column names.""" + + response = pd.DataFrame( + { + "High": range(0, 5), + "CLOSE": range(0, 5), + "oPen": range(0, 5), + "low": range(0, 5), + } + ) + response = sort_columns(dataframe=response) + + assert response.columns == "low" + + def test_index_and_cut_dataframe(self): + """ Test to cut the response to the initially defined start/end dates.""" + + response = pd.DataFrame( + { + "open": range(0, 100), + "time": pd.period_range(end="2020-12-31", periods=100, freq="d"), + } + ) + + self.CryptoReader.start = datetime.datetime(2020, 12, 1) + self.CryptoReader.end = datetime.datetime(2020, 12, 20) + + response = self.CryptoReader._index_and_cut_dataframe(response) + + assert response.shape[0] == 20 + assert min(response.index).to_timestamp() == self.CryptoReader.start + assert max(response.index).to_timestamp() == self.CryptoReader.end + + def test_get_currency_pairs(self): + """ Test to retrieve all listed currency-pairs.""" + + temp_reader = CryptoReader(exchange_name="coinbase") + pairs = temp_reader.get_currency_pairs() + + assert isinstance(pairs, pd.DataFrame) + assert pairs.empty is False + + +class TestExchange: + """ Unit tests for the Exchange class.""" + + exchange_name = "coinbase" + symbols = "btc/usd" + CryptoReader = CryptoReader(symbols=symbols, exchange_name=exchange_name) + + def test_correct_symbol_splitter(self): + """ Test to check for the correct symbol splitter.""" + + valid_symbols = ["btc-usd", "btc/usd", "btc-bitcoin/usd", "bitcoin/usd"] + invalid_symbols = ["btc$usd", "btc_usd", "btc-bitcoin-usd", "btc/bitcoin/usd"] + + formatted_pairs = [ + self.CryptoReader.apply_currency_pair_format(cp) for cp in valid_symbols + ] + assert all( + [isinstance(formatted_pair, str) for formatted_pair in formatted_pairs] + ) + + with pytest.raises(BaseException): + [self.CryptoReader.apply_currency_pair_format(cp) for cp in invalid_symbols] + + def test_extract_mappings(self): + """ Test to extract the mapping keys and values from the yaml files.""" + + result = extract_mappings( + self.CryptoReader.name, self.CryptoReader.yaml_file.get("requests") + ).get("historic_rates") + + assert isinstance(result, list) + assert result + + def test_all_exchanges_have_mappings_and_necessary_values(self): + """ Test if all exchange yaml-files have a specified mapping.""" + + exchanges = self.CryptoReader.get_all_exchanges() + assert isinstance(exchanges, list) + assert exchanges + + for exchange in exchanges: + file = yaml_loader(exchange) + result = extract_mappings(exchange, file.get("requests")).get( + "historic_rates" + ) + assert isinstance(result, list) + assert result + + def test_necessary_values_in_mappings(self): + """ Test if all necessary values are in the mappings.""" + + exchanges = self.CryptoReader.get_all_exchanges() + + for exchange in exchanges: + file = yaml_loader(exchange) + mappings = extract_mappings(exchange, file.get("requests")).get( + "historic_rates" + ) + + for mapping in mappings: + # Check if the object dict contains all necessary keys + # and not-None values. + assert all( + [ + item in mapping.__dict__.keys() + for item in ["key", "path", "types"] + ] + ) + assert all([val is not None for _, val in mapping.__dict__.items()]) + + def test_extract_param_dict(self): + """ Test to extract the request url and parameters.""" + + request_types = ["historic_rates", "currency_pairs"] + + for request_type in request_types: + self.CryptoReader.param_dict = request_type + + assert isinstance(self.CryptoReader.param_dict, dict) + assert request_type in self.CryptoReader.param_dict.keys() + assert isinstance(self.CryptoReader.param_dict.get(request_type), dict) + assert "url" in self.CryptoReader.param_dict.get(request_type).keys() + + def test_format_url_and_params(self): + """ Test to correctly format the request url and parameters.""" + + request_types = ["historic_rates", "currency_pairs"] + + for request_type in request_types: + self.CryptoReader.param_dict = request_type + self.CryptoReader.url_and_params = request_type + + assert isinstance(self.CryptoReader.url_and_params, dict) + assert isinstance(self.CryptoReader.url, str) + assert isinstance(self.CryptoReader.params, dict) + + def test_empty_response(self): + """ Test the behavior for an valid but empty response.""" + resp = [] + with pytest.raises(EmptyResponseError): + self.CryptoReader.format_data(resp) + + def test_format_data(self): + """ Test to correctly extract the response values.""" + + request_types = ["historic_rates", "currency_pairs"] + + for request_type in request_types: + self.CryptoReader.param_dict = request_type + self.CryptoReader.url_and_params = request_type + + resp = self.CryptoReader._get_data() + data, mappings = self.CryptoReader.format_data(resp) + + assert isinstance(data, list) + assert isinstance(mappings, list) + assert all([len(item) == len(mappings) for item in data]) + + +class TestMapping: + """ Test class for Mapping.""" + + # pylint: disable=too-many-public-methods + + def test_extract_value_split_index_zero(self): + """ Test of splitting a str and taking the index zero.""" + + mapping = Mapping("exchange_name", ["product_id"], ["str", "split", "-", 0]) + result = mapping.extract_value({"product_id": "BTC-ETH"}) + assert result == "BTC" + + def test_extract_value_split_index_one(self): + """ Test of splitting a str and taking the index one.""" + + mapping = Mapping("exchange_name", ["product_id"], ["str", "split", "-", 1]) + result = mapping.extract_value({"product_id": "BTC-ETH"}) + assert result == "ETH" + + def test_extract_value_split_index_two(self): + """ Test of splitting a str and taking the index two.""" + + mapping = Mapping("exchange_name", ["product_id"], ["str", "split", "-", 2]) + result = mapping.extract_value({"product_id": "BTC-ETH-USD"}) + assert result == "USD" + + def test_extract_value_slice_first_half(self): + """ Test of slicing a str and taking the first half.""" + + mapping = Mapping("exchange_name", ["product_id"], ["str", "slice", 0, 3]) + result = mapping.extract_value({"product_id": "BTCETH"}) + assert result == "BTC" + + def test_extract_value_slice_second_half(self): + """ Test of slicing a str and taking the second half.""" + + mapping = Mapping("exchange_name", ["product_id"], ["str", "slice", 3, 6]) + result = mapping.extract_value({"product_id": "BTCETH"}) + assert result == "ETH" + + def test_extract_value_str_to_bool_true(self): + """ Test of conversion from str to bool in case of True.""" + + mapping = Mapping("active", ["active"], ["str", "bool"]) + + result = mapping.extract_value({"active": "True"}) + + assert isinstance(result, bool) + assert result + + def test_extract_value_str_to_bool_true_lowercase(self): + """ Test of conversion from str to bool in case of lowercase True.""" + + mapping = Mapping("active", ["active"], ["str", "bool"]) + + result = mapping.extract_value({"active": "true"}) + + assert isinstance(result, bool) + assert result + + def test_extract_value_str_to_bool_true_uppercase(self): + """ Test of conversion from str to bool in case of uppercase True.""" + + mapping = Mapping("active", ["active"], ["str", "bool"]) + + result = mapping.extract_value({"active": "TRUE"}) + + assert isinstance(result, bool) + assert result + + def test_extract_value_str_to_bool_false(self): # + """ Test of conversion from str to bool in case of False.""" + + mapping = Mapping("active", ["active"], ["str", "bool"]) + + result = mapping.extract_value({"active": "False"}) + + assert isinstance(result, bool) + assert not result + + def test_extract_value_str_to_bool_false_lowercase(self): + """ Test of conversion from str to bool in case of lowercase False.""" + + mapping = Mapping("active", ["active"], ["str", "bool"]) + + result = mapping.extract_value({"active": "false"}) + + assert isinstance(result, bool) + assert not result + + def test_extract_value_str_to_bool_false_uppercase(self): + """ Test of conversion from str to bool in case of uppercase False.""" + + mapping = Mapping("active", ["active"], ["str", "bool"]) + + result = mapping.extract_value({"active": "FALSE"}) + + assert isinstance(result, bool) + assert not result + + def test_extract_value_str_to_bool_false_anything(self): + """ Test of conversion from str to bool in case of anything.""" + + mapping = Mapping("active", ["active"], ["str", "bool"]) + + result = mapping.extract_value({"active": "anything"}) + + assert isinstance(result, bool) + assert not result + + def test_extract_value_bool_to_int_true(self): + """ Test of conversion from bool to int in case of True.""" + + mapping = Mapping("active", ["active"], ["bool", "int"]) + + result = mapping.extract_value({"active": True}) + + assert isinstance(result, int) + assert result == 1 + + def test_extract_value_bool_to_int_false(self): + """ Test of conversion from bool to int in case of False.""" + + mapping = Mapping("active", ["active"], ["bool", "int"]) + + result = mapping.extract_value({"active": False}) + + assert isinstance(result, int) + assert result == 0 + + def test_extract_value_int_to_bool_one(self): + """ Test of conversion from int to bool in case of one.""" + + mapping = Mapping("active", ["active"], ["int", "bool"]) + + result = mapping.extract_value({"active": 1}) + + assert isinstance(result, bool) + assert result + + def test_extract_value_int_to_bool_zero(self): + """ Test of conversion from int to bool in case of zero.""" + + mapping = Mapping("active", ["active"], ["int", "bool"]) + + result = mapping.extract_value({"active": 0}) + + assert isinstance(result, bool) + assert not result + + def test_extract_value_int_to_bool_two(self): + """ Test of conversion from int to bool in case of two.""" + + mapping = Mapping("active", ["active"], ["int", "bool"]) + + result = mapping.extract_value({"active": 2}) + + assert isinstance(result, bool) + assert result + + def test_extract_value_int_to_bool_neg_two(self): + """ Test of conversion from int to bool in case of negative two.""" + + mapping = Mapping("active", ["active"], ["int", "bool"]) + + result = mapping.extract_value({"active": -2}) + + assert isinstance(result, bool) + assert result + + def test_extract_value_int_fromtimestamp(self): + """ Test of conversion from an int timestamp to datetime.""" + + mapping = Mapping("time", ["time"], ["float", "from_timestamp", "0"]) + + result = mapping.extract_value({"time": 1538122622}) + + assert isinstance(result, datetime.datetime) + # Different results depending on timezone + # self.assertEqual(result, datetime.datetime(2018, 9, 28, 8, 17, 2)) + + def test_extract_value_int_utcfromtimestamp(self): + """ Test of conversion from an int UTC timestamp to datetime.""" + + mapping = Mapping("time", ["time"], ["float", "from_timestamp", "1"]) + + result = mapping.extract_value({"time": 1538122622}) + + assert isinstance(result, datetime.datetime) + + def test_extract_value_int_fromtimestampms(self): + """ Test of conversion from an int timestamp with ms to datetime.""" + + mapping = Mapping("time", ["time"], ["float", "from_timestamp", "1"]) + + result = mapping.extract_value({"time": 1538122622123}) + + assert isinstance(result, datetime.datetime) + assert result.microsecond == 123000 + + def test_extract_value_float_fromtimestamp(self): + """ Test of conversion from a float timestamp to datetime.""" + + mapping = Mapping("time", ["time"], ["float", "from_timestamp", "0"]) + + result = mapping.extract_value({"time": 1538122622.123}) + + assert isinstance(result, datetime.datetime) + assert result.microsecond == 123000 + + def test_extract_value_float_utcfromtimestamp(self): + """ Test of conversion from a float UTC timestamp to datetime.""" + + mapping = Mapping("time", ["time"], ["float", "from_timestamp", "0"]) + + result = mapping.extract_value({"time": 1538122622.123}) + + assert isinstance(result, datetime.datetime) + assert result.microsecond == 123000 + + def test_extract_value_str_to_int_zero(self): + """ Test of conversion from str to int in case of zero.""" + + mapping = Mapping("number", ["number"], ["str", "int"]) + + result = mapping.extract_value({"number": "0"}) + + assert isinstance(result, int) + assert result == 0 + + def test_extract_value_str_to_int_one(self): + """ Test of conversion from str to int in case of one.""" + + mapping = Mapping("number", ["number"], ["str", "int"]) + + result = mapping.extract_value({"number": "1"}) + + assert isinstance(result, int) + assert result == 1 + + def test_extract_value_str_to_int_two(self): + """ Test of conversion from str to int in case of two.""" + + mapping = Mapping("number", ["number"], ["str", "int"]) + + result = mapping.extract_value({"number": "2"}) + + assert isinstance(result, int) + assert result == 2 + + def test_extract_value_str_to_int_twelve(self): + """ Test of conversion from str to int in case of twelve.""" + + mapping = Mapping("number", ["number"], ["str", "int"]) + + result = mapping.extract_value({"number": "12"}) + + assert isinstance(result, int) + assert result == 12 + + def test_extract_value_str_to_int_neg_one(self): + """ Test of conversion from str to int in case negative one.""" + + mapping = Mapping("number", ["number"], ["str", "int"]) + + result = mapping.extract_value({"number": "-1"}) + + assert isinstance(result, int) + assert result == -1 + + def test_extract_value_str_to_float_zero(self): + """ Test of conversion from str to float in case of zero.""" + + mapping = Mapping("number", ["number"], ["str", "float"]) + + result = mapping.extract_value({"number": "0.0"}) + + assert isinstance(result, float) + assert result == 0.0 + + def test_extract_value_str_to_float_one(self): + """ Test of conversion from str to float in case of one.""" + + mapping = Mapping("number", ["number"], ["str", "float"]) + + result = mapping.extract_value({"number": "1.0"}) + + assert isinstance(result, float) + assert result == 1.0 + + def test_extract_value_str_to_float_two(self): + """ Test of conversion from str to float in case of two.""" + + mapping = Mapping("number", ["number"], ["str", "float"]) + + result = mapping.extract_value({"number": "2.0"}) + + assert isinstance(result, float) + assert result == 2.0 + + def test_extract_value_str_to_float_twelve(self): + """ Test of conversion from str to float in case of twelve.""" + + mapping = Mapping("number", ["number"], ["str", "float"]) + + result = mapping.extract_value({"number": "12.0"}) + + assert isinstance(result, float) + assert result == 12.0 + + def test_extract_value_str_to_float_pi(self): + """ Test of conversion from str to float in case of Pi.""" + + mapping = Mapping("number", ["number"], ["str", "float"]) + + result = mapping.extract_value({"number": "3.141592654"}) + + assert isinstance(result, float) + assert result == 3.141592654 + + def test_extract_value_str_to_float_neg_one(self): + """ Test of conversion from str to float in case of negative one.""" + + mapping = Mapping("number", ["number"], ["str", "float"]) + + result = mapping.extract_value({"number": "-1.0"}) + + assert isinstance(result, float) + assert result == -1.0 + + def test_extract_value_str_to_float_neg_pi(self): + """ Test of conversion from str to float in case of negative Pi.""" + + mapping = Mapping("number", ["number"], ["str", "float"]) + + result = mapping.extract_value({"number": "-3.141592654"}) + + assert isinstance(result, float) + assert result == -3.141592654 + + def test_extract_value_datetime_totimestamp(self): + """ Test of conversion from datetome to timestamp.""" + + mapping = Mapping("date", ["date"], ["datetime", "totimestamp"]) + + result = mapping.extract_value( + {"date": datetime.datetime(2018, 10, 11, 11, 20)} + ) + + assert isinstance(result, int) + # Different results depending on timezone + # self.assertEqual(result, 1539249600) + + def test_extract_value_datetime_totimestampms(self): + """ Test of conversion from datetome to timestamp with ms.""" + + mapping = Mapping("date", ["date"], ["datetime", "totimestampms"]) + + result = mapping.extract_value( + {"date": datetime.datetime(2018, 10, 11, 11, 20, 0, 123000)} + ) + + assert isinstance(result, int) + # Different results depending on timezone + # self.assertEqual(result, 1539249600123) + + def test_extract_value_datetime_utctotimestamp(self): + """ Test of conversion from datetome to UTC timestamp.""" + + mapping = Mapping("date", ["date"], ["datetime", "utctotimestamp"]) + + result = mapping.extract_value( + {"date": datetime.datetime(2018, 10, 11, 11, 20, 0)} + ) + + assert isinstance(result, int) + # Different results depending on timezone + + def test_extract_value_str_strptime_date(self): + """ Test of conversion timestring via strptime in case of a date.""" + + mapping = Mapping("date", ["date"], ["str", "strptime", "%Y-%m-%d"]) + + result = mapping.extract_value({"date": "2018-10-11"}) + + assert isinstance(result, datetime.datetime) + assert result == datetime.datetime(2018, 10, 11) + + def test_extract_value_str_strptime_datetime(self): + """ Test of conversion timestring via strptime in case of a datetime.""" + + mapping = Mapping("date", ["date"], ["str", "strptime", "%Y-%m-%d %H:%M"]) + + result = mapping.extract_value({"date": "2018-10-11 12:06"}) + + assert isinstance(result, datetime.datetime) + assert result == datetime.datetime(2018, 10, 11, 12, 6) + + def test_extract_value_datetime_strftime_date(self): + """ Test of conversion from datetime via strftime in case of a date.""" + + mapping = Mapping("date", ["date"], ["datetime", "strftime", "%Y-%m-%d"]) + + result = mapping.extract_value({"date": datetime.datetime(2018, 10, 11)}) + + assert isinstance(result, str) + assert result == "2018-10-11" + + def test_extract_value_datetime_strftime_datetime(self): + """ Test of conversion from datetime via strftime in case of a dt.""" + + mapping = Mapping("date", ["date"], ["datetime", "strftime", "%Y-%m-%d %H:%M"]) + + result = mapping.extract_value({"date": datetime.datetime(2018, 10, 11, 12, 6)}) + + assert isinstance(result, str) + assert result == "2018-10-11 12:06" + + def test_extract_value_dict_key(self): + """ Test of extract value for dict_keys without further processing.""" + + mapping = Mapping("pair", ["dict_key"], ["str"]) + + result = mapping.extract_value({"BTC_USD": "value", "ETH_EUR": "value"}) + + assert isinstance(result, list) + assert result == ["BTC_USD", "ETH_EUR"] + + def test_extract_value_dict_key_split_index_zero(self): + """ Test of extract value for dict_keys with split and index 0.""" + + mapping = Mapping("pair", ["dict_key"], ["str", "split", "_", 0]) + + result = mapping.extract_value({"BTC_USD": "value", "ETH_EUR": "value"}) + + assert isinstance(result, list) + assert result == ["BTC", "ETH"] + + def test_extract_value_dict_key_split_index_one(self): + """ Test of extract value for dict_keys with split and index 1.""" + + mapping = Mapping("pair", ["dict_key"], ["str", "split", "_", 1]) + + result = mapping.extract_value({"BTC_USD": "value", "ETH_EUR": "value"}) + + assert isinstance(result, list) + assert result == ["USD", "EUR"] + + def test_extract_value_where_pair_can_not_be_split(self): + """ Test extract value for case where value is currency pair but cannot + be extracted since there is no delimiter for splitting the pair.""" + mapping = Mapping("first", [], ["first_currency"]) + result = mapping.extract_value( + ["ETHBTC", "XRPBTC"], currency_pair_info=("XRP", "BTC", "XRPBTC") + ) + assert result == "XRP" + + mapping = Mapping("second", [], ["second_currency"]) + result = mapping.extract_value( + ["ETHBTC", "XRPBTC"], currency_pair_info=("ETH", "BTC", "ETHBTC") + ) + assert result == "BTC" + + def test_extract_value_list(self): + """Test of extracting all elements in a list.""" + mapping = Mapping("number_as_string", [[]], ["str"]) + value_list = ["1.0", "1.1", "1.2", "1.3", "2.4", "2.5", "3.6", "3.7"] + result = mapping.extract_value(value_list) + + assert value_list == result + + def test_extract_value_list_containing_dict_with_key(self): + """ Test of extract value for a list that contains a dict for each + index with a known key.""" + + # list element directly holds value behind key + mapping = Mapping("first_currency", ["first"], ["str"]) + + extract_list = [ + {"first": "BTC"}, + {"first": "ETH"}, + {"first": "XRP"}, + {"first": "DOGE"}, + {"first": "XSA"}, + {"first": "TEST"}, + ] + result = mapping.extract_value(extract_list) + value_list = ["BTC", "ETH", "XRP", "DOGE", "XSA", "TEST"] + assert value_list == result + + # list element holds dict that holds another dict which holds the + # value behind key + mapping = Mapping( + "first_currency", + [ + "a", + "first", + ], # ['dict_values', 'first'] works also since it's only one level + ["str"], + ) + + extract_list = [ + {"a": {"first": "BTC", "second": "should not matter"}}, + {"a": {"first": "ETH", "second": "should not matter"}}, + {"a": {"first": "XRP", "second": "should not matter"}}, + {"a": {"first": "DOGE", "second": "should not matter"}}, + {"a": {"first": "XSA", "second": "should not matter"}}, + {"a": {"first": "TEST", "second": "should not matter"}}, + ] + result = mapping.extract_value(extract_list) + assert value_list == result + + # list element with few more levels of dictionaries + mapping = Mapping("first_currency", ["a", "b", "c", "d", "first"], ["str"]) + + extract_list = [ + { + "a": { + "b": { + "c": { + "d": {"first": "BTC", "second": "should not matter"}, + "dist": "other_value", + } + } + } + }, + { + "a": { + "b": { + "c": {"d": {"first": "ETH", "second": "should not matter"}}, + "dist": "other_value", + } + } + }, + { + "a": { + "b": {"c": {"d": {"first": "XRP", "second": "should not matter"}}}, + "dist": "other_value", + } + }, + { + "a": { + "b": {"c": {"d": {"first": "DOGE", "second": "should not matter"}}} + }, + "dist": "other_value", + }, + { + "a": { + "b": {"c": {"d": {"first": "XSA", "second": "should not matter"}}}, + "dist": "other_value", + } + }, + { + "a": { + "b": { + "c": {"d": {"first": "TEST", "second": "should not matter"}}, + "dist": "other_value", + } + } + }, + ] + result = mapping.extract_value(extract_list) + assert value_list == result + + def test_extract_values_dict_values(self): + """ Test of extract values for the special case that each key of a + dictionary holds the values.""" + mapping = Mapping("first_currency", ["dict_values"], ["str"]) + + extract_dict = {"1": "XRP", 2: "ETH", "3": "BTC", 4: "DOGE"} + result = mapping.extract_value(extract_dict) + value_list = ["XRP", "ETH", "BTC", "DOGE"] + assert value_list == result + + # extracting dicts with dict_values -> aka flattening the json + mapping = Mapping("first_currency", ["dict_values", "first"], ["str"]) + + extract_dict = { + "1": {"first": "XRP", "second": "Whatever"}, + 2: {"first": "ETH", "second": "Whatever"}, + "3": {"first": "BTC", "second": "Whatever"}, + 4: {"first": "DOGE", "second": "Whatever"}, + } + result = mapping.extract_value(extract_dict) + value_list = ["XRP", "ETH", "BTC", "DOGE"] + assert value_list == result + + # How to not use dict_values, since other values will be filtered also + mapping = Mapping( + "first_currency", + ["dict_values", "dict_values", "dict_values", "dict_values", "first"], + ["str"], + ) + extract_list = [ + { + "a": { + "b": { + "c": { + "d": {"first": "BTC", "second": "should not matter"}, + "dist": "other_value", + } + } + } + }, + { + "a": { + "b": { + "c": {"d": {"first": "ETH", "second": "should not matter"}}, + "dist": "other_value", + } + } + }, + { + "a": { + "b": {"c": {"d": {"first": "XRP", "second": "should not matter"}}}, + "dist": "other_value", + } + }, + { + "a": { + "b": {"c": {"d": {"first": "DOGE", "second": "should not matter"}}} + }, + "dist": "other_value", + }, + { + "a": { + "b": {"c": {"d": {"first": "XSA", "second": "should not matter"}}}, + "dist": "other_value", + } + }, + { + "a": { + "b": { + "c": {"d": {"first": "TEST", "second": "should not matter"}}, + "dist": "other_value", + } + } + }, + ] + + with pytest.raises(TypeError): + mapping.extract_value(extract_list) + + def test_extract_value_list_containing_dict_where_key_is_value(self): + """ Test of extract value for a list that contains a dict that contains a dict. + The first dict only has one key, which is the value we search for.""" + mapping = Mapping("second_currency", ["dict_key"], ["str", "split", "_", 1]) + extract_list = [ + {"btc_eth": {"other": "values"}}, + {"btc_eur": {"other": "values"}}, + {"btc_usd": {"other": "values"}}, + {"btc_usdt": {"other": "values"}}, + ] + value_list = ["eth", "eur", "usd", "usdt"] + result = mapping.extract_value(extract_list) + assert value_list == result + + def test_extract_value_list_containing_dict_where_pair_is_key_to_values(self): + """ Test of extract value for a list that contains dicts that hold + a single dict. The key is the formatted currency pair that is needed + to gain access to the value.""" + mapping = Mapping("value", ["currency_pair", 1], ["str", "float"]) + extract_dict = { + "btc_eth": {1: "123.456"}, + "btc_xrp": {1: "789.101"}, + "xrp_eth": {1: "112.131"}, + "doge_btc": {1: "415.161"}, + } + value_list = [415.161, 112.131, 789.101, 123.456] + + # note that currency pair infos are from bottom to top + # if compared to extract_dict + currency_pair_infos = ( + ("doge", "BTC", "doge_btc"), + ("xrp", "eth", "xrp_eth"), + ("btc", "xrp", "btc_xrp"), + ("btc", "eth", "btc_eth"), + ) + + result = [] + for currency_pair_info in currency_pair_infos: + result.append( + mapping.extract_value( + extract_dict, currency_pair_info=currency_pair_info + ) + ) + assert value_list == result + + def test_extract_value_dict_containing_list(self): + """ Test of extract value where the response is a dict and the + known key contains a list of the values.""" + mapping = Mapping("first_currency", ["data"], ["str", "split", "_", 0]) + extract_dict = { + "data": ["eth_btc", "usd_btc", "xrp_eth", "eth_xrp"], + "other_stuff": "that does not matter", + } + value_list = ["eth", "usd", "xrp", "eth"] + result = mapping.extract_value(extract_dict) + assert value_list == result + + def test_extract_value_dict_containing_list_containing_dict_with_value(self): + """ Test of extract value where the response is a dict and + a known key contains a list of dicts that hold the value.""" + + mapping = Mapping("value", ["data", "value"], ["str", "float"]) + extract_dict = { + "data": [ + {"value": "1.12"}, + {"value": "1.44"}, + {"value": "1.34"}, + {"value": "1.89"}, + ] + } + value_list = [1.12, 1.44, 1.34, 1.89] + result = mapping.extract_value(extract_dict) + assert value_list == result + + def test_extract_value_dict_containing_list_containing_dict_where_key_is_value( + self, + ): + """ Test of extract value where the response is a dict and a known key + contains a list of dicts with a single key that is the value.""" + mapping = Mapping( + "second_currency", ["data", "dict_key"], ["str", "split", "_", 1] + ) + extract_dict = { + "data": [ + {"eth_btc": {"other": "values"}}, + {"btc_xrp": {"other": "values"}}, + {"tsla_usd": {"other": "values"}}, + {"usdt_eth": {"other": "values"}}, + ] + } + value_list = ["btc", "xrp", "usd", "eth"] + result = mapping.extract_value(extract_dict) + assert value_list == result + + +class TestUtilities: + """ Test class for the utility functions.""" + + def test_yaml_loader(self): + """ Test the yaml-file loader. """ + + with pytest.raises(ValueError): + # Should except the FileNotFoundError and raise a ValueError instead. + yaml_loader("some_unsupported_exchange") + # Raise a ValueError directly. + yaml_loader() + + def test_replace_list_item(self): + """ Test to replace a specific value form a list.""" + + condition = 5 + replace_list = [1, 5, 6, 7, 8, 9] + new_list = replace_list_item(replace_list, condition, 999) + + assert new_list == [1, 999, 6, 7, 8, 9] + + def test_split_str_to_list(self): + """ Test split a string into a list""" + + string = "btc- usd, btc-usd,btc - usd, btc-u s d , btc-usd" + list_values = split_str_to_list(string) + + assert list_values == list(itertools.repeat("btc-usd", 5)) + + def test_sort_columns(self): + """ Test to sort the columns of the response.""" + + ordered_cols = ["open", "high", "low", "close"] + response = pd.DataFrame( + { + "high": range(0, 5), + "close": range(0, 5), + "open": range(0, 5), + "low": range(0, 5), + } + ) + response = sort_columns(dataframe=response) + + assert all(ordered_cols == response.columns) diff --git a/requirements.txt b/requirements.txt index 25c6f68a..ccd7756b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,7 @@ lxml pandas>=0.23 requests>=2.19.0 +pytz +datetime_periods +pyyaml +python-dateutil \ No newline at end of file