├── .idea └── vcs.xml ├── LICENSE.md ├── MANIFEST ├── README.md ├── ccs ├── __init__.py ├── abstract.py ├── bitfinex │ ├── __init__.py │ ├── configuration.py │ └── public │ │ ├── __init__.py │ │ └── response.py ├── bitstamp │ ├── __init__.py │ ├── configuration.py │ └── public │ │ ├── __init__.py │ │ └── response.py ├── bittrex │ ├── __init__.py │ ├── configuration.py │ └── public │ │ ├── __init__.py │ │ └── response.py ├── btcc │ ├── __init__.py │ ├── configuration.py │ └── public │ │ ├── __init__.py │ │ └── response.py ├── btccpro │ ├── __init__.py │ ├── configuration.py │ └── public │ │ ├── __init__.py │ │ └── response.py ├── btccusd │ ├── __init__.py │ ├── configuration.py │ └── public │ │ ├── __init__.py │ │ └── response.py ├── btce │ ├── __init__.py │ ├── configuration.py │ └── public │ │ ├── __init__.py │ │ └── response.py ├── bter │ ├── __init__.py │ ├── configuration.py │ └── public │ │ ├── __init__.py │ │ └── response.py ├── cexio │ ├── __init__.py │ ├── configuration.py │ └── public │ │ ├── __init__.py │ │ └── response.py ├── constants.py ├── core.py ├── default.py ├── initials.py ├── kraken │ ├── __init__.py │ ├── configuration.py │ └── public │ │ ├── __init__.py │ │ └── response.py ├── logger.py ├── okcoin │ ├── __init__.py │ ├── configuration.py │ └── public │ │ ├── __init__.py │ │ └── response.py ├── okcoincn │ ├── __init__.py │ ├── configuration.py │ └── public │ │ ├── __init__.py │ │ └── response.py ├── okcoincom │ ├── __init__.py │ ├── configuration.py │ └── public │ │ ├── __init__.py │ │ └── response.py └── poloniex │ ├── __init__.py │ ├── configuration.py │ └── public │ ├── __init__.py │ └── response.py ├── dev ├── __init__.py ├── bit2c │ ├── __init__.py │ ├── configuration.py │ └── public │ │ ├── __init__.py │ │ └── response.py ├── bitbay │ ├── __init__.py │ ├── configuration.py │ └── public │ │ ├── __init__.py │ │ └── response.py ├── bitkonan │ ├── __init__.py │ ├── configuration.py │ └── public │ │ ├── __init__.py │ │ └── response.py ├── bitmarket │ ├── __init__.py │ ├── configuration.py │ └── public │ │ ├── __init__.py │ │ └── response.py ├── bitnz │ ├── __init__.py │ ├── configuration.py │ └── public │ │ ├── __init__.py │ │ └── response.py ├── btcmarkets │ ├── __init__.py │ ├── configuration.py │ └── public │ │ ├── __init__.py │ │ └── response.py ├── campbx │ ├── __init__.py │ ├── configuration.py │ └── public │ │ ├── __init__.py │ │ └── response.py ├── coinfloor │ ├── __init__.py │ ├── configuration.py │ └── public │ │ ├── __init__.py │ │ └── response.py ├── exmo │ ├── __init__.py │ ├── configuration.py │ └── public │ │ ├── __init__.py │ │ └── response.py ├── fyb │ ├── __init__.py │ ├── configuration.py │ └── public │ │ ├── __init__.py │ │ └── response.py ├── fybse │ ├── __init__.py │ ├── configuration.py │ └── public │ │ ├── __init__.py │ │ └── response.py ├── fybsg │ ├── __init__.py │ ├── configuration.py │ └── public │ │ ├── __init__.py │ │ └── response.py ├── hitbtc │ ├── __init__.py │ ├── configuration.py │ └── public │ │ ├── __init__.py │ │ └── response.py ├── huobi │ ├── __init__.py │ ├── configuration.py │ └── public │ │ ├── __init__.py │ │ └── response.py ├── itbit │ ├── __init__.py │ ├── configuration.py │ └── public │ │ ├── __init__.py │ │ └── response.py ├── lakebtc │ ├── __init__.py │ ├── configuration.py │ └── public │ │ ├── __init__.py │ │ └── response.py ├── localbitcoins │ ├── __init__.py │ ├── configuration.py │ └── public │ │ ├── __init__.py │ │ └── response.py ├── mercadobitcoin │ ├── __init__.py │ ├── configuration.py │ └── public │ │ ├── __init__.py │ │ └── response.py └── therocktraiding │ ├── __init__.py │ ├── configuration.py │ └── public │ ├── __init__.py │ └── response.py ├── doc ├── Makefile ├── make.bat └── source │ ├── bitfinex.rst │ ├── bitstamp.rst │ ├── bittrex.rst │ ├── btcc.rst │ ├── btccpro.rst │ ├── btccusd.rst │ ├── btce.rst │ ├── bter.rst │ ├── cexio.rst │ ├── conf.py │ ├── configuration.rst │ ├── constants.rst │ ├── general_informations.rst │ ├── index.rst │ ├── instalation.rst │ ├── kraken.rst │ ├── okcoin.rst │ ├── orderbook.rst │ ├── overview.rst │ ├── poloniex.rst │ ├── ticker.rst │ ├── trades.rst │ └── warnings.rst ├── empty ├── __init__.py ├── configuration.py └── public │ ├── __init__.py │ └── response.py ├── requirements.txt ├── setup.cfg ├── setup.py └── tests ├── __init__.py ├── testAdapter ├── __init__.py ├── testBitfinex │ ├── __init__.py │ ├── testOrder.py │ ├── testOrderbook.py │ ├── testOrders.py │ ├── testTicker.py │ ├── testTrade.py │ └── testTrades.py ├── testBitstamp │ ├── __init__.py │ ├── testOrder.py │ ├── testOrderbook.py │ ├── testOrders.py │ ├── testTicker.py │ ├── testTrade.py │ └── testTrades.py ├── testBittrex │ ├── __init__.py │ ├── testOrder.py │ ├── testOrderbook.py │ ├── testOrders.py │ ├── testTicker.py │ ├── testTrade.py │ └── testTrades.py ├── testBtcc │ ├── __init__.py │ ├── testOrder.py │ ├── testOrderbook.py │ ├── testOrders.py │ ├── testTicker.py │ ├── testTrade.py │ └── testTrades.py ├── testBtccpro │ ├── __init__.py │ ├── testOrder.py │ ├── testOrderbook.py │ ├── testOrders.py │ ├── testTicker.py │ ├── testTrade.py │ └── testTrades.py ├── testBtccusd │ ├── __init__.py │ ├── testOrder.py │ ├── testOrderbook.py │ ├── testOrders.py │ ├── testTicker.py │ ├── testTrade.py │ └── testTrades.py ├── testBtce │ ├── __init__.py │ ├── testOrder.py │ ├── testOrderbook.py │ ├── testOrders.py │ ├── testTicker.py │ ├── testTrade.py │ └── testTrades.py ├── testBter │ ├── __init__.py │ ├── testOrder.py │ ├── testOrderbook.py │ ├── testOrders.py │ ├── testTicker.py │ ├── testTrade.py │ └── testTrades.py ├── testCexio │ ├── __init__.py │ ├── testOrder.py │ ├── testOrderbook.py │ ├── testOrders.py │ ├── testTicker.py │ ├── testTrade.py │ └── testTrades.py ├── testKraken │ ├── __init__.py │ ├── testOrder.py │ ├── testOrderbook.py │ ├── testOrders.py │ ├── testTicker.py │ ├── testTrade.py │ └── testTrades.py ├── testOkcoincn │ ├── __init__.py │ ├── testOrder.py │ ├── testOrderbook.py │ ├── testOrders.py │ ├── testTicker.py │ ├── testTrade.py │ └── testTrades.py ├── testOkcoincom │ ├── __init__.py │ ├── testOrder.py │ ├── testOrderbook.py │ ├── testOrders.py │ ├── testTicker.py │ ├── testTrade.py │ └── testTrades.py └── testPoloniex │ ├── __init__.py │ ├── testOrder.py │ ├── testOrderbook.py │ ├── testOrders.py │ ├── testTicker.py │ ├── testTrade.py │ └── testTrades.py ├── testApi ├── __init__.py └── testPublic │ ├── __init__.py │ ├── testBitfinex │ ├── __init__.py │ ├── testFundingbook.py │ ├── testLends.py │ ├── testOrderbook.py │ ├── testStats.py │ ├── testSymbols.py │ ├── testSymbolsDetails.py │ ├── testTicker.py │ └── testTrades.py │ ├── testBitstamp │ ├── __init__.py │ ├── testEurUsdConversionRate.py │ ├── testHourlyTicker.py │ ├── testOrderbook.py │ ├── testTicker.py │ └── testTransactions.py │ ├── testBittrex │ ├── __init__.py │ ├── testCurrencies.py │ ├── testHistory.py │ ├── testMarkets.py │ ├── testOrderbook.py │ ├── testSummaries.py │ ├── testSummary.py │ └── testTicker.py │ ├── testBtcc │ ├── __init__.py │ ├── testOrderbook.py │ ├── testTicker.py │ ├── testTradeHistory.py │ └── testTrades.py │ ├── testBtccpro │ ├── __init__.py │ ├── testOrderbook.py │ ├── testTicker.py │ └── testTradeHistory.py │ ├── testBtccusd │ ├── __init__.py │ ├── testOrderbook.py │ ├── testTicker.py │ └── testTradeHistory.py │ ├── testBtce │ ├── __init__.py │ ├── testDepth.py │ ├── testInfo.py │ ├── testTicker.py │ └── testTrades.py │ ├── testBter │ ├── __init__.py │ ├── testDepth.py │ ├── testMarketDetails.py │ ├── testMarketInfo.py │ ├── testTicker.py │ ├── testTickers.py │ ├── testTradeHistory.py │ └── testTradingPairs.py │ ├── testCexio │ ├── __init__.py │ ├── testLimits.py │ ├── testOrderbook.py │ ├── testPrice.py │ ├── testPrices.py │ ├── testTicker.py │ ├── testTickers.py │ └── testTrades.py │ ├── testKraken │ ├── __init__.py │ ├── testAssetinfo.py │ ├── testOhlc.py │ ├── testOrderbook.py │ ├── testPairs.py │ ├── testServertime.py │ ├── testSpread.py │ ├── testTicker.py │ └── testTrades.py │ ├── testOkcoincn │ ├── __init__.py │ ├── testDepth.py │ ├── testTicker.py │ └── testTrades.py │ ├── testOkcoincom │ ├── __init__.py │ ├── testDepth.py │ ├── testTicker.py │ └── testTrades.py │ └── testPoloniex │ ├── __init__.py │ ├── test24hvolume.py │ ├── testChart.py │ ├── testCurrencies.py │ ├── testLoan.py │ ├── testOrderbook.py │ ├── testTicker.py │ └── testTrades.py └── testResponse ├── __init__.py ├── testBitfinex ├── __init__.py ├── testTicker.py ├── testTrade.py └── testTrades.py ├── testBitstamp ├── __init__.py └── testTicker.py ├── testBittrex ├── __init__.py └── testTicker.py ├── testBtcc ├── __init__.py └── testTicker.py ├── testBtccpro ├── __init__.py ├── testOrder.py ├── testOrderbook.py ├── testOrders.py ├── testTicker.py ├── testTrade.py └── testTrades.py ├── testBtccusd ├── __init__.py ├── testOrder.py ├── testOrderbook.py ├── testOrders.py ├── testTicker.py ├── testTrade.py └── testTrades.py ├── testBtce ├── __init__.py └── testTicker.py ├── testBter ├── __init__.py └── testTicker.py ├── testCexio ├── __init__.py └── testTicker.py ├── testKraken ├── __init__.py └── testTicker.py ├── testOkcoincn ├── __init__.py └── testTicker.py ├── testOkcoincom ├── __init__.py └── testTicker.py └── testPoloniex ├── __init__.py └── testTicker.py /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /ccs/default.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf8 -*- 2 | 3 | # TODO 4 | """ 5 | ... 6 | """ 7 | 8 | __author__ = "Jan Seda" 9 | __copyright__ = "Copyright (C) Jan Seda" 10 | __credits__ = [] 11 | __license__ = "" 12 | __version__ = "0.1" 13 | __maintainer__ = "Jan Seda" 14 | __email__ = "" 15 | __status__ = "Production" 16 | 17 | from .constants import * 18 | 19 | 20 | def complete(default, extension): 21 | for key in default: 22 | if key in extension: 23 | continue 24 | else: 25 | extension[key] = default[key] 26 | 27 | HEADER = {'Connection': 'keep-alive', 28 | 'Cache-Control': 'no-cache', 29 | 'Accept': 'application/json', 30 | 'Accept-Charset': UTF8, 31 | 'Content-Type': 'application/x-www-form-urlencoded'} 32 | 33 | TIMEOUT = 20 34 | 35 | TICKER = {LOW: 'low', 36 | HIGH: 'high', 37 | ASK: 'ask', 38 | BID: 'bid', 39 | LAST: 'last', 40 | VOLUME24H: 'volume24h', 41 | TIMESTAMP: 'timestamp'} 42 | 43 | TRADE = {TID: "tid", 44 | PRICE: "price", 45 | AMOUNT: "amount", 46 | TIMESTAMP: "timestamp"} 47 | 48 | ORDER = {PRICE: "price", AMOUNT: "amount"} -------------------------------------------------------------------------------- /ccs/logger.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf8 -*- 2 | 3 | # TODO 4 | """ 5 | ... 6 | """ 7 | 8 | __author__ = "Jan Seda" 9 | __copyright__ = "Copyright (C) Jan Seda" 10 | __credits__ = [] 11 | __license__ = "" 12 | __version__ = "0.1" 13 | __maintainer__ = "Jan Seda" 14 | __email__ = "" 15 | __status__ = "Production" 16 | 17 | import logging 18 | import logging.handlers 19 | from . import initials 20 | 21 | def inicialization(): 22 | name = initials.LOGGER_NAME 23 | format = initials.LOGGER_FORMAT 24 | timeformat = initials.LOGGER_TIMEFORMAT 25 | 26 | logger = logging.getLogger(name) 27 | logger.setLevel(logging.DEBUG) 28 | removeAllHandlers(logger) 29 | setConsoleOutput(logger, format, timeformat) 30 | return logger 31 | 32 | def removeAllHandlers(logger): 33 | for hdlr in logger.handlers: 34 | logger.removeHandler(hdlr) 35 | 36 | def setConsoleOutput(logger, format, timeformat): 37 | ch = logging.StreamHandler() 38 | ch.setLevel(logging.DEBUG) 39 | ch.setFormatter(logging.Formatter(format, timeformat)) ## 40 | logger.addHandler(ch) 41 | 42 | 43 | -------------------------------------------------------------------------------- /ccs/okcoincn/public/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf8 -*- 2 | 3 | """ 4 | This file contains configuration for Okcoin.cn stock. 5 | """ 6 | 7 | __author__ = "Jan Seda" 8 | __copyright__ = "Copyright (C) Jan Seda" 9 | __credits__ = [] 10 | __license__ = "" 11 | __version__ = "0.1" 12 | __maintainer__ = "Jan Seda" 13 | __email__ = "" 14 | __status__ = "Production" 15 | 16 | import urllib.parse 17 | import inspect 18 | 19 | from ... import core 20 | from ... import constants 21 | from . import response 22 | import sys 23 | 24 | # !! WARN This recover response from okcoin. 25 | # from ...okcoin.public import * 26 | 27 | from ...okcoin.public import ticker 28 | from ...okcoin.public import trades 29 | from ...okcoin.public import depth 30 | from ...okcoin.public import kline 31 | 32 | TICKER_METHOD = inspect.getsource(ticker) 33 | exec(TICKER_METHOD) 34 | 35 | TRADES_METHOD = inspect.getsource(trades) 36 | exec(TRADES_METHOD) 37 | 38 | DEPTH_METHOD = inspect.getsource(depth) 39 | exec(DEPTH_METHOD) 40 | 41 | KLINE_METHOD = inspect.getsource(kline) 42 | exec(KLINE_METHOD) 43 | 44 | -------------------------------------------------------------------------------- /ccs/okcoincom/public/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf8 -*- 2 | 3 | """ 4 | This file contains configuration for Okcoin.com stock. 5 | """ 6 | 7 | __author__ = "Jan Seda" 8 | __copyright__ = "Copyright (C) Jan Seda" 9 | __credits__ = [] 10 | __license__ = "" 11 | __version__ = "0.1" 12 | __maintainer__ = "Jan Seda" 13 | __email__ = "" 14 | __status__ = "Production" 15 | 16 | import urllib.parse 17 | import inspect 18 | 19 | from ... import core 20 | from ... import constants 21 | from . import response 22 | import sys 23 | 24 | # !! WARN This recover response from okcoin. 25 | # from ...okcoin.public import * 26 | 27 | from ...okcoin.public import ticker 28 | from ...okcoin.public import trades 29 | from ...okcoin.public import depth 30 | from ...okcoin.public import kline 31 | 32 | TICKER_METHOD = inspect.getsource(ticker) 33 | exec(TICKER_METHOD) 34 | 35 | TRADES_METHOD = inspect.getsource(trades) 36 | exec(TRADES_METHOD) 37 | 38 | DEPTH_METHOD = inspect.getsource(depth) 39 | exec(DEPTH_METHOD) 40 | 41 | KLINE_METHOD = inspect.getsource(kline) 42 | exec(KLINE_METHOD) 43 | 44 | -------------------------------------------------------------------------------- /dev/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Honzin/ccs/c02a1ce2e2a829f2eebe6d6eb39174939a807646/dev/__init__.py -------------------------------------------------------------------------------- /dev/bit2c/__init__.py: -------------------------------------------------------------------------------- 1 | from ccs import abstract 2 | 3 | from . import public 4 | from . import configuration 5 | 6 | 7 | class Symbol(abstract.Symbol): 8 | def __init__(self, cur1, cur2): 9 | self._cur1 = cur1 10 | self._cur2 = cur2 11 | 12 | def base(self): 13 | return self.normalize(self._cur1) 14 | 15 | def quote(self): 16 | return self.normalize(self._cur2) 17 | 18 | def normalize(self, cur): 19 | return cur.lower().strip() 20 | 21 | def __str__(self): 22 | return self.normalize(self._cur1) + self.normalize(self._cur2) 23 | 24 | 25 | class Adapter(abstract.Adapter): 26 | @staticmethod 27 | def ticker(cur1, cur2): 28 | symbol = Symbol(cur1, cur2) 29 | s = str(symbol) 30 | return public.response.Ticker(public.ticker(s), s) 31 | 32 | @staticmethod 33 | def trades(cur1, cur2, limit=None, direction=None): 34 | symbol = Symbol(cur1, cur2) 35 | s = str(symbol) 36 | return public.response.Trades(public.trades(s), s) 37 | 38 | @staticmethod 39 | def orderbook(cur1, cur2, limit=None): 40 | symbol = Symbol(cur1, cur2) 41 | s = str(symbol) 42 | return public.response.OrderBook(public.orderbook(s), s) 43 | -------------------------------------------------------------------------------- /dev/bit2c/public/__init__.py: -------------------------------------------------------------------------------- 1 | import urllib.parse 2 | import sys 3 | from ccs import core 4 | from ccs import constants 5 | from . import response 6 | 7 | def ticker(cur1, cur2): 8 | s = __name__.split(".")[1] 9 | r = sys._getframe().f_code.co_name 10 | 11 | symbol = cur1.capitalize() + cur2.capitalize() 12 | 13 | # complete request 14 | cr = core.request(s, r).replace(constants.SYMBOL_PATTERN, symbol) 15 | 16 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) 17 | 18 | 19 | def trades(cur1, cur2,since=None): 20 | s = __name__.split(".")[1] 21 | r = sys._getframe().f_code.co_name 22 | 23 | symbol = cur1.capitalize() + cur2.capitalize() 24 | 25 | params = {} 26 | 27 | if since: 28 | params["since"] = since 29 | 30 | # complete request 31 | cr = core.request(s, r).replace(constants.SYMBOL_PATTERN, symbol) + urllib.parse.urlencode(params) 32 | 33 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) 34 | 35 | 36 | def orderbook(cur1, cur2): 37 | s = __name__.split(".")[1] 38 | r = sys._getframe().f_code.co_name 39 | 40 | symbol = cur1.capitalize() + cur2.capitalize() 41 | 42 | # complete request 43 | cr = core.request(s, r).replace(constants.SYMBOL_PATTERN, symbol) 44 | 45 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) -------------------------------------------------------------------------------- /dev/bit2c/public/response.py: -------------------------------------------------------------------------------- 1 | from ccs import abstract 2 | from ccs import constants 3 | 4 | 5 | ################################################################################## 6 | # TICKER # 7 | ################################################################################## 8 | 9 | class Ticker(abstract.Ticker): 10 | pass 11 | 12 | 13 | ################################################################################## 14 | # TRADES # 15 | ################################################################################## 16 | 17 | class Trade(abstract.Trade): 18 | pass 19 | 20 | class Trades(abstract.Trades): 21 | def __getitem__(self, item): 22 | return Trade(self._data[item], self._symbol) 23 | 24 | 25 | 26 | ################################################################################## 27 | # ORDERBOOK # 28 | ################################################################################## 29 | 30 | class Order(abstract.Order): 31 | pass 32 | 33 | class Orders(abstract.Orders): 34 | def __getitem__(self, item): 35 | return Order(self._data[item]) 36 | 37 | class OrderBook(abstract.OrderBook): 38 | def loadAsks(self): 39 | self._asks = Orders(self._data["asks"]) 40 | 41 | def loadBids(self): 42 | self._bids = Orders(self._data["bids"]) -------------------------------------------------------------------------------- /dev/bitbay/__init__.py: -------------------------------------------------------------------------------- 1 | from ccs import abstract 2 | 3 | from . import public 4 | from . import configuration 5 | 6 | 7 | class Symbol(abstract.Symbol): 8 | def __init__(self, cur1, cur2): 9 | self._cur1 = cur1 10 | self._cur2 = cur2 11 | 12 | def base(self): 13 | return self.normalize(self._cur1) 14 | 15 | def quote(self): 16 | return self.normalize(self._cur2) 17 | 18 | def normalize(self, cur): 19 | return cur.lower().strip() 20 | 21 | def __str__(self): 22 | return self.normalize(self._cur1) + self.normalize(self._cur2) 23 | 24 | 25 | class Adapter(abstract.Adapter): 26 | @staticmethod 27 | def ticker(cur1, cur2): 28 | symbol = Symbol(cur1, cur2) 29 | s = str(symbol) 30 | return public.response.Ticker(public.ticker(s), s) 31 | 32 | @staticmethod 33 | def trades(cur1, cur2, limit=None, direction=None): 34 | symbol = Symbol(cur1, cur2) 35 | s = str(symbol) 36 | return public.response.Trades(public.trades(s), s) 37 | 38 | @staticmethod 39 | def orderbook(cur1, cur2, limit=None): 40 | symbol = Symbol(cur1, cur2) 41 | s = str(symbol) 42 | return public.response.OrderBook(public.orderbook(s), s) 43 | -------------------------------------------------------------------------------- /dev/bitbay/public/response.py: -------------------------------------------------------------------------------- 1 | from ccs import abstract 2 | from ccs import constants 3 | 4 | 5 | ################################################################################## 6 | # TICKER # 7 | ################################################################################## 8 | 9 | class Ticker(abstract.Ticker): 10 | pass 11 | 12 | 13 | ################################################################################## 14 | # TRADES # 15 | ################################################################################## 16 | 17 | class Trade(abstract.Trade): 18 | pass 19 | 20 | class Trades(abstract.Trades): 21 | def __getitem__(self, item): 22 | return Trade(self._data[item], self._symbol) 23 | 24 | 25 | 26 | ################################################################################## 27 | # ORDERBOOK # 28 | ################################################################################## 29 | 30 | class Order(abstract.Order): 31 | pass 32 | 33 | class Orders(abstract.Orders): 34 | def __getitem__(self, item): 35 | return Order(self._data[item]) 36 | 37 | class OrderBook(abstract.OrderBook): 38 | def loadAsks(self): 39 | self._asks = Orders(self._data["asks"]) 40 | 41 | def loadBids(self): 42 | self._bids = Orders(self._data["bids"]) -------------------------------------------------------------------------------- /dev/bitkonan/__init__.py: -------------------------------------------------------------------------------- 1 | from ccs import abstract 2 | 3 | from . import public 4 | from . import configuration -------------------------------------------------------------------------------- /dev/bitkonan/public/__init__.py: -------------------------------------------------------------------------------- 1 | import urllib.parse 2 | import sys 3 | 4 | from ccs import core 5 | from ccs import constants 6 | from . import response 7 | 8 | def btcticker(): 9 | s = __name__.split(".")[1] 10 | r = sys._getframe().f_code.co_name 11 | 12 | # complete request 13 | cr = core.request(s, r) 14 | 15 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) 16 | 17 | def ltcticker(): 18 | s = __name__.split(".")[1] 19 | r = sys._getframe().f_code.co_name 20 | 21 | # complete request 22 | cr = core.request(s, r) 23 | 24 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) 25 | 26 | 27 | def btctransactions(): 28 | s = __name__.split(".")[1] 29 | r = sys._getframe().f_code.co_name 30 | 31 | # complete request 32 | cr = core.request(s, r) 33 | 34 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) 35 | 36 | def ltctransactions(): 37 | s = __name__.split(".")[1] 38 | r = sys._getframe().f_code.co_name 39 | 40 | # complete request 41 | cr = core.request(s, r) 42 | 43 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) 44 | 45 | 46 | def btcorderbook(): 47 | s = __name__.split(".")[1] 48 | r = sys._getframe().f_code.co_name 49 | 50 | # complete request 51 | cr = core.request(s, r) 52 | 53 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) 54 | 55 | def ltcorderbook(): 56 | s = __name__.split(".")[1] 57 | r = sys._getframe().f_code.co_name 58 | 59 | # complete request 60 | cr = core.request(s, r) 61 | 62 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) 63 | -------------------------------------------------------------------------------- /dev/bitkonan/public/response.py: -------------------------------------------------------------------------------- 1 | import json 2 | import time 3 | 4 | from ccs import abstract 5 | from ccs import constants 6 | 7 | 8 | ################################################################################## 9 | # TICKER # 10 | ################################################################################## 11 | 12 | class Ticker(abstract.Ticker): 13 | def _load(self, raw): 14 | # IMPROVE - TOHLE JE JEN PRO TESTOVANI 15 | self._data = json.loads(raw) # TEST 16 | self._ts = time.time() 17 | 18 | def timestamp(self): 19 | return self._ts 20 | 21 | 22 | ################################################################################## 23 | # TRADES # 24 | ################################################################################## 25 | 26 | class Trade(abstract.Trade): 27 | pass 28 | 29 | class Trades(abstract.Trades): 30 | def __getitem__(self, item): 31 | return Trade(self._data[item], self._symbol) 32 | 33 | 34 | 35 | ################################################################################## 36 | # ORDERBOOK # 37 | ################################################################################## 38 | 39 | class Order(abstract.Order): 40 | pass 41 | 42 | class Orders(abstract.Orders): 43 | def __getitem__(self, item): 44 | return Order(self._data[item]) 45 | 46 | class OrderBook(abstract.OrderBook): 47 | def loadAsks(self): 48 | self._asks = Orders(self._data["asks"]) 49 | 50 | def loadBids(self): 51 | self._bids = Orders(self._data["bids"]) -------------------------------------------------------------------------------- /dev/bitmarket/__init__.py: -------------------------------------------------------------------------------- 1 | from ccs import abstract 2 | 3 | from . import public 4 | from . import configuration 5 | 6 | 7 | class Symbol(abstract.Symbol): 8 | def __init__(self, cur1, cur2): 9 | self._cur1 = cur1 10 | self._cur2 = cur2 11 | 12 | def base(self): 13 | return self.normalize(self._cur1) 14 | 15 | def quote(self): 16 | return self.normalize(self._cur2) 17 | 18 | def normalize(self, cur): 19 | return cur.lower().strip() 20 | 21 | def __str__(self): 22 | return self.normalize(self._cur1) + self.normalize(self._cur2) 23 | 24 | 25 | class Adapter(abstract.Adapter): 26 | @staticmethod 27 | def ticker(cur1, cur2): 28 | symbol = Symbol(cur1, cur2) 29 | s = str(symbol) 30 | return public.response.Ticker(public.ticker(s), s) 31 | 32 | @staticmethod 33 | def trades(cur1, cur2, limit=None, direction=None): 34 | symbol = Symbol(cur1, cur2) 35 | s = str(symbol) 36 | return public.response.Trades(public.trades(s), s) 37 | 38 | @staticmethod 39 | def orderbook(cur1, cur2, limit=None): 40 | symbol = Symbol(cur1, cur2) 41 | s = str(symbol) 42 | return public.response.OrderBook(public.orderbook(s), s) 43 | -------------------------------------------------------------------------------- /dev/bitmarket/public/response.py: -------------------------------------------------------------------------------- 1 | from ccs import abstract 2 | from ccs import constants 3 | 4 | 5 | ################################################################################## 6 | # TICKER # 7 | ################################################################################## 8 | 9 | class Ticker(abstract.Ticker): 10 | pass 11 | 12 | 13 | ################################################################################## 14 | # TRADES # 15 | ################################################################################## 16 | 17 | class Trade(abstract.Trade): 18 | pass 19 | 20 | class Trades(abstract.Trades): 21 | def __getitem__(self, item): 22 | return Trade(self._data[item], self._symbol) 23 | 24 | 25 | 26 | ################################################################################## 27 | # ORDERBOOK # 28 | ################################################################################## 29 | 30 | class Order(abstract.Order): 31 | pass 32 | 33 | class Orders(abstract.Orders): 34 | def __getitem__(self, item): 35 | return Order(self._data[item]) 36 | 37 | class OrderBook(abstract.OrderBook): 38 | def loadAsks(self): 39 | self._asks = Orders(self._data["asks"]) 40 | 41 | def loadBids(self): 42 | self._bids = Orders(self._data["bids"]) -------------------------------------------------------------------------------- /dev/bitnz/__init__.py: -------------------------------------------------------------------------------- 1 | from ccs import abstract 2 | 3 | from . import public 4 | from . import configuration 5 | 6 | 7 | class Symbol(abstract.Symbol): 8 | def __init__(self, cur1, cur2): 9 | self._cur1 = cur1 10 | self._cur2 = cur2 11 | 12 | def base(self): 13 | return self.normalize(self._cur1) 14 | 15 | def quote(self): 16 | return self.normalize(self._cur2) 17 | 18 | def normalize(self, cur): 19 | return cur.lower().strip() 20 | 21 | def __str__(self): 22 | return self.normalize(self._cur1) + self.normalize(self._cur2) 23 | 24 | 25 | class Adapter(abstract.Adapter): 26 | @staticmethod 27 | def ticker(cur1, cur2): 28 | symbol = Symbol(cur1, cur2) 29 | s = str(symbol) 30 | return public.response.Ticker(public.ticker(s), s) 31 | 32 | @staticmethod 33 | def trades(cur1, cur2, limit=None, direction=None): 34 | symbol = Symbol(cur1, cur2) 35 | s = str(symbol) 36 | return public.response.Trades(public.trades(s), s) 37 | 38 | @staticmethod 39 | def orderbook(cur1, cur2, limit=None): 40 | symbol = Symbol(cur1, cur2) 41 | s = str(symbol) 42 | return public.response.OrderBook(public.orderbook(s), s) 43 | -------------------------------------------------------------------------------- /dev/bitnz/public/__init__.py: -------------------------------------------------------------------------------- 1 | import urllib.parse 2 | import sys 3 | 4 | from ccs import core 5 | from ccs import constants 6 | from . import response 7 | 8 | 9 | def ticker(): 10 | s = __name__.split(".")[1] 11 | r = sys._getframe().f_code.co_name 12 | 13 | # complete request 14 | cr = core.request(s, r) 15 | 16 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) 17 | 18 | def trades(): 19 | s = __name__.split(".")[1] 20 | r = sys._getframe().f_code.co_name 21 | 22 | # complete request 23 | cr = core.request(s, r) 24 | 25 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) 26 | 27 | # nejaky problem s kodovanim 28 | # def trades_chart(): 29 | # s = __name__.split(".")[1] 30 | # r = sys._getframe().f_code.co_name 31 | # 32 | # # complete request 33 | # cr = core.request(s, r) 34 | # 35 | # return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) 36 | 37 | def orderbook(): 38 | s = __name__.split(".")[1] 39 | r = sys._getframe().f_code.co_name 40 | 41 | # complete request 42 | cr = core.request(s, r) 43 | 44 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) -------------------------------------------------------------------------------- /dev/bitnz/public/response.py: -------------------------------------------------------------------------------- 1 | from ccs import abstract 2 | from ccs import constants 3 | 4 | 5 | ################################################################################## 6 | # TICKER # 7 | ################################################################################## 8 | 9 | class Ticker(abstract.Ticker): 10 | pass 11 | 12 | 13 | ################################################################################## 14 | # TRADES # 15 | ################################################################################## 16 | 17 | class Trade(abstract.Trade): 18 | pass 19 | 20 | class Trades(abstract.Trades): 21 | def __getitem__(self, item): 22 | return Trade(self._data[item], self._symbol) 23 | 24 | 25 | 26 | ################################################################################## 27 | # ORDERBOOK # 28 | ################################################################################## 29 | 30 | class Order(abstract.Order): 31 | pass 32 | 33 | class Orders(abstract.Orders): 34 | def __getitem__(self, item): 35 | return Order(self._data[item]) 36 | 37 | class OrderBook(abstract.OrderBook): 38 | def loadAsks(self): 39 | self._asks = Orders(self._data["asks"]) 40 | 41 | def loadBids(self): 42 | self._bids = Orders(self._data["bids"]) -------------------------------------------------------------------------------- /dev/btcmarkets/__init__.py: -------------------------------------------------------------------------------- 1 | from ccs import abstract 2 | 3 | from . import public 4 | from . import configuration 5 | 6 | 7 | class Symbol(abstract.Symbol): 8 | def __init__(self, cur1, cur2): 9 | self._cur1 = cur1 10 | self._cur2 = cur2 11 | 12 | def base(self): 13 | return self.normalize(self._cur1) 14 | 15 | def quote(self): 16 | return self.normalize(self._cur2) 17 | 18 | def normalize(self, cur): 19 | return cur.lower().strip() 20 | 21 | def __str__(self): 22 | return self.normalize(self._cur1) + self.normalize(self._cur2) 23 | 24 | 25 | class Adapter(abstract.Adapter): 26 | @staticmethod 27 | def ticker(cur1, cur2): 28 | symbol = Symbol(cur1, cur2) 29 | s = str(symbol) 30 | return public.response.Ticker(public.ticker(s), s) 31 | 32 | @staticmethod 33 | def trades(cur1, cur2, limit=None, direction=None): 34 | symbol = Symbol(cur1, cur2) 35 | s = str(symbol) 36 | return public.response.Trades(public.trades(s), s) 37 | 38 | @staticmethod 39 | def orderbook(cur1, cur2, limit=None): 40 | symbol = Symbol(cur1, cur2) 41 | s = str(symbol) 42 | return public.response.OrderBook(public.orderbook(s), s) 43 | -------------------------------------------------------------------------------- /dev/btcmarkets/public/__init__.py: -------------------------------------------------------------------------------- 1 | import urllib.parse 2 | import sys 3 | 4 | from ccs import core 5 | from ccs import constants 6 | from . import response 7 | 8 | 9 | def tick(cur1, cur2): 10 | s = __name__.split(".")[1] 11 | r = sys._getframe().f_code.co_name 12 | 13 | # complete request 14 | cr = core.request(s, r).replace(constants.CUR1_PATTERN, cur1.strip().upper()) 15 | cr = cr.replace(constants.CUR2_PATTERN, cur2.strip().upper()) 16 | 17 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) 18 | 19 | 20 | def trades(cur1, cur2): 21 | s = __name__.split(".")[1] 22 | r = sys._getframe().f_code.co_name 23 | 24 | # complete request 25 | cr = core.request(s, r).replace(constants.CUR1_PATTERN, cur1.strip().upper()) 26 | cr = cr.replace(constants.CUR2_PATTERN, cur2.strip().upper()) 27 | 28 | 29 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) 30 | 31 | def orderbook(cur1, cur2): 32 | s = __name__.split(".")[1] 33 | r = sys._getframe().f_code.co_name 34 | 35 | # complete request 36 | cr = core.request(s, r).replace(constants.CUR1_PATTERN, cur1.strip().upper()) 37 | cr = cr.replace(constants.CUR2_PATTERN, cur2.strip().upper()) 38 | 39 | 40 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) -------------------------------------------------------------------------------- /dev/btcmarkets/public/response.py: -------------------------------------------------------------------------------- 1 | from ccs import abstract 2 | from ccs import constants 3 | 4 | 5 | ################################################################################## 6 | # TICKER # 7 | ################################################################################## 8 | 9 | class Ticker(abstract.Ticker): 10 | pass 11 | 12 | 13 | ################################################################################## 14 | # TRADES # 15 | ################################################################################## 16 | 17 | class Trade(abstract.Trade): 18 | pass 19 | 20 | class Trades(abstract.Trades): 21 | def __getitem__(self, item): 22 | return Trade(self._data[item], self._symbol) 23 | 24 | 25 | 26 | ################################################################################## 27 | # ORDERBOOK # 28 | ################################################################################## 29 | 30 | class Order(abstract.Order): 31 | pass 32 | 33 | class Orders(abstract.Orders): 34 | def __getitem__(self, item): 35 | return Order(self._data[item]) 36 | 37 | class OrderBook(abstract.OrderBook): 38 | def loadAsks(self): 39 | self._asks = Orders(self._data["asks"]) 40 | 41 | def loadBids(self): 42 | self._bids = Orders(self._data["bids"]) -------------------------------------------------------------------------------- /dev/campbx/__init__.py: -------------------------------------------------------------------------------- 1 | from ccs import abstract 2 | 3 | from . import public 4 | from . import configuration 5 | 6 | 7 | class Symbol(abstract.Symbol): 8 | def __init__(self, cur1, cur2): 9 | self._cur1 = cur1 10 | self._cur2 = cur2 11 | 12 | def base(self): 13 | return self.normalize(self._cur1) 14 | 15 | def quote(self): 16 | return self.normalize(self._cur2) 17 | 18 | def normalize(self, cur): 19 | return cur.lower().strip() 20 | 21 | def __str__(self): 22 | return self.normalize(self._cur1) + self.normalize(self._cur2) 23 | 24 | 25 | class Adapter(abstract.Adapter): 26 | @staticmethod 27 | def ticker(cur1, cur2): 28 | symbol = Symbol(cur1, cur2) 29 | s = str(symbol) 30 | return public.response.Ticker(public.ticker(s), s) 31 | 32 | @staticmethod 33 | def trades(cur1, cur2, limit=None, direction=None): 34 | symbol = Symbol(cur1, cur2) 35 | s = str(symbol) 36 | return public.response.Trades(public.trades(s), s) 37 | 38 | @staticmethod 39 | def orderbook(cur1, cur2, limit=None): 40 | symbol = Symbol(cur1, cur2) 41 | s = str(symbol) 42 | return public.response.OrderBook(public.orderbook(s), s) 43 | -------------------------------------------------------------------------------- /dev/campbx/public/__init__.py: -------------------------------------------------------------------------------- 1 | import urllib.parse 2 | import sys 3 | 4 | from ccs import core 5 | from ccs import constants 6 | from . import response 7 | 8 | def xticker(callback=None): 9 | s = __name__.split(".")[1] 10 | r = sys._getframe().f_code.co_name 11 | 12 | params = {} 13 | if callback: 14 | params["callback"] = callback 15 | 16 | # complete request 17 | cr = core.request(s, r) + urllib.parse.urlencode(params) 18 | 19 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) 20 | 21 | 22 | def xdepth(callback=None): 23 | s = __name__.split(".")[1] 24 | r = sys._getframe().f_code.co_name 25 | 26 | params = {} 27 | if callback: 28 | params["callback"] = callback 29 | 30 | # complete request 31 | cr = core.request(s, r) + urllib.parse.urlencode(params) 32 | 33 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) -------------------------------------------------------------------------------- /dev/campbx/public/response.py: -------------------------------------------------------------------------------- 1 | from ccs import abstract 2 | from ccs import constants 3 | 4 | 5 | ################################################################################## 6 | # TICKER # 7 | ################################################################################## 8 | 9 | class Ticker(abstract.Ticker): 10 | pass 11 | 12 | 13 | ################################################################################## 14 | # TRADES # 15 | ################################################################################## 16 | 17 | class Trade(abstract.Trade): 18 | pass 19 | 20 | class Trades(abstract.Trades): 21 | def __getitem__(self, item): 22 | return Trade(self._data[item], self._symbol) 23 | 24 | 25 | 26 | ################################################################################## 27 | # ORDERBOOK # 28 | ################################################################################## 29 | 30 | class Order(abstract.Order): 31 | pass 32 | 33 | class Orders(abstract.Orders): 34 | def __getitem__(self, item): 35 | return Order(self._data[item]) 36 | 37 | class OrderBook(abstract.OrderBook): 38 | def loadAsks(self): 39 | self._asks = Orders(self._data["asks"]) 40 | 41 | def loadBids(self): 42 | self._bids = Orders(self._data["bids"]) -------------------------------------------------------------------------------- /dev/coinfloor/__init__.py: -------------------------------------------------------------------------------- 1 | from ccs import abstract 2 | 3 | from . import public 4 | from . import configuration 5 | 6 | 7 | class Symbol(abstract.Symbol): 8 | def __init__(self, cur1, cur2): 9 | self._cur1 = cur1 10 | self._cur2 = cur2 11 | 12 | def base(self): 13 | return self.normalize(self._cur1) 14 | 15 | def quote(self): 16 | return self.normalize(self._cur2) 17 | 18 | def normalize(self, cur): 19 | return cur.lower().strip() 20 | 21 | def __str__(self): 22 | return self.normalize(self._cur1) + self.normalize(self._cur2) 23 | 24 | 25 | class Adapter(abstract.Adapter): 26 | @staticmethod 27 | def ticker(cur1, cur2): 28 | symbol = Symbol(cur1, cur2) 29 | s = str(symbol) 30 | return public.response.Ticker(public.ticker(s), s) 31 | 32 | @staticmethod 33 | def trades(cur1, cur2, limit=None, direction=None): 34 | symbol = Symbol(cur1, cur2) 35 | s = str(symbol) 36 | return public.response.Trades(public.trades(s), s) 37 | 38 | @staticmethod 39 | def orderbook(cur1, cur2, limit=None): 40 | symbol = Symbol(cur1, cur2) 41 | s = str(symbol) 42 | return public.response.OrderBook(public.orderbook(s), s) 43 | -------------------------------------------------------------------------------- /dev/coinfloor/public/__init__.py: -------------------------------------------------------------------------------- 1 | import urllib.parse 2 | import sys 3 | 4 | from ccs import core 5 | from ccs import constants 6 | from . import response 7 | 8 | def ticker(cur1, cur2): 9 | s = __name__.split(".")[1] 10 | r = sys._getframe().f_code.co_name 11 | 12 | symbol = cur1 + '/' + cur2 13 | 14 | # complete request 15 | cr = core.request(s, r).replace(constants.SYMBOL_PATTERN, symbol) 16 | 17 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) 18 | 19 | 20 | def transactions(cur1, cur2): 21 | s = __name__.split(".")[1] 22 | r = sys._getframe().f_code.co_name 23 | 24 | symbol = cur1 + '/' + cur2 25 | 26 | # complete request 27 | cr = core.request(s, r).replace(constants.SYMBOL_PATTERN, symbol) 28 | 29 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) 30 | 31 | def orderbook(cur1, cur2): 32 | s = __name__.split(".")[1] 33 | r = sys._getframe().f_code.co_name 34 | 35 | symbol = cur1 + '/' + cur2 36 | 37 | # complete request 38 | cr = core.request(s, r).replace(constants.SYMBOL_PATTERN, symbol) 39 | 40 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) -------------------------------------------------------------------------------- /dev/coinfloor/public/response.py: -------------------------------------------------------------------------------- 1 | from ccs import abstract 2 | from ccs import constants 3 | 4 | 5 | ################################################################################## 6 | # TICKER # 7 | ################################################################################## 8 | 9 | class Ticker(abstract.Ticker): 10 | pass 11 | 12 | 13 | ################################################################################## 14 | # TRADES # 15 | ################################################################################## 16 | 17 | class Trade(abstract.Trade): 18 | pass 19 | 20 | class Trades(abstract.Trades): 21 | def __getitem__(self, item): 22 | return Trade(self._data[item], self._symbol) 23 | 24 | 25 | 26 | ################################################################################## 27 | # ORDERBOOK # 28 | ################################################################################## 29 | 30 | class Order(abstract.Order): 31 | pass 32 | 33 | class Orders(abstract.Orders): 34 | def __getitem__(self, item): 35 | return Order(self._data[item]) 36 | 37 | class OrderBook(abstract.OrderBook): 38 | def loadAsks(self): 39 | self._asks = Orders(self._data["asks"]) 40 | 41 | def loadBids(self): 42 | self._bids = Orders(self._data["bids"]) -------------------------------------------------------------------------------- /dev/exmo/__init__.py: -------------------------------------------------------------------------------- 1 | from ccs import abstract 2 | 3 | from . import public 4 | from . import configuration 5 | 6 | 7 | class Symbol(abstract.Symbol): 8 | def __init__(self, cur1, cur2): 9 | self._cur1 = cur1 10 | self._cur2 = cur2 11 | 12 | def base(self): 13 | return self.normalize(self._cur1) 14 | 15 | def quote(self): 16 | return self.normalize(self._cur2) 17 | 18 | def normalize(self, cur): 19 | return cur.lower().strip() 20 | 21 | def __str__(self): 22 | return self.normalize(self._cur1) + self.normalize(self._cur2) 23 | 24 | 25 | class Adapter(abstract.Adapter): 26 | @staticmethod 27 | def ticker(cur1, cur2): 28 | symbol = Symbol(cur1, cur2) 29 | s = str(symbol) 30 | return public.response.Ticker(public.ticker(s), s) 31 | 32 | @staticmethod 33 | def trades(cur1, cur2, limit=None, direction=None): 34 | symbol = Symbol(cur1, cur2) 35 | s = str(symbol) 36 | return public.response.Trades(public.trades(s), s) 37 | 38 | @staticmethod 39 | def orderbook(cur1, cur2, limit=None): 40 | symbol = Symbol(cur1, cur2) 41 | s = str(symbol) 42 | return public.response.OrderBook(public.orderbook(s), s) 43 | -------------------------------------------------------------------------------- /dev/exmo/public/__init__.py: -------------------------------------------------------------------------------- 1 | import urllib.parse 2 | import sys 3 | 4 | from ccs import core 5 | from ccs import constants 6 | from . import response 7 | 8 | def ticker(): 9 | s = __name__.split(".")[1] 10 | r = sys._getframe().f_code.co_name 11 | 12 | # complete request 13 | cr = core.request(s, r) 14 | 15 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) 16 | 17 | 18 | def trades(pair): 19 | s = __name__.split(".")[1] 20 | r = sys._getframe().f_code.co_name 21 | 22 | params = {} 23 | params["pair"] = pair 24 | 25 | # complete request 26 | cr = core.request(s, r) + urllib.parse.urlencode(params) 27 | 28 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) 29 | 30 | 31 | def order_book(pair, limit=None): 32 | s = __name__.split(".")[1] 33 | r = sys._getframe().f_code.co_name 34 | 35 | params = {} 36 | params["pair"] = pair 37 | 38 | if limit: 39 | params["limit"] = limit 40 | 41 | # complete request 42 | cr = core.request(s, r) + urllib.parse.urlencode(params) 43 | 44 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) 45 | 46 | 47 | def pair_settings(): 48 | s = __name__.split(".")[1] 49 | r = sys._getframe().f_code.co_name 50 | 51 | # complete request 52 | cr = core.request(s, r) 53 | 54 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) 55 | 56 | 57 | def currency(): 58 | s = __name__.split(".")[1] 59 | r = sys._getframe().f_code.co_name 60 | 61 | # complete request 62 | cr = core.request(s, r) 63 | 64 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) -------------------------------------------------------------------------------- /dev/exmo/public/response.py: -------------------------------------------------------------------------------- 1 | from ccs import abstract 2 | from ccs import constants 3 | 4 | 5 | ################################################################################## 6 | # TICKER # 7 | ################################################################################## 8 | 9 | class Ticker(abstract.Ticker): 10 | pass 11 | 12 | 13 | ################################################################################## 14 | # TRADES # 15 | ################################################################################## 16 | 17 | class Trade(abstract.Trade): 18 | pass 19 | 20 | class Trades(abstract.Trades): 21 | def __getitem__(self, item): 22 | return Trade(self._data[item], self._symbol) 23 | 24 | 25 | 26 | ################################################################################## 27 | # ORDERBOOK # 28 | ################################################################################## 29 | 30 | class Order(abstract.Order): 31 | pass 32 | 33 | class Orders(abstract.Orders): 34 | def __getitem__(self, item): 35 | return Order(self._data[item]) 36 | 37 | class OrderBook(abstract.OrderBook): 38 | def loadAsks(self): 39 | self._asks = Orders(self._data["asks"]) 40 | 41 | def loadBids(self): 42 | self._bids = Orders(self._data["bids"]) -------------------------------------------------------------------------------- /dev/fyb/__init__.py: -------------------------------------------------------------------------------- 1 | from ccs import abstract 2 | 3 | from . import public 4 | from . import configuration 5 | 6 | 7 | class Symbol(abstract.Symbol): 8 | def __init__(self, cur1, cur2): 9 | self._cur1 = cur1 10 | self._cur2 = cur2 11 | 12 | def base(self): 13 | return self.normalize(self._cur1) 14 | 15 | def quote(self): 16 | return self.normalize(self._cur2) 17 | 18 | def normalize(self, cur): 19 | return cur.lower().strip() 20 | 21 | def __str__(self): 22 | return self.normalize(self._cur1) + self.normalize(self._cur2) 23 | 24 | 25 | class Adapter(abstract.Adapter): 26 | @staticmethod 27 | def ticker(cur1, cur2): 28 | symbol = Symbol(cur1, cur2) 29 | s = str(symbol) 30 | return public.response.Ticker(public.ticker(s), s) 31 | 32 | @staticmethod 33 | def trades(cur1, cur2, limit=None, direction=None): 34 | symbol = Symbol(cur1, cur2) 35 | s = str(symbol) 36 | return public.response.Trades(public.trades(s), s) 37 | 38 | @staticmethod 39 | def orderbook(cur1, cur2, limit=None): 40 | symbol = Symbol(cur1, cur2) 41 | s = str(symbol) 42 | return public.response.OrderBook(public.orderbook(s), s) 43 | -------------------------------------------------------------------------------- /dev/fyb/public/__init__.py: -------------------------------------------------------------------------------- 1 | import urllib.parse 2 | import sys 3 | 4 | from ccs import core 5 | from ccs import constants 6 | from . import response 7 | 8 | def ticker(): 9 | s = __name__.split(".")[1] 10 | r = sys._getframe().f_code.co_name 11 | 12 | # complete request 13 | cr = core.request(s, r) 14 | 15 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) 16 | 17 | def tickerdetailed(): 18 | s = __name__.split(".")[1] 19 | r = sys._getframe().f_code.co_name 20 | 21 | # complete request 22 | cr = core.request(s, r) 23 | 24 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) 25 | 26 | def trades(since=None): 27 | s = __name__.split(".")[1] 28 | r = sys._getframe().f_code.co_name 29 | 30 | params = {} 31 | if since: 32 | params["since"] = since 33 | 34 | # complete request 35 | cr = core.request(s, r) + urllib.parse.urlencode(params) 36 | 37 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) 38 | 39 | def orderbook(): 40 | s = __name__.split(".")[1] 41 | r = sys._getframe().f_code.co_name 42 | 43 | # complete request 44 | cr = core.request(s, r) 45 | 46 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) -------------------------------------------------------------------------------- /dev/fyb/public/response.py: -------------------------------------------------------------------------------- 1 | from ccs import abstract 2 | from ccs import constants 3 | 4 | 5 | ################################################################################## 6 | # TICKER # 7 | ################################################################################## 8 | 9 | class Ticker(abstract.Ticker): 10 | pass 11 | 12 | 13 | ################################################################################## 14 | # TRADES # 15 | ################################################################################## 16 | 17 | class Trade(abstract.Trade): 18 | pass 19 | 20 | class Trades(abstract.Trades): 21 | def __getitem__(self, item): 22 | return Trade(self._data[item], self._symbol) 23 | 24 | 25 | 26 | ################################################################################## 27 | # ORDERBOOK # 28 | ################################################################################## 29 | 30 | class Order(abstract.Order): 31 | pass 32 | 33 | class Orders(abstract.Orders): 34 | def __getitem__(self, item): 35 | return Order(self._data[item]) 36 | 37 | class OrderBook(abstract.OrderBook): 38 | def loadAsks(self): 39 | self._asks = Orders(self._data["asks"]) 40 | 41 | def loadBids(self): 42 | self._bids = Orders(self._data["bids"]) -------------------------------------------------------------------------------- /dev/fybse/__init__.py: -------------------------------------------------------------------------------- 1 | from ccs import abstract 2 | 3 | from . import public 4 | from . import configuration 5 | 6 | 7 | class Symbol(abstract.Symbol): 8 | def __init__(self, cur1, cur2): 9 | self._cur1 = cur1 10 | self._cur2 = cur2 11 | 12 | def base(self): 13 | return self.normalize(self._cur1) 14 | 15 | def quote(self): 16 | return self.normalize(self._cur2) 17 | 18 | def normalize(self, cur): 19 | return cur.lower().strip() 20 | 21 | def __str__(self): 22 | return self.normalize(self._cur1) + self.normalize(self._cur2) 23 | 24 | 25 | class Adapter(abstract.Adapter): 26 | @staticmethod 27 | def ticker(cur1, cur2): 28 | symbol = Symbol(cur1, cur2) 29 | s = str(symbol) 30 | return public.response.Ticker(public.ticker(s), s) 31 | 32 | @staticmethod 33 | def trades(cur1, cur2, limit=None, direction=None): 34 | symbol = Symbol(cur1, cur2) 35 | s = str(symbol) 36 | return public.response.Trades(public.trades(s), s) 37 | 38 | @staticmethod 39 | def orderbook(cur1, cur2, limit=None): 40 | symbol = Symbol(cur1, cur2) 41 | s = str(symbol) 42 | return public.response.OrderBook(public.orderbook(s), s) 43 | -------------------------------------------------------------------------------- /dev/fybse/public/__init__.py: -------------------------------------------------------------------------------- 1 | import urllib.parse 2 | 3 | from ccs import core 4 | from ccs import constants 5 | from . import response 6 | 7 | from ...fyb.public import * 8 | import inspect 9 | 10 | TICKER_METHOD = inspect.getsource(ticker) 11 | exec(TICKER_METHOD) 12 | 13 | TICKERDETAILED_METHOD = inspect.getsource(tickerdetailed) 14 | exec(TICKERDETAILED_METHOD) 15 | 16 | TRADES_METHOD = inspect.getsource(trades) 17 | exec(TRADES_METHOD) 18 | 19 | ORDERBOOK_METHOD = inspect.getsource(orderbook) 20 | exec(ORDERBOOK_METHOD) -------------------------------------------------------------------------------- /dev/fybse/public/response.py: -------------------------------------------------------------------------------- 1 | from ccs import abstract 2 | from ccs import constants 3 | 4 | 5 | ################################################################################## 6 | # TICKER # 7 | ################################################################################## 8 | 9 | class Ticker(abstract.Ticker): 10 | pass 11 | 12 | 13 | ################################################################################## 14 | # TRADES # 15 | ################################################################################## 16 | 17 | class Trade(abstract.Trade): 18 | pass 19 | 20 | class Trades(abstract.Trades): 21 | def __getitem__(self, item): 22 | return Trade(self._data[item], self._symbol) 23 | 24 | 25 | 26 | ################################################################################## 27 | # ORDERBOOK # 28 | ################################################################################## 29 | 30 | class Order(abstract.Order): 31 | pass 32 | 33 | class Orders(abstract.Orders): 34 | def __getitem__(self, item): 35 | return Order(self._data[item]) 36 | 37 | class OrderBook(abstract.OrderBook): 38 | def loadAsks(self): 39 | self._asks = Orders(self._data["asks"]) 40 | 41 | def loadBids(self): 42 | self._bids = Orders(self._data["bids"]) -------------------------------------------------------------------------------- /dev/fybsg/__init__.py: -------------------------------------------------------------------------------- 1 | from ccs import abstract 2 | 3 | from . import public 4 | from . import configuration 5 | 6 | 7 | class Symbol(abstract.Symbol): 8 | def __init__(self, cur1, cur2): 9 | self._cur1 = cur1 10 | self._cur2 = cur2 11 | 12 | def base(self): 13 | return self.normalize(self._cur1) 14 | 15 | def quote(self): 16 | return self.normalize(self._cur2) 17 | 18 | def normalize(self, cur): 19 | return cur.lower().strip() 20 | 21 | def __str__(self): 22 | return self.normalize(self._cur1) + self.normalize(self._cur2) 23 | 24 | 25 | class Adapter(abstract.Adapter): 26 | @staticmethod 27 | def ticker(cur1, cur2): 28 | symbol = Symbol(cur1, cur2) 29 | s = str(symbol) 30 | return public.response.Ticker(public.ticker(s), s) 31 | 32 | @staticmethod 33 | def trades(cur1, cur2, limit=None, direction=None): 34 | symbol = Symbol(cur1, cur2) 35 | s = str(symbol) 36 | return public.response.Trades(public.trades(s), s) 37 | 38 | @staticmethod 39 | def orderbook(cur1, cur2, limit=None): 40 | symbol = Symbol(cur1, cur2) 41 | s = str(symbol) 42 | return public.response.OrderBook(public.orderbook(s), s) 43 | -------------------------------------------------------------------------------- /dev/fybsg/public/__init__.py: -------------------------------------------------------------------------------- 1 | import urllib.parse 2 | 3 | from ccs import core 4 | from ccs import constants 5 | from . import response 6 | 7 | from ...fyb.public import * 8 | import inspect 9 | 10 | TICKER_METHOD = inspect.getsource(ticker) 11 | exec(TICKER_METHOD) 12 | 13 | TICKERDETAILED_METHOD = inspect.getsource(tickerdetailed) 14 | exec(TICKERDETAILED_METHOD) 15 | 16 | TRADES_METHOD = inspect.getsource(trades) 17 | exec(TRADES_METHOD) 18 | 19 | ORDERBOOK_METHOD = inspect.getsource(orderbook) 20 | exec(ORDERBOOK_METHOD) -------------------------------------------------------------------------------- /dev/fybsg/public/response.py: -------------------------------------------------------------------------------- 1 | from ccs import abstract 2 | from ccs import constants 3 | 4 | 5 | ################################################################################## 6 | # TICKER # 7 | ################################################################################## 8 | 9 | class Ticker(abstract.Ticker): 10 | pass 11 | 12 | 13 | ################################################################################## 14 | # TRADES # 15 | ################################################################################## 16 | 17 | class Trade(abstract.Trade): 18 | pass 19 | 20 | class Trades(abstract.Trades): 21 | def __getitem__(self, item): 22 | return Trade(self._data[item], self._symbol) 23 | 24 | 25 | 26 | ################################################################################## 27 | # ORDERBOOK # 28 | ################################################################################## 29 | 30 | class Order(abstract.Order): 31 | pass 32 | 33 | class Orders(abstract.Orders): 34 | def __getitem__(self, item): 35 | return Order(self._data[item]) 36 | 37 | class OrderBook(abstract.OrderBook): 38 | def loadAsks(self): 39 | self._asks = Orders(self._data["asks"]) 40 | 41 | def loadBids(self): 42 | self._bids = Orders(self._data["bids"]) -------------------------------------------------------------------------------- /dev/hitbtc/__init__.py: -------------------------------------------------------------------------------- 1 | from ccs import abstract 2 | 3 | from . import public 4 | from . import configuration 5 | 6 | 7 | class Symbol(abstract.Symbol): 8 | def __init__(self, cur1, cur2): 9 | self._cur1 = cur1 10 | self._cur2 = cur2 11 | 12 | def base(self): 13 | return self.normalize(self._cur1) 14 | 15 | def quote(self): 16 | return self.normalize(self._cur2) 17 | 18 | def normalize(self, cur): 19 | return cur.lower().strip() 20 | 21 | def __str__(self): 22 | return self.normalize(self._cur1) + self.normalize(self._cur2) 23 | 24 | 25 | class Adapter(abstract.Adapter): 26 | @staticmethod 27 | def ticker(cur1, cur2): 28 | symbol = Symbol(cur1, cur2) 29 | s = str(symbol) 30 | return public.response.Ticker(public.ticker(s), s) 31 | 32 | @staticmethod 33 | def trades(cur1, cur2, limit=None, direction=None): 34 | symbol = Symbol(cur1, cur2) 35 | s = str(symbol) 36 | return public.response.Trades(public.trades(s), s) 37 | 38 | @staticmethod 39 | def orderbook(cur1, cur2, limit=None): 40 | symbol = Symbol(cur1, cur2) 41 | s = str(symbol) 42 | return public.response.OrderBook(public.orderbook(s), s) 43 | -------------------------------------------------------------------------------- /dev/hitbtc/public/__init__.py: -------------------------------------------------------------------------------- 1 | import urllib.parse 2 | import sys 3 | 4 | from ccs import core 5 | from ccs import constants 6 | from . import response 7 | 8 | 9 | def ticker(symbol): 10 | s = __name__.split(".")[1] 11 | r = sys._getframe().f_code.co_name 12 | 13 | # complete request 14 | cr = core.request(s, r).replace(constants.SYMBOL_PATTERN, symbol) 15 | 16 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) 17 | 18 | def trades(symbol): 19 | s = __name__.split(".")[1] 20 | r = sys._getframe().f_code.co_name 21 | 22 | # complete request 23 | cr = core.request(s, r).replace(constants.SYMBOL_PATTERN, symbol) 24 | 25 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) 26 | 27 | def orderbook(symbol): 28 | s = __name__.split(".")[1] 29 | r = sys._getframe().f_code.co_name 30 | 31 | # complete request 32 | cr = core.request(s, r).replace(constants.SYMBOL_PATTERN, symbol) 33 | 34 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) 35 | 36 | def recenttrades(): 37 | s = __name__.split(".")[1] 38 | r = sys._getframe().f_code.co_name 39 | 40 | # complete request 41 | cr = core.request(s, r) 42 | 43 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) 44 | 45 | def time(): 46 | s = __name__.split(".")[1] 47 | r = sys._getframe().f_code.co_name 48 | 49 | # complete request 50 | cr = core.request(s, r) 51 | 52 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) 53 | 54 | def symbols(): 55 | s = __name__.split(".")[1] 56 | r = sys._getframe().f_code.co_name 57 | 58 | # complete request 59 | cr = core.request(s, r) 60 | 61 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) -------------------------------------------------------------------------------- /dev/hitbtc/public/response.py: -------------------------------------------------------------------------------- 1 | from ccs import abstract 2 | from ccs import constants 3 | 4 | 5 | ################################################################################## 6 | # TICKER # 7 | ################################################################################## 8 | 9 | class Ticker(abstract.Ticker): 10 | pass 11 | 12 | 13 | ################################################################################## 14 | # TRADES # 15 | ################################################################################## 16 | 17 | class Trade(abstract.Trade): 18 | pass 19 | 20 | class Trades(abstract.Trades): 21 | def __getitem__(self, item): 22 | return Trade(self._data[item], self._symbol) 23 | 24 | 25 | 26 | ################################################################################## 27 | # ORDERBOOK # 28 | ################################################################################## 29 | 30 | class Order(abstract.Order): 31 | pass 32 | 33 | class Orders(abstract.Orders): 34 | def __getitem__(self, item): 35 | return Order(self._data[item]) 36 | 37 | class OrderBook(abstract.OrderBook): 38 | def loadAsks(self): 39 | self._asks = Orders(self._data["asks"]) 40 | 41 | def loadBids(self): 42 | self._bids = Orders(self._data["bids"]) -------------------------------------------------------------------------------- /dev/huobi/__init__.py: -------------------------------------------------------------------------------- 1 | from ccs import abstract 2 | 3 | from . import public 4 | from . import configuration 5 | 6 | 7 | class Symbol(abstract.Symbol): 8 | def __init__(self, cur1, cur2): 9 | self._cur1 = cur1 10 | self._cur2 = cur2 11 | 12 | def base(self): 13 | return self.normalize(self._cur1) 14 | 15 | def quote(self): 16 | return self.normalize(self._cur2) 17 | 18 | def normalize(self, cur): 19 | return cur.lower().strip() 20 | 21 | def __str__(self): 22 | return self.normalize(self._cur1) + self.normalize(self._cur2) 23 | 24 | 25 | class Adapter(abstract.Adapter): 26 | @staticmethod 27 | def ticker(cur1, cur2): 28 | symbol = Symbol(cur1, cur2) 29 | s = str(symbol) 30 | return public.response.Ticker(public.ticker(s), s) 31 | 32 | @staticmethod 33 | def trades(cur1, cur2, limit=None, direction=None): 34 | symbol = Symbol(cur1, cur2) 35 | s = str(symbol) 36 | return public.response.Trades(public.trades(s), s) 37 | 38 | @staticmethod 39 | def orderbook(cur1, cur2, limit=None): 40 | symbol = Symbol(cur1, cur2) 41 | s = str(symbol) 42 | return public.response.OrderBook(public.orderbook(s), s) 43 | -------------------------------------------------------------------------------- /dev/huobi/public/response.py: -------------------------------------------------------------------------------- 1 | from ccs import abstract 2 | from ccs import constants 3 | 4 | 5 | ################################################################################## 6 | # TICKER # 7 | ################################################################################## 8 | 9 | class Ticker(abstract.Ticker): 10 | pass 11 | 12 | 13 | ################################################################################## 14 | # TRADES # 15 | ################################################################################## 16 | 17 | class Trade(abstract.Trade): 18 | pass 19 | 20 | class Trades(abstract.Trades): 21 | def __getitem__(self, item): 22 | return Trade(self._data[item], self._symbol) 23 | 24 | 25 | 26 | ################################################################################## 27 | # ORDERBOOK # 28 | ################################################################################## 29 | 30 | class Order(abstract.Order): 31 | pass 32 | 33 | class Orders(abstract.Orders): 34 | def __getitem__(self, item): 35 | return Order(self._data[item]) 36 | 37 | class OrderBook(abstract.OrderBook): 38 | def loadAsks(self): 39 | self._asks = Orders(self._data["asks"]) 40 | 41 | def loadBids(self): 42 | self._bids = Orders(self._data["bids"]) -------------------------------------------------------------------------------- /dev/itbit/__init__.py: -------------------------------------------------------------------------------- 1 | from ccs import abstract 2 | 3 | from . import public 4 | from . import configuration 5 | 6 | 7 | class Symbol(abstract.Symbol): 8 | def __init__(self, cur1, cur2): 9 | self._cur1 = cur1 10 | self._cur2 = cur2 11 | 12 | def base(self): 13 | return self.normalize(self._cur1) 14 | 15 | def quote(self): 16 | return self.normalize(self._cur2) 17 | 18 | def normalize(self, cur): 19 | return cur.lower().strip() 20 | 21 | def __str__(self): 22 | return self.normalize(self._cur1) + self.normalize(self._cur2) 23 | 24 | 25 | class Adapter(abstract.Adapter): 26 | @staticmethod 27 | def ticker(cur1, cur2): 28 | symbol = Symbol(cur1, cur2) 29 | s = str(symbol) 30 | return dev.itbit.public.response.Ticker(public.ticker(s), s) 31 | 32 | @staticmethod 33 | def trades(cur1, cur2, limit=None, direction=None): 34 | symbol = Symbol(cur1, cur2) 35 | s = str(symbol) 36 | return dev.itbit.public.response.Trades(public.trades(s), s) 37 | 38 | @staticmethod 39 | def orderbook(cur1, cur2, limit=None): 40 | symbol = Symbol(cur1, cur2) 41 | s = str(symbol) 42 | return dev.itbit.public.response.OrderBook(public.orderbook(s), s) 43 | -------------------------------------------------------------------------------- /dev/itbit/public/__init__.py: -------------------------------------------------------------------------------- 1 | import urllib.parse 2 | import sys 3 | 4 | from ccs import core 5 | from ccs import constants 6 | from . import response 7 | 8 | 9 | def ticker(symbol): 10 | s = __name__.split(".")[1] 11 | r = sys._getframe().f_code.co_name 12 | 13 | # XBTUSD 14 | # XBTSGD 15 | # XBTEUR 16 | 17 | # complete request 18 | cr = core.request(s, r).replace(constants.SYMBOL_PATTERN, symbol) 19 | 20 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) 21 | 22 | 23 | def trades(symbol, since=None): 24 | s = __name__.split(".")[1] 25 | r = sys._getframe().f_code.co_name 26 | 27 | params = {} 28 | 29 | if since: 30 | params["since"] = since 31 | 32 | # complete request 33 | cr = core.request(s, r).replace(constants.SYMBOL_PATTERN, symbol) + urllib.parse.urlencode(params) 34 | 35 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) 36 | 37 | 38 | def orderbook(symbol): 39 | s = __name__.split(".")[1] 40 | r = sys._getframe().f_code.co_name 41 | 42 | # complete request 43 | cr = core.request(s, r).replace(constants.SYMBOL_PATTERN, symbol) 44 | 45 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) 46 | -------------------------------------------------------------------------------- /dev/itbit/public/response.py: -------------------------------------------------------------------------------- 1 | from ccs import abstract 2 | from ccs import constants 3 | 4 | 5 | ################################################################################## 6 | # TICKER # 7 | ################################################################################## 8 | 9 | class Ticker(abstract.Ticker): 10 | pass 11 | 12 | 13 | ################################################################################## 14 | # TRADES # 15 | ################################################################################## 16 | 17 | class Trade(abstract.Trade): 18 | pass 19 | 20 | class Trades(abstract.Trades): 21 | def __getitem__(self, item): 22 | return Trade(self._data[item], self._symbol) 23 | 24 | 25 | 26 | ################################################################################## 27 | # ORDERBOOK # 28 | ################################################################################## 29 | 30 | class Order(abstract.Order): 31 | pass 32 | 33 | class Orders(abstract.Orders): 34 | def __getitem__(self, item): 35 | return Order(self._data[item]) 36 | 37 | class OrderBook(abstract.OrderBook): 38 | def loadAsks(self): 39 | self._asks = Orders(self._data["asks"]) 40 | 41 | def loadBids(self): 42 | self._bids = Orders(self._data["bids"]) -------------------------------------------------------------------------------- /dev/lakebtc/__init__.py: -------------------------------------------------------------------------------- 1 | from ccs import abstract 2 | from . import configuration 3 | from . import public 4 | 5 | 6 | class Symbol(abstract.Symbol): 7 | def __init__(self, cur1, cur2): 8 | self._cur1 = cur1 9 | self._cur2 = cur2 10 | 11 | def base(self): 12 | return self.normalize(self._cur1) 13 | 14 | def quote(self): 15 | return self.normalize(self._cur2) 16 | 17 | def normalize(self, cur): 18 | return cur.lower().strip() 19 | 20 | def __str__(self): 21 | return self.normalize(self._cur1) + self.normalize(self._cur2) 22 | 23 | 24 | class Adapter(abstract.Adapter): 25 | @staticmethod 26 | def ticker(cur1, cur2): 27 | symbol = Symbol(cur1, cur2) 28 | s = str(symbol) 29 | return public.response.Ticker(public.ticker(s), s) 30 | 31 | @staticmethod 32 | def trades(cur1, cur2, limit=None, direction=None): 33 | symbol = Symbol(cur1, cur2) 34 | s = str(symbol) 35 | return public.response.Trades(public.trades(s), s) 36 | 37 | @staticmethod 38 | def orderbook(cur1, cur2, limit=None): 39 | symbol = Symbol(cur1, cur2) 40 | s = str(symbol) 41 | return public.response.OrderBook(public.orderbook(s), s) 42 | -------------------------------------------------------------------------------- /dev/lakebtc/public/__init__.py: -------------------------------------------------------------------------------- 1 | import urllib.parse 2 | import sys 3 | 4 | from ccs import core 5 | from ccs import constants 6 | from . import response 7 | 8 | 9 | def ticker(): 10 | s = __name__.split(".")[1] 11 | r = sys._getframe().f_code.co_name 12 | 13 | # complete request 14 | cr = core.request(s, r) 15 | 16 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) 17 | 18 | 19 | def trades(since=None): 20 | s = __name__.split(".")[1] 21 | r = sys._getframe().f_code.co_name 22 | 23 | params = {} 24 | if since: 25 | params["since"] = since 26 | 27 | # complete request 28 | cr = core.request(s, r) + urllib.parse.urlencode(params) 29 | 30 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) 31 | 32 | 33 | def orderbook(symbol="btcusd"): 34 | s = __name__.split(".")[1] 35 | r = sys._getframe().f_code.co_name 36 | 37 | params = {} 38 | if symbol: 39 | params["symbol"] = symbol 40 | 41 | # complete request 42 | cr = core.request(s, r) + urllib.parse.urlencode(params) 43 | 44 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) -------------------------------------------------------------------------------- /dev/lakebtc/public/response.py: -------------------------------------------------------------------------------- 1 | from ccs import abstract 2 | from ccs import constants 3 | 4 | 5 | ################################################################################## 6 | # TICKER # 7 | ################################################################################## 8 | 9 | class Ticker(abstract.Ticker): 10 | pass 11 | 12 | 13 | ################################################################################## 14 | # TRADES # 15 | ################################################################################## 16 | 17 | class Trade(abstract.Trade): 18 | pass 19 | 20 | class Trades(abstract.Trades): 21 | def __getitem__(self, item): 22 | return Trade(self._data[item], self._symbol) 23 | 24 | 25 | 26 | ################################################################################## 27 | # ORDERBOOK # 28 | ################################################################################## 29 | 30 | class Order(abstract.Order): 31 | pass 32 | 33 | class Orders(abstract.Orders): 34 | def __getitem__(self, item): 35 | return Order(self._data[item]) 36 | 37 | class OrderBook(abstract.OrderBook): 38 | def loadAsks(self): 39 | self._asks = Orders(self._data["asks"]) 40 | 41 | def loadBids(self): 42 | self._bids = Orders(self._data["bids"]) -------------------------------------------------------------------------------- /dev/localbitcoins/__init__.py: -------------------------------------------------------------------------------- 1 | from ccs import abstract 2 | 3 | from . import public 4 | from . import configuration 5 | 6 | 7 | class Symbol(abstract.Symbol): 8 | def __init__(self, cur1, cur2): 9 | self._cur1 = cur1 10 | self._cur2 = cur2 11 | 12 | def base(self): 13 | return self.normalize(self._cur1) 14 | 15 | def quote(self): 16 | return self.normalize(self._cur2) 17 | 18 | def normalize(self, cur): 19 | return cur.lower().strip() 20 | 21 | def __str__(self): 22 | return self.normalize(self._cur1) + self.normalize(self._cur2) 23 | 24 | 25 | class Adapter(abstract.Adapter): 26 | @staticmethod 27 | def ticker(cur1, cur2): 28 | symbol = Symbol(cur1, cur2) 29 | s = str(symbol) 30 | return public.response.Ticker(public.ticker(s), s) 31 | 32 | @staticmethod 33 | def trades(cur1, cur2, limit=None, direction=None): 34 | symbol = Symbol(cur1, cur2) 35 | s = str(symbol) 36 | return public.response.Trades(public.trades(s), s) 37 | 38 | @staticmethod 39 | def orderbook(cur1, cur2, limit=None): 40 | symbol = Symbol(cur1, cur2) 41 | s = str(symbol) 42 | return public.response.OrderBook(public.orderbook(s), s) 43 | -------------------------------------------------------------------------------- /dev/localbitcoins/public/__init__.py: -------------------------------------------------------------------------------- 1 | import urllib.parse 2 | import sys 3 | 4 | from ccs import core 5 | from ccs import constants 6 | from . import response 7 | 8 | 9 | def tickers(): 10 | s = __name__.split(".")[1] 11 | r = sys._getframe().f_code.co_name 12 | 13 | # complete request 14 | cr = core.request(s, r) 15 | 16 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) 17 | 18 | 19 | def trades(currency): 20 | s = __name__.split(".")[1] 21 | r = sys._getframe().f_code.co_name 22 | 23 | # complete request 24 | cr = core.request(s, r).replace(constants.CURRENCY_PATTERN, currency) 25 | 26 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) 27 | 28 | def orderbook(currency): 29 | s = __name__.split(".")[1] 30 | r = sys._getframe().f_code.co_name 31 | 32 | # complete request 33 | cr = core.request(s, r).replace(constants.CURRENCY_PATTERN, currency) 34 | 35 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) -------------------------------------------------------------------------------- /dev/localbitcoins/public/response.py: -------------------------------------------------------------------------------- 1 | from ccs import abstract 2 | from ccs import constants 3 | 4 | 5 | ################################################################################## 6 | # TICKER # 7 | ################################################################################## 8 | 9 | class Ticker(abstract.Ticker): 10 | pass 11 | 12 | 13 | ################################################################################## 14 | # TRADES # 15 | ################################################################################## 16 | 17 | class Trade(abstract.Trade): 18 | pass 19 | 20 | class Trades(abstract.Trades): 21 | def __getitem__(self, item): 22 | return Trade(self._data[item], self._symbol) 23 | 24 | 25 | 26 | ################################################################################## 27 | # ORDERBOOK # 28 | ################################################################################## 29 | 30 | class Order(abstract.Order): 31 | pass 32 | 33 | class Orders(abstract.Orders): 34 | def __getitem__(self, item): 35 | return Order(self._data[item]) 36 | 37 | class OrderBook(abstract.OrderBook): 38 | def loadAsks(self): 39 | self._asks = Orders(self._data["asks"]) 40 | 41 | def loadBids(self): 42 | self._bids = Orders(self._data["bids"]) -------------------------------------------------------------------------------- /dev/mercadobitcoin/__init__.py: -------------------------------------------------------------------------------- 1 | from ccs import abstract 2 | 3 | from . import public 4 | from . import configuration 5 | 6 | 7 | class Symbol(abstract.Symbol): 8 | def __init__(self, cur1, cur2): 9 | self._cur1 = cur1 10 | self._cur2 = cur2 11 | 12 | def base(self): 13 | return self.normalize(self._cur1) 14 | 15 | def quote(self): 16 | return self.normalize(self._cur2) 17 | 18 | def normalize(self, cur): 19 | return cur.lower().strip() 20 | 21 | def __str__(self): 22 | return self.normalize(self._cur1) + self.normalize(self._cur2) 23 | 24 | 25 | class Adapter(abstract.Adapter): 26 | @staticmethod 27 | def ticker(cur1, cur2): 28 | symbol = Symbol(cur1, cur2) 29 | s = str(symbol) 30 | return public.response.Ticker(public.ticker(s), s) 31 | 32 | @staticmethod 33 | def trades(cur1, cur2, limit=None, direction=None): 34 | symbol = Symbol(cur1, cur2) 35 | s = str(symbol) 36 | return public.response.Trades(public.trades(s), s) 37 | 38 | @staticmethod 39 | def orderbook(cur1, cur2, limit=None): 40 | symbol = Symbol(cur1, cur2) 41 | s = str(symbol) 42 | return public.response.OrderBook(public.orderbook(s), s) 43 | -------------------------------------------------------------------------------- /dev/mercadobitcoin/public/__init__.py: -------------------------------------------------------------------------------- 1 | import urllib.parse 2 | import sys 3 | 4 | from ccs import core 5 | from ccs import constants 6 | from . import response 7 | 8 | def ticker(currency): 9 | s = __name__.split(".")[1] 10 | r = sys._getframe().f_code.co_name 11 | 12 | c = "" 13 | if currency == constants.BTC: 14 | c = "" 15 | 16 | if currency == constants.LTC: 17 | c = "_litecoin" 18 | 19 | # complete request 20 | cr = core.request(s, r).replace(constants.CURRENCY_PATTERN, c) 21 | 22 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) 23 | 24 | 25 | def trades(currency, tid=None, since=None): 26 | s = __name__.split(".")[1] 27 | r = sys._getframe().f_code.co_name 28 | 29 | c = "" 30 | if currency == constants.BTC: 31 | c = "" 32 | 33 | if currency == constants.LTC: 34 | c = "_litecoin" 35 | 36 | # IMPROVE 37 | # viz dokumentace 38 | # nelze kombinovat since & tid 39 | # neni to uplne jeste je mozne nastavovat time_inicial ... 40 | params = {} 41 | if tid: 42 | params["tid"] = tid 43 | 44 | if since: 45 | params["since"] = since 46 | 47 | # complete request 48 | cr = core.request(s, r).replace(constants.CURRENCY_PATTERN, c) + urllib.parse.urlencode(params) 49 | 50 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) 51 | 52 | 53 | 54 | def orderbook(currency): 55 | s = __name__.split(".")[1] 56 | r = sys._getframe().f_code.co_name 57 | 58 | c = "" 59 | if currency == constants.BTC: 60 | c = "" 61 | 62 | if currency == constants.LTC: 63 | c = "_litecoin" 64 | 65 | # complete request 66 | cr = core.request(s, r).replace(constants.CURRENCY_PATTERN, c) 67 | 68 | return core.get(core.hostname(s), cr, core.header(s), core.compression(s), core.timeout(s)) -------------------------------------------------------------------------------- /dev/mercadobitcoin/public/response.py: -------------------------------------------------------------------------------- 1 | from ccs import abstract 2 | from ccs import constants 3 | 4 | 5 | ################################################################################## 6 | # TICKER # 7 | ################################################################################## 8 | 9 | class Ticker(abstract.Ticker): 10 | pass 11 | 12 | 13 | ################################################################################## 14 | # TRADES # 15 | ################################################################################## 16 | 17 | class Trade(abstract.Trade): 18 | pass 19 | 20 | class Trades(abstract.Trades): 21 | def __getitem__(self, item): 22 | return Trade(self._data[item], self._symbol) 23 | 24 | 25 | 26 | ################################################################################## 27 | # ORDERBOOK # 28 | ################################################################################## 29 | 30 | class Order(abstract.Order): 31 | pass 32 | 33 | class Orders(abstract.Orders): 34 | def __getitem__(self, item): 35 | return Order(self._data[item]) 36 | 37 | class OrderBook(abstract.OrderBook): 38 | def loadAsks(self): 39 | self._asks = Orders(self._data["asks"]) 40 | 41 | def loadBids(self): 42 | self._bids = Orders(self._data["bids"]) -------------------------------------------------------------------------------- /dev/therocktraiding/__init__.py: -------------------------------------------------------------------------------- 1 | from ccs import abstract 2 | 3 | from . import public 4 | from . import configuration 5 | 6 | 7 | class Symbol(abstract.Symbol): 8 | def __init__(self, cur1, cur2): 9 | self._cur1 = cur1 10 | self._cur2 = cur2 11 | 12 | def base(self): 13 | return self.normalize(self._cur1) 14 | 15 | def quote(self): 16 | return self.normalize(self._cur2) 17 | 18 | def normalize(self, cur): 19 | return cur.lower().strip() 20 | 21 | def __str__(self): 22 | return self.normalize(self._cur1) + self.normalize(self._cur2) 23 | 24 | 25 | class Adapter(abstract.Adapter): 26 | @staticmethod 27 | def ticker(cur1, cur2): 28 | symbol = Symbol(cur1, cur2) 29 | s = str(symbol) 30 | return public.response.Ticker(public.ticker(s), s) 31 | 32 | @staticmethod 33 | def trades(cur1, cur2, limit=None, direction=None): 34 | symbol = Symbol(cur1, cur2) 35 | s = str(symbol) 36 | return public.response.Trades(public.trades(s), s) 37 | 38 | @staticmethod 39 | def orderbook(cur1, cur2, limit=None): 40 | symbol = Symbol(cur1, cur2) 41 | s = str(symbol) 42 | return public.response.OrderBook(public.orderbook(s), s) 43 | -------------------------------------------------------------------------------- /dev/therocktraiding/public/response.py: -------------------------------------------------------------------------------- 1 | from ccs import abstract 2 | from ccs import constants 3 | 4 | 5 | ################################################################################## 6 | # TICKER # 7 | ################################################################################## 8 | 9 | class Ticker(abstract.Ticker): 10 | pass 11 | 12 | 13 | ################################################################################## 14 | # TRADES # 15 | ################################################################################## 16 | 17 | class Trade(abstract.Trade): 18 | pass 19 | 20 | class Trades(abstract.Trades): 21 | def __getitem__(self, item): 22 | return Trade(self._data[item], self._symbol) 23 | 24 | 25 | 26 | ################################################################################## 27 | # ORDERBOOK # 28 | ################################################################################## 29 | 30 | class Order(abstract.Order): 31 | pass 32 | 33 | class Orders(abstract.Orders): 34 | def __getitem__(self, item): 35 | return Order(self._data[item]) 36 | 37 | class OrderBook(abstract.OrderBook): 38 | def loadAsks(self): 39 | self._asks = Orders(self._data["asks"]) 40 | 41 | def loadBids(self): 42 | self._bids = Orders(self._data["bids"]) -------------------------------------------------------------------------------- /doc/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | SPHINXPROJ = CryptoCurrenciesStocks 8 | SOURCEDIR = source 9 | BUILDDIR = build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) -------------------------------------------------------------------------------- /doc/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=source 11 | set BUILDDIR=build 12 | set SPHINXPROJ=CryptoCurrenciesStocks 13 | 14 | if "%1" == "" goto help 15 | 16 | %SPHINXBUILD% >NUL 2>NUL 17 | if errorlevel 9009 ( 18 | echo. 19 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 20 | echo.installed, then set the SPHINXBUILD environment variable to point 21 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 22 | echo.may add the Sphinx directory to PATH. 23 | echo. 24 | echo.If you don't have Sphinx installed, grab it from 25 | echo.http://sphinx-doc.org/ 26 | exit /b 1 27 | ) 28 | 29 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% 30 | goto end 31 | 32 | :help 33 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% 34 | 35 | :end 36 | popd 37 | -------------------------------------------------------------------------------- /doc/source/bitfinex.rst: -------------------------------------------------------------------------------- 1 | Bifinex 2 | ======= 3 | 4 | This implementation is build on Bitfinex REST API version 1.1. The official documentation is available `here `_. It is highly recommended that the user should read `General_informations`_ before using. 5 | 6 | .. _General_informations: general_informations.html 7 | 8 | .. currentmodule:: ccs.bitfinex.public 9 | 10 | Fundingbook 11 | ----------- 12 | .. autofunction:: fundingbook 13 | 14 | Lends 15 | ----- 16 | .. autofunction:: lends 17 | 18 | Orderbook 19 | --------- 20 | .. autofunction:: orderbook 21 | 22 | Stats 23 | ----- 24 | .. autofunction:: stats 25 | 26 | Symbols 27 | ------- 28 | .. autofunction:: symbols 29 | 30 | Symbols details 31 | --------------- 32 | .. autofunction:: symbolsDetails 33 | 34 | Ticker 35 | ------ 36 | .. autofunction:: ticker 37 | 38 | Trades 39 | ------ 40 | .. autofunction:: trades 41 | 42 | -------------------------------------------------------------------------------- /doc/source/bitstamp.rst: -------------------------------------------------------------------------------- 1 | Bitstamp 2 | ======== 3 | 4 | This implementation is build on Bitstamp REST API version 2. The official documentation is available `here `_. It is highly recommended that the user should read `General_informations`_ before using. 5 | 6 | .. _General_informations: general_informations.html 7 | 8 | .. currentmodule:: ccs.bitstamp.public 9 | 10 | EUR USD conversion rate 11 | ----------------------- 12 | .. autofunction:: eurUsdConversionRate 13 | 14 | Hourly ticker 15 | ------------- 16 | .. autofunction:: hourlyTicker 17 | 18 | Orderbook 19 | --------- 20 | .. autofunction:: orderbook 21 | 22 | Ticker 23 | ------ 24 | .. autofunction:: ticker 25 | 26 | Transactions 27 | ------------ 28 | .. autofunction:: transactions 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /doc/source/bittrex.rst: -------------------------------------------------------------------------------- 1 | Bittrex 2 | ======= 3 | 4 | .. currentmodule:: ccs.bittrex.public 5 | 6 | 7 | Get currencies 8 | -------------- 9 | .. autofunction:: getCurrencies 10 | 11 | Get markets 12 | ----------- 13 | .. autofunction:: getMarkets 14 | 15 | Get market history 16 | ------------------ 17 | .. autofunction:: getMarketHistory 18 | 19 | Get market summary 20 | ------------------ 21 | .. autofunction:: getMarketSummary 22 | 23 | Get market summaries 24 | -------------------- 25 | .. autofunction:: getMarketSummaries 26 | 27 | Get orderbook 28 | ------------- 29 | .. autofunction:: getOrderbook 30 | 31 | Get ticker 32 | ---------- 33 | .. autofunction:: getTicker 34 | 35 | -------------------------------------------------------------------------------- /doc/source/btcc.rst: -------------------------------------------------------------------------------- 1 | Btcc 2 | ==== 3 | 4 | .. automodule:: ccs.btcc.public 5 | :members: -------------------------------------------------------------------------------- /doc/source/btccpro.rst: -------------------------------------------------------------------------------- 1 | Btccpro 2 | ======= 3 | 4 | .. automodule:: ccs.btccpro.public 5 | :members: -------------------------------------------------------------------------------- /doc/source/btccusd.rst: -------------------------------------------------------------------------------- 1 | Btccusd 2 | ======= 3 | 4 | .. automodule:: ccs.btccusd.public 5 | :members: -------------------------------------------------------------------------------- /doc/source/btce.rst: -------------------------------------------------------------------------------- 1 | Btce 2 | ==== 3 | 4 | .. currentmodule:: ccs.btce.public 5 | 6 | Depth 7 | ----- 8 | .. autofunction:: depth 9 | 10 | Info 11 | ---- 12 | .. autofunction:: info 13 | 14 | Ticker 15 | ------ 16 | .. autofunction:: ticker 17 | 18 | Trades 19 | ------ 20 | .. autofunction:: trades 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /doc/source/bter.rst: -------------------------------------------------------------------------------- 1 | Bter 2 | ==== 3 | 4 | .. currentmodule:: ccs.bter.public 5 | 6 | Depth 7 | ----- 8 | .. autofunction:: depth 9 | 10 | Market info 11 | ----------- 12 | .. autofunction:: marketInfo 13 | 14 | Market details 15 | -------------- 16 | .. autofunction:: marketDetails 17 | 18 | Ticker 19 | ------ 20 | .. autofunction:: ticker 21 | 22 | Tickers 23 | ------- 24 | .. autofunction:: tickers 25 | 26 | Trading pairs 27 | ------------- 28 | .. autofunction:: tradingPairs 29 | 30 | Trade history 31 | ------------- 32 | .. autofunction:: tradeHistory -------------------------------------------------------------------------------- /doc/source/cexio.rst: -------------------------------------------------------------------------------- 1 | Cexio 2 | ===== 3 | 4 | .. currentmodule:: ccs.cexio.public 5 | 6 | Chart 7 | ----- 8 | .. autofunction:: chart 9 | 10 | Convert 11 | ------- 12 | .. autofunction:: convert 13 | 14 | Currency limits 15 | --------------- 16 | .. autofunction:: currencyLimits 17 | 18 | Historical 1m OHLCV chart 19 | ------------------------- 20 | .. autofunction:: historical1mOHLCVChart 21 | 22 | Last price 23 | ---------- 24 | .. autofunction:: lastPrice 25 | 26 | Last prices for given market 27 | ---------------------------- 28 | .. autofunction:: lastPricesForGivenMarket 29 | 30 | Orderbook 31 | --------- 32 | .. autofunction:: orderbook 33 | 34 | Ticker 35 | ------ 36 | .. autofunction:: ticker 37 | 38 | Tickers for all pairs by market 39 | ------------------------------- 40 | .. autofunction:: tickersForAllPairsByMarket 41 | 42 | Trade history 43 | ------------- 44 | .. autofunction:: tradeHistory 45 | 46 | 47 | -------------------------------------------------------------------------------- /doc/source/configuration.rst: -------------------------------------------------------------------------------- 1 | Configuration 2 | ============= 3 | -------------------------------------------------------------------------------- /doc/source/constants.rst: -------------------------------------------------------------------------------- 1 | Constants 2 | ========= 3 | -------------------------------------------------------------------------------- /doc/source/index.rst: -------------------------------------------------------------------------------- 1 | .. Crypto Currencies Stocks documentation master file, created by 2 | sphinx-quickstart on Mon Dec 19 12:18:40 2016. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Welcome to Crypto Currencies Stocks's documentation! 7 | ==================================================== 8 | 9 | CCS is Python package for communication with stocks which is traiding with crypto currencies. 10 | 11 | 12 | .. toctree:: 13 | :maxdepth: 2 14 | :caption: General: 15 | 16 | overview 17 | instalation 18 | configuration 19 | warnings 20 | constants 21 | 22 | .. toctree:: 23 | :maxdepth: 2 24 | :caption: Unificated API: 25 | 26 | ticker 27 | trades 28 | orderbook 29 | 30 | .. toctree:: 31 | :maxdepth: 3 32 | :caption: Stocks API: 33 | 34 | general_informations.rst 35 | bitfinex 36 | bitstamp 37 | bittrex 38 | btcc 39 | btccpro 40 | btccusd 41 | btce 42 | bter 43 | cexio 44 | kraken 45 | okcoin 46 | poloniex 47 | 48 | 49 | Indices and tables 50 | ================== 51 | 52 | * :ref:`genindex` 53 | * :ref:`modindex` 54 | * :ref:`search` 55 | -------------------------------------------------------------------------------- /doc/source/instalation.rst: -------------------------------------------------------------------------------- 1 | Instalation 2 | =========== 3 | 4 | This package is part of pypi. Command for instalation is: 5 | 6 | :: 7 | 8 | $ pip install ccs 9 | 10 | -------------------------------------------------------------------------------- /doc/source/kraken.rst: -------------------------------------------------------------------------------- 1 | Kraken 2 | ====== 3 | 4 | API call rate limit 5 | 6 | Every user of our API has a "call counter" which starts at 0. 7 | 8 | Ledger/trade history calls increase the counter by 2. 9 | 10 | Place/cancel order calls do not affect the counter. 11 | 12 | All other API calls increase the counter by 1. 13 | 14 | The user's counter is reduced every couple of seconds, and if the counter exceeds the user's maximum API access is suspended for 15 minutes. Tier 2 users have a maximum of 15 and their count gets reduced by 1 every 3 seconds. 15 | 16 | 17 | .. currentmodule:: ccs.kraken.public 18 | 19 | Asset info 20 | ---------- 21 | .. autofunction:: getAssetInfo 22 | 23 | 24 | Asset pairs 25 | ----------- 26 | .. autofunction:: getTradableAssetPairs 27 | 28 | OHLC 29 | ---- 30 | .. autofunction:: getOHLCdata 31 | 32 | Orderbook 33 | --------- 34 | .. autofunction:: getOrderBook 35 | 36 | 37 | Ticker 38 | ------ 39 | .. autofunction:: getTickerInformation 40 | 41 | Trades 42 | ------ 43 | .. autofunction:: getRecentTrades 44 | 45 | Server time 46 | ----------- 47 | .. autofunction:: getServerTime 48 | 49 | Spread 50 | ------ 51 | .. autofunction:: getRecentSpreadData 52 | 53 | 54 | -------------------------------------------------------------------------------- /doc/source/okcoin.rst: -------------------------------------------------------------------------------- 1 | Okcoin 2 | ====== 3 | 4 | .. currentmodule:: ccs.okcoin.public 5 | 6 | Depth 7 | ----- 8 | .. autofunction:: depth 9 | 10 | Kline 11 | ----- 12 | .. autofunction:: kline 13 | 14 | Ticker 15 | ------ 16 | .. autofunction:: ticker 17 | 18 | Trades 19 | ------ 20 | .. autofunction:: trades 21 | 22 | -------------------------------------------------------------------------------- /doc/source/orderbook.rst: -------------------------------------------------------------------------------- 1 | Orderbook 2 | ========= 3 | -------------------------------------------------------------------------------- /doc/source/overview.rst: -------------------------------------------------------------------------------- 1 | Overview 2 | ======== 3 | Crypto currencies stocks (ccs) is Python package for communication with stocks which is traiding with crypto currencies. This library has two levels: 4 | 5 | * basic stock's API 6 | 7 | * unificated API build over basic API 8 | 9 | It means here are two ways how use this library. 10 | using basic api and than parse himself 11 | using unificated api 12 | 13 | Public api 14 | 15 | REST 16 | 17 | implemented method 18 | 19 | Here is effort solve problem that crypto currencies stocks offer similarly information in different formats. Unfication is associated with: 20 | 21 | * API unification for most frequented requests (ticker, trade history, orderbook ...) 22 | 23 | * responses unification from requests 24 | 25 | Supported stocks 26 | ---------------- 27 | ============ ============================ 28 | Stock Link 29 | ============ ============================ 30 | Bitfinex https://www.bitfinex.com/ 31 | Bitstamp https://www.bitstamp.net/ 32 | Bittrex https://bittrex.com/ 33 | Btcc https://www.btcc.com/ 34 | Btce https://btc-e.com/ 35 | Bter https://bter.com/ 36 | Cex.io https://cex.io/ 37 | Kraken https://www.kraken.com/ 38 | Okcoin.com https://www.okcoin.com/ 39 | Okcoin.cn https://www.okcoin.cn/ 40 | Poloniex https://poloniex.com/ 41 | ============ ============================ 42 | 43 | -------------------------------------------------------------------------------- /doc/source/poloniex.rst: -------------------------------------------------------------------------------- 1 | Poloniex 2 | ======== 3 | 4 | .. currentmodule:: ccs.poloniex.public 5 | 6 | Ticker 7 | ------ 8 | .. autofunction:: returnTicker 9 | 10 | Trade history 11 | ------------- 12 | .. autofunction:: returnTradeHistory 13 | 14 | Orderbook 15 | --------- 16 | .. autofunction:: returnOrderBook 17 | 18 | 24h volume 19 | ---------- 20 | .. autofunction:: return24hVolume 21 | 22 | Chart data 23 | ---------- 24 | .. autofunction:: returnChartData 25 | 26 | Currencies 27 | ---------- 28 | .. autofunction:: returnCurrencies 29 | 30 | Loan orders 31 | ----------- 32 | .. autofunction:: returnLoanOrders -------------------------------------------------------------------------------- /doc/source/ticker.rst: -------------------------------------------------------------------------------- 1 | Ticker 2 | ====== 3 | 4 | Example of using 5 | ---------------- 6 | 7 | >>> import ccs 8 | >>> ticker = ccs.ticker(ccs.constants.BITFINEX, ccs.constants.BTC, ccs.constants.USD) 9 | >>> print(str(ticker)) 10 | ... 11 | >>> print(str(ticker.usymbol())) 12 | ... 13 | >>> print(str(ticker.osymbol())) 14 | ... 15 | >>> print(str(ticker.stock())) 16 | ... 17 | >>> print(str(ticker.last())) 18 | ... 19 | >>> print(str(ticker.low())) 20 | ... 21 | >>> print(str(ticker.high())) 22 | ... 23 | >>> print(str(ticker.ask())) 24 | ... 25 | >>> print(str(ticker.bid())) 26 | ... 27 | >>> print(str(ticker.volume24h())) 28 | ... 29 | >>> print(str(ticker.timestamp())) 30 | ... 31 | >>> print(str(ticker.dt())) 32 | 33 | 34 | Stock argument 35 | -------------- 36 | 37 | Currencies arguments 38 | -------------------- 39 | 40 | Invalid 41 | ------- 42 | 43 | 44 | Class Ticker 45 | ------------ 46 | 47 | This is description of abstract class. 48 | 49 | .. autoclass:: ccs.abstract.Ticker 50 | :members: 51 | :inherited-members: 52 | 53 | 54 | Mapping 55 | ------- 56 | -------------------------------------------------------------------------------- /doc/source/trades.rst: -------------------------------------------------------------------------------- 1 | Trades 2 | ====== 3 | -------------------------------------------------------------------------------- /doc/source/warnings.rst: -------------------------------------------------------------------------------- 1 | Warnings 2 | ======== 3 | -------------------------------------------------------------------------------- /empty/__init__.py: -------------------------------------------------------------------------------- 1 | from .. import abstract 2 | 3 | from . import public 4 | from . import configuration 5 | 6 | 7 | class Symbol(abstract.Symbol): 8 | def __init__(self, cur1, cur2): 9 | self._cur1 = cur1 10 | self._cur2 = cur2 11 | 12 | def cur1(self): 13 | return self.normalize(self._cur1) 14 | 15 | def cur2(self): 16 | return self.normalize(self._cur2) 17 | 18 | def normalize(self, cur): 19 | return cur.lower().strip() 20 | 21 | def __str__(self): 22 | return self.normalize(self._cur1) + self.normalize(self._cur2) 23 | 24 | 25 | class Adapter(abstract.Adapter): 26 | @staticmethod 27 | def ticker(cur1, cur2): 28 | symbol = Symbol(cur1, cur2) 29 | s = str(symbol) 30 | return public.response.Ticker(public.ticker(s), s) 31 | 32 | @staticmethod 33 | def trades(cur1, cur2, limit=None, direction=None): 34 | symbol = Symbol(cur1, cur2) 35 | s = str(symbol) 36 | return public.response.Trades(public.trades(s), s) 37 | 38 | @staticmethod 39 | def orderbook(cur1, cur2, limit=None): 40 | symbol = Symbol(cur1, cur2) 41 | s = str(symbol) 42 | return public.response.OrderBook(public.orderbook(s), s) 43 | -------------------------------------------------------------------------------- /empty/public/__init__.py: -------------------------------------------------------------------------------- 1 | import urllib.parse 2 | 3 | from ... import core 4 | from ... import constants 5 | from . import response -------------------------------------------------------------------------------- /empty/public/response.py: -------------------------------------------------------------------------------- 1 | from ... import abstract 2 | from ... import constants 3 | 4 | 5 | ################################################################################## 6 | # TICKER # 7 | ################################################################################## 8 | 9 | class Ticker(abstract.Ticker): 10 | pass 11 | 12 | 13 | ################################################################################## 14 | # TRADES # 15 | ################################################################################## 16 | 17 | class Trade(abstract.Trade): 18 | pass 19 | 20 | class Trades(abstract.Trades): 21 | def __getitem__(self, item): 22 | return Trade(self._data[item], self._symbol) 23 | 24 | 25 | 26 | ################################################################################## 27 | # ORDERBOOK # 28 | ################################################################################## 29 | 30 | class Order(abstract.Order): 31 | pass 32 | 33 | class Orders(abstract.Orders): 34 | def __getitem__(self, item): 35 | return Order(self._data[item]) 36 | 37 | class OrderBook(abstract.OrderBook): 38 | def loadAsks(self): 39 | self._asks = Orders(self._data["asks"]) 40 | 41 | def loadBids(self): 42 | self._bids = Orders(self._data["bids"]) -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | jsonschema -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [metadata] 2 | description-file = README.md -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- 1 | from . import testAdapter 2 | from . import testApi 3 | from . import testResponse -------------------------------------------------------------------------------- /tests/testAdapter/__init__.py: -------------------------------------------------------------------------------- 1 | from .testBitfinex import * 2 | from .testBitstamp import * 3 | from .testBittrex import * 4 | from .testBtcc import * 5 | from .testBtccpro import * 6 | from .testBtccusd import * 7 | from .testBtce import * 8 | from .testBter import * 9 | from .testCexio import * 10 | from .testKraken import * 11 | from .testOkcoincn import * 12 | from .testOkcoincom import * 13 | from .testPoloniex import * 14 | 15 | -------------------------------------------------------------------------------- /tests/testAdapter/testBitfinex/__init__.py: -------------------------------------------------------------------------------- 1 | from . import testOrder 2 | from . import testOrderbook 3 | from . import testOrders 4 | from . import testTicker 5 | from . import testTrade 6 | from . import testTrades -------------------------------------------------------------------------------- /tests/testAdapter/testBitfinex/testOrderbook.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import ccs 3 | import datetime 4 | import time 5 | 6 | #################################################################################################################### 7 | # BITFINEX # 8 | #################################################################################################################### 9 | 10 | class Valid(unittest.TestCase): 11 | def setUp(self): 12 | self.stock = ccs.constants.BITFINEX 13 | self.base = ccs.constants.BTC 14 | self.quote = ccs.constants.USD 15 | self.orderbook = ccs.orderbook(self.stock, self.base, self.quote) 16 | self.m = ccs.bitfinex.public.response 17 | #time.sleep(3) 18 | 19 | def testAsks(self): 20 | self.assertIsInstance(self.orderbook.asks(), self.m.Orders) 21 | 22 | def testBids(self): 23 | self.assertIsInstance(self.orderbook.bids(), self.m.Orders) 24 | 25 | def testStock(self): 26 | self.assertEqual(self.orderbook.stock(), self.stock) 27 | 28 | def testMethod(self): 29 | self.assertEqual(self.orderbook.method(), ccs.constants.ORDERBOOK) 30 | 31 | def testUsymbol(self): 32 | self.assertEqual(self.orderbook.usymbol(), self.base + ":" + self.quote) 33 | 34 | def testOsymbol(self): 35 | pass 36 | 37 | def testData(self): 38 | pass 39 | 40 | def testRaw(self): 41 | pass 42 | 43 | def testStr(self): 44 | pass 45 | 46 | 47 | if __name__ == '__main__': 48 | unittest.main() 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /tests/testAdapter/testBitfinex/testTrades.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import ccs 3 | import time 4 | 5 | #################################################################################################################### 6 | # BITFINEX # 7 | #################################################################################################################### 8 | 9 | class Valid(unittest.TestCase): 10 | def setUp(self): 11 | self.stock = ccs.constants.BITFINEX 12 | self.base = ccs.constants.BTC 13 | self.quote = ccs.constants.USD 14 | self.trades = ccs.trades(self.stock, self.base, self.quote) 15 | self.m = ccs.bitfinex.public.response 16 | #time.sleep(3) 17 | 18 | def testLen(self): 19 | self.assertIsInstance(len(self.trades), int) 20 | 21 | def testGetItem(self): 22 | self.assertIsInstance(self.trades[0], self.m.Trade) 23 | 24 | def testStock(self): 25 | self.assertEqual(self.trades.stock(), self.stock) 26 | 27 | def testMethod(self): 28 | self.assertEqual(self.trades.method(), ccs.constants.TRADES) 29 | 30 | def testUsymbol(self): 31 | self.assertEqual(self.trades.usymbol(), self.base + ":" + self.quote) 32 | 33 | def testOsymbol(self): 34 | pass 35 | 36 | def testData(self): 37 | pass 38 | 39 | def testRaw(self): 40 | pass 41 | 42 | def testStr(self): 43 | pass 44 | 45 | 46 | if __name__ == '__main__': 47 | unittest.main() 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /tests/testAdapter/testBitstamp/__init__.py: -------------------------------------------------------------------------------- 1 | from . import testOrder 2 | from . import testOrderbook 3 | from . import testOrders 4 | from . import testTicker 5 | from . import testTrade 6 | from . import testTrades 7 | -------------------------------------------------------------------------------- /tests/testAdapter/testBitstamp/testOrderbook.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import ccs 3 | import datetime 4 | import time 5 | 6 | #################################################################################################################### 7 | # BITSTAMP # 8 | #################################################################################################################### 9 | 10 | class Valid(unittest.TestCase): 11 | def setUp(self): 12 | self.stock = ccs.constants.BITSTAMP 13 | self.base = ccs.constants.BTC 14 | self.quote = ccs.constants.USD 15 | self.orderbook = ccs.orderbook(self.stock, self.base, self.quote) 16 | self.m = ccs.bitstamp.public.response 17 | #time.sleep(3) 18 | 19 | def testAsks(self): 20 | self.assertIsInstance(self.orderbook.asks(), self.m.Orders) 21 | 22 | def testBids(self): 23 | self.assertIsInstance(self.orderbook.bids(), self.m.Orders) 24 | 25 | def testStock(self): 26 | self.assertEqual(self.orderbook.stock(), self.stock) 27 | 28 | def testMethod(self): 29 | self.assertEqual(self.orderbook.method(), ccs.constants.ORDERBOOK) 30 | 31 | def testUsymbol(self): 32 | self.assertEqual(self.orderbook.usymbol(), self.base + ":" + self.quote) 33 | 34 | def testOsymbol(self): 35 | pass 36 | 37 | def testData(self): 38 | pass 39 | 40 | def testRaw(self): 41 | pass 42 | 43 | def testStr(self): 44 | pass 45 | 46 | 47 | if __name__ == '__main__': 48 | unittest.main() 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /tests/testAdapter/testBitstamp/testTrades.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import ccs 3 | import time 4 | 5 | #################################################################################################################### 6 | # BITSTAMP # 7 | #################################################################################################################### 8 | 9 | class Valid(unittest.TestCase): 10 | def setUp(self): 11 | self.stock = ccs.constants.BITSTAMP 12 | self.base = ccs.constants.BTC 13 | self.quote = ccs.constants.USD 14 | self.trades = ccs.trades(self.stock, self.base, self.quote) 15 | self.m = ccs.bitstamp.public.response 16 | # time.sleep(3) 17 | 18 | def testLen(self): 19 | self.assertIsInstance(len(self.trades), int) 20 | 21 | def testGetItem(self): 22 | self.assertIsInstance(self.trades[0], self.m.Trade) 23 | 24 | def testStock(self): 25 | self.assertEqual(self.trades.stock(), self.stock) 26 | 27 | def testMethod(self): 28 | self.assertEqual(self.trades.method(), ccs.constants.TRADES) 29 | 30 | def testUsymbol(self): 31 | self.assertEqual(self.trades.usymbol(), self.base + ":" + self.quote) 32 | 33 | def testOsymbol(self): 34 | pass 35 | 36 | def testData(self): 37 | pass 38 | 39 | def testRaw(self): 40 | pass 41 | 42 | def testStr(self): 43 | pass 44 | 45 | 46 | if __name__ == '__main__': 47 | unittest.main() 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /tests/testAdapter/testBittrex/__init__.py: -------------------------------------------------------------------------------- 1 | from . import testOrder 2 | from . import testOrderbook 3 | from . import testOrders 4 | from . import testTicker 5 | from . import testTrade 6 | from . import testTrades -------------------------------------------------------------------------------- /tests/testAdapter/testBittrex/testOrderbook.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import ccs 3 | import datetime 4 | import time 5 | 6 | #################################################################################################################### 7 | # BITTREX # 8 | #################################################################################################################### 9 | 10 | class Valid(unittest.TestCase): 11 | def setUp(self): 12 | self.stock = ccs.constants.BITTREX 13 | self.base = ccs.constants.BTC 14 | self.quote = ccs.constants.LTC 15 | self.orderbook = ccs.orderbook(self.stock, self.base, self.quote) 16 | self.m = ccs.bittrex.public.response 17 | #time.sleep(3) 18 | 19 | def testAsks(self): 20 | self.assertIsInstance(self.orderbook.asks(), self.m.Orders) 21 | 22 | def testBids(self): 23 | self.assertIsInstance(self.orderbook.bids(), self.m.Orders) 24 | 25 | def testStock(self): 26 | self.assertEqual(self.orderbook.stock(), self.stock) 27 | 28 | def testMethod(self): 29 | self.assertEqual(self.orderbook.method(), ccs.constants.ORDERBOOK) 30 | 31 | def testUsymbol(self): 32 | self.assertEqual(self.orderbook.usymbol(), self.base + ":" + self.quote) 33 | 34 | def testOsymbol(self): 35 | pass 36 | 37 | def testData(self): 38 | pass 39 | 40 | def testRaw(self): 41 | pass 42 | 43 | def testStr(self): 44 | pass 45 | 46 | 47 | if __name__ == '__main__': 48 | unittest.main() 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /tests/testAdapter/testBittrex/testTrades.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import ccs 3 | import time 4 | 5 | #################################################################################################################### 6 | # BITTREX # 7 | #################################################################################################################### 8 | 9 | class Valid(unittest.TestCase): 10 | def setUp(self): 11 | self.stock = ccs.constants.BITTREX 12 | self.base = ccs.constants.BTC 13 | self.quote = ccs.constants.LTC 14 | self.trades = ccs.trades(self.stock, self.base, self.quote) 15 | self.m = ccs.bittrex.public.response 16 | #time.sleep(3) 17 | 18 | def testLen(self): 19 | self.assertIsInstance(len(self.trades), int) 20 | 21 | def testGetItem(self): 22 | self.assertIsInstance(self.trades[0], self.m.Trade) 23 | 24 | def testStock(self): 25 | self.assertEqual(self.trades.stock(), self.stock) 26 | 27 | def testMethod(self): 28 | self.assertEqual(self.trades.method(), ccs.constants.TRADES) 29 | 30 | def testUsymbol(self): 31 | self.assertEqual(self.trades.usymbol(), self.base + ":" + self.quote) 32 | 33 | def testOsymbol(self): 34 | pass 35 | 36 | def testData(self): 37 | pass 38 | 39 | def testRaw(self): 40 | pass 41 | 42 | def testStr(self): 43 | pass 44 | 45 | 46 | if __name__ == '__main__': 47 | unittest.main() 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /tests/testAdapter/testBtcc/__init__.py: -------------------------------------------------------------------------------- 1 | from . import testOrder 2 | from . import testOrderbook 3 | from . import testOrders 4 | from . import testTicker 5 | from . import testTrade 6 | from . import testTrades -------------------------------------------------------------------------------- /tests/testAdapter/testBtcc/testOrderbook.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import ccs 3 | import datetime 4 | import time 5 | 6 | #################################################################################################################### 7 | # BITFINEX # 8 | #################################################################################################################### 9 | 10 | class Valid(unittest.TestCase): 11 | def setUp(self): 12 | self.stock = ccs.constants.BTCC 13 | self.base = ccs.constants.BTC 14 | self.quote = ccs.constants.CNY 15 | self.orderbook = ccs.orderbook(self.stock, self.base, self.quote) 16 | self.m = ccs.btcc.public.response 17 | #time.sleep(3) 18 | 19 | def testAsks(self): 20 | self.assertIsInstance(self.orderbook.asks(), self.m.Orders) 21 | 22 | def testBids(self): 23 | self.assertIsInstance(self.orderbook.bids(), self.m.Orders) 24 | 25 | def testStock(self): 26 | self.assertEqual(self.orderbook.stock(), self.stock) 27 | 28 | def testMethod(self): 29 | self.assertEqual(self.orderbook.method(), ccs.constants.ORDERBOOK) 30 | 31 | def testUsymbol(self): 32 | self.assertEqual(self.orderbook.usymbol(), self.base + ":" + self.quote) 33 | 34 | def testOsymbol(self): 35 | pass 36 | 37 | def testData(self): 38 | pass 39 | 40 | def testRaw(self): 41 | pass 42 | 43 | def testStr(self): 44 | pass 45 | 46 | 47 | if __name__ == '__main__': 48 | unittest.main() 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /tests/testAdapter/testBtcc/testTrades.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import ccs 3 | import time 4 | 5 | #################################################################################################################### 6 | # BITFINEX # 7 | #################################################################################################################### 8 | 9 | class Valid(unittest.TestCase): 10 | def setUp(self): 11 | self.stock = ccs.constants.BTCC 12 | self.base = ccs.constants.BTC 13 | self.quote = ccs.constants.CNY 14 | self.trades = ccs.trades(self.stock, self.base, self.quote) 15 | self.m = ccs.btcc.public.response 16 | #time.sleep(3) 17 | 18 | def testLen(self): 19 | self.assertIsInstance(len(self.trades), int) 20 | 21 | def testGetItem(self): 22 | self.assertIsInstance(self.trades[0], self.m.Trade) 23 | 24 | def testStock(self): 25 | self.assertEqual(self.trades.stock(), self.stock) 26 | 27 | def testMethod(self): 28 | self.assertEqual(self.trades.method(), ccs.constants.TRADES) 29 | 30 | def testUsymbol(self): 31 | self.assertEqual(self.trades.usymbol(), self.base + ":" + self.quote) 32 | 33 | def testOsymbol(self): 34 | pass 35 | 36 | def testData(self): 37 | pass 38 | 39 | def testRaw(self): 40 | pass 41 | 42 | def testStr(self): 43 | pass 44 | 45 | 46 | if __name__ == '__main__': 47 | unittest.main() 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /tests/testAdapter/testBtccpro/__init__.py: -------------------------------------------------------------------------------- 1 | from . import testOrder 2 | from . import testOrderbook 3 | from . import testOrders 4 | from . import testTicker 5 | from . import testTrade 6 | from . import testTrades -------------------------------------------------------------------------------- /tests/testAdapter/testBtccpro/testOrderbook.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import ccs 3 | import datetime 4 | import time 5 | 6 | #################################################################################################################### 7 | # BTCCPRO # 8 | #################################################################################################################### 9 | 10 | class Valid(unittest.TestCase): 11 | def setUp(self): 12 | self.stock = ccs.constants.BTCCPRO 13 | self.base = ccs.constants.XBT 14 | self.quote = ccs.constants.CNY 15 | self.orderbook = ccs.orderbook(self.stock, self.base, self.quote) 16 | self.m = ccs.btccpro.public.response 17 | #time.sleep(3) 18 | 19 | def testAsks(self): 20 | self.assertIsInstance(self.orderbook.asks(), self.m.Orders) 21 | 22 | def testBids(self): 23 | self.assertIsInstance(self.orderbook.bids(), self.m.Orders) 24 | 25 | def testStock(self): 26 | self.assertEqual(self.orderbook.stock(), self.stock) 27 | 28 | def testMethod(self): 29 | self.assertEqual(self.orderbook.method(), ccs.constants.ORDERBOOK) 30 | 31 | def testUsymbol(self): 32 | self.assertEqual(self.orderbook.usymbol(), self.base + ":" + self.quote) 33 | 34 | def testOsymbol(self): 35 | pass 36 | 37 | def testData(self): 38 | pass 39 | 40 | def testRaw(self): 41 | pass 42 | 43 | def testStr(self): 44 | pass 45 | 46 | 47 | if __name__ == '__main__': 48 | unittest.main() 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /tests/testAdapter/testBtccpro/testTrades.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import ccs 3 | import time 4 | 5 | #################################################################################################################### 6 | # BTCCPRO # 7 | #################################################################################################################### 8 | 9 | class Valid(unittest.TestCase): 10 | def setUp(self): 11 | self.stock = ccs.constants.BTCCPRO 12 | self.base = ccs.constants.XBT 13 | self.quote = ccs.constants.CNY 14 | self.trades = ccs.trades(self.stock, self.base, self.quote) 15 | self.m = ccs.btccusd.public.response 16 | #time.sleep(3) 17 | 18 | def testLen(self): 19 | self.assertIsInstance(len(self.trades), int) 20 | 21 | def testGetItem(self): 22 | self.assertIsInstance(self.trades[0], self.m.Trade) 23 | 24 | def testStock(self): 25 | self.assertEqual(self.trades.stock(), self.stock) 26 | 27 | def testMethod(self): 28 | self.assertEqual(self.trades.method(), ccs.constants.TRADES) 29 | 30 | def testUsymbol(self): 31 | self.assertEqual(self.trades.usymbol(), self.base + ":" + self.quote) 32 | 33 | def testOsymbol(self): 34 | pass 35 | 36 | def testData(self): 37 | pass 38 | 39 | def testRaw(self): 40 | pass 41 | 42 | def testStr(self): 43 | pass 44 | 45 | 46 | if __name__ == '__main__': 47 | unittest.main() 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /tests/testAdapter/testBtccusd/__init__.py: -------------------------------------------------------------------------------- 1 | from . import testOrder 2 | from . import testOrderbook 3 | from . import testOrders 4 | from . import testTicker 5 | from . import testTrade 6 | from . import testTrades -------------------------------------------------------------------------------- /tests/testAdapter/testBtccusd/testOrderbook.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import ccs 3 | import datetime 4 | import time 5 | 6 | #################################################################################################################### 7 | # BTCCPRO # 8 | #################################################################################################################### 9 | 10 | class Valid(unittest.TestCase): 11 | def setUp(self): 12 | self.stock = ccs.constants.BTCCUSD 13 | self.base = ccs.constants.BTC 14 | self.quote = ccs.constants.USD 15 | self.orderbook = ccs.orderbook(self.stock, self.base, self.quote) 16 | self.m = ccs.btccusd.public.response 17 | #time.sleep(3) 18 | 19 | def testAsks(self): 20 | self.assertIsInstance(self.orderbook.asks(), self.m.Orders) 21 | 22 | def testBids(self): 23 | self.assertIsInstance(self.orderbook.bids(), self.m.Orders) 24 | 25 | def testStock(self): 26 | self.assertEqual(self.orderbook.stock(), self.stock) 27 | 28 | def testMethod(self): 29 | self.assertEqual(self.orderbook.method(), ccs.constants.ORDERBOOK) 30 | 31 | def testUsymbol(self): 32 | self.assertEqual(self.orderbook.usymbol(), self.base + ":" + self.quote) 33 | 34 | def testOsymbol(self): 35 | pass 36 | 37 | def testData(self): 38 | pass 39 | 40 | def testRaw(self): 41 | pass 42 | 43 | def testStr(self): 44 | pass 45 | 46 | 47 | if __name__ == '__main__': 48 | unittest.main() 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /tests/testAdapter/testBtccusd/testTrades.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import ccs 3 | import time 4 | 5 | #################################################################################################################### 6 | # BTCCPRO # 7 | #################################################################################################################### 8 | 9 | class Valid(unittest.TestCase): 10 | def setUp(self): 11 | self.stock = ccs.constants.BTCCUSD 12 | self.base = ccs.constants.BTC 13 | self.quote = ccs.constants.USD 14 | self.trades = ccs.trades(self.stock, self.base, self.quote) 15 | self.m = ccs.btccusd.public.response 16 | #time.sleep(3) 17 | 18 | def testLen(self): 19 | self.assertIsInstance(len(self.trades), int) 20 | 21 | def testGetItem(self): 22 | self.assertIsInstance(self.trades[0], self.m.Trade) 23 | 24 | def testStock(self): 25 | self.assertEqual(self.trades.stock(), self.stock) 26 | 27 | def testMethod(self): 28 | self.assertEqual(self.trades.method(), ccs.constants.TRADES) 29 | 30 | def testUsymbol(self): 31 | self.assertEqual(self.trades.usymbol(), self.base + ":" + self.quote) 32 | 33 | def testOsymbol(self): 34 | pass 35 | 36 | def testData(self): 37 | pass 38 | 39 | def testRaw(self): 40 | pass 41 | 42 | def testStr(self): 43 | pass 44 | 45 | 46 | if __name__ == '__main__': 47 | unittest.main() 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /tests/testAdapter/testBtce/__init__.py: -------------------------------------------------------------------------------- 1 | from . import testOrder 2 | from . import testOrderbook 3 | from . import testOrders 4 | from . import testTicker 5 | from . import testTrade 6 | from . import testTrades -------------------------------------------------------------------------------- /tests/testAdapter/testBtce/testOrderbook.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import ccs 3 | import datetime 4 | import time 5 | 6 | #################################################################################################################### 7 | # BTCE # 8 | #################################################################################################################### 9 | 10 | class Valid(unittest.TestCase): 11 | def setUp(self): 12 | self.stock = ccs.constants.BTCE 13 | self.base = ccs.constants.BTC 14 | self.quote = ccs.constants.USD 15 | self.orderbook = ccs.orderbook(self.stock, self.base, self.quote) 16 | self.m = ccs.btce.public.response 17 | #time.sleep(3) 18 | 19 | def testAsks(self): 20 | self.assertIsInstance(self.orderbook.asks(), self.m.Orders) 21 | 22 | def testBids(self): 23 | self.assertIsInstance(self.orderbook.bids(), self.m.Orders) 24 | 25 | def testStock(self): 26 | self.assertEqual(self.orderbook.stock(), self.stock) 27 | 28 | def testMethod(self): 29 | self.assertEqual(self.orderbook.method(), ccs.constants.ORDERBOOK) 30 | 31 | def testUsymbol(self): 32 | self.assertEqual(self.orderbook.usymbol(), self.base + ":" + self.quote) 33 | 34 | def testOsymbol(self): 35 | pass 36 | 37 | def testData(self): 38 | pass 39 | 40 | def testRaw(self): 41 | pass 42 | 43 | def testStr(self): 44 | pass 45 | 46 | 47 | if __name__ == '__main__': 48 | unittest.main() 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /tests/testAdapter/testBtce/testTrades.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import ccs 3 | import time 4 | 5 | #################################################################################################################### 6 | # BTCE # 7 | #################################################################################################################### 8 | 9 | class Valid(unittest.TestCase): 10 | def setUp(self): 11 | self.stock = ccs.constants.BTCE 12 | self.base = ccs.constants.BTC 13 | self.quote = ccs.constants.USD 14 | self.trades = ccs.trades(self.stock, self.base, self.quote) 15 | self.m = ccs.btce.public.response 16 | #time.sleep(3) 17 | 18 | def testLen(self): 19 | self.assertIsInstance(len(self.trades), int) 20 | 21 | def testGetItem(self): 22 | self.assertIsInstance(self.trades[0], self.m.Trade) 23 | 24 | def testStock(self): 25 | self.assertEqual(self.trades.stock(), self.stock) 26 | 27 | def testMethod(self): 28 | self.assertEqual(self.trades.method(), ccs.constants.TRADES) 29 | 30 | def testUsymbol(self): 31 | self.assertEqual(self.trades.usymbol(), self.base + ":" + self.quote) 32 | 33 | def testOsymbol(self): 34 | pass 35 | 36 | def testData(self): 37 | pass 38 | 39 | def testRaw(self): 40 | pass 41 | 42 | def testStr(self): 43 | pass 44 | 45 | 46 | if __name__ == '__main__': 47 | unittest.main() 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /tests/testAdapter/testBter/__init__.py: -------------------------------------------------------------------------------- 1 | from . import testOrder 2 | from . import testOrderbook 3 | from . import testOrders 4 | from . import testTicker 5 | from . import testTrade 6 | from . import testTrades -------------------------------------------------------------------------------- /tests/testAdapter/testBter/testOrderbook.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import ccs 3 | import datetime 4 | import time 5 | 6 | #################################################################################################################### 7 | # BTER # 8 | #################################################################################################################### 9 | 10 | class Valid(unittest.TestCase): 11 | def setUp(self): 12 | self.stock = ccs.constants.BTER 13 | self.base = ccs.constants.BTC 14 | self.quote = ccs.constants.CNY 15 | self.orderbook = ccs.orderbook(self.stock, self.base, self.quote) 16 | self.m = ccs.bter.public.response 17 | #time.sleep(3) 18 | 19 | def testAsks(self): 20 | self.assertIsInstance(self.orderbook.asks(), self.m.Orders) 21 | 22 | def testBids(self): 23 | self.assertIsInstance(self.orderbook.bids(), self.m.Orders) 24 | 25 | def testStock(self): 26 | self.assertEqual(self.orderbook.stock(), self.stock) 27 | 28 | def testMethod(self): 29 | self.assertEqual(self.orderbook.method(), ccs.constants.ORDERBOOK) 30 | 31 | def testUsymbol(self): 32 | self.assertEqual(self.orderbook.usymbol(), self.base + ":" + self.quote) 33 | 34 | def testOsymbol(self): 35 | pass 36 | 37 | def testData(self): 38 | pass 39 | 40 | def testRaw(self): 41 | pass 42 | 43 | def testStr(self): 44 | pass 45 | 46 | 47 | if __name__ == '__main__': 48 | unittest.main() 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /tests/testAdapter/testBter/testTrades.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import ccs 3 | import time 4 | 5 | #################################################################################################################### 6 | # BTER # 7 | #################################################################################################################### 8 | 9 | class Valid(unittest.TestCase): 10 | def setUp(self): 11 | self.stock = ccs.constants.BTER 12 | self.base = ccs.constants.BTC 13 | self.quote = ccs.constants.CNY 14 | self.trades = ccs.trades(self.stock, self.base, self.quote) 15 | self.m = ccs.bter.public.response 16 | #time.sleep(3) 17 | 18 | def testLen(self): 19 | self.assertIsInstance(len(self.trades), int) 20 | 21 | def testGetItem(self): 22 | self.assertIsInstance(self.trades[0], self.m.Trade) 23 | 24 | def testStock(self): 25 | self.assertEqual(self.trades.stock(), self.stock) 26 | 27 | def testMethod(self): 28 | self.assertEqual(self.trades.method(), ccs.constants.TRADES) 29 | 30 | def testUsymbol(self): 31 | self.assertEqual(self.trades.usymbol(), self.base + ":" + self.quote) 32 | 33 | def testOsymbol(self): 34 | pass 35 | 36 | def testData(self): 37 | pass 38 | 39 | def testRaw(self): 40 | pass 41 | 42 | def testStr(self): 43 | pass 44 | 45 | 46 | if __name__ == '__main__': 47 | unittest.main() 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /tests/testAdapter/testCexio/__init__.py: -------------------------------------------------------------------------------- 1 | from . import testOrder 2 | from . import testOrderbook 3 | from . import testOrders 4 | from . import testTicker 5 | from . import testTrade 6 | from . import testTrades -------------------------------------------------------------------------------- /tests/testAdapter/testCexio/testOrderbook.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import ccs 3 | import datetime 4 | import time 5 | 6 | #################################################################################################################### 7 | # CEXIO # 8 | #################################################################################################################### 9 | 10 | class Valid(unittest.TestCase): 11 | def setUp(self): 12 | self.stock = ccs.constants.CEXIO 13 | self.base = ccs.constants.BTC 14 | self.quote = ccs.constants.USD 15 | self.orderbook = ccs.orderbook(self.stock, self.base, self.quote) 16 | self.m = ccs.cexio.public.response 17 | #time.sleep(3) 18 | 19 | def testAsks(self): 20 | self.assertIsInstance(self.orderbook.asks(), self.m.Orders) 21 | 22 | def testBids(self): 23 | self.assertIsInstance(self.orderbook.bids(), self.m.Orders) 24 | 25 | def testStock(self): 26 | self.assertEqual(self.orderbook.stock(), self.stock) 27 | 28 | def testMethod(self): 29 | self.assertEqual(self.orderbook.method(), ccs.constants.ORDERBOOK) 30 | 31 | def testUsymbol(self): 32 | self.assertEqual(self.orderbook.usymbol(), self.base + ":" + self.quote) 33 | 34 | def testOsymbol(self): 35 | pass 36 | 37 | def testData(self): 38 | pass 39 | 40 | def testRaw(self): 41 | pass 42 | 43 | def testStr(self): 44 | pass 45 | 46 | 47 | if __name__ == '__main__': 48 | unittest.main() 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /tests/testAdapter/testCexio/testTrades.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import ccs 3 | import time 4 | 5 | #################################################################################################################### 6 | # CEXIO # 7 | #################################################################################################################### 8 | 9 | class Valid(unittest.TestCase): 10 | def setUp(self): 11 | self.stock = ccs.constants.CEXIO 12 | self.base = ccs.constants.BTC 13 | self.quote = ccs.constants.USD 14 | self.trades = ccs.trades(self.stock, self.base, self.quote) 15 | self.m = ccs.cexio.public.response 16 | #time.sleep(3) 17 | 18 | def testLen(self): 19 | self.assertIsInstance(len(self.trades), int) 20 | 21 | def testGetItem(self): 22 | self.assertIsInstance(self.trades[0], self.m.Trade) 23 | 24 | def testStock(self): 25 | self.assertEqual(self.trades.stock(), self.stock) 26 | 27 | def testMethod(self): 28 | self.assertEqual(self.trades.method(), ccs.constants.TRADES) 29 | 30 | def testUsymbol(self): 31 | self.assertEqual(self.trades.usymbol(), self.base + ":" + self.quote) 32 | 33 | def testOsymbol(self): 34 | pass 35 | 36 | def testData(self): 37 | pass 38 | 39 | def testRaw(self): 40 | pass 41 | 42 | def testStr(self): 43 | pass 44 | 45 | 46 | if __name__ == '__main__': 47 | unittest.main() 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /tests/testAdapter/testKraken/__init__.py: -------------------------------------------------------------------------------- 1 | from . import testOrder 2 | from . import testOrderbook 3 | from . import testOrders 4 | from . import testTicker 5 | from . import testTrade 6 | from . import testTrades -------------------------------------------------------------------------------- /tests/testAdapter/testKraken/testOrderbook.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import ccs 3 | import datetime 4 | import time 5 | 6 | #################################################################################################################### 7 | # KRAKEN # 8 | #################################################################################################################### 9 | 10 | class Valid(unittest.TestCase): 11 | def setUp(self): 12 | self.stock = ccs.constants.KRAKEN 13 | self.base = ccs.constants.XBT 14 | self.quote = ccs.constants.EUR 15 | self.orderbook = ccs.orderbook(self.stock, self.base, self.quote) 16 | self.m = ccs.kraken.public.response 17 | #time.sleep(3) 18 | 19 | def testAsks(self): 20 | self.assertIsInstance(self.orderbook.asks(), self.m.Orders) 21 | 22 | def testBids(self): 23 | self.assertIsInstance(self.orderbook.bids(), self.m.Orders) 24 | 25 | def testStock(self): 26 | self.assertEqual(self.orderbook.stock(), self.stock) 27 | 28 | def testMethod(self): 29 | self.assertEqual(self.orderbook.method(), ccs.constants.ORDERBOOK) 30 | 31 | def testUsymbol(self): 32 | self.assertEqual(self.orderbook.usymbol(), self.base + ":" + self.quote) 33 | 34 | def testOsymbol(self): 35 | pass 36 | 37 | def testData(self): 38 | pass 39 | 40 | def testRaw(self): 41 | pass 42 | 43 | def testStr(self): 44 | pass 45 | 46 | 47 | if __name__ == '__main__': 48 | unittest.main() 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /tests/testAdapter/testKraken/testTrades.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import ccs 3 | import time 4 | 5 | #################################################################################################################### 6 | # KRAKEN # 7 | #################################################################################################################### 8 | 9 | class Valid(unittest.TestCase): 10 | def setUp(self): 11 | self.stock = ccs.constants.KRAKEN 12 | self.base = ccs.constants.XBT 13 | self.quote = ccs.constants.EUR 14 | self.trades = ccs.trades(self.stock, self.base, self.quote) 15 | self.m = ccs.kraken.public.response 16 | #time.sleep(3) 17 | 18 | def testLen(self): 19 | self.assertIsInstance(len(self.trades), int) 20 | 21 | def testGetItem(self): 22 | self.assertIsInstance(self.trades[0], self.m.Trade) 23 | 24 | def testStock(self): 25 | self.assertEqual(self.trades.stock(), self.stock) 26 | 27 | def testMethod(self): 28 | self.assertEqual(self.trades.method(), ccs.constants.TRADES) 29 | 30 | def testUsymbol(self): 31 | self.assertEqual(self.trades.usymbol(), self.base + ":" + self.quote) 32 | 33 | def testOsymbol(self): 34 | pass 35 | 36 | def testData(self): 37 | pass 38 | 39 | def testRaw(self): 40 | pass 41 | 42 | def testStr(self): 43 | pass 44 | 45 | 46 | if __name__ == '__main__': 47 | unittest.main() 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /tests/testAdapter/testOkcoincn/__init__.py: -------------------------------------------------------------------------------- 1 | from . import testOrder 2 | from . import testOrderbook 3 | from . import testOrders 4 | from . import testTicker 5 | from . import testTrade 6 | from . import testTrades -------------------------------------------------------------------------------- /tests/testAdapter/testOkcoincn/testOrderbook.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import ccs 3 | import datetime 4 | import time 5 | 6 | #################################################################################################################### 7 | # OKCOINCN # 8 | #################################################################################################################### 9 | 10 | class Valid(unittest.TestCase): 11 | def setUp(self): 12 | self.stock = ccs.constants.OKCOINCN 13 | self.base = ccs.constants.BTC 14 | self.quote = ccs.constants.CNY 15 | self.orderbook = ccs.orderbook(self.stock, self.base, self.quote) 16 | self.m = ccs.okcoincn.public.response 17 | #time.sleep(3) 18 | 19 | def testAsks(self): 20 | self.assertIsInstance(self.orderbook.asks(), self.m.Orders) 21 | 22 | def testBids(self): 23 | self.assertIsInstance(self.orderbook.bids(), self.m.Orders) 24 | 25 | def testStock(self): 26 | self.assertEqual(self.orderbook.stock(), self.stock) 27 | 28 | def testMethod(self): 29 | self.assertEqual(self.orderbook.method(), ccs.constants.ORDERBOOK) 30 | 31 | def testUsymbol(self): 32 | self.assertEqual(self.orderbook.usymbol(), self.base + ":" + self.quote) 33 | 34 | def testOsymbol(self): 35 | pass 36 | 37 | def testData(self): 38 | pass 39 | 40 | def testRaw(self): 41 | pass 42 | 43 | def testStr(self): 44 | pass 45 | 46 | 47 | if __name__ == '__main__': 48 | unittest.main() 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /tests/testAdapter/testOkcoincn/testTrades.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import ccs 3 | import time 4 | 5 | #################################################################################################################### 6 | # OKCOINCN # 7 | #################################################################################################################### 8 | 9 | class Valid(unittest.TestCase): 10 | def setUp(self): 11 | self.stock = ccs.constants.OKCOINCN 12 | self.base = ccs.constants.BTC 13 | self.quote = ccs.constants.CNY 14 | self.trades = ccs.trades(self.stock, self.base, self.quote) 15 | self.m = ccs.okcoincn.public.response 16 | #time.sleep(3) 17 | 18 | def testLen(self): 19 | self.assertIsInstance(len(self.trades), int) 20 | 21 | def testGetItem(self): 22 | self.assertIsInstance(self.trades[0], self.m.Trade) 23 | 24 | def testStock(self): 25 | self.assertEqual(self.trades.stock(), self.stock) 26 | 27 | def testMethod(self): 28 | self.assertEqual(self.trades.method(), ccs.constants.TRADES) 29 | 30 | def testUsymbol(self): 31 | self.assertEqual(self.trades.usymbol(), self.base + ":" + self.quote) 32 | 33 | def testOsymbol(self): 34 | pass 35 | 36 | def testData(self): 37 | pass 38 | 39 | def testRaw(self): 40 | pass 41 | 42 | def testStr(self): 43 | pass 44 | 45 | 46 | if __name__ == '__main__': 47 | unittest.main() 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /tests/testAdapter/testOkcoincom/__init__.py: -------------------------------------------------------------------------------- 1 | from . import testOrder 2 | from . import testOrderbook 3 | from . import testOrders 4 | from . import testTicker 5 | from . import testTrade 6 | from . import testTrades -------------------------------------------------------------------------------- /tests/testAdapter/testOkcoincom/testOrderbook.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import ccs 3 | import datetime 4 | import time 5 | 6 | #################################################################################################################### 7 | # OKCOINCOM # 8 | #################################################################################################################### 9 | 10 | class Valid(unittest.TestCase): 11 | def setUp(self): 12 | self.stock = ccs.constants.OKCOINCOM 13 | self.base = ccs.constants.BTC 14 | self.quote = ccs.constants.USD 15 | self.orderbook = ccs.orderbook(self.stock, self.base, self.quote) 16 | self.m = ccs.okcoincom.public.response 17 | #time.sleep(3) 18 | 19 | def testAsks(self): 20 | self.assertIsInstance(self.orderbook.asks(), self.m.Orders) 21 | 22 | def testBids(self): 23 | self.assertIsInstance(self.orderbook.bids(), self.m.Orders) 24 | 25 | def testStock(self): 26 | self.assertEqual(self.orderbook.stock(), self.stock) 27 | 28 | def testMethod(self): 29 | self.assertEqual(self.orderbook.method(), ccs.constants.ORDERBOOK) 30 | 31 | def testUsymbol(self): 32 | self.assertEqual(self.orderbook.usymbol(), self.base + ":" + self.quote) 33 | 34 | def testOsymbol(self): 35 | pass 36 | 37 | def testData(self): 38 | pass 39 | 40 | def testRaw(self): 41 | pass 42 | 43 | def testStr(self): 44 | pass 45 | 46 | 47 | if __name__ == '__main__': 48 | unittest.main() 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /tests/testAdapter/testOkcoincom/testTrades.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import ccs 3 | import time 4 | 5 | #################################################################################################################### 6 | # OKCOINCOM # 7 | #################################################################################################################### 8 | 9 | class Valid(unittest.TestCase): 10 | def setUp(self): 11 | self.stock = ccs.constants.OKCOINCOM 12 | self.base = ccs.constants.BTC 13 | self.quote = ccs.constants.USD 14 | self.trades = ccs.trades(self.stock, self.base, self.quote) 15 | self.m = ccs.okcoincom.public.response 16 | #time.sleep(3) 17 | 18 | def testLen(self): 19 | self.assertIsInstance(len(self.trades), int) 20 | 21 | def testGetItem(self): 22 | self.assertIsInstance(self.trades[0], self.m.Trade) 23 | 24 | def testStock(self): 25 | self.assertEqual(self.trades.stock(), self.stock) 26 | 27 | def testMethod(self): 28 | self.assertEqual(self.trades.method(), ccs.constants.TRADES) 29 | 30 | def testUsymbol(self): 31 | self.assertEqual(self.trades.usymbol(), self.base + ":" + self.quote) 32 | 33 | def testOsymbol(self): 34 | pass 35 | 36 | def testData(self): 37 | pass 38 | 39 | def testRaw(self): 40 | pass 41 | 42 | def testStr(self): 43 | pass 44 | 45 | 46 | if __name__ == '__main__': 47 | unittest.main() 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /tests/testAdapter/testPoloniex/__init__.py: -------------------------------------------------------------------------------- 1 | from . import testOrder 2 | from . import testOrderbook 3 | from . import testOrders 4 | from . import testTicker 5 | from . import testTrade 6 | from . import testTrades -------------------------------------------------------------------------------- /tests/testAdapter/testPoloniex/testOrderbook.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import ccs 3 | import datetime 4 | import time 5 | 6 | #################################################################################################################### 7 | # POLONIEX # 8 | #################################################################################################################### 9 | 10 | class Valid(unittest.TestCase): 11 | def setUp(self): 12 | self.stock = ccs.constants.POLONIEX 13 | self.base = ccs.constants.BTC 14 | self.quote = ccs.constants.LTC 15 | self.orderbook = ccs.orderbook(self.stock, self.base, self.quote) 16 | self.m = ccs.poloniex.public.response 17 | #time.sleep(3) 18 | 19 | def testAsks(self): 20 | self.assertIsInstance(self.orderbook.asks(), self.m.Orders) 21 | 22 | def testBids(self): 23 | self.assertIsInstance(self.orderbook.bids(), self.m.Orders) 24 | 25 | def testStock(self): 26 | self.assertEqual(self.orderbook.stock(), self.stock) 27 | 28 | def testMethod(self): 29 | self.assertEqual(self.orderbook.method(), ccs.constants.ORDERBOOK) 30 | 31 | def testUsymbol(self): 32 | self.assertEqual(self.orderbook.usymbol(), self.base + ":" + self.quote) 33 | 34 | def testOsymbol(self): 35 | pass 36 | 37 | def testData(self): 38 | pass 39 | 40 | def testRaw(self): 41 | pass 42 | 43 | def testStr(self): 44 | pass 45 | 46 | 47 | if __name__ == '__main__': 48 | unittest.main() 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /tests/testAdapter/testPoloniex/testTrades.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import ccs 3 | import time 4 | 5 | #################################################################################################################### 6 | # POLONIEX # 7 | #################################################################################################################### 8 | 9 | class Valid(unittest.TestCase): 10 | def setUp(self): 11 | self.stock = ccs.constants.POLONIEX 12 | self.base = ccs.constants.BTC 13 | self.quote = ccs.constants.LTC 14 | self.trades = ccs.trades(self.stock, self.base, self.quote) 15 | self.m = ccs.poloniex.public.response 16 | #time.sleep(3) 17 | 18 | def testLen(self): 19 | self.assertIsInstance(len(self.trades), int) 20 | 21 | def testGetItem(self): 22 | self.assertIsInstance(self.trades[0], self.m.Trade) 23 | 24 | def testStock(self): 25 | self.assertEqual(self.trades.stock(), self.stock) 26 | 27 | def testMethod(self): 28 | self.assertEqual(self.trades.method(), ccs.constants.TRADES) 29 | 30 | def testUsymbol(self): 31 | self.assertEqual(self.trades.usymbol(), self.base + ":" + self.quote) 32 | 33 | def testOsymbol(self): 34 | pass 35 | 36 | def testData(self): 37 | pass 38 | 39 | def testRaw(self): 40 | pass 41 | 42 | def testStr(self): 43 | pass 44 | 45 | 46 | if __name__ == '__main__': 47 | unittest.main() 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /tests/testApi/__init__.py: -------------------------------------------------------------------------------- 1 | from . import testPublic -------------------------------------------------------------------------------- /tests/testApi/testPublic/__init__.py: -------------------------------------------------------------------------------- 1 | from .testBitfinex import * 2 | from .testBitstamp import * 3 | from .testBittrex import * 4 | from .testBtcc import * 5 | from .testBtccpro import * 6 | from .testBtce import * 7 | from .testBter import * 8 | from .testCexio import * 9 | from .testKraken import * 10 | from .testOkcoincn import * 11 | from .testOkcoincom import * 12 | from .testPoloniex import * 13 | 14 | -------------------------------------------------------------------------------- /tests/testApi/testPublic/testBitfinex/__init__.py: -------------------------------------------------------------------------------- 1 | from . import testFundingbook 2 | from . import testLends 3 | from . import testOrderbook 4 | from . import testStats 5 | from . import testSymbols 6 | from . import testSymbolsDetails 7 | from . import testTicker 8 | from . import testTrades 9 | 10 | -------------------------------------------------------------------------------- /tests/testApi/testPublic/testBitfinex/testStats.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import ccs 3 | import jsonschema 4 | import json 5 | import time 6 | 7 | class Valid(unittest.TestCase): 8 | def setUp(self): 9 | self.symbols = ["btcusd", "ltcusd", "ltcbtc", "ethusd", "ethbtc", "etcbtc", "etcusd", "bfxusd", "bfxbtc", "rrtusd", "rrtbtc", "zecusd", "zecbtc", "xmrusd", "xmrbtc"] 10 | self.schema = ccs.bitfinex.configuration.SCHEMA["stats"] 11 | 12 | def testSymbols(self): 13 | for symbol in self.symbols: 14 | r = ccs.bitfinex.public.stats(symbol) 15 | jsonschema.validate(json.loads(r), self.schema) 16 | time.sleep(3) 17 | 18 | 19 | class Invalid(unittest.TestCase): 20 | def setUp(self): 21 | self.fail_symbol = "abcdef" 22 | self.schema = ccs.bitfinex.configuration.SCHEMA["stats"] 23 | 24 | def testSymbol(self): 25 | with self.assertRaises(jsonschema.exceptions.ValidationError): 26 | r = ccs.bitfinex.public.stats(self.fail_symbol) 27 | jsonschema.validate(json.loads(r), self.schema) 28 | 29 | 30 | if __name__ == '__main__': 31 | unittest.main() 32 | -------------------------------------------------------------------------------- /tests/testApi/testPublic/testBitfinex/testSymbols.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import ccs 3 | import jsonschema 4 | import json 5 | 6 | class Valid(unittest.TestCase): 7 | def setUp(self): 8 | self.schema = ccs.bitfinex.configuration.SCHEMA["symbols"] 9 | 10 | def testSchema(self): 11 | r = ccs.bitfinex.public.symbols() 12 | jsonschema.validate(json.loads(r), self.schema) 13 | 14 | 15 | if __name__ == '__main__': 16 | unittest.main() 17 | -------------------------------------------------------------------------------- /tests/testApi/testPublic/testBitfinex/testSymbolsDetails.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import ccs 3 | import jsonschema 4 | import json 5 | 6 | class Valid(unittest.TestCase): 7 | def setUp(self): 8 | self.schema = ccs.bitfinex.configuration.SCHEMA["symbolsDetails"] 9 | 10 | def testSchema(self): 11 | r = ccs.bitfinex.public.symbolsDetails() 12 | jsonschema.validate(json.loads(r), self.schema) 13 | 14 | 15 | 16 | class Invalid(unittest.TestCase): 17 | pass # Nothing for testing 18 | 19 | 20 | if __name__ == '__main__': 21 | unittest.main() 22 | -------------------------------------------------------------------------------- /tests/testApi/testPublic/testBitfinex/testTicker.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import ccs 3 | import jsonschema 4 | import json 5 | import time 6 | 7 | class Valid(unittest.TestCase): 8 | def setUp(self): 9 | self.symbols = ["btcusd", "ltcusd", "ltcbtc", "ethusd", "ethbtc", "etcbtc", "etcusd", "bfxusd", "bfxbtc", "rrtusd", "rrtbtc", "zecusd", "zecbtc", "xmrusd", "xmrbtc"] 10 | self.schema = ccs.bitfinex.configuration.SCHEMA["ticker"] 11 | 12 | def testSymbols(self): 13 | for symbol in self.symbols: 14 | r = ccs.bitfinex.public.ticker(symbol) 15 | jsonschema.validate(json.loads(r), self.schema) 16 | time.sleep(3) 17 | 18 | class Invalid(unittest.TestCase): 19 | def setUp(self): 20 | self.fail_symbol = "abcdef" 21 | self.schema = ccs.bitfinex.configuration.SCHEMA["ticker"] 22 | 23 | def testSymbol(self): 24 | with self.assertRaises(jsonschema.exceptions.ValidationError): 25 | r = ccs.bitfinex.public.ticker(self.fail_symbol) 26 | jsonschema.validate(json.loads(r), self.schema) 27 | 28 | 29 | if __name__ == '__main__': 30 | unittest.main() 31 | -------------------------------------------------------------------------------- /tests/testApi/testPublic/testBitstamp/__init__.py: -------------------------------------------------------------------------------- 1 | from . import testEurUsdConversionRate 2 | from . import testHourlyTicker 3 | from . import testOrderbook 4 | from . import testTicker 5 | from . import testTransactions 6 | -------------------------------------------------------------------------------- /tests/testApi/testPublic/testBitstamp/testEurUsdConversionRate.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf8 -*- 2 | 3 | """ 4 | This file implements test cases for validation communication with REST endpoint on Bitstamp. This endpoint offer informations about conversion rate between EUR and USD. 5 | """ 6 | 7 | __author__ = "Jan Seda" 8 | __copyright__ = "Copyright (C) Jan Seda" 9 | __credits__ = [] 10 | __license__ = "" 11 | __version__ = "0.1" 12 | __maintainer__ = "Jan Seda" 13 | __email__ = "" 14 | __status__ = "Production" 15 | 16 | 17 | import unittest 18 | import ccs 19 | import jsonschema 20 | import json 21 | import time 22 | 23 | 24 | def schema(): 25 | return ccs.bitstamp.configuration.SCHEMA["eurUsdConversionRate"] 26 | 27 | 28 | def sleep(): 29 | time.sleep(3) 30 | 31 | 32 | class Valid(unittest.TestCase): 33 | def setUp(self): 34 | sleep() 35 | 36 | def testSchema(self): 37 | r = ccs.bitstamp.public.eurUsdConversionRate() 38 | jsonschema.validate(json.loads(r), schema()) 39 | 40 | 41 | class Invalid(unittest.TestCase): 42 | def setUp(self): 43 | self.symbol = "aaabbb" 44 | 45 | def testResponse(self): 46 | with self.assertRaises(jsonschema.exceptions.ValidationError): 47 | r = '{"error": "Invalid request"}' 48 | jsonschema.validate(json.loads(r), schema()) 49 | 50 | 51 | if __name__ == '__main__': 52 | unittest.main() 53 | -------------------------------------------------------------------------------- /tests/testApi/testPublic/testBitstamp/testHourlyTicker.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf8 -*- 2 | 3 | """ 4 | This file implements test cases for validation communication with REST endpoint on Bitstamp. This endpoint offer hourly tick informations. 5 | """ 6 | 7 | __author__ = "Jan Seda" 8 | __copyright__ = "Copyright (C) Jan Seda" 9 | __credits__ = [] 10 | __license__ = "" 11 | __version__ = "0.1" 12 | __maintainer__ = "Jan Seda" 13 | __email__ = "" 14 | __status__ = "Production" 15 | 16 | 17 | import unittest 18 | import ccs 19 | import jsonschema 20 | import json 21 | import time 22 | 23 | 24 | def schema(): 25 | return ccs.bitstamp.configuration.SCHEMA["hourlyTicker"] 26 | 27 | 28 | def sleep(): 29 | time.sleep(3) 30 | 31 | 32 | class Valid(unittest.TestCase): 33 | def setUp(self): 34 | self.symbols = ["btcusd", "btceur", "eurusd"] 35 | self.symbol = self.symbols[0] 36 | sleep() 37 | 38 | def testSchema(self): 39 | r = ccs.bitstamp.public.hourlyTicker(self.symbol) 40 | jsonschema.validate(json.loads(r), schema()) 41 | 42 | @unittest.skip("time-consuming") 43 | def testSymbols(self): 44 | for symbol in self.symbols: 45 | r = ccs.bitstamp.public.hourlyTicker(symbol) 46 | jsonschema.validate(json.loads(r), schema()) 47 | sleep() 48 | 49 | 50 | class Invalid(unittest.TestCase): 51 | def setUp(self): 52 | self.symbol = "aaabbb" 53 | 54 | def testResponse(self): 55 | with self.assertRaises(jsonschema.exceptions.ValidationError): 56 | r = ccs.bitstamp.public.hourlyTicker(self.symbol) 57 | jsonschema.validate(json.loads(r), schema()) 58 | 59 | 60 | if __name__ == '__main__': 61 | unittest.main() 62 | -------------------------------------------------------------------------------- /tests/testApi/testPublic/testBitstamp/testOrderbook.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf8 -*- 2 | 3 | """ 4 | This file implements test cases for validation communication with REST endpoint on Bitstamp. This endpoint offer informations about orderbook. 5 | """ 6 | 7 | __author__ = "Jan Seda" 8 | __copyright__ = "Copyright (C) Jan Seda" 9 | __credits__ = [] 10 | __license__ = "" 11 | __version__ = "0.1" 12 | __maintainer__ = "Jan Seda" 13 | __email__ = "" 14 | __status__ = "Production" 15 | 16 | 17 | import unittest 18 | import ccs 19 | import jsonschema 20 | import json 21 | import time 22 | 23 | 24 | def schema(): 25 | return ccs.bitstamp.configuration.SCHEMA["orderbook"] 26 | 27 | 28 | def sleep(): 29 | time.sleep(3) 30 | 31 | 32 | class Valid(unittest.TestCase): 33 | def setUp(self): 34 | self.symbols = ["btcusd", "btceur", "eurusd"] 35 | self.symbol = self.symbols[0] 36 | sleep() 37 | 38 | def testSchema(self): 39 | r = ccs.bitstamp.public.orderbook(self.symbol) 40 | jsonschema.validate(json.loads(r), schema()) 41 | 42 | @unittest.skip("time-consuming") 43 | def testSymbols(self): 44 | for symbol in self.symbols: 45 | r = ccs.bitstamp.public.orderbook(symbol) 46 | jsonschema.validate(json.loads(r), schema()) 47 | sleep() 48 | 49 | 50 | class Invalid(unittest.TestCase): 51 | def setUp(self): 52 | self.symbol = "aaabbb" 53 | 54 | def testResponse(self): 55 | with self.assertRaises(jsonschema.exceptions.ValidationError): 56 | r = ccs.bitstamp.public.orderbook(self.symbol) 57 | jsonschema.validate(json.loads(r), schema()) 58 | 59 | 60 | if __name__ == '__main__': 61 | unittest.main() 62 | -------------------------------------------------------------------------------- /tests/testApi/testPublic/testBitstamp/testTicker.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf8 -*- 2 | 3 | """ 4 | This file implements test cases for validation communication with REST endpoint on Bitstamp. This endpoint offer tick informations. 5 | """ 6 | 7 | __author__ = "Jan Seda" 8 | __copyright__ = "Copyright (C) Jan Seda" 9 | __credits__ = [] 10 | __license__ = "" 11 | __version__ = "0.1" 12 | __maintainer__ = "Jan Seda" 13 | __email__ = "" 14 | __status__ = "Production" 15 | 16 | 17 | import unittest 18 | import ccs 19 | import jsonschema 20 | import json 21 | import time 22 | 23 | 24 | def schema(): 25 | return ccs.bitstamp.configuration.SCHEMA["ticker"] 26 | 27 | 28 | def sleep(): 29 | time.sleep(3) 30 | 31 | 32 | class Valid(unittest.TestCase): 33 | def setUp(self): 34 | self.symbols = ["btcusd", "btceur", "eurusd"] 35 | self.symbol = self.symbols[0] 36 | sleep() 37 | 38 | def testSchema(self): 39 | r = ccs.bitstamp.public.ticker(self.symbol) 40 | jsonschema.validate(json.loads(r), schema()) 41 | 42 | @unittest.skip("time-consuming") 43 | def testSymbols(self): 44 | for symbol in self.symbols: 45 | r = ccs.bitstamp.public.ticker(symbol) 46 | jsonschema.validate(json.loads(r), schema()) 47 | sleep() 48 | 49 | 50 | class Invalid(unittest.TestCase): 51 | def setUp(self): 52 | self.symbol = "aaabbb" 53 | 54 | def testResponse(self): 55 | with self.assertRaises(jsonschema.exceptions.ValidationError): 56 | r = ccs.bitstamp.public.ticker(self.symbol) 57 | jsonschema.validate(json.loads(r), schema()) 58 | 59 | 60 | if __name__ == '__main__': 61 | unittest.main() 62 | -------------------------------------------------------------------------------- /tests/testApi/testPublic/testBittrex/__init__.py: -------------------------------------------------------------------------------- 1 | from . import testCurrencies 2 | from . import testHistory 3 | from . import testMarkets 4 | from . import testOrderbook 5 | from . import testSummaries 6 | from . import testSummary 7 | from . import testTicker 8 | -------------------------------------------------------------------------------- /tests/testApi/testPublic/testBittrex/testCurrencies.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf8 -*- 2 | 3 | """ 4 | This file implements test cases for validation communication with REST endpoint on Bittrex. This endpoint offer informations about currencies. 5 | """ 6 | 7 | __author__ = "Jan Seda" 8 | __copyright__ = "Copyright (C) Jan Seda" 9 | __credits__ = [] 10 | __license__ = "" 11 | __version__ = "0.1" 12 | __maintainer__ = "Jan Seda" 13 | __email__ = "" 14 | __status__ = "Production" 15 | 16 | 17 | import unittest 18 | import ccs 19 | import jsonschema 20 | import json 21 | import time 22 | 23 | 24 | def schema(): 25 | return ccs.bittrex.configuration.SCHEMA["getCurrencies"] 26 | 27 | 28 | def sleep(): 29 | time.sleep(3) 30 | 31 | 32 | class Valid(unittest.TestCase): 33 | def setUp(self): 34 | sleep() 35 | 36 | def testSchema(self): 37 | r = ccs.bittrex.public.getCurrencies() 38 | jsonschema.validate(json.loads(r), schema()) 39 | 40 | 41 | class Invalid(unittest.TestCase): 42 | def setUp(self): 43 | pass 44 | 45 | def testResponse(self): 46 | with self.assertRaises(jsonschema.exceptions.ValidationError): 47 | r = '{"success":false,"message":"INVALID","result":null}' 48 | jsonschema.validate(json.loads(r), schema()) 49 | 50 | 51 | if __name__ == '__main__': 52 | unittest.main() 53 | -------------------------------------------------------------------------------- /tests/testApi/testPublic/testBittrex/testMarkets.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf8 -*- 2 | 3 | """ 4 | This file implements test cases for validation communication with REST endpoint on Bittrex. This endpoint offer informations about markets. 5 | """ 6 | 7 | __author__ = "Jan Seda" 8 | __copyright__ = "Copyright (C) Jan Seda" 9 | __credits__ = [] 10 | __license__ = "" 11 | __version__ = "0.1" 12 | __maintainer__ = "Jan Seda" 13 | __email__ = "" 14 | __status__ = "Production" 15 | 16 | 17 | import unittest 18 | import ccs 19 | import jsonschema 20 | import json 21 | import time 22 | 23 | 24 | def schema(): 25 | return ccs.bittrex.configuration.SCHEMA["getMarkets"] 26 | 27 | 28 | def sleep(): 29 | time.sleep(3) 30 | 31 | 32 | class Valid(unittest.TestCase): 33 | def setUp(self): 34 | sleep() 35 | 36 | def testSchema(self): 37 | r = ccs.bittrex.public.getMarkets() 38 | jsonschema.validate(json.loads(r), schema()) 39 | 40 | 41 | class Invalid(unittest.TestCase): 42 | def setUp(self): 43 | pass 44 | 45 | def testResponse(self): 46 | with self.assertRaises(jsonschema.exceptions.ValidationError): 47 | r = '{"success":false,"message":"INVALID","result":null}' 48 | jsonschema.validate(json.loads(r), schema()) 49 | 50 | 51 | if __name__ == '__main__': 52 | unittest.main() 53 | -------------------------------------------------------------------------------- /tests/testApi/testPublic/testBittrex/testSummaries.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf8 -*- 2 | 3 | """ 4 | This file implements test cases for validation communication with REST endpoint on Bittrex. This endpoint offer markets summary informations. 5 | """ 6 | 7 | __author__ = "Jan Seda" 8 | __copyright__ = "Copyright (C) Jan Seda" 9 | __credits__ = [] 10 | __license__ = "" 11 | __version__ = "0.1" 12 | __maintainer__ = "Jan Seda" 13 | __email__ = "" 14 | __status__ = "Production" 15 | 16 | 17 | import unittest 18 | import ccs 19 | import jsonschema 20 | import json 21 | import time 22 | 23 | 24 | def schema(): 25 | return ccs.bittrex.configuration.SCHEMA["getMarketSummaries"] 26 | 27 | 28 | def sleep(): 29 | time.sleep(3) 30 | 31 | 32 | class Valid(unittest.TestCase): 33 | def setUp(self): 34 | pass 35 | 36 | def testSchema(self): 37 | r = ccs.bittrex.public.getMarketSummaries() 38 | jsonschema.validate(json.loads(r), schema()) 39 | 40 | 41 | class Invalid(unittest.TestCase): 42 | def setUp(self): 43 | pass 44 | 45 | def testResponse(self): 46 | with self.assertRaises(jsonschema.exceptions.ValidationError): 47 | r = '{"success":false,"message":"INVALID","result":null}' 48 | jsonschema.validate(json.loads(r), schema()) 49 | 50 | 51 | if __name__ == '__main__': 52 | unittest.main() 53 | -------------------------------------------------------------------------------- /tests/testApi/testPublic/testBtcc/__init__.py: -------------------------------------------------------------------------------- 1 | from . import testOrderbook 2 | from . import testTicker 3 | from . import testTradeHistory 4 | from . import testTrades 5 | -------------------------------------------------------------------------------- /tests/testApi/testPublic/testBtcc/testOrderbook.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf8 -*- 2 | 3 | """ 4 | This file implements test cases for validation communication with REST endpoint on Btcc-spot. This endpoint offer informations about orderbook. 5 | """ 6 | 7 | __author__ = "Jan Seda" 8 | __copyright__ = "Copyright (C) Jan Seda" 9 | __credits__ = [] 10 | __license__ = "" 11 | __version__ = "0.1" 12 | __maintainer__ = "Jan Seda" 13 | __email__ = "" 14 | __status__ = "Production" 15 | 16 | 17 | import unittest 18 | import ccs 19 | import jsonschema 20 | import json 21 | import time 22 | 23 | 24 | def schema(): 25 | return ccs.btcc.configuration.SCHEMA["orderbook"] 26 | 27 | 28 | def sleep(): 29 | time.sleep(3) 30 | 31 | 32 | class Valid(unittest.TestCase): 33 | def setUp(self): 34 | self. markets = ['btccny', "ltccny"] 35 | self.market = self.markets[0] 36 | sleep() 37 | 38 | def testSchema(self): 39 | r = ccs.btcc.public.orderbook(self.market) 40 | jsonschema.validate(json.loads(r), schema()) 41 | 42 | def testLimit(self): 43 | l = 2 44 | r = ccs.btcc.public.orderbook(self.market, limit=l) 45 | d = json.loads(r) 46 | jsonschema.validate(d, schema()) 47 | 48 | self.assertLessEqual(len(d["asks"]), l) 49 | self.assertLessEqual(len(d["bids"]), l) 50 | 51 | 52 | class Invalid(unittest.TestCase): 53 | def setUp(self): 54 | self.market = "aaabbb" 55 | 56 | # TODO Solve test & catch JSONDecodeError 57 | @unittest.skip("JSON='' -> JSONDecodeError") 58 | def testResponse(self): 59 | with self.assertRaises(jsonschema.exceptions.ValidationError): 60 | r = ccs.btcc.public.orderbook(self.market) 61 | jsonschema.validate(json.loads(r), schema()) 62 | 63 | 64 | if __name__ == '__main__': 65 | unittest.main() 66 | -------------------------------------------------------------------------------- /tests/testApi/testPublic/testBtcc/testTicker.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf8 -*- 2 | 3 | """ 4 | This file implements test cases for validation communication with REST endpoint on Btcc-spot. This endpoint offer tick informations. 5 | """ 6 | 7 | __author__ = "Jan Seda" 8 | __copyright__ = "Copyright (C) Jan Seda" 9 | __credits__ = [] 10 | __license__ = "" 11 | __version__ = "0.1" 12 | __maintainer__ = "Jan Seda" 13 | __email__ = "" 14 | __status__ = "Production" 15 | 16 | 17 | import unittest 18 | import ccs 19 | import jsonschema 20 | import json 21 | import time 22 | 23 | 24 | def schema(): 25 | return ccs.btcc.configuration.SCHEMA["ticker"] 26 | 27 | 28 | def sleep(): 29 | time.sleep(3) 30 | 31 | 32 | class Valid(unittest.TestCase): 33 | def setUp(self): 34 | self. markets = ['btccny', "ltccny"] 35 | self.market = self.markets[0] 36 | sleep() 37 | 38 | def testSchema(self): 39 | r = ccs.btcc.public.ticker(self.market) 40 | jsonschema.validate(json.loads(r), schema()) 41 | 42 | @unittest.skip("time-consuming") 43 | def testCurrencies(self): 44 | for market in self.markets: 45 | r = ccs.btcc.public.ticker(market) 46 | jsonschema.validate(json.loads(r), schema()) 47 | sleep() 48 | 49 | 50 | class Invalid(unittest.TestCase): 51 | def setUp(self): 52 | self.market = "aaabbb" 53 | 54 | # TODO Solve test & catch JSONDecodeError 55 | @unittest.skip("JSON='' -> JSONDecodeError") 56 | def testResponse(self): 57 | with self.assertRaises(jsonschema.exceptions.ValidationError): 58 | r = ccs.btcc.public.trades(self.market) 59 | jsonschema.validate(json.loads(r), schema()) 60 | 61 | 62 | if __name__ == '__main__': 63 | unittest.main() 64 | -------------------------------------------------------------------------------- /tests/testApi/testPublic/testBtcc/testTrades.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf8 -*- 2 | 3 | """ 4 | This file implements test cases for validation communication with REST endpoint on Btcc-spot. This endpoint offer informations about trades. 5 | """ 6 | 7 | __author__ = "Jan Seda" 8 | __copyright__ = "Copyright (C) Jan Seda" 9 | __credits__ = [] 10 | __license__ = "" 11 | __version__ = "0.1" 12 | __maintainer__ = "Jan Seda" 13 | __email__ = "" 14 | __status__ = "Production" 15 | 16 | 17 | import unittest 18 | import ccs 19 | import jsonschema 20 | import json 21 | import time 22 | 23 | 24 | def schema(): 25 | return ccs.btcc.configuration.SCHEMA["trades"] 26 | 27 | 28 | def sleep(): 29 | time.sleep(3) 30 | 31 | 32 | class Valid(unittest.TestCase): 33 | def setUp(self): 34 | self. markets = ['btccny', "ltccny"] 35 | self.market = self.markets[0] 36 | sleep() 37 | 38 | def testSchema(self): 39 | r = ccs.btcc.public.trades(self.market) 40 | jsonschema.validate(json.loads(r), schema()) 41 | 42 | @unittest.skip("time-consuming") 43 | def testCurrencies(self): 44 | for market in self.markets: 45 | r = ccs.btcc.public.trades(market) 46 | jsonschema.validate(json.loads(r), schema()) 47 | sleep() 48 | 49 | 50 | class Invalid(unittest.TestCase): 51 | def setUp(self): 52 | self.market = "aaabbb" 53 | 54 | # TODO Solve test & catch JSONDecodeError 55 | @unittest.skip("JSON='' -> JSONDecodeError") 56 | def testResponse(self): 57 | with self.assertRaises(jsonschema.exceptions.ValidationError): 58 | r = ccs.btcc.public.trades(self.market) 59 | jsonschema.validate(json.loads(r), schema()) 60 | 61 | 62 | if __name__ == '__main__': 63 | unittest.main() 64 | -------------------------------------------------------------------------------- /tests/testApi/testPublic/testBtccpro/__init__.py: -------------------------------------------------------------------------------- 1 | from . import testOrderbook 2 | from . import testTicker 3 | from . import testTradeHistory 4 | -------------------------------------------------------------------------------- /tests/testApi/testPublic/testBtccpro/testOrderbook.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf8 -*- 2 | 3 | """ 4 | This file implements test cases for validation communication with REST endpoint on Btcc-spot. This endpoint offer informations about orderbook. 5 | """ 6 | 7 | __author__ = "Jan Seda" 8 | __copyright__ = "Copyright (C) Jan Seda" 9 | __credits__ = [] 10 | __license__ = "" 11 | __version__ = "0.1" 12 | __maintainer__ = "Jan Seda" 13 | __email__ = "" 14 | __status__ = "Production" 15 | 16 | 17 | import unittest 18 | import ccs 19 | import jsonschema 20 | import json 21 | import time 22 | 23 | 24 | def schema(): 25 | return ccs.btccpro.configuration.SCHEMA["orderbook"] 26 | 27 | 28 | def sleep(): 29 | time.sleep(3) 30 | 31 | 32 | class Valid(unittest.TestCase): 33 | def setUp(self): 34 | self. markets = ['xbtcny'] 35 | self.market = self.markets[0] 36 | sleep() 37 | 38 | def testSchema(self): 39 | r = ccs.btccpro.public.orderbook(self.market) 40 | jsonschema.validate(json.loads(r), schema()) 41 | 42 | def testLimit(self): 43 | l = 2 44 | r = ccs.btccpro.public.orderbook(self.market, limit=l) 45 | d = json.loads(r) 46 | jsonschema.validate(d, schema()) 47 | 48 | self.assertLessEqual(len(d["asks"]), l) 49 | self.assertLessEqual(len(d["bids"]), l) 50 | 51 | 52 | class Invalid(unittest.TestCase): 53 | def setUp(self): 54 | self.market = "aaabbb" 55 | 56 | # TODO Solve test & catch JSONDecodeError 57 | @unittest.skip("JSON='' -> JSONDecodeError") 58 | def testResponse(self): 59 | with self.assertRaises(jsonschema.exceptions.ValidationError): 60 | r = ccs.btccpro.public.orderbook(self.market) 61 | jsonschema.validate(json.loads(r), schema()) 62 | 63 | 64 | if __name__ == '__main__': 65 | unittest.main() 66 | -------------------------------------------------------------------------------- /tests/testApi/testPublic/testBtccpro/testTicker.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf8 -*- 2 | 3 | """ 4 | This file implements test cases for validation communication with REST endpoint on Btcc-spot. This endpoint offer tick informations. 5 | """ 6 | 7 | __author__ = "Jan Seda" 8 | __copyright__ = "Copyright (C) Jan Seda" 9 | __credits__ = [] 10 | __license__ = "" 11 | __version__ = "0.1" 12 | __maintainer__ = "Jan Seda" 13 | __email__ = "" 14 | __status__ = "Production" 15 | 16 | 17 | import unittest 18 | import ccs 19 | import jsonschema 20 | import json 21 | import time 22 | 23 | 24 | def schema(): 25 | return ccs.btccpro.configuration.SCHEMA["ticker"] 26 | 27 | 28 | def sleep(): 29 | time.sleep(3) 30 | 31 | 32 | class Valid(unittest.TestCase): 33 | def setUp(self): 34 | self. markets = ['xbtcny'] 35 | self.market = self.markets[0] 36 | sleep() 37 | 38 | def testSchema(self): 39 | r = ccs.btccpro.public.ticker(self.market) 40 | jsonschema.validate(json.loads(r), schema()) 41 | 42 | @unittest.skip("time-consuming") 43 | def testCurrencies(self): 44 | for market in self.markets: 45 | r = ccs.btccpro.public.ticker(market) 46 | jsonschema.validate(json.loads(r), schema()) 47 | sleep() 48 | 49 | 50 | class Invalid(unittest.TestCase): 51 | def setUp(self): 52 | self.market = "aaabbb" 53 | 54 | # TODO Solve test & catch JSONDecodeError 55 | @unittest.skip("JSON='' -> JSONDecodeError") 56 | def testResponse(self): 57 | with self.assertRaises(jsonschema.exceptions.ValidationError): 58 | r = ccs.btccpro.public.trades(self.market) 59 | jsonschema.validate(json.loads(r), schema()) 60 | 61 | 62 | if __name__ == '__main__': 63 | unittest.main() 64 | -------------------------------------------------------------------------------- /tests/testApi/testPublic/testBtccusd/__init__.py: -------------------------------------------------------------------------------- 1 | from . import testOrderbook 2 | from . import testTicker 3 | from . import testTradeHistory 4 | -------------------------------------------------------------------------------- /tests/testApi/testPublic/testBtccusd/testOrderbook.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf8 -*- 2 | 3 | """ 4 | This file implements test cases for validation communication with REST endpoint on Btcc-spot. This endpoint offer informations about orderbook. 5 | """ 6 | 7 | __author__ = "Jan Seda" 8 | __copyright__ = "Copyright (C) Jan Seda" 9 | __credits__ = [] 10 | __license__ = "" 11 | __version__ = "0.1" 12 | __maintainer__ = "Jan Seda" 13 | __email__ = "" 14 | __status__ = "Production" 15 | 16 | 17 | import unittest 18 | import ccs 19 | import jsonschema 20 | import json 21 | import time 22 | 23 | 24 | def schema(): 25 | return ccs.btccusd.configuration.SCHEMA["orderbook"] 26 | 27 | 28 | def sleep(): 29 | time.sleep(3) 30 | 31 | 32 | class Valid(unittest.TestCase): 33 | def setUp(self): 34 | self. markets = ['btcusd'] 35 | self.market = self.markets[0] 36 | sleep() 37 | 38 | def testSchema(self): 39 | r = ccs.btccusd.public.orderbook(self.market) 40 | jsonschema.validate(json.loads(r), schema()) 41 | 42 | def testLimit(self): 43 | l = 2 44 | r = ccs.btccusd.public.orderbook(self.market, limit=l) 45 | d = json.loads(r) 46 | jsonschema.validate(d, schema()) 47 | 48 | self.assertLessEqual(len(d["asks"]), l) 49 | self.assertLessEqual(len(d["bids"]), l) 50 | 51 | 52 | class Invalid(unittest.TestCase): 53 | def setUp(self): 54 | self.market = "aaabbb" 55 | 56 | # TODO Solve test & catch JSONDecodeError 57 | @unittest.skip("JSON='' -> JSONDecodeError") 58 | def testResponse(self): 59 | with self.assertRaises(jsonschema.exceptions.ValidationError): 60 | r = ccs.btccusd.public.orderbook(self.market) 61 | jsonschema.validate(json.loads(r), schema()) 62 | 63 | 64 | if __name__ == '__main__': 65 | unittest.main() 66 | -------------------------------------------------------------------------------- /tests/testApi/testPublic/testBtccusd/testTicker.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf8 -*- 2 | 3 | """ 4 | This file implements test cases for validation communication with REST endpoint on Btcc-spot. This endpoint offer tick informations. 5 | """ 6 | 7 | __author__ = "Jan Seda" 8 | __copyright__ = "Copyright (C) Jan Seda" 9 | __credits__ = [] 10 | __license__ = "" 11 | __version__ = "0.1" 12 | __maintainer__ = "Jan Seda" 13 | __email__ = "" 14 | __status__ = "Production" 15 | 16 | 17 | import unittest 18 | import ccs 19 | import jsonschema 20 | import json 21 | import time 22 | 23 | 24 | def schema(): 25 | return ccs.btccusd.configuration.SCHEMA["ticker"] 26 | 27 | 28 | def sleep(): 29 | time.sleep(3) 30 | 31 | 32 | class Valid(unittest.TestCase): 33 | def setUp(self): 34 | self. markets = ['btcusd'] 35 | self.market = self.markets[0] 36 | sleep() 37 | 38 | def testSchema(self): 39 | r = ccs.btccusd.public.ticker(self.market) 40 | jsonschema.validate(json.loads(r), schema()) 41 | 42 | @unittest.skip("time-consuming") 43 | def testCurrencies(self): 44 | for market in self.markets: 45 | r = ccs.btccusd.public.ticker(market) 46 | jsonschema.validate(json.loads(r), schema()) 47 | sleep() 48 | 49 | 50 | class Invalid(unittest.TestCase): 51 | def setUp(self): 52 | self.market = "aaabbb" 53 | 54 | # TODO Solve test & catch JSONDecodeError 55 | @unittest.skip("JSON='' -> JSONDecodeError") 56 | def testResponse(self): 57 | with self.assertRaises(jsonschema.exceptions.ValidationError): 58 | r = ccs.btccusd.public.trades(self.market) 59 | jsonschema.validate(json.loads(r), schema()) 60 | 61 | 62 | if __name__ == '__main__': 63 | unittest.main() 64 | -------------------------------------------------------------------------------- /tests/testApi/testPublic/testBtce/__init__.py: -------------------------------------------------------------------------------- 1 | from . import testDepth 2 | from . import testInfo 3 | from . import testTicker 4 | from . import testTrades 5 | -------------------------------------------------------------------------------- /tests/testApi/testPublic/testBtce/testInfo.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf8 -*- 2 | 3 | """ 4 | This file implements test cases for validation communication with REST endpoint on Btce. This endpoint offer markets informations. 5 | """ 6 | 7 | __author__ = "Jan Seda" 8 | __copyright__ = "Copyright (C) Jan Seda" 9 | __credits__ = [] 10 | __license__ = "" 11 | __version__ = "0.1" 12 | __maintainer__ = "Jan Seda" 13 | __email__ = "" 14 | __status__ = "Production" 15 | 16 | 17 | import unittest 18 | import ccs 19 | import jsonschema 20 | import json 21 | import time 22 | 23 | 24 | def schema(): 25 | return ccs.btce.configuration.SCHEMA["info"] 26 | 27 | 28 | def sleep(): 29 | time.sleep(3) 30 | 31 | 32 | class Valid(unittest.TestCase): 33 | def setUp(self): 34 | sleep() 35 | 36 | def testSchema(self): 37 | r = ccs.btce.public.info() 38 | jsonschema.validate(json.loads(r), schema()) 39 | 40 | 41 | class Invalid(unittest.TestCase): 42 | def setUp(self): 43 | pass 44 | 45 | def testResponse(self): 46 | with self.assertRaises(jsonschema.exceptions.ValidationError): 47 | r = '{"success":0, "error":"Invalid ...."}' 48 | jsonschema.validate(json.loads(r), schema()) 49 | 50 | 51 | if __name__ == '__main__': 52 | unittest.main() 53 | -------------------------------------------------------------------------------- /tests/testApi/testPublic/testBtce/testTicker.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf8 -*- 2 | 3 | """ 4 | This file implements test cases for validation communication with REST endpoint on Btce. This endpoint offer tick informations. 5 | """ 6 | 7 | __author__ = "Jan Seda" 8 | __copyright__ = "Copyright (C) Jan Seda" 9 | __credits__ = [] 10 | __license__ = "" 11 | __version__ = "0.1" 12 | __maintainer__ = "Jan Seda" 13 | __email__ = "" 14 | __status__ = "Production" 15 | 16 | 17 | import unittest 18 | import ccs 19 | import jsonschema 20 | import json 21 | import time 22 | 23 | 24 | def schema(): 25 | return ccs.btce.configuration.SCHEMA["ticker"] 26 | 27 | 28 | def sleep(): 29 | time.sleep(3) 30 | 31 | 32 | class Valid(unittest.TestCase): 33 | def setUp(self): 34 | self.pairs = ["btc_usd", "btc_rur", "btc_eur", "ltc_btc", "ltc_usd", "ltc_rur", "ltc_eur", "nmc_btc", "nmc_usd", "nvc_btc", "nvc_usd", 35 | "usd_rur", "eur_usd", "eur_rur", "ppc_btc", "ppc_usd", "dsh_btc", "dsh_usd", "eth_btc", "eth_usd", "eth_eur", "eth_ltc", "eth_rur"] 36 | self.pair = self.pairs[0] 37 | sleep() 38 | 39 | def testSchema(self): 40 | r = ccs.btce.public.ticker(self.pair) 41 | jsonschema.validate(json.loads(r), schema()) 42 | 43 | @unittest.skip("time-consuming") 44 | def testSymbols(self): 45 | for pair in self.pairs: 46 | r = ccs.btce.public.ticker(pair) 47 | jsonschema.validate(json.loads(r), schema()) 48 | sleep() 49 | 50 | 51 | class Invalid(unittest.TestCase): 52 | def setUp(self): 53 | self.pair = "aaa_bbb" 54 | 55 | def testResponse(self): 56 | with self.assertRaises(jsonschema.exceptions.ValidationError): 57 | r = ccs.btce.public.ticker(self.pair) 58 | jsonschema.validate(json.loads(r), schema()) 59 | 60 | 61 | if __name__ == '__main__': 62 | unittest.main() 63 | -------------------------------------------------------------------------------- /tests/testApi/testPublic/testBter/__init__.py: -------------------------------------------------------------------------------- 1 | from . import testDepth 2 | from . import testMarketDetails 3 | from . import testMarketInfo 4 | from . import testTicker 5 | from . import testTickers 6 | from . import testTradeHistory 7 | from . import testTradingPairs 8 | -------------------------------------------------------------------------------- /tests/testApi/testPublic/testBter/testMarketDetails.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf8 -*- 2 | 3 | """ 4 | This file implements test cases for validation communication with REST endpoint on Bter. This endpoint offer informations about markets. 5 | """ 6 | 7 | __author__ = "Jan Seda" 8 | __copyright__ = "Copyright (C) Jan Seda" 9 | __credits__ = [] 10 | __license__ = "" 11 | __version__ = "0.1" 12 | __maintainer__ = "Jan Seda" 13 | __email__ = "" 14 | __status__ = "Production" 15 | 16 | 17 | import unittest 18 | import ccs 19 | import jsonschema 20 | import json 21 | import time 22 | 23 | 24 | def schema(): 25 | return ccs.bter.configuration.SCHEMA["marketDetails"] 26 | 27 | 28 | def sleep(): 29 | time.sleep(3) 30 | 31 | 32 | class Valid(unittest.TestCase): 33 | def setUp(self): 34 | sleep() 35 | 36 | def testSchema(self): 37 | r = ccs.bter.public.marketDetails() 38 | jsonschema.validate(json.loads(r), schema()) 39 | 40 | 41 | class Invalid(unittest.TestCase): 42 | def setUp(self): 43 | pass 44 | 45 | def testResponse(self): 46 | with self.assertRaises(jsonschema.exceptions.ValidationError): 47 | r = '{"result":"false","code":0,"message":"Error: invalid ..."}' 48 | jsonschema.validate(json.loads(r), schema()) 49 | 50 | 51 | if __name__ == '__main__': 52 | unittest.main() 53 | -------------------------------------------------------------------------------- /tests/testApi/testPublic/testBter/testMarketInfo.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf8 -*- 2 | 3 | """ 4 | This file implements test cases for validation communication with REST endpoint on Bter. This endpoint offer informations about markets. 5 | """ 6 | 7 | __author__ = "Jan Seda" 8 | __copyright__ = "Copyright (C) Jan Seda" 9 | __credits__ = [] 10 | __license__ = "" 11 | __version__ = "0.1" 12 | __maintainer__ = "Jan Seda" 13 | __email__ = "" 14 | __status__ = "Production" 15 | 16 | 17 | import unittest 18 | import ccs 19 | import jsonschema 20 | import json 21 | import time 22 | 23 | 24 | def schema(): 25 | return ccs.bter.configuration.SCHEMA["marketInfo"] 26 | 27 | 28 | def sleep(): 29 | time.sleep(3) 30 | 31 | 32 | class Valid(unittest.TestCase): 33 | def setUp(self): 34 | sleep() 35 | 36 | def testSchema(self): 37 | r = ccs.bter.public.marketInfo() 38 | jsonschema.validate(json.loads(r), schema()) 39 | 40 | 41 | 42 | class Invalid(unittest.TestCase): 43 | def setUp(self): 44 | pass 45 | 46 | def testResponse(self): 47 | with self.assertRaises(jsonschema.exceptions.ValidationError): 48 | r = '{"result":"false","code":0,"message":"Error: invalid ..."}' 49 | jsonschema.validate(json.loads(r), schema()) 50 | 51 | 52 | if __name__ == '__main__': 53 | unittest.main() 54 | -------------------------------------------------------------------------------- /tests/testApi/testPublic/testBter/testTickers.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf8 -*- 2 | 3 | """ 4 | This file implements test cases for validation communication with REST endpoint on Bter. This endpoint offer tick informations for all markets. 5 | """ 6 | 7 | __author__ = "Jan Seda" 8 | __copyright__ = "Copyright (C) Jan Seda" 9 | __credits__ = [] 10 | __license__ = "" 11 | __version__ = "0.1" 12 | __maintainer__ = "Jan Seda" 13 | __email__ = "" 14 | __status__ = "Production" 15 | 16 | 17 | import unittest 18 | import ccs 19 | import jsonschema 20 | import json 21 | import time 22 | 23 | 24 | def schema(): 25 | return ccs.bter.configuration.SCHEMA["tickers"] 26 | 27 | 28 | def sleep(): 29 | time.sleep(3) 30 | 31 | 32 | class Valid(unittest.TestCase): 33 | def setUp(self): 34 | sleep() 35 | 36 | def testSchema(self): 37 | r = ccs.bter.public.tickers() 38 | jsonschema.validate(json.loads(r), schema()) 39 | 40 | 41 | 42 | class Invalid(unittest.TestCase): 43 | def setUp(self): 44 | pass 45 | 46 | def testResponse(self): 47 | with self.assertRaises(jsonschema.exceptions.ValidationError): 48 | r = '{"result":"false","code":0,"message":"Error: invalid ..."}' 49 | jsonschema.validate(json.loads(r), schema()) 50 | 51 | 52 | if __name__ == '__main__': 53 | unittest.main() 54 | -------------------------------------------------------------------------------- /tests/testApi/testPublic/testBter/testTradingPairs.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf8 -*- 2 | 3 | """ 4 | This file implements test cases for validation communication with REST endpoint on Bter. This endpoint offer list of traiding pairs. 5 | """ 6 | 7 | __author__ = "Jan Seda" 8 | __copyright__ = "Copyright (C) Jan Seda" 9 | __credits__ = [] 10 | __license__ = "" 11 | __version__ = "0.1" 12 | __maintainer__ = "Jan Seda" 13 | __email__ = "" 14 | __status__ = "Production" 15 | 16 | 17 | import unittest 18 | import ccs 19 | import jsonschema 20 | import json 21 | import time 22 | 23 | 24 | def schema(): 25 | return ccs.bter.configuration.SCHEMA["tradingPairs"] 26 | 27 | 28 | def sleep(): 29 | time.sleep(3) 30 | 31 | 32 | class Valid(unittest.TestCase): 33 | def setUp(self): 34 | sleep() 35 | 36 | def testSchema(self): 37 | r = ccs.bter.public.tradingPairs() 38 | jsonschema.validate(json.loads(r), schema()) 39 | 40 | 41 | 42 | class Invalid(unittest.TestCase): 43 | def setUp(self): 44 | pass 45 | 46 | def testResponse(self): 47 | with self.assertRaises(jsonschema.exceptions.ValidationError): 48 | r = '{"result":"false","code":0,"message":"Error: invalid ..."}' 49 | jsonschema.validate(json.loads(r), schema()) 50 | 51 | 52 | if __name__ == '__main__': 53 | unittest.main() 54 | -------------------------------------------------------------------------------- /tests/testApi/testPublic/testCexio/__init__.py: -------------------------------------------------------------------------------- 1 | from . import testLimits 2 | from . import testOrderbook 3 | from . import testPrice 4 | from . import testPrices 5 | from . import testTicker 6 | from . import testTickers 7 | from . import testTrades 8 | -------------------------------------------------------------------------------- /tests/testApi/testPublic/testCexio/testLimits.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf8 -*- 2 | 3 | """ 4 | This file implements test cases for validation communication with REST endpoint on Cexio. This endpoint offer informations about currencies. 5 | """ 6 | 7 | __author__ = "Jan Seda" 8 | __copyright__ = "Copyright (C) Jan Seda" 9 | __credits__ = [] 10 | __license__ = "" 11 | __version__ = "0.1" 12 | __maintainer__ = "Jan Seda" 13 | __email__ = "" 14 | __status__ = "Production" 15 | 16 | 17 | import unittest 18 | import ccs 19 | import jsonschema 20 | import json 21 | import time 22 | 23 | 24 | def schema(): 25 | return ccs.cexio.configuration.SCHEMA["currencyLimits"] 26 | 27 | 28 | def sleep(): 29 | time.sleep(3) 30 | 31 | 32 | class Valid(unittest.TestCase): 33 | def setUp(self): 34 | pass 35 | 36 | def testSchema(self): 37 | r = ccs.cexio.public.currencyLimits() 38 | jsonschema.validate(json.loads(r), schema()) 39 | 40 | 41 | class Invalid(unittest.TestCase): 42 | def setUp(self): 43 | pass 44 | 45 | def testResponse(self): 46 | with self.assertRaises(jsonschema.exceptions.ValidationError): 47 | r = '{"e":"Unspecified"}' 48 | jsonschema.validate(json.loads(r), schema()) 49 | 50 | 51 | if __name__ == '__main__': 52 | unittest.main() 53 | -------------------------------------------------------------------------------- /tests/testApi/testPublic/testKraken/__init__.py: -------------------------------------------------------------------------------- 1 | from . import testAssetinfo 2 | from . import testOhlc 3 | from . import testOrderbook 4 | from . import testPairs 5 | from . import testServertime 6 | from . import testSpread 7 | from . import testTicker 8 | from . import testTrades 9 | -------------------------------------------------------------------------------- /tests/testApi/testPublic/testOkcoincn/__init__.py: -------------------------------------------------------------------------------- 1 | from . import testDepth 2 | from . import testTicker 3 | from . import testTrades 4 | -------------------------------------------------------------------------------- /tests/testApi/testPublic/testOkcoincn/testTicker.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf8 -*- 2 | 3 | """ 4 | This file implements test cases for validation communication with REST endpoint on Okcoin.com. This endpoint offer tick informations. 5 | """ 6 | 7 | __author__ = "Jan Seda" 8 | __copyright__ = "Copyright (C) Jan Seda" 9 | __credits__ = [] 10 | __license__ = "" 11 | __version__ = "0.1" 12 | __maintainer__ = "Jan Seda" 13 | __email__ = "" 14 | __status__ = "Production" 15 | 16 | 17 | import unittest 18 | import ccs 19 | import jsonschema 20 | import json 21 | import time 22 | 23 | 24 | def schema(): 25 | return ccs.okcoincn.configuration.SCHEMA["ticker"] 26 | 27 | 28 | def sleep(): 29 | time.sleep(3) 30 | 31 | 32 | class Valid(unittest.TestCase): 33 | def setUp(self): 34 | self.symbols = ["btc_cny", "ltc_cny"] 35 | self.symbol = self.symbols[0] 36 | sleep() 37 | 38 | def testSchema(self): 39 | r = ccs.okcoincn.public.ticker(self.symbol) 40 | jsonschema.validate(json.loads(r), schema()) 41 | 42 | @unittest.skip("time-consuming") 43 | def testSymbols(self): 44 | for symbol in self.symbols: 45 | r = ccs.okcoincn.public.ticker(symbol) 46 | jsonschema.validate(json.loads(r), schema()) 47 | sleep() 48 | 49 | 50 | class Invalid(unittest.TestCase): 51 | def setUp(self): 52 | self.symbol = "aaa_bbb" 53 | 54 | @unittest.skip("server is able recover") 55 | def testResponse(self): 56 | with self.assertRaises(jsonschema.exceptions.ValidationError): 57 | r = ccs.okcoincn.public.ticker(self.symbol) 58 | jsonschema.validate(json.loads(r), schema()) 59 | 60 | 61 | if __name__ == '__main__': 62 | unittest.main() 63 | -------------------------------------------------------------------------------- /tests/testApi/testPublic/testOkcoincom/__init__.py: -------------------------------------------------------------------------------- 1 | from . import testDepth 2 | from . import testTicker 3 | from . import testTrades 4 | -------------------------------------------------------------------------------- /tests/testApi/testPublic/testOkcoincom/testTicker.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf8 -*- 2 | 3 | """ 4 | This file implements test cases for validation communication with REST endpoint on Okcoin.com. This endpoint offer tick informations. 5 | """ 6 | 7 | __author__ = "Jan Seda" 8 | __copyright__ = "Copyright (C) Jan Seda" 9 | __credits__ = [] 10 | __license__ = "" 11 | __version__ = "0.1" 12 | __maintainer__ = "Jan Seda" 13 | __email__ = "" 14 | __status__ = "Production" 15 | 16 | 17 | import unittest 18 | import ccs 19 | import jsonschema 20 | import json 21 | import time 22 | 23 | 24 | def schema(): 25 | return ccs.okcoincom.configuration.SCHEMA["ticker"] 26 | 27 | 28 | def sleep(): 29 | time.sleep(3) 30 | 31 | 32 | class Valid(unittest.TestCase): 33 | def setUp(self): 34 | self.symbols = ["btc_usd", "ltc_usd"] 35 | self.symbol = self.symbols[0] 36 | sleep() 37 | 38 | def testSchema(self): 39 | r = ccs.okcoincom.public.ticker(self.symbol) 40 | jsonschema.validate(json.loads(r), schema()) 41 | 42 | @unittest.skip("time-consuming") 43 | def testSymbols(self): 44 | for symbol in self.symbols: 45 | r = ccs.okcoincom.public.ticker(symbol) 46 | jsonschema.validate(json.loads(r), schema()) 47 | sleep() 48 | 49 | 50 | class Invalid(unittest.TestCase): 51 | def setUp(self): 52 | self.symbol = "aaa_bbb" 53 | 54 | @unittest.skip("server is able recover") 55 | def testResponse(self): 56 | with self.assertRaises(jsonschema.exceptions.ValidationError): 57 | r = ccs.okcoincom.public.ticker(self.symbol) 58 | jsonschema.validate(json.loads(r), schema()) 59 | 60 | 61 | if __name__ == '__main__': 62 | unittest.main() 63 | -------------------------------------------------------------------------------- /tests/testApi/testPublic/testPoloniex/__init__.py: -------------------------------------------------------------------------------- 1 | from . import test24hvolume 2 | from . import testChart 3 | from . import testCurrencies 4 | from . import testLoan 5 | from . import testOrderbook 6 | from . import testTicker 7 | from . import testTrades 8 | -------------------------------------------------------------------------------- /tests/testApi/testPublic/testPoloniex/test24hvolume.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf8 -*- 2 | 3 | """ 4 | This file implements test cases for validation communication with REST endpoint on Poloniex. This endpoint offer 24h volume informations. 5 | """ 6 | 7 | __author__ = "Jan Seda" 8 | __copyright__ = "Copyright (C) Jan Seda" 9 | __credits__ = [] 10 | __license__ = "" 11 | __version__ = "0.1" 12 | __maintainer__ = "Jan Seda" 13 | __email__ = "" 14 | __status__ = "Production" 15 | 16 | 17 | import unittest 18 | import ccs 19 | import jsonschema 20 | import json 21 | import time 22 | 23 | 24 | def schema(): 25 | return ccs.poloniex.configuration.SCHEMA["return24hVolume"] 26 | 27 | 28 | def sleep(): 29 | time.sleep(3) 30 | 31 | 32 | class Valid(unittest.TestCase): 33 | def setUp(self): 34 | sleep() 35 | 36 | def testSchema(self): 37 | r = ccs.poloniex.public.return24hVolume() 38 | jsonschema.validate(json.loads(r), schema()) 39 | 40 | 41 | class Invalid(unittest.TestCase): 42 | def setUp(self): 43 | pass 44 | 45 | def testResponse(self): 46 | with self.assertRaises(jsonschema.exceptions.ValidationError): 47 | r = '{"error":"Unspecified"}' 48 | jsonschema.validate(json.loads(r), schema()) 49 | 50 | 51 | if __name__ == '__main__': 52 | unittest.main() 53 | -------------------------------------------------------------------------------- /tests/testApi/testPublic/testPoloniex/testCurrencies.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf8 -*- 2 | 3 | """ 4 | This file implements test cases for validation communication with REST endpoint on Poloniex. This endpoint offer informations about currencies. 5 | """ 6 | 7 | __author__ = "Jan Seda" 8 | __copyright__ = "Copyright (C) Jan Seda" 9 | __credits__ = [] 10 | __license__ = "" 11 | __version__ = "0.1" 12 | __maintainer__ = "Jan Seda" 13 | __email__ = "" 14 | __status__ = "Production" 15 | 16 | 17 | import unittest 18 | import ccs 19 | import jsonschema 20 | import json 21 | import time 22 | 23 | 24 | def schema(): 25 | return ccs.poloniex.configuration.SCHEMA["returnCurrencies"] 26 | 27 | 28 | def sleep(): 29 | time.sleep(3) 30 | 31 | 32 | class Valid(unittest.TestCase): 33 | def setUp(self): 34 | pass 35 | 36 | def testSchema(self): 37 | r = ccs.poloniex.public.returnCurrencies() 38 | jsonschema.validate(json.loads(r), schema()) 39 | sleep() 40 | 41 | 42 | class Invalid(unittest.TestCase): 43 | def setUp(self): 44 | pass 45 | 46 | def testResponse(self): 47 | with self.assertRaises(jsonschema.exceptions.ValidationError): 48 | r = '{"error":"Unspecified"}' 49 | jsonschema.validate(json.loads(r), schema()) 50 | 51 | 52 | if __name__ == '__main__': 53 | unittest.main() 54 | -------------------------------------------------------------------------------- /tests/testApi/testPublic/testPoloniex/testTicker.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf8 -*- 2 | 3 | """ 4 | This file implements test cases for validation communication with REST endpoint on Poloniex. This endpoint offer tick informations. 5 | """ 6 | 7 | __author__ = "Jan Seda" 8 | __copyright__ = "Copyright (C) Jan Seda" 9 | __credits__ = [] 10 | __license__ = "" 11 | __version__ = "0.1" 12 | __maintainer__ = "Jan Seda" 13 | __email__ = "" 14 | __status__ = "Production" 15 | 16 | 17 | import unittest 18 | import ccs 19 | import jsonschema 20 | import json 21 | import time 22 | 23 | 24 | def schema(): 25 | return ccs.poloniex.configuration.SCHEMA["returnTicker"] 26 | 27 | 28 | def sleep(): 29 | time.sleep(3) 30 | 31 | 32 | class Valid(unittest.TestCase): 33 | def setUp(self): 34 | pass 35 | 36 | def testSchema(self): 37 | r = ccs.poloniex.public.returnTicker() 38 | jsonschema.validate(json.loads(r), schema()) 39 | sleep() 40 | 41 | 42 | class Invalid(unittest.TestCase): 43 | def setUp(self): 44 | pass 45 | 46 | def testResponse(self): 47 | with self.assertRaises(jsonschema.exceptions.ValidationError): 48 | r = '{"error":"Unspecified"}' 49 | jsonschema.validate(json.loads(r), schema()) 50 | 51 | 52 | if __name__ == '__main__': 53 | unittest.main() 54 | -------------------------------------------------------------------------------- /tests/testResponse/__init__.py: -------------------------------------------------------------------------------- 1 | from .testBitfinex import * 2 | from .testBitstamp import * 3 | from .testBittrex import * 4 | from .testBtcc import * 5 | from .testBtccpro import * 6 | from .testBtce import * 7 | from .testBter import * 8 | from .testCexio import * 9 | from .testKraken import * 10 | from .testOkcoincn import * 11 | from .testOkcoincom import * 12 | from .testPoloniex import * 13 | 14 | -------------------------------------------------------------------------------- /tests/testResponse/testBitfinex/__init__.py: -------------------------------------------------------------------------------- 1 | from . import testTicker 2 | from . import testTrade 3 | from . import testTrades -------------------------------------------------------------------------------- /tests/testResponse/testBitfinex/testTrades.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import ccs 3 | 4 | class Valid(unittest.TestCase): 5 | def setUp(self): 6 | self.limit = 2 7 | self.json = '[{"timestamp":1480850761,"tid":24902281,"price":"765.0","amount":"0.27731462","exchange":"bitfinex","type":"buy"},{"timestamp":1480850759,"tid":24902279,"price":"764.99","amount":"0.01907827","exchange":"bitfinex","type":"sell"}]' 8 | self.trades = ccs.bitfinex.public.response.Trades(self.json) 9 | 10 | def testLen(self): 11 | self.assertAlmostEqual(len(self.trades), self.limit) 12 | 13 | def testGetItem(self): 14 | self.assertIsInstance(self.trades[0], ccs.bitfinex.public.response.Trade) 15 | 16 | def testMethod(self): 17 | pass 18 | 19 | def testStock(self): 20 | pass 21 | 22 | def testOsymbol(self): 23 | pass 24 | 25 | def testUsymbol(self): 26 | pass 27 | 28 | def testStr(self): 29 | pass -------------------------------------------------------------------------------- /tests/testResponse/testBitstamp/__init__.py: -------------------------------------------------------------------------------- 1 | from . import testTicker -------------------------------------------------------------------------------- /tests/testResponse/testBitstamp/testTicker.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import ccs 3 | import datetime 4 | 5 | 6 | #################################################################################################################### 7 | # BITSTAMP # 8 | #################################################################################################################### 9 | 10 | class Valid(unittest.TestCase): 11 | def setUp(self): 12 | self.tz = datetime.timezone.utc 13 | self.json = '{"high": "765.00", "last": "759.01", "timestamp": "1480859680", "bid": "758.99", "vwap": "759.67", "volume": "2858.43054110", "low": "752.41", "ask": "759.00", "open": 762.97}' 14 | symbol = ccs.bitstamp.Symbol(ccs.constants.BTC, ccs.constants.USD) 15 | self.ticker = ccs.bitstamp.public.response.Ticker(self.json, symbol) 16 | 17 | def testLow(self): 18 | self.assertEqual(self.ticker.low(), 752.41) 19 | 20 | def testHigh(self): 21 | self.assertEqual(self.ticker.high(), 765.00) 22 | 23 | def testAsk(self): 24 | self.assertEqual(self.ticker.ask(), 759.00) 25 | 26 | def testBid(self): 27 | self.assertEqual(self.ticker.bid(), 758.99) 28 | 29 | def testLast(self): 30 | self.assertEqual(self.ticker.last(), 759.01) 31 | 32 | def testVolume24h(self): 33 | self.assertEqual(self.ticker.volume24h(), 2858.43054110) 34 | 35 | def testTimestamp(self): 36 | self.assertEqual(self.ticker.timestamp(), 1480859680) 37 | 38 | def testDt(self): 39 | 40 | self.assertEqual(self.ticker.dt(tz=self.tz), datetime.datetime(2016, 12, 4, 13, 54, 40, tzinfo=self.tz)) 41 | 42 | def testSpread(self): 43 | self.assertEqual(self.ticker.spread(), ((759.00 - 758.99) / 759.00) * 100) -------------------------------------------------------------------------------- /tests/testResponse/testBittrex/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Honzin/ccs/c02a1ce2e2a829f2eebe6d6eb39174939a807646/tests/testResponse/testBittrex/__init__.py -------------------------------------------------------------------------------- /tests/testResponse/testBtcc/__init__.py: -------------------------------------------------------------------------------- 1 | from . import testTicker -------------------------------------------------------------------------------- /tests/testResponse/testBtcc/testTicker.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import ccs 3 | import datetime 4 | 5 | #################################################################################################################### 6 | # BTCC # 7 | #################################################################################################################### 8 | 9 | class Valid(unittest.TestCase): 10 | def setUp(self): 11 | self.tz = datetime.timezone.utc 12 | self.json = '{"ticker": {"high": "5430.00", "low": "5350.00", "buy": "5425.77", "sell": "5425.87", "last": "5425.98","vol": "1165699.19230000", "date": 1480859730, "vwap": "5402.76", "prev_close": "5391.56", "open": "5391.6"}}' 13 | symbol = ccs.btcc.Symbol(ccs.constants.BTC, ccs.constants.CNY) 14 | self.ticker = ccs.btcc.public.response.Ticker(self.json, symbol) 15 | 16 | def testLow(self): 17 | self.assertEqual(self.ticker.low(), 5350.00) 18 | 19 | def testHigh(self): 20 | self.assertEqual(self.ticker.high(), 5430.00) 21 | 22 | def testAsk(self): 23 | self.assertEqual(self.ticker.ask(), 5425.77) 24 | 25 | def testBid(self): 26 | self.assertEqual(self.ticker.bid(), 5425.87) 27 | 28 | def testLast(self): 29 | self.assertEqual(self.ticker.last(), 5425.98) 30 | 31 | def testVolume24h(self): 32 | self.assertEqual(self.ticker.volume24h(), 1165699.19230000) 33 | 34 | def testTimestamp(self): 35 | self.assertEqual(self.ticker.timestamp(), 1480859730) 36 | 37 | def testDt(self): 38 | self.assertEqual(self.ticker.dt(tz=self.tz), datetime.datetime(2016, 12, 4, 13, 55, 30, tzinfo=self.tz)) 39 | 40 | def testSpread(self): 41 | self.assertEqual(self.ticker.spread(), ((5425.77 - 5425.87) / 5425.77) * 100) -------------------------------------------------------------------------------- /tests/testResponse/testBtccpro/__init__.py: -------------------------------------------------------------------------------- 1 | from . import testOrder 2 | from . import testOrderbook 3 | from . import testOrders 4 | from . import testTicker 5 | from . import testTrade 6 | from .import testTrades -------------------------------------------------------------------------------- /tests/testResponse/testBtccpro/testOrderbook.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import ccs 3 | import datetime 4 | import time 5 | 6 | #################################################################################################################### 7 | # BTCCPRO # 8 | #################################################################################################################### 9 | 10 | class Valid(unittest.TestCase): 11 | def setUp(self): 12 | self.stock = ccs.constants.BTCCPRO 13 | self.base = ccs.constants.XBT 14 | self.quote = ccs.constants.CNY 15 | symbol = ccs.btccpro.Symbol(self.base, self.quote) 16 | 17 | self.tz = datetime.timezone.utc 18 | 19 | self.json = '{"asks":[[6929,22],[6930,25]],"bids":[[6910.3,11],[6903,4]],"date":1486145574689}' 20 | self.orderbook = ccs.btccpro.public.response.OrderBook(self.json, symbol) 21 | 22 | self.m = ccs.btccpro.public.response 23 | #time.sleep(3) 24 | 25 | def testAsks(self): 26 | self.assertIsInstance(self.orderbook.asks(), self.m.Orders) 27 | 28 | def testBids(self): 29 | self.assertIsInstance(self.orderbook.bids(), self.m.Orders) 30 | 31 | def testStock(self): 32 | self.assertEqual(self.orderbook.stock(), self.stock) 33 | 34 | def testMethod(self): 35 | self.assertEqual(self.orderbook.method(), ccs.constants.ORDERBOOK) 36 | 37 | def testUsymbol(self): 38 | self.assertEqual(self.orderbook.usymbol(), self.base + ":" + self.quote) 39 | 40 | def testOsymbol(self): 41 | pass 42 | 43 | def testData(self): 44 | pass 45 | 46 | def testRaw(self): 47 | pass 48 | 49 | def testStr(self): 50 | pass 51 | 52 | 53 | if __name__ == '__main__': 54 | unittest.main() 55 | -------------------------------------------------------------------------------- /tests/testResponse/testBtccpro/testTicker.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import ccs 3 | import datetime 4 | 5 | #################################################################################################################### 6 | # BTCCPRO # 7 | #################################################################################################################### 8 | 9 | class Valid(unittest.TestCase): 10 | def setUp(self): 11 | self.tz = datetime.timezone.utc 12 | self.json = '{"ticker":{"BidPrice":6003,"AskPrice":6017,"Open":6061.859999999999,"High":6083.4,"Low":5877,"Last":6005,"LastQuantity":5,"PrevCls":5974,"Volume":3834,"Volume24H":16495,"Timestamp":1484822829240,"ExecutionLimitDown":5881.1,"ExecutionLimitUp":6246.8}}' 13 | symbol = ccs.btccpro.Symbol(ccs.constants.XBT, ccs.constants.CNY) 14 | self.ticker = ccs.btccpro.public.response.Ticker(self.json, symbol) 15 | 16 | def testLow(self): 17 | self.assertEqual(self.ticker.low(), 5877) 18 | 19 | def testHigh(self): 20 | self.assertEqual(self.ticker.high(), 6083.4) 21 | 22 | def testAsk(self): 23 | self.assertEqual(self.ticker.ask(), 6017) 24 | 25 | def testBid(self): 26 | self.assertEqual(self.ticker.bid(), 6003) 27 | 28 | def testLast(self): 29 | self.assertEqual(self.ticker.last(), 6005) 30 | 31 | def testVolume24h(self): 32 | self.assertEqual(self.ticker.volume24h(), 16495) 33 | 34 | def testTimestamp(self): 35 | self.assertEqual(self.ticker.timestamp(), 1484822829) 36 | 37 | def testDt(self): 38 | self.assertEqual(self.ticker.dt(tz=self.tz), datetime.datetime(2017, 1, 19, 10, 47, 9, tzinfo=self.tz)) 39 | 40 | def testSpread(self): 41 | self.assertEqual(self.ticker.spread(), ((6017 - 6003) / 6017) * 100) -------------------------------------------------------------------------------- /tests/testResponse/testBtccpro/testTrades.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import ccs 3 | 4 | #################################################################################################################### 5 | # BTCCPRO # 6 | #################################################################################################################### 7 | 8 | class Valid(unittest.TestCase): 9 | def setUp(self): 10 | self.stock = ccs.constants.BTCCPRO 11 | self.base = ccs.constants.XBT 12 | self.quote = ccs.constants.CNY 13 | symbol = ccs.btccpro.Symbol(self.base, self.quote) 14 | 15 | self.limit = 2 16 | self.json = '[{"Id":3,"Timestamp":1445592744686,"Price":1778,"Quantity":1,"Side":"Buy"},{"Id":4,"Timestamp":1445594157046,"Price":1780,"Quantity":1,"Side":"Sell"}]' 17 | self.trades = ccs.btccpro.public.response.Trades(self.json) 18 | self.m = ccs.btccpro.public.response 19 | 20 | def testLen(self): 21 | self.assertAlmostEqual(len(self.trades), self.limit) 22 | 23 | def testGetItem(self): 24 | self.assertIsInstance(self.trades[0], self.m.Trade) 25 | 26 | def testMethod(self): 27 | pass 28 | 29 | def testStock(self): 30 | pass 31 | 32 | def testOsymbol(self): 33 | pass 34 | 35 | def testUsymbol(self): 36 | pass 37 | 38 | def testStr(self): 39 | pass 40 | 41 | 42 | 43 | if __name__ == '__main__': 44 | unittest.main() -------------------------------------------------------------------------------- /tests/testResponse/testBtccusd/__init__.py: -------------------------------------------------------------------------------- 1 | from . import testOrder 2 | from . import testOrderbook 3 | from . import testOrders 4 | from . import testTicker 5 | from . import testTrade 6 | from .import testTrades -------------------------------------------------------------------------------- /tests/testResponse/testBtccusd/testOrderbook.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import ccs 3 | import datetime 4 | import time 5 | 6 | #################################################################################################################### 7 | # BTCCUSD # 8 | #################################################################################################################### 9 | 10 | class Valid(unittest.TestCase): 11 | def setUp(self): 12 | self.stock = ccs.constants.BTCCUSD 13 | self.base = ccs.constants.BTC 14 | self.quote = ccs.constants.USD 15 | symbol = ccs.btccusd.Symbol(self.base, self.quote) 16 | 17 | self.tz = datetime.timezone.utc 18 | 19 | self.json = '{"asks":[[1038.97,0.188],[1049,0.5]],"bids":[[981.09,0.0004],[981.08,0.004]],"date":1486140539483}' 20 | self.orderbook = ccs.btccusd.public.response.OrderBook(self.json, symbol) 21 | 22 | self.m = ccs.btccusd.public.response 23 | #time.sleep(3) 24 | 25 | def testAsks(self): 26 | self.assertIsInstance(self.orderbook.asks(), self.m.Orders) 27 | 28 | def testBids(self): 29 | self.assertIsInstance(self.orderbook.bids(), self.m.Orders) 30 | 31 | def testStock(self): 32 | self.assertEqual(self.orderbook.stock(), self.stock) 33 | 34 | def testMethod(self): 35 | self.assertEqual(self.orderbook.method(), ccs.constants.ORDERBOOK) 36 | 37 | def testUsymbol(self): 38 | self.assertEqual(self.orderbook.usymbol(), self.base + ":" + self.quote) 39 | 40 | def testOsymbol(self): 41 | pass 42 | 43 | def testData(self): 44 | pass 45 | 46 | def testRaw(self): 47 | pass 48 | 49 | def testStr(self): 50 | pass 51 | 52 | 53 | if __name__ == '__main__': 54 | unittest.main() 55 | -------------------------------------------------------------------------------- /tests/testResponse/testBtccusd/testTrades.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import ccs 3 | 4 | #################################################################################################################### 5 | # BTCCUSD # 6 | #################################################################################################################### 7 | 8 | class Valid(unittest.TestCase): 9 | def setUp(self): 10 | self.stock = ccs.constants.BTCCUSD 11 | self.base = ccs.constants.BTC 12 | self.quote = ccs.constants.USD 13 | symbol = ccs.btccusd.Symbol(self.base, self.quote) 14 | 15 | self.limit = 2 16 | self.json = '[{"Id":7618,"Timestamp":1485830873401,"Price":969.96,"Quantity":0.092,"Side":"Buy"},{"Id":7619,"Timestamp":1485834001646,"Price":965,"Quantity":0.003,"Side":"Sell"}]' 17 | self.trades = ccs.btccusd.public.response.Trades(self.json, symbol) 18 | 19 | def testLen(self): 20 | self.assertAlmostEqual(len(self.trades), self.limit) 21 | 22 | def testGetItem(self): 23 | self.assertIsInstance(self.trades[0], ccs.btccusd.public.response.Trade) 24 | 25 | def testMethod(self): 26 | pass 27 | 28 | def testStock(self): 29 | pass 30 | 31 | def testOsymbol(self): 32 | pass 33 | 34 | def testUsymbol(self): 35 | pass 36 | 37 | def testStr(self): 38 | pass 39 | 40 | 41 | 42 | if __name__ == '__main__': 43 | unittest.main() -------------------------------------------------------------------------------- /tests/testResponse/testBtce/__init__.py: -------------------------------------------------------------------------------- 1 | from . import testTicker -------------------------------------------------------------------------------- /tests/testResponse/testBtce/testTicker.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import ccs 3 | import datetime 4 | 5 | #################################################################################################################### 6 | # BTCE # 7 | #################################################################################################################### 8 | 9 | class Valid(unittest.TestCase): 10 | def setUp(self): 11 | self.tz = datetime.timezone.utc 12 | self.json = '{"btc_usd":{"high":765,"low":750,"avg":757.5,"vol":1935696.62913,"vol_cur":2551.40496,"last":764.999,"buy":765.27,"sell":765.1,"updated":1480859797}}' 13 | symbol = ccs.btce.Symbol(ccs.constants.BTC, ccs.constants.USD) 14 | self.ticker = ccs.btce.public.response.Ticker(self.json, symbol) 15 | 16 | def testLow(self): 17 | self.assertEqual(self.ticker.low(), 750) 18 | 19 | def testHigh(self): 20 | self.assertEqual(self.ticker.high(), 765) 21 | 22 | def testAsk(self): 23 | self.assertEqual(self.ticker.ask(), 765.27) 24 | 25 | def testBid(self): 26 | self.assertEqual(self.ticker.bid(), 765.1) 27 | 28 | def testLast(self): 29 | self.assertEqual(self.ticker.last(), 764.999) 30 | 31 | def testVolume24h(self): 32 | self.assertEqual(self.ticker.volume24h(), 1935696.62913) 33 | 34 | def testTimestamp(self): 35 | self.assertEqual(self.ticker.timestamp(), 1480859797) 36 | 37 | def testDt(self): 38 | self.assertEqual(self.ticker.dt(tz=self.tz), datetime.datetime(2016, 12, 4, 13, 56, 37, tzinfo=self.tz)) 39 | 40 | def testSpread(self): 41 | self.assertEqual(self.ticker.spread(), ((765.27 - 765.1) / 765.27) * 100) -------------------------------------------------------------------------------- /tests/testResponse/testBter/__init__.py: -------------------------------------------------------------------------------- 1 | from . import testTicker -------------------------------------------------------------------------------- /tests/testResponse/testCexio/__init__.py: -------------------------------------------------------------------------------- 1 | from . import testTicker -------------------------------------------------------------------------------- /tests/testResponse/testCexio/testTicker.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import ccs 3 | import datetime 4 | 5 | #################################################################################################################### 6 | # CEXIO # 7 | #################################################################################################################### 8 | 9 | class Valid(unittest.TestCase): 10 | def setUp(self): 11 | self.tz = datetime.timezone.utc 12 | self.json = '{"timestamp":"1484832214","low":"853","high":"908.218","last":"898.85","volume":"529.78497768","volume30d":"19771.36729506","bid":895.5261,"ask":898.85}' 13 | symbol = ccs.cexio.Symbol(ccs.constants.BTC, ccs.constants.USD) 14 | self.ticker = ccs.cexio.public.response.Ticker(self.json, symbol) 15 | 16 | def testLow(self): 17 | self.assertEqual(self.ticker.low(), 853) 18 | 19 | def testHigh(self): 20 | self.assertEqual(self.ticker.high(), 908.218) 21 | 22 | def testAsk(self): 23 | self.assertEqual(self.ticker.ask(), 898.85) 24 | 25 | def testBid(self): 26 | self.assertEqual(self.ticker.bid(), 895.5261) 27 | 28 | def testLast(self): 29 | self.assertEqual(self.ticker.last(), 898.85) 30 | 31 | def testVolume24h(self): 32 | self.assertEqual(self.ticker.volume24h(), 529.78497768) 33 | 34 | def testTimestamp(self): 35 | self.assertEqual(self.ticker.timestamp(), 1484832214) 36 | 37 | def testDt(self): 38 | self.assertEqual(self.ticker.dt(tz=self.tz), datetime.datetime(2017, 1, 19, 13, 23, 34, tzinfo=self.tz)) 39 | 40 | def testSpread(self): 41 | self.assertEqual(self.ticker.spread(), ((898.85 - 895.5261) / 898.85) * 100) -------------------------------------------------------------------------------- /tests/testResponse/testKraken/__init__.py: -------------------------------------------------------------------------------- 1 | from . import testTicker -------------------------------------------------------------------------------- /tests/testResponse/testOkcoincn/__init__.py: -------------------------------------------------------------------------------- 1 | from . import testTicker -------------------------------------------------------------------------------- /tests/testResponse/testOkcoincn/testTicker.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import ccs 3 | import datetime 4 | 5 | #################################################################################################################### 6 | # OKCOINCOM # 7 | #################################################################################################################### 8 | 9 | class Valid(unittest.TestCase): 10 | def setUp(self): 11 | self.tz = datetime.timezone.utc 12 | self.json = '{"date":"1480859886","ticker":{"buy":"768.8","high":"769.0","last":"768.23","low":"761.0","sell":"768.92","vol":"1158.384"}}' 13 | symbol = ccs.okcoincn.Symbol(ccs.constants.BTC, ccs.constants.CNY) 14 | self.ticker = ccs.okcoincn.public.response.Ticker(self.json, symbol) 15 | 16 | def testLow(self): 17 | self.assertEqual(self.ticker.low(), 761.0) 18 | 19 | def testHigh(self): 20 | self.assertEqual(self.ticker.high(), 769.0) 21 | 22 | def testAsk(self): 23 | self.assertEqual(self.ticker.ask(), 768.8) 24 | 25 | def testBid(self): 26 | self.assertEqual(self.ticker.bid(), 768.92) 27 | 28 | def testLast(self): 29 | self.assertEqual(self.ticker.last(), 768.23) 30 | 31 | def testVolume24h(self): 32 | self.assertEqual(self.ticker.volume24h(), 1158.384) 33 | 34 | def testTimestamp(self): 35 | self.assertEqual(self.ticker.timestamp(), 1480859886) 36 | 37 | def testDt(self): 38 | self.assertEqual(self.ticker.dt(tz=self.tz), datetime.datetime(2016, 12, 4, 13, 58, 6, tzinfo=self.tz)) 39 | 40 | def testSpread(self): 41 | self.assertEqual(self.ticker.spread(), ((768.8 - 768.92) / 768.8) * 100) -------------------------------------------------------------------------------- /tests/testResponse/testOkcoincom/__init__.py: -------------------------------------------------------------------------------- 1 | from . import testTicker -------------------------------------------------------------------------------- /tests/testResponse/testOkcoincom/testTicker.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import ccs 3 | import datetime 4 | 5 | #################################################################################################################### 6 | # OKCOINCOM # 7 | #################################################################################################################### 8 | 9 | class Valid(unittest.TestCase): 10 | def setUp(self): 11 | self.tz = datetime.timezone.utc 12 | self.json = '{"date":"1480859886","ticker":{"buy":"768.8","high":"769.0","last":"768.23","low":"761.0","sell":"768.92","vol":"1158.384"}}' 13 | symbol = ccs.okcoincom.Symbol(ccs.constants.BTC, ccs.constants.USD) 14 | self.ticker = ccs.okcoincom.public.response.Ticker(self.json, symbol) 15 | 16 | def testLow(self): 17 | self.assertEqual(self.ticker.low(), 761.0) 18 | 19 | def testHigh(self): 20 | self.assertEqual(self.ticker.high(), 769.0) 21 | 22 | def testAsk(self): 23 | self.assertEqual(self.ticker.ask(), 768.8) 24 | 25 | def testBid(self): 26 | self.assertEqual(self.ticker.bid(), 768.92) 27 | 28 | def testLast(self): 29 | self.assertEqual(self.ticker.last(), 768.23) 30 | 31 | def testVolume24h(self): 32 | self.assertEqual(self.ticker.volume24h(), 1158.384) 33 | 34 | def testTimestamp(self): 35 | self.assertEqual(self.ticker.timestamp(), 1480859886) 36 | 37 | def testDt(self): 38 | self.assertEqual(self.ticker.dt(tz=self.tz), datetime.datetime(2016, 12, 4, 13, 58, 6, tzinfo=self.tz)) 39 | 40 | def testSpread(self): 41 | self.assertEqual(self.ticker.spread(), ((768.8 - 768.92) / 768.8) * 100) -------------------------------------------------------------------------------- /tests/testResponse/testPoloniex/__init__.py: -------------------------------------------------------------------------------- 1 | from . import testTicker --------------------------------------------------------------------------------