CCXT框架如何隐含所有交易所的API方法【以okex为例】

参考中文文档: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))

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值