def __init__(self,setAuto=True): setup_logger(logger_name="broker", log_file='broker.log') self.logger = logging.getLogger("broker") self.afacade = facade.Facade() #in memory data self.balances = None self.openorders = list() self.submitted_orders = list() self.active_exchanges = list() self.selected_exchange = None if setAuto: self.set_keys_exchange_file() try: all_conf = parse_toml("conf.toml") except: self.logger.error("no conf.toml file") try: mongo_conf = all_conf["MONGO"] uri = mongo_conf["uri"] self.set_mongo(uri) self.using_mongo = True except: self.using_mongo = False self.logger.error("could not set mongo") self.starttime = datetime.datetime.utcnow()
def __init__(self, abroker, exchange): threading.Thread.__init__(self) setup_logger(logger_name=__name__, log_file='broker.log') self.logger = logging.getLogger(__name__) #config = agent_config()["AGENT"] #m = config["market"] market = "LTC_BTC" self.agent_id = "agent" #config["agentid"] self.threadID = "thread-" + self.agent_id self.afacade = facade.Facade() self.abroker = abroker nom,denom = market.split('_') #TODO config self.e = exchange #self.market = models.get_market(nom,denom,self.e) self.market = market self.rho = 0.1 #TODO broker already keeps track self.openorders = list() self.positions = list() self.round_precision = 8 #pip paramter for ordering self.pip = 0.0000001 self.logger.info("agent inited")
import archon.exchange.exchanges as exc import archon.model.models as models import archon.facade as facade import archon.broker as broker import archon.markets as m afacade = facade.Facade() broker.setClientsFromFile(afacade) a = broker.Broker() ae = [exc.KUCOIN,exc.BITTREX] a.set_active_exchanges(ae) market = models.market_from("LTC","BTC") print ("sync ",market) a.sync_orderbook_all(market) db = a.get_db() x = db.orderbooks.find({'market':market}) for z in x: print (z)
def run_balance_report(): log.info("run report") #logpath = '/tmp/log' afacade = facade.Facade() broker.setClientsFromFile(afacade) balance_report(afacade)