参考中文文档:http://cw.hubwiz.com/card/c/ccxt-dev-manual/1/4/2/
参考官方文档:https://ccxt.readthedocs.io/en/latest/manual.html#implicit-api-methods
本人实际调用隐式api抓取okex3的期货合约行情的方法【带参数的】:
import ccxt
from app.exchanges.config.exchange_api_config import ExchangeAPIConfig
from app.exchanges.utils.utils_datatime import UtilsDatatime
from app.exchanges.common.pandas_base import PandasBase
exchange = ccxt.okex3({
"apiKey": ExchangeAPIConfig.okex_api_v3["api_key"],
"secret": ExchangeAPIConfig.okex_api_v3["seceret_key"],
"password": ExchangeAPIConfig.okex_api_v3["passphrase"],
'timeout': 30000,
'enableRateLimit': True,
})
# 输出exchange所有方法和属性
# print(dir(exchange))
"""
对于有参数的隐式方法如何传参?
GET /api/futures/v3/instruments/<instrument_id>/candles
request(path, api='public', method='GET', params={}, headers=None, body=None) method of ccxt.okex3.okex3 instance
Exchange.request is the entry point for all generated methods
"""
# 输出这个方法的帮助
# print(help(exchange.futures_get_instruments_instrument_id_candles))
data = exchange.futures_get_instruments_instrument_id_candles(params={
"instrument_id": "BTC-USDT-191227",
"granularity": 60 * 60
})
print(PandasBase.generate_datatime_index_iso8601_pandas(data))