‘’’
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, tld=‘us’)
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)
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"
}
side = data['strategy']['order_action'].upper()
quantity = data['strategy']['order_contracts']
order_response = order(side, quantity, "BTCUSDT")
if order_response:
return {
"code": "success",
"message": "order executed"
}
else:
print("order failed")
return {
"code": "error",
"message": "order failed"
}
…
now im taking this code form "youtuber parttimelarry", this code is basically based on trading view
s strategy webhook in to a trade. i wanna convert this into futures trade.
1 how can i add leverage setting in here?
2 the trading views webhook is order Short in to negative quantities.es(-0.01)is this working as a SHORT potsition?,if it won
t how can i do that?
3 as i said in 2 tradingviews json is ordered base on BTC currency not the USDT isn
t matter to working?, if this could be problem, how can i solve this?