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

Viewed 50
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)

In this way, I would like to order 10$, but it is inconvenient because the amount is based on the price of one coin. Is there a way to do something like amount=10$ instead of amount = 1 ?

1 Answers

The closest you could do would be to multiply the contractSize by the price and the amount you want to spend

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,
)
Related