i wanted change binance api to spot trading in to futures trading

  binance, binance-chain, python, trading, webhooks

i wanted change this spot trading code into futures trading

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):
    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

def welcome():
    return render_template('index.html')

@app.route('/webhook', methods=['POST'])
def webhook():
    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"
    print("order failed")

    return {
        "code": "error",
        "message": "order failed"

basically, this script is working as get a data from tradingview webhook as json and convert in to binance order.

1 i want to change this spot trading into futures trading what should i change?ex(order_response to futures_creste_order)

2 i want keep this webhook based trading

3 the function what i want add is just leverage setup

conclusion:i wanted change this spot trading to futures trading what i should convert? and additnal function i wants to add is leverage set up. if you helps you`ll become my saver,really thanks

Source: Python Questions