How can I place a market order in ccxt for binance futures? Trading on binance futures with ccxt is already implemented
https://github.com/ccxt/ccxt/pull/5907
In this post they suggest to use this line of code:
let binance_futures = new ccxt.binance({ options: { defaultMarket: 'futures' } })
The above line was written in JavaScript. How would the equivalent line in python look like? Like this I get an error:
binance_futures = ccxt.binance({ 'option': { defaultMarket: 'futures' } })
NameError: name 'defaultMarket' is not defined
The correct answer is that 'defaultType' (instead of defaultMarket) must be in quotes, but also the value must be 'future' (not 'futures')
import ccxt
print('CCXT version:', ccxt.__version__) # requires CCXT version > 1.20.31
exchange = ccxt.binance({
'apiKey': 'YOUR_API_KEY',
'secret': 'YOUR_API_SECRET',
'enableRateLimit': True,
'options': {
'defaultType': 'future', # ←-------------- quotes and 'future'
},
})
exchange.load_markets()
# exchange.verbose = True # uncomment this line if it doesn't work
# your code here...
Put quotes around defaultMarket:
binance_futures = ccxt.binance({ 'option': { 'defaultMarket': 'futures' } })
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With