Exemplo n.º 1
0
def getURL():
    data = json.loads(request.get_data(as_text=True))
    global counter
    counter = counter + 1
    if counter == 1:
        trader.main(data['URL'])
    else:
        pass
    return str(counter)
Exemplo n.º 2
0
    def __init__(self):
        """Start the bot."""
        self.opened_trades,self.closed_trades=trader.main()
        # Create the Updater and pass it your bot's token.
        # Make sure to set use_context=True to use the new context based callbacks
        # Post version 12 this will no longer be necessary
        updater = Updater("TOKEN", use_context=True)

        # Get the dispatcher to register handlers
        dp = updater.dispatcher

        # Custom commands
        dp.add_handler(CommandHandler("start", self.start))
        dp.add_handler(CommandHandler("help", self.help))
        dp.add_handler(CommandHandler("open", self.opened))
        dp.add_handler(CommandHandler("closed", self.closed))
        dp.add_handler(CommandHandler("analyze", self.analyze))

        # on noncommand i.e message - echo the message on Telegram
        dp.add_handler(MessageHandler(Filters.text, self.not_found))

        # log all errors
        dp.add_error_handler(self.error)

        # Start the Bot
        updater.start_polling()
    
        # Run the bot until you press Ctrl-C or the process receives SIGINT,
        # SIGTERM or SIGABRT. This should be used most of the time, since
        # start_polling() is non-blocking and will stop the bot gracefully.
        updater.idle()
Exemplo n.º 3
0
def loop():
    trader_running(True)
    while True:
        try:
            if stop_trader:
                break
            lbl_next_update.set_text('updating...')
            trader.main()
            sleep()

        except:
            exc_type, exc_value, exc_traceback = sys.exc_info()
            log.log_error(exc_type, exc_value, exc_traceback)
            lbl_next_update.set_text('error!')
            time.sleep(10)

    print('Trader Stopped')
    lbl_next_update.set_text('-')
    trader_running(False)
Exemplo n.º 4
0
 def analyze(self, update, context):
     update.message.reply_text("Analyzing...")
     self.opened_trades,self.closed_trades=trader.main()
     update.message.reply_text("Finished")
Exemplo n.º 5
0
def start():
    trader.main(True)
    return str('Started')