Hello, I am trying to return success to a POST from TradingView. If they don't get it, they resend up to 3 times! So, I think I'm returning a 200, but not sure. Please tell me:
@app.route('/TV-BIN', methods=['POST'])
def webhook_TV_BIN():
message = now + " TV-BIN order received"
db.session.add(Comment(content=message))
db.session.commit()
if request.method == 'POST':
request_data = request.get_json()
if request_data:
qty = 0
price = 0
side = 'sell'
symbol = 'BNBUSDT'
if 'side' in request_data:
side = request_data['side']
if 'qty' in request_data:
qty = request_data['qty']
if 'symbol' in request_data:
symbol = request_data['symbol']
if 'digits' in request_data:
digits = request_data['digits']
if 'price' in request_data:
price = request_data['price']
price = round(float(price),digits)
api_key=BIN_config.API
api_secret=BIN_config.SECRET
client = Client(api_key, api_secret)
try:
response = type(client.create_order(
symbol=symbol,
side=side,
type='LIMIT',
timeInForce='GTC',
quantity=qty,
price=price))
if type(response) == str:
result = response
else:
result = response.get('status')
message = now + ' : Binance Order ' + result + '- ' + side + ' ' + str(qty) + ' ' + symbol
except binance.exceptions.BinanceAPIException as err:
message = now + " BIN Msg: " + str(err)
except:
message = now + " BIN order: " + str(response)
db.session.add(Comment(content=message))
db.session.commit()
return Response(status=200)
return Response(status=200)
else:
return Response(status=200)