'an exception occured - APIError(code=-2015): Invalid API-key, IP, or permissions for action
I'm using binance api trying to automate a tradingview strategy, I'm using DOGEUSDT to test out since it is the same ticker Part time larry uses on youtube (I am following his videos). However I keep getting this error and have no idea what to to. I've already deleted the tld='us', but don't know what else I can do, the api permissions to trade have already been granted. Here is the code:
import json, config
from flask import Flask, request, jsonify, render_template
from binance.client import Client
from binance.enums import *
app = Flask(__name__)
client = Client(config.API_KEY, config.API_SECRET)
def order(side, quantity, symbol,order_type=ORDER_TYPE_MARKET):
try:
print(f"sending order {order_type} - {side} {quantity} {symbol}")
order = client.create_order(symbol=symbol, side=side, type=order_type, quantity=quantity)
print(order)
except Exception as e:
print("an exception occured - {}".format(e))
return False
return order
@app.route("/")
def welcome():
return render_template('index.html')
@app.route("/webhook", methods=['POST'])
def webhook():
#print(request.data)
data = json.loads(request.data)
if data['passphrase'] != config.WEBHOOK_PASSPHRASE:
return {
"code": "error",
"message": "Nice try, invalid passphrase"
}
print(data['ticker'])
print(data['bar'])
side = data['strategy']['order_action'].upper()
quantity = data['strategy']['order_contracts']
order_response = order(side, quantity, "DOGEUSDT")
if order_response:
return {
"code": "success",
"message": "order executed"
}
else:
print("order failed")
return{
"code": "error",
"message": "order failed"
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
