def clock(start): """ Prints out the elapsed time when called from start. """ send_order() print("elapsed: {:0.3f} seconds", format(time.time() - start))
def webhook(): """Combine all functions in actions.py, and run flask server""" if request.method == 'POST': print('*' * 60) # Parse the string data from tradingview into a python dict data = parse_webhook(request.get_data(as_text=True))[0] tail = parse_webhook(request.get_data(as_text=True))[1] message = tail if (data['type'] != "Skip") and (get_token() == data['key']): # Check that the key is correct print(' [Alert Received] ') print(tail) for account, account_info in config.Accounts.items(): if account_info['Name'] in data['BotName']: exchange = ccxt.ftx({ 'apiKey': account_info['exchangeapi'], 'secret': account_info['exchangesecret'], 'enableRateLimit': True, }) if account_info['Subaccount'] == 'Yes': exchange.headers = { 'FTX-SUBACCOUNT': account_info['SubName'], } send_order(data, tail, exchange, account_info['Name'], account_info['Track']) if account_info['UseTelegram'] == 'Yes': send_to_telegram(tail, data) if account_info['UseTwitter'] == 'Yes': post_tweet(message) else: pass return '', 200 if data['type'] == "Skip": print(' [ALERT ONLY - NO TRADE] ') print(tail) for account, account_info in config.Accounts.items(): if account_info['Name'] in data['BotName']: if account_info['UseTelegram'] == 'Yes': send_to_telegram(tail, data) if account_info['UseTwitter'] == 'Yes': post_tweet(message) print('*' * 60, '/n') return '', 200 else: abort(400)
def webhook(): if request.method == 'POST': # Parse the string data from tradingview into a python dict datas = parse_webhook(request.get_data(as_text=True)) print(datas) # Check that the key is correct if get_token() == datas['key']: print(' [Alert Received] ') print('POST Received/Updated Data:', datas) send_order(datas) return '', 200 else: logger.error("Incoming Signal From Unauthorized User.") abort(403) else: abort(400)