def run_subscribe(self): while not self.stopped: try: pool = Pool( PoolClient, dict(name=self.name, server_address=self.master_address)) while True: with pool.connection() as client: client.subscribe(self.name, self.bound_address) gevent.sleep(1.0) except Exception as e: self.logger.exception(str(e)) gevent.sleep(1.0)
def run_put_accounts(self): while not self.stopped: try: pool = Pool(PoolClient, dict(name=self.name, server_address=self.master_address)) while True: accounts = [] for service in ['click', 'nano', 'yjfx']: accounts.append(new_account(service, equity=100)) with pool.connection() as client: client.put_accounts(accounts) gevent.sleep(1.0) except Exception as e: self.logger.exception(str(e)) gevent.sleep(1.0)
def run_put_prices(self): while not self.stopped: try: pool = Pool(PoolClient, dict(name=self.name, server_address=self.master_address)) while True: prices = [] for service in ['click', 'nano', 'yjfx']: for instrument in ['USD/JPY', 'AUD/JPY']: prices.append(dict(service=service, instrument=instrument, bid=100.0, ask=100.0, time=None)) with pool.connection() as client: client.put_prices(prices) gevent.sleep(1.0) except Exception as e: self.logger.exception(str(e)) gevent.sleep(1.0)