如何在python中使用ccxt进行Kucoin期货订单?



以下代码使用ccxt工作币安期货。比特币期货的正确代码/配置是什么?

import ccxt
import pandas as pd
binance = ccxt.binance()
binance.options = {'defaultType': 'delivery', 'adjustForTimeDifference': True}
securities = pd.DataFrame(binance.load_markets()).transpose()
print(securities)
=== OUTPUT ===
percentage feeSide tierBased   taker   maker  ... inverse         expiry            expiryDatetime active contractSize
BTC/USD              True     get     False  0.0005  0.0001  ...    True           None                      None   True          100
BTCUSD_210924        True     get     False  0.0005  0.0001  ...    True  1632470400000  2021-09-24T08:00:00.000Z   True          100
...

kucoinfutures需要你在futures.kucin.com上创建一个apiKey和secret,这与你在kucin.com上创建的kucoin的apiKey和secret是分开的。因此,kucinfutures是与kucoin

分开的一个类。

与您的问题中的代码等价的kucinfutures代码是

import ccxt
import pandas as pd
import sys
from pprint import pprint
# import logging
# logging.basicConfig(level=logging.DEBUG)
print('python', sys.version)
print('CCXT Version:', ccxt.__version__)
exchange = ccxt.kucoinfutures({
'adjustForTimeDifference': True,
"apiKey": '...',
"secret": '...',
'password': 'This is you 6-7 digit trading password',
})
# exchange.verbose = True
securities = pd.DataFrame(exchange.load_markets()).transpose()
pprint(securities)

python 3.10.1 (main, Dec  6 2021, 22:25:40) [Clang 13.0.0 (clang-1300.0.29.3)]
CCXT Version: 1.67.1
percentage  ...                                               info
BTC/USDT:USDT            True  ...  {'symbol': 'XBTUSDTM', 'rootSymbol': 'USDT', '...
BTC/USD:BTC              True  ...  {'symbol': 'XBTUSDM', 'rootSymbol': 'XBT', 'ty...
ETH/USDT:USDT            True  ...  {'symbol': 'ETHUSDTM', 'rootSymbol': 'USDT', '...
BCH/USDT:USDT            True  ...  {'symbol': 'BCHUSDTM', 'rootSymbol': 'USDT', '...
BSV/USDT:USDT            True  ...  {'symbol': 'BSVUSDTM', 'rootSymbol': 'USDT', '...
...                       ...  ...                                                ...
OMG/USDT:USDT            True  ...  {'symbol': 'OMGUSDTM', 'rootSymbol': 'USDT', '...
LINA/USDT:USDT           True  ...  {'symbol': 'LINAUSDTM', 'rootSymbol': 'USDT', ...
IMX/USDT:USDT            True  ...  {'symbol': 'IMXUSDTM', 'rootSymbol': 'USDT', '...
NFT/USDT:USDT            True  ...  {'symbol': 'NFTUSDTM', 'rootSymbol': 'USDT', '...
BTC/USD:BTC-220325       True  ...  {'symbol': 'XBTMH22', 'rootSymbol': 'XBT', 'ty...
[90 rows x 29 columns]

如果你想在kucoinfutures上创建一个订单,你可以执行

order_response = exchange.createOrder('ADA/USDT:USDT', 'limit', 'buy', 1, 1, {'leverage': 10})
pprint(order_response)

{'amount': None,
'average': None,
'clientOrderId': None,
'cost': None,
'datetime': None,
'fee': None,
'filled': None,
'id': '39292jdf8392039kldlsjas393020',
'info': {'code': '200000', 'data': {'orderId': '39292jdf8392039kldlsjas393020'}},
'lastTradeTimestamp': None,
'postOnly': None,
'price': None,
'remaining': None,
'side': None,
'status': None,
'stopPrice': None,
'symbol': None,
'timeInForce': None,
'timestamp': None,
'trades': None,
'type': None}

相关内容

  • 没有找到相关文章

最新更新