Package that implements a remote client for hummingbot in Python.
You can use this client to implement remote control and monitoring software of multi-botenvironments using the MQTT feature of hummingbot.
TheBotCommands class provides methods for calling bot commands.Each instance is bound to a specific bot instance.
def__init__(self,bot_id:str,host:str='localhost',port:int=1883,username:str='',password:str='',namespace:str='hbot',**kwargs ):
Below is an example of using theBotCommands class to send commands to a bot
importasynciofromhbotrcimportBotListener,BotCommandsasyncdefrun_commands(client):resp=client.start()print(f'Start Command Response:{resp}')resp=client.import_strategy('conf_pure_mm')print(f'Import Command Response:{resp}')awaitasyncio.sleep(1)resp=client.import_strategy('conf_pure_mm_1')print(f'Import Command Response:{resp}')awaitasyncio.sleep(1)resp=client.config([('bid_spread',0.1), ('ask_spread',0.1)])print(f'Config Command Response:{resp}')awaitasyncio.sleep(1)resp=client.start()print(f'Start Command Response:{resp}')awaitasyncio.sleep(1)resp=client.status()print(f'Status Command Response:{resp}')awaitasyncio.sleep(1)resp=client.history()print(f'History Command Response:{resp}')awaitasyncio.sleep(1)resp=client.stop()print(f'Stop Command Response:{resp}')awaitasyncio.sleep(1)if__name__=="__main__":importsysiflen(sys.argv)<2:print('Give instance_id argument')_id=sys.argv[1]client=BotCommands(host='localhost',port=1883,username='',password='',bot_id=_id, )asyncio.new_event_loop().run_until_complete(run_commands(client))TheBotListener class provides methods for subscribing to notifications,internal events (e.g. market events), logs and heartbeat messages for a specificbot instance.
def__init__(self,host:str='localhost',port:int=1883,username:str='',password:str='',bot_id:str='bot1',namespace:str='hbot',notifications:bool=True,events:bool=True,logs:bool=True,on_notification:Optional[Callable[[NotifyMessage],None]]=None,on_event:Optional[Callable[[EventMessage],None]]=None,on_log:Optional[Callable[[EventMessage],None]]=None,**kwargs
Below is an example of using theBotListener class to listen to bot events andnotifications.
importasynciofromhbotrcimportBotListenerdefon_notification(msg):_text=msg.msgprint(f'[NOTIFICATION] -{_text}')defon_event(msg):print(f'[EVENT] -{event}')if__name__=="__main__":importsysiflen(sys.argv)<2:print('Give instance_id argument')_id=sys.argv[1]client=BotListener(host='localhost',port=1883,username='',password='',bot_id=_id,notifications=True,events=True,logs=True,on_notification=on_notification,on_event=on_event )asyncio.new_event_loop().run_until_complete(client.run_forever())Head to the./examples directory for more examples.