CCXT框架如何隐含所有交易所的API方法【以okex为例】 秒速五厘米 2021-08-14 00:17 803阅读 0赞 参考中文文档:[http://cw.hubwiz.com/card/c/ccxt-dev-manual/1/4/2/][http_cw.hubwiz.com_card_c_ccxt-dev-manual_1_4_2] 参考官方文档:[https://ccxt.readthedocs.io/en/latest/manual.html\#implicit-api-methods][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)) ![watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MzM0MzE0NA_size_16_color_FFFFFF_t_70][] ![watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MzM0MzE0NA_size_16_color_FFFFFF_t_70 1][] ![watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MzM0MzE0NA_size_16_color_FFFFFF_t_70 2][] [http_cw.hubwiz.com_card_c_ccxt-dev-manual_1_4_2]: http://cw.hubwiz.com/card/c/ccxt-dev-manual/1/4/2/ [https_ccxt.readthedocs.io_en_latest_manual.html_implicit-api-methods]: https://ccxt.readthedocs.io/en/latest/manual.html#implicit-api-methods [watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MzM0MzE0NA_size_16_color_FFFFFF_t_70]: /images/20210813/101f1c4ed08442888c090c029b9aa575.png [watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MzM0MzE0NA_size_16_color_FFFFFF_t_70 1]: /images/20210813/119373d36e0a454c85df6df8c50ec8bd.png [watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MzM0MzE0NA_size_16_color_FFFFFF_t_70 2]: /images/20210813/8faf54d3336a453faf6760c6c3dbbe5d.png
还没有评论,来说两句吧...