金额可以在 Binance Api Future Trade 上以 USDT 计价吗?

Can the amount be in USDT on Binanace Api Future Trade?

import ccxt
import pprint

with open("D:/api.txt") as f:
    lines = f.readlines()
    api_key = lines[0].strip()
    secret  = lines[1].strip()

binance = ccxt.binance({
    'apiKey' : api_key,
    'secret' :  secret,
    'enableRateLimit': True,
    'options': {
        'defaultType': 'future'
    }
    })
markets = binance.fetch_tickers()
print(markets.keys())

order = binance.create_limit_buy_order(
    symbol = 'ENSUSDT',
    amount = 1,
    price = 19.5,
    )

pprint.pprint(order)

这样我想订10$,但是金额是按一枚硬币的价格计算的,很不方便。有没有办法做类似 amount=10$ 而不是 amount = 1 的事情?

您最接近的做法是将 contractSize 乘以 priceamount 您想要花费的金额

usdt_amount = 10
market['contractSize'] * price * usdt_amount

with open("D:/api.txt") as f:
    lines = f.readlines()
    api_key = lines[0].strip()
    secret  = lines[1].strip()

binance = ccxt.binance({
    'apiKey' : api_key,
    'secret' :  secret,
    'enableRateLimit': True,
    'options': {
        'defaultType': 'future'
    }
})
tickers = binance.fetch_tickers()

price = 19.5
symbol = 'ENS/USDT'
market = binance.market(symbol)
usdt_amount = 10

order = binance.create_limit_buy_order(
    symbol = symbol,
    amount = market['contractSize'] * price * usdt_amount,
    price = price,
)