vnpy-connect-binance

779 words, 3 mins

使用vnpy连接binance

新建run.py

from vnpy.event import EventEngine
from vnpy.trader.engine import MainEngine
from vnpy.trader.ui import MainWindow, create_qapp
from vnpy.gateway.binance import BinanceGateway
from vnpy.app.cta_strategy import CtaStrategyApp
from vnpy.app.cta_backtester import CtaBacktesterApp

def main():
    """Start VN Trader"""
    qapp = create_qapp()

    event_engine = EventEngine()
    main_engine = MainEngine(event_engine)

    main_engine.add_gateway(BinanceGateway)
    main_engine.add_app(CtaStrategyApp)
    main_engine.add_app(CtaBacktesterApp)

    main_window = MainWindow(main_engine, event_engine)
    main_window.showMaximized()

    qapp.exec()

if __name__ == "__main__":
    main()

点击连接binance,填写api key和secret

没有注册的可以使用此链接 https://www.binance.com/en/register?ref=UC0VE7Q5,交易时,会得到10%的返佣比例

代码栏中填写相应的交易对,即可展现对应的orderbook以及最新的行情数据

image-20201224162433033

下单

参考上图的例子,我下了个600卖出ETH的限价单