-
Notifications
You must be signed in to change notification settings - Fork 659
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6f19ded
commit 631787b
Showing
5 changed files
with
102 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,107 @@ | ||
.. _vscode: | ||
|
||
Visual Studio Code 插件 | ||
========================================================================= | ||
对于习惯使用 Visual Studio Code 进行 Python 开发的用户,我们通过IDE插件的方式提供了一些有用的附加功能。包括: | ||
天勤 Vs Code 插件 | ||
==================================================== | ||
天勤 Vs Code插件为在vscode中进行tqsdk相关程序提供一系列便利和支持。它可以帮助您: | ||
|
||
* 复盘支持 | ||
* 交易监控及图表标记 | ||
* 在行情图上绘制指标 | ||
* 在策略运行时自动保存日志和成交记录 | ||
* 自动显示策略相关合约的K线图 | ||
* 一键打包 python 程序为独立可执行程序 | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
安装天勤 Vs Code插件 | ||
---------------------------------------------------- | ||
在 Vs Code extension 中输入 "天勤量化"或“tqsdk”, 点击【install】按钮 | ||
|
||
vscode.rst | ||
.. figure:: ../../images/vscode_install.png | ||
|
||
插件安装好以后, 需要先配置账户参数才能使用,可以右键选项,选择【设置天勤参数】 | ||
|
||
.. figure:: ../../images/vscode_setting_config.png | ||
|
||
然后配置如下信息 | ||
|
||
* 实盘交易账号(选填) | ||
* 模拟交易账号(没有的话可以前往 :ref:`sim_trading` 注册) | ||
|
||
.. figure:: ../../images/vscode_setting_account.png | ||
|
||
配置完毕后,点击菜单栏上的【天勤量化】,将出现一个这样的面板: | ||
|
||
.. figure:: ../../images/vscode_click_tianqinlianghua.png | ||
|
||
祝贺你, Vs Code插件已经安装配置完毕,可以开始使用了 | ||
|
||
|
||
Vs Code插件策略运行 | ||
---------------------------------------------------- | ||
要运行策略程序,请在策略程序的右键菜单中选择【在实盘中运行】或【在模拟账户中运行】 | ||
|
||
.. figure:: ../../images/vscode_click.png | ||
|
||
一旦策略程序开始运行,右侧的天勤面板中将输出策略运行日志。如果策略程序中有绘图输出,也会输出到右侧面板中: | ||
|
||
插件会自动保存用户策略的全部报单和print输出信息到硬盘文件,并可在reports目录下随时查看 | ||
|
||
.. figure:: ../../images/vscode_strategy_picture.png | ||
|
||
|
||
注意:当右键菜单已经设置了账户信息,但与代码中设置的不一致时,将以右键设置的账户信息为准:: | ||
|
||
api = TqApi(TqAccount("快期模拟", "[email protected]", "123838")) # 使用实盘交易账户 | ||
|
||
当我们使用右键菜单【实盘账户运行策略】时,程序会以菜单中设置的实盘账户运行,而不是代码中的账户 | ||
|
||
|
||
Vs Code插件回测策略 | ||
---------------------------------------------------- | ||
要回测策略程序,右键菜单中提供默认【回测7天】和【回测30天】 | ||
|
||
同时我们也提供自定义回测区间功能,右键选择【设置天勤参数】,即可进入设置自定义回测区间 | ||
|
||
.. figure:: ../../images/vscode_setting_backtesttime.png | ||
|
||
设置成功之后,菜单栏中的【回测策略(自定义回测区间)】即可以刚刚设置的自定义回测区间回测任何策略 | ||
|
||
.. figure:: ../../images/vscode_backtest_setting_finished.png | ||
|
||
回测策略程序时,策略交易记录和日志同样会在天勤面板中输出 | ||
|
||
|
||
Vs Code插件复盘行情 | ||
---------------------------------------------------- | ||
在Vs Code中提供和天勤终端一致的历史复盘功能,只需点击右下角【复盘控制器 展开】即可 | ||
|
||
.. figure:: ../../images/vscode_repaly.png | ||
|
||
打开复盘,依次点击日期框,选择历史复盘具体日期,然后点击确定,历史复盘环境即开始创建 | ||
|
||
.. figure:: ../../images/vscode_setting_config.png | ||
|
||
复盘环境创建完成之后,复盘状态会显示为暂停中,这时选择需要在复盘环境中运行的策略,右键点击【复盘环境运行策略文件】 | ||
|
||
.. figure:: ../../images/vscode_run_replay.png | ||
|
||
在Vs Code插件中绘图形 | ||
-------------------------------------------------------------------------- | ||
策略在Vs Code插件版运行时,也可以进行自定义指标绘图,具体操作请参见 :ref:`draw_indicator` | ||
|
||
|
||
策略程序打包成独立应用程序 | ||
---------------------------------------------------- | ||
在Vs Code版本中我们提供了一键策略程序打包功能,可以将指定策略程序打包成exe文件,方便用户将自己私人策略打包加密之后提供他人使用 | ||
|
||
使用策略程序打包功能之前,建议先阅读 :ref:`gui` | ||
|
||
以下面代码为例,我们来看看策略程序打包成独立应用程序,具体有什么表现效果 | ||
|
||
.. literalinclude:: ../../../tqsdk/demo/gui/param_input.py | ||
:language: python | ||
|
||
首先右键点击【策略程序打包成独立应用程序】 | ||
|
||
.. figure:: ../../images/vscode_save_exe.png | ||
|
||
打包完成之后,运行对应exe文件画面显示效果如下 | ||
|
||
.. figure:: ../../images/vscode_gui_performance.png | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters