convert spot trading code in to futers ps:plz help me

‘’’
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 views 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 wont how can i do that?

3 as i said in 2 tradingviews json is ordered base on BTC currency not the USDT isnt matter to working?, if this could be problem, how can i solve this?

Hi. I’m. not so sure about its webhook mechanism but here are some ideas regarding the APIs.

  1. To set up the leverage, you can send a request POST /fapi/v1/leverage ( https://binance-docs.github.io/apidocs/futures/en/#change-initial-leverage-trade )
  2. You can create new orders with positionSide = SHORT and the positive quantity using POST /fapi/v1/order ( https://binance-docs.github.io/apidocs/futures/en/#new-order-trade ). When you query the position information, it will show as a negative value.
  3. The positions are measured in BTC. You have to convert it from your end to USDT or any other coins you preferred. One approach is to get the last price (close price) from GET /fapi/v1/klines ( https://binance-docs.github.io/apidocs/futures/en/#kline-candlestick-data ) and then do the calculation locally. For example, to get the positions measured un USDT, you can query price of BTCUSDT and then multiply it with the number of BTC.