vnpy2.0安装后报错ModuleNotFoundError: No module named 'vnpy.api.ctp.vnctpmd'

1,git clone vnpy的代码

2,安装bash install.sh

3,新建run.py

copy如下内容

from vnpy.event import EventEngine
from vnpy.trader.engine import MainEngine
from vnpy.trader.ui import MainWindow, create_qapp
from vnpy.gateway.ctp import CtpGateway
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(CtpGateway)
    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()

python run.py

报错:ModuleNotFoundError: No module named 'vnpy.api.ctp.vnctpmd'

原因:ctp这一坨都是c相关代码,所以肯定是缺少了c相关代码导致,ctp目录下看到了dll文件,没看到so文件

所以应该是作者忘了放so文件了

setup.py里面有编译脚本

python setup.py build

然后项目的vnpy/bulid/lib/vnpy/api/ctp/vnctpmd.so和vnctptd.so拷贝到vnpy/vnpy/api/ctp/下面就行了

再次执行python run.py有界面了

你可能感兴趣的:(量化_量化投资)