Skip to content

Commit

Permalink
make mongo optional. set flag
Browse files Browse the repository at this point in the history
  • Loading branch information
benjyz committed Jan 11, 2019
1 parent fa70a50 commit 29b920f
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions archon/broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")


Expand All @@ -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()
Expand Down Expand Up @@ -138,8 +129,6 @@ def margin_balance(self, e):
logger.info("margin balance %s"%mbal)
return mbal




# --- broker data ---

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 29b920f

Please sign in to comment.