def Main(): resetOrdersPairs = False session = getSession('sqlite:///' + db_name) exchange = Binance(get_credentials_from_env=True) # Add all symbols on exchange # for symbol in exchange.SYMBOL_DATAS.keys(): # if exchange.SYMBOL_DATAS[symbol]["status"] == "TRADING" \ # and exchange.SYMBOL_DATAS[symbol]["quoteAsset"] == "BTC": # symbols.append(symbol) # First time you run this, uncomment the next line #initialize_database(session, symbols) bot = session.query(Bot).filter_by(name=bot_name).first() # strategy = AlwaysBuyStrategy() strategy = BBRSIStrategy(13, 40, 70, 30) bot_controller = BotController(session, bot, exchange, strategy) sp = yaspin() bot_controller.sp = sp bot_controller.sp_on = True while True: try: bot_controller.executeBot() except KeyboardInterrupt: return bot_controller.sp.start() left_to_sleep = time_to_sleep while left_to_sleep > 0: bot_controller.sp.text = "Waiting for {} more seconds...".format( left_to_sleep) time.sleep(1) left_to_sleep -= 1
def Main(): bot_config = getYamlConfig(bot_name) db_url = None if bot_config.__contains__('db_url'): db_url = bot_config['db_url'] session = getSession(db_url) exchange = CcxtExchange( 'binance', { 'apiKey': getenv('BINANCE_API_KEY'), 'secret': getenv('BINANCE_API_SECRET'), 'timeout': 30000, 'enableRateLimit': True, }) Strategies = getStrategies() bot = session.query(Bot).filter_by(name=bot_name).first() if bot is None: print('No bot found by name: {}. Creating...'.format(bot_name)) InitializeDatabase(session, bot_config) Main() symbols = [] if bot_config.__contains__('symbols') is not None: symbols = bot_config['symbols'] strategy = Strategies[bot_config['strategy']['name']]( **bot_config['strategy']['params']) bot_controller = BotController(session, bot, exchange, strategy) sp = yaspin() bot_controller.sp = sp bot_controller.sp_on = True while True: try: bot_controller.executeBot() except KeyboardInterrupt: return bot_controller.sp.start() left_to_sleep = bot_config['time_to_sleep'] while left_to_sleep > 0: bot_controller.sp.text = "Waiting for {} more seconds...".format( left_to_sleep) time.sleep(1) left_to_sleep -= 1
def Main(): symbols = [] resetOrdersPairs = False session = getSession() exchange = Binance(get_credentials_from_env=True) Strategies = BotInitializer.getStrategies() bot = session.query(Bot).filter_by(name=bot_name).first() if bot is None: print('No bot found by name: ' + bot_name + '. Creating...') if bot_config['symbols'] is None: print('No symbols found in template. Adding all...') for symbol in exchange.SYMBOL_DATAS.keys(): if exchange.SYMBOL_DATAS[symbol]["status"] == "TRADING" \ and exchange.SYMBOL_DATAS[symbol]["quoteAsset"] == "BTC": symbols.append(symbol) InitializeDatabase(session, symbols, bot_name=bot_name) # Restart? Main() bot_config = BotInitializer.getYamlConfig(bot_name) if bot_config['symbols'] is not None: symbols = bot_config['strategy'] strategy = Strategies[bot_config['strategy']['name']](**bot_config['strategy']['params']) bot_controller = BotController(session, bot, exchange, strategy) sp = yaspin() bot_controller.sp = sp bot_controller.sp_on = True while True: try: bot_controller.executeBot() except KeyboardInterrupt: return bot_controller.sp.start() left_to_sleep = time_to_sleep while left_to_sleep > 0: bot_controller.sp.text = "Waiting for {} more seconds...".format(left_to_sleep) time.sleep(1) left_to_sleep -= 1
def Main(): resetOrdersPairs = False session = getSession('sqlite:///pyjuque_test_3.db') exchange = Binance() symbols = [] for symbol in exchange.SYMBOL_DATAS.keys(): if exchange.SYMBOL_DATAS[symbol]["status"] == "TRADING" \ and exchange.SYMBOL_DATAS[symbol]["quoteAsset"] == "BTC": symbols.append(symbol) # First time you run this, uncomment the next line # initialize_database(session, symbols) if resetOrdersPairs: clearOrdersFromDB(session) bot = session.query(Bot).filter_by(name='test_bot_2').first() # input your path to credentials here. # strategy = AlwaysBuyStrategy() strategy = BBRSIStrategy(13, 40, 70, 30) bot_controller = BotController(session, bot, exchange, strategy) sp = yaspin() bot_controller.sp = sp bot_controller.sp_on = True while True: try: bot_controller.executeBot() except KeyboardInterrupt: return bot_controller.sp.start() bot_controller.sp.text = "Waiting for {} seconds...".format( time_to_sleep) time.sleep(time_to_sleep)
def Main(): resetOrdersPairs = False session = getSession('sqlite:///pyjuque_ccxt_binance_live_1.db') exchange = CcxtExchange('binance', { 'apiKey': getenv('BINANCE_API_KEY'), 'secret': getenv('BINANCE_API_SECRET'), # 'password': getenv('OKEX_PASSWORD'), 'timeout': 30000, # 'verbose': True, 'enableRateLimit': True, }) symbols = ['TRX/ETH', 'XRP/ETH'] # First time you run this, uncomment the next line # initialize_database(session, symbols) bot = session.query(Bot).filter_by(name='test_bot_ccxt_tudor').first() strategy = AlwaysBuyStrategy() # BBRSIStrategy(13, 40, 70, 30) bot_controller = BotController(session, bot, exchange, strategy) sp = yaspin() bot_controller.sp = sp bot_controller.sp_on = True while True: try: bot_controller.executeBot() except KeyboardInterrupt: return bot_controller.sp.start() left_to_sleep = time_to_sleep while left_to_sleep > 0: bot_controller.sp.text = "Waiting for {} more seconds...".format(left_to_sleep) time.sleep(1) left_to_sleep -= 1