From 29b920f2f0eab97bb59d816b0e26e9c3afdb2937 Mon Sep 17 00:00:00 2001 From: benjyz Date: Fri, 11 Jan 2019 19:33:22 +0700 Subject: [PATCH] make mongo optional. set flag --- archon/broker.py | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/archon/broker.py b/archon/broker.py index 2416a62..2cbc7b8 100644 --- a/archon/broker.py +++ b/archon/broker.py @@ -25,7 +25,6 @@ def __init__(self,setAuto=True): logger.start("log/broker.log", rotation="500 MB") logger.debug("init broker") - self.afacade = facade.Facade() #in memory data @@ -45,13 +44,11 @@ def __init__(self,setAuto=True): try: mongo_conf = all_conf["MONGO"] - #mongoHost = mongo_conf['host'] - #dbName = mongo_conf['db'] - #url = mongo_conf["url"] - uri = mongo_conf["uri"] - #self.set_mongo(url, dbName) + uri = mongo_conf["uri"] self.set_mongo(uri) + self.using_mongo = True except: + self.using_mongo = False logger.error("could not set mongo") @@ -62,13 +59,7 @@ def __init__(self,setAuto=True): logging.getLogger("requests").setLevel(logging.WARNING) - def set_mongo(self, uri): - """ - self.mongo_url = url - self.mongoclient = MongoClient(self.mongo_url) - logger.debug("db %s"%dbName) - self.db = self.mongoclient[dbName] - """ + def set_mongo(self, uri): logger.debug("using mongo " + str(uri)) mongoclient = MongoClient(uri) self.db = mongoclient.get_default_database() @@ -138,8 +129,6 @@ def margin_balance(self, e): logger.info("margin balance %s"%mbal) return mbal - - # --- broker data --- @@ -306,7 +295,6 @@ def fetch_global_markets(self,denom=None): allmarkets += m return allmarkets - def global_orderbook(self, market): #self.db.orderbooks.drop() logger.info("global orderbook for %s"%market) @@ -526,11 +514,9 @@ def sync_book_work(self, market, exchange): self.sync_orderbook(market, exchange) time.sleep(10) - def sync_book_thread(self, market, exchange): start_new_thread(self.sync_book_work(market, exchange)) - def transaction_queue(self,exchange): now = datetime.datetime.utcnow() #delta = now - self.starttime