Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openquant2014引用QuantBox.APIProvider和XAPI3的CSharp版本新手指南 #5

Open
zhuce2022 opened this issue Sep 30, 2021 · 2 comments

Comments

@zhuce2022
Copy link

zhuce2022 commented Sep 30, 2021

经过请教伍侃老师,终于弄清楚怎么引用新版XAPI3和APIProvider,写在这里作为记录,也指导一下新手吧。

1、在sfit下载最新版ctp_api
V6.6.1_P1_20210407_tradeapi
http://www.sfit.com.cn/DocumentDown/api_3/5_2_2/v6.6.1_P1_tradeapi.zip

2、压缩包内的win64目录下各种c++源文件覆盖XAPI3/include/CTP_SE/目录下的同名文件。
3、压缩包内的dl和lib复制到XAPI3/include/CTP_SE/win64目录
4、设置Release64模式编译,把编译后的CTP_SE_Quote_x64.dll和CTP_SE_Trade_x64.dll以及压缩包内的thostmduserapi_se.dll、thosttraderapi_se.dll放到D:\XAPI\CTP_SE(该目录可以自定义)
5、用X64模式编译XAPI_CSharp、QuantBox.APIProvider、QuantBox.Extension,把三个编译后的dll放到openquant2014安装目录。
6、编辑“C:\Users\xxx\AppData\Roaming\SmartQuant Ltd\OpenQuant 2014\config\configuration.xml”文件,在相关地方加入

<Provider>
      <TypeName>QuantBox.APIProvider.ProviderHost, QuantBox.APIProvider</TypeName>
      <Id>0</Id>
      <X64>true</X64>
    </Provider>

7、启动运行oq2014,会自动在C:\Users\xxx\AppData\Roaming\SmartQuant Ltd\OpenQuant 2014\config\目录下创建API_Host.json文件,编辑该文件,内容为:

[
  {
    "Id": 55,
    "Name": "simnow"
  }
]

8、重新启动oq2014,会自动创建目录C:\Users\xxx\AppData\Roaming\SmartQuant Ltd\OpenQuant 2014\config\simnow,在该目录下会自动新建4个文件,其中三个文件需要手工修改,分别是:
ApiList.json

[
  {
    "DllPath": "d:\\XAPI\\CTP_SE\\CTP_SE_Quote_x64.dll",
    "TypeName": "XAPI.Callback.XApi, XAPI_CSharp",
    "Name": "CTP_SE",
    "Version": "0.4.0.20190417",
    "User": 0,
    "Server": 0,
    "LogPrefix": null,
    "Type": 10,
    "UseType": 10
  },
  {
    "DllPath": "d:\\XAPI\\CTP_SE\\CTP_SE_Trade_x64.dll",
    "TypeName": "XAPI.Callback.XApi, XAPI_CSharp",
    "Name": "CTP_SE",
    "Version": "0.4.0.20190418",
    "User": 0,
    "Server": 1,
    "LogPrefix": null,
    "Type": 97,
    "UseType": 97
  }
]

ServerList.json

[
  {
    "Label": "simnow_m",
    "Path": "d:\\XAPI\\CTP_SE\\server_m.json"
  },
  {
    "Label": "simnow_t",
    "Path": "d:\\XAPI\\CTP_SE\\server_t.json"
  }
]

UserList.json

[
  {
    "Label": "111111",
    "Path": "d:\\XAPI\\CTP_SE\\user.json"
  }
]

9、改好以上三个文件后,重新启动oq2014,会在D:\XAPI\CTP_SE目录自动创建三个文件,根据自己的实际情况填写文件内容。即可正常使用插件。

@wukan1986
Copy link
Collaborator

wukan1986 commented Oct 1, 2021

第8步的三个文件不需要手工修改,在Provider的属性界面的AllConfig中点击弹出的对话框中点击进行选择就会自动生成。

参考
https://github.com/QuantBox/QuantBox.APIProvider/blob/master/QuantBox.APIProvider/Single/SingleProvider.Settings.cs

其实,7 8 9 都是在界面上点点就可以了,不需要手工修改

@zyghost119
Copy link

zyghost119 commented Jun 10, 2022

有个问题很奇怪,openquant 2014目录下缺少nlog.config文件时,apihost和ctp接口都不显示,有这个文件,接口显示正常。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants