Git Product home page Git Product logo

okex-hc's Introduction

如何使用?

python版本:3.6+

WebSocketAPI:建议websockets库版本为6.0

第一步:下载SDK,安装相关所需库

1.1 下载python SDK

  • 将SDK目录Clone或者Download到本地,选择使用okex-python-sdk-api即可

1.2 安装所需库

pip install requests
pip install websockets==6.0

第二步:配置个人信息

2.1 如果还未有API,可点击前往官网进行申请

2.2 将各项信息在example.py(RestAPI)websocket_example.py(WebSocketAPI)中填写

api_key = ""
secret_key = ""
passphrase = ""

第三步:调用接口

  • RestAPI

    • 运行example.py

    • 解开相应方法的注释传参调用各接口即可

  • WebSocketAPI

    • 运行websocket_example.py

    • 根据个人/公共频道选择对应启动方法,解开相应频道的注释即可

    # 公共数据 不需要登录(行情,K线,交易数据,资金费率,限价范围,深度数据,标记价格等频道)
    loop.run_until_complete(subscribe_without_login(url, channels))
    
    # 个人数据 需要登录(用户账户,用户交易,用户持仓等频道)
    loop.run_until_complete(subscribe(url, api_key, passphrase, secret_key, channels))

附言:

  • 如果对API尚不了解,建议参考OKEx官方API文档

  • 若使用WebSocketAPI遇到问题建议参考相关链接

    • asynciowebsockets文档/github

        https://docs.python.org/3/library/asyncio-dev.html
        https://websockets.readthedocs.io/en/stable/intro.html
        https://github.com/aaugustin/websockets
      
    • 关于code=1006

        https://github.com/Rapptz/discord.py/issues/1996
        https://github.com/aaugustin/websockets/issues/587
      

okex-hc's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.