本文整理汇总了Python中binance.client.Client方法的典型用法代码示例。如果您正苦于以下问题:Python client.Client方法的具体用法?Python client.Client怎么用?Python client.Client使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类binance.client
的用法示例。
在下文中一共展示了client.Client方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: binance2btrx
# 需要导入模块: from binance import client [as 别名]
# 或者: from binance.client import Client [as 别名]
def binance2btrx (_data):
'''
Converts Binance data structure into Bittrex's model.
'''
new_data={}
new_data['MarketName'] = str(_data['symbol'])
new_data['Ask'] = float(_data['askPrice'])
new_data['BaseVolume'] = float(_data['quoteVolume'])
new_data['Bid'] = float(_data['bidPrice'])
new_data['High'] = float(_data['highPrice'])
new_data['Last'] = float(_data['lastPrice'])
new_data['Low'] = float(_data['lowPrice'])
new_data['Volume'] = float(_data['volume'])
new_data['Count'] = float(_data['count'])
return new_data
示例2: client
# 需要导入模块: from binance import client [as 别名]
# 或者: from binance.client import Client [as 别名]
def client(self):
if not self._client:
self._client = Client(self.__key, self.__secret)
return self._client
示例3: __init__
# 需要导入模块: from binance import client [as 别名]
# 或者: from binance.client import Client [as 别名]
def __init__(self, client: Client):
Thread.__init__(self)
Logger.__init__(self)
self.client = client
self.stop = False
self.ticker_websocket: WebSocketClientProtocol = None
self.user_webscoket: WebSocketClientProtocol = None
self.ticker_ws_future = None
self.user_ws_future = None
self.mngmt_future = None
self.connection_key = None
self.user_info_cb = None
self.ticker_cb = None
self.symbols = None
if not BinanceWebsocket.__EVENT_LOOP:
self.loop = asyncio.get_event_loop()
BinanceWebsocket.__EVENT_LOOP = self.loop
else:
self.loop = BinanceWebsocket.__EVENT_LOOP
self.time = None
self.name = 'Binance WebSocket Thread'
示例4: __init__
# 需要导入模块: from binance import client [as 别名]
# 或者: from binance.client import Client [as 别名]
def __init__(self, key=None, secret=None):
super().__init__()
self.__key = key
self.__secret = secret
self._client = None #Client(key, secret)
self.bs: BinanceWebsocket = None
# self.connection = None
self.ticker_connection = None
self.user_data_connection = None
示例5: __init__
# 需要导入模块: from binance import client [as 别名]
# 或者: from binance.client import Client [as 别名]
def __init__(self, key=None, secret=None):
super().__init__()
self.__key = key
self.__secret = secret
self.client = Client(key, secret)
self.bs = BinanceSocketManager(self.client)
# self.connection = None
self.ticker_connection = None
self.user_data_connection = None
示例6: listen_symbols
# 需要导入模块: from binance import client [as 别名]
# 或者: from binance.client import Client [as 别名]
def listen_symbols(self, symbols, on_ticker_received, user_data_handler):
# self.client = Client(self.__key, self.__secret)
self.bs = BinanceSocketManager(self.client)
# self.connection = self.bs.start_multiplex_socket(['{}@trade'.format(s.lower()) for s in symbols],
# socket_handler)
self.bs.start_ticker_socket(on_ticker_received)
# self.ticker_connection = self.bs.start_multiplex_socket(['{}@ticker'.format(s.lower()) for s in symbols],
# on_ticker_received)
self.user_data_connection = self.bs.start_user_socket(user_data_handler)
self.logInfo('Ticker and User WS initialized')
self.bs.name = 'Binance WS'
示例7: get_markets_list
# 需要导入模块: from binance import client [as 别名]
# 或者: from binance.client import Client [as 别名]
def get_markets_list(base='BTC', exchange='bittrex'):
'''
Gets all coins from a certain market.
Args:
- base: if you want just one market. Ex: BTC.
Empty for all markets.
Returns:
- list of markets.
- False if unsupported exchange.
'''
ret = False
if exchange=='bittrex':
try:
bt = Bittrex('', '')
log("[INFO] Connected to Bittrex." , 1)
ret = [i['MarketName'] for i in bt.get_markets()['result'] if i['MarketName'].startswith(base)]
except Exception as e:
log("[ERROR] Connecting to Bittrex..." , 0)
elif exchange=='binance':
try:
bnb = Binance('','')
log("[INFO] Connected to Binance." , 1)
ret = [i['symbol'] for i in bnb.get_all_tickers() if i['symbol'].endswith(base)]
except Exception as e:
log("[ERROR] Connecting to Binance..." , 0)
return ret
示例8: __init__
# 需要导入模块: from binance import client [as 别名]
# 或者: from binance.client import Client [as 别名]
def __init__(self, api_key, api_secret):
self.client = Client(api_key, api_secret)
示例9: __init__
# 需要导入模块: from binance import client [as 别名]
# 或者: from binance.client import Client [as 别名]
def __init__(self, key, secret):
self.logger = Logger(__name__)
try:
self.client = Client(key, secret)
except Exception as e:
self.logger.log(e)
raise ExchangeException(self.__class__.__name__, e)
示例10: __init__
# 需要导入模块: from binance import client [as 别名]
# 或者: from binance.client import Client [as 别名]
def __init__(self, binance_client: BinanceClient):
self._binance_client: BinanceClient = binance_client
self._current_listen_key = None
self._listen_for_user_stream_task = None
self._last_recv_time: float = 0
super().__init__()
示例11: __init__
# 需要导入模块: from binance import client [as 别名]
# 或者: from binance.client import Client [as 别名]
def __init__(self,
data_source_type: UserStreamTrackerDataSourceType = UserStreamTrackerDataSourceType.EXCHANGE_API,
binance_client: Optional[BinanceClient] = None):
super().__init__(data_source_type=data_source_type)
self._binance_client: BinanceClient = binance_client
self._ev_loop: asyncio.events.AbstractEventLoop = asyncio.get_event_loop()
self._data_source: Optional[UserStreamTrackerDataSource] = None
self._user_stream_tracking_task: Optional[asyncio.Task] = None