Esempio n. 1
0
    def __init__(self):
        client = Client('****', '****')
        logging.basicConfig(
            format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
            level=logging.INFO)

        self.order_id = 0
        self.has_trade = False
        self.cur_thread = None
        self.cur_thread_started_at = 0
        self.file_last_modified = os.path.getmtime('main.py')
        self.tele = telegram_bot.Telegram(self)
        self.db = database_handler.DatabaseHandler(self.tele, False)
        self.db.create_trading_session()
        self.db.delete_tests()
        # self.db.delete_old_strategies()

        self.db.send_balance_image()

        self.strategies = []
        self.create_primary_strategy()
        self.db.set_strategies(self.strategies)
        self.db.set_balance(1000, strategy='primary')

        # load ai
        self.clf = load('tests/ai.joblib')

        with_strategy_test = False
        if len(sys.argv) > 1:
            with_strategy_test = sys.argv[1] == 'True'

        if not with_strategy_test:
            bm = BinanceSocketManager(client)
            bm.start_symbol_ticker_socket('BTCUSDT', self.test_tick)
            bm.start()
Esempio n. 2
0
async def _start_telegram(account: dict, bot: Bot):
    telegram = telegram_bot.Telegram(token=account['telegram']['token'],
                                     chat_id=account['telegram']['chat_id'],
                                     bot=bot,
                                     loop=asyncio.get_event_loop())
    telegram.log_start()
    return telegram