返回列表 发布新帖

mini qmt ,#from xtquant import xtdata 就出错,其他没问题

3762 5
发表于 2024-11-24 17:58:52 | 显示全部楼层 阅读模式

请教

使用 mini QMT 一个很奇怪的问题

代码中一旦加:from xtquant import xtdata

就会报错

File ~.conda\envs\qmt_mini\lib\xtquant\xtdata.py:14

from .IPythonApiClient import IPythonApiClient as RPCClient

ImportError:DLL load failed while importing IPythonApiClient: 找不到指定的模块。

如果不用这个模块

链接都可以成功

我的环境是 anaconda 下 3.8.20 64位的,我检查过了

mini qmt 的版本,网站上最新的 xtquant_241014.rar 试了不行

国金的客户端,配套的环境

C:\Users\tr-minipc.conda\envs\qmt_mini\lib\site-packages

我去找了,都试了不行

评论5

迅投kiki
发表于 2024-11-25 16:14:16 | 显示全部楼层
已微信沟通:

把旧环境的整个xtquant删一下(旧版包有个ipy开头的文件,新版包没有,覆盖不会覆盖这个旧的)

再重新pip install xtquant
*******2200楼主
发表于 2024-11-24 18:08:39 | 显示全部楼层
  1. import random

  2. from xtquant.xttype import StockAccount
  3. from xtquant.xttrader import XtQuantTrader
  4. from xtquant import xtconstant

  5. #打开下面这段行情代码,就失败
  6. #from xtquant import xtdata
  7. #xtdata.download_history_data2(stock_list=['600519.SH'], period='1d')
  8. #res = xtdata.get_market_data(stock_list=['600519.SH'], period='1d')
  9. #print(res)

  10. # miniQMT安装路径
  11. mini_qmt_path = r'D:\\国金QMT交易端模拟\\userdata_mini'
  12. # QMT账号
  13. account = 'xxxxxx'

  14. # 创建session_id
  15. session_id = int(random.randint(100000, 999999))
  16. # 创建交易对象
  17. xt_trader = XtQuantTrader(mini_qmt_path, session_id)
  18. # 启动交易对象
  19. xt_trader.start()
  20. # 连接客户端
  21. connect_result = xt_trader.connect()

  22. print(connect_result)

  23. if connect_result == 0:
  24.     print('连接成功')
复制代码
*******2200楼主
发表于 2024-11-24 20:42:53 | 显示全部楼层
又经过几番折腾,发现情况如下
貌似不是xtquant版本的问题
因为
同样的官网的最后这个版本,我在我之前编程的一个虚拟环境下,运行正常

但是,在新的虚拟环境下,到底缺少了什么(库),这个就不太好查找了
首先我可以肯定的,PANDAS安装了。
还需要什么呢?
*******2200楼主
发表于 2024-11-25 09:13:37 | 显示全部楼层
在AI的帮助下,写了一个批处理文件,对比 大QMT的PYTHON环境和当前出问题的环境安装的包的差异,批处理文件如下

  1. @echo off
  2. setlocal enabledelayedexpansion

  3. :: 设置两个目录的路径
  4. set "dir1=D:\QuantitativeTrading\qmt\Lib\site-packages"
  5. set "dir2=C:\Users\tr-minipc\.conda\envs\qmt_mini\lib\site-packages"
  6. set "output=diff.txt"

  7. :: 创建临时文件来存储目录内容
  8. set "temp1=dir1_subdirs.txt"
  9. set "temp2=dir2_subdirs.txt"

  10. :: 清空临时文件
  11. if exist "%temp1%" del "%temp1%"
  12. if exist "%temp2%" del "%temp2%"

  13. :: 使用dir命令列出两个目录的第一级子目录,**排除以-info结尾的目录**,并只保存目录名
  14. for /d %%d in ("%dir1%\*") do (
  15.     set "dirName=%%~nxd"
  16.     if "!dirName:-info=!" == "!dirName!" (
  17.         if not "!dirName:~0,1!" == "_" (
  18.                 echo !dirName! >> "%temp1%"
  19.         )
  20.     )
  21. )

  22. for /d %%d in ("%dir2%\*") do (
  23.     set "dirName=%%~nxd"
  24.     if "!dirName:-info=!" == "!dirName!" (
  25.         if not "!dirName:~0,1!" == "_" (
  26.                 echo !dirName! >> "%temp2%"
  27.         )
  28.     )
  29. )

  30. :: 显示临时文件的内容
  31. echo Directory names in %temp1%:
  32. type "%temp1%"

  33. echo Directory names in %temp2%:
  34. type "%temp2%"


  35. :: 检查 "diff.txt" 文件是否存在,如果存在则删除
  36. if exist "diff.txt" (
  37.     del "diff.txt"
  38. )

  39. if exist "%output%" del "%output%"

  40. for /f "delims=" %%a in ('type "%temp1%"') do (
  41.     set "line=%%a"
  42.     findstr /R /C:"^!line!$" "%temp2%" >nul
  43.     if errorlevel 1 echo !line!>>"%output%"
  44. )

  45. echo Done. The differences have been written to "%output%".

  46. :: 清理临时文件
  47. if exist "%temp1%" del "%temp1%"
  48. if exist "%temp2%" del "%temp2%"

  49. endlocal
复制代码

生成的diff文件如下

  1. absl
  2. aenum
  3. astor
  4. attr
  5. backcall
  6. bin
  7. bleach
  8. bson
  9. caffe2
  10. certifi
  11. chardet
  12. colorama
  13. cvxopt
  14. cvxpy
  15. dateutil
  16. dbf
  17. dbfpy
  18. defusedxml
  19. dill
  20. fastcache
  21. gast
  22. google
  23. gridfs
  24. grpc
  25. html5lib
  26. idna
  27. ipykernel
  28. IPython
  29. ipython_genutils
  30. jedi
  31. jinja2
  32. joblib
  33. jsonschema
  34. jupyter_client
  35. jupyter_core
  36. markdown
  37. markupsafe
  38. matplotlib
  39. mpl_toolkits
  40. multiprocess
  41. nbconvert
  42. nbformat
  43. notebook
  44. numexpr
  45. numpy
  46. pandas
  47. parso
  48. patsy
  49. PIL
  50. pip
  51. pkg_resources
  52. prometheus_client
  53. prompt_toolkit
  54. pygments
  55. pymongo
  56. pyreadline
  57. pyrsistent
  58. pytz
  59. qmt_api
  60. redis
  61. requests
  62. scipy
  63. scs
  64. send2trash
  65. setuptools
  66. share
  67. simplejson
  68. sklearn
  69. statsmodels
  70. tables
  71. talib
  72. tensorboard
  73. tensorflow
  74. terminado
  75. testpath
  76. tlz
  77. toolz
  78. torch
  79. tornado
  80. traitlets
  81. urllib3
  82. wcwidth
  83. webencodings
  84. werkzeug
  85. wheel
  86. winpty
  87. xlrd
  88. xlsxwriter
  89. xlwt
  90. xtdbf
  91. xtquant
  92. zmq
复制代码


这个差别有点大啊,到底要装哪些库呢?
*******2200楼主
发表于 2024-11-25 13:51:13 | 显示全部楼层
补充一下,批处理文件(及结果),只列出来了左边有但没在右边的,即大QMT(运行正常的)中有的,在出问题的环境中没有的库

回复

您需要登录后才可以回帖 登录 | 立即注册

客服专线

400-080-8112

用思考的速度交易,用真诚的态度合作,我们是认真的!
  • 关注公众号
  • 添加微信客服
Copyright © 2001-2025 迅投QMT社区 版权所有 All Rights Reserved. 京ICP备2025122616号-3
关灯 快速发帖
扫一扫添加微信客服
QQ客服返回顶部
快速回复 返回顶部 返回列表