Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
EricWang committed Feb 27, 2017
1 parent 4d0f00d commit a11e5b9
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 54 deletions.
64 changes: 33 additions & 31 deletions docs/source/api/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ N/A `- -` config 设置配置文件路径
# 可以指定回测的唯一ID,用户区分多次回测的结果
run_id: 9999
# 数据源所存储的文件路径
data_bundle_path: ./bundle/
data_bundle_path: ~
# 启动的策略文件路径
strategy_file: ./rqalpha/examples/test.py
strategy_file: strategy.py
# 回测起始日期
start_date: 2016-06-01
start_date: 2015-06-01
# 回测结束日期(如果是实盘,则忽略该配置)
end_date: 2050-01-01
# 股票起始资金,默认为0
Expand All @@ -113,68 +113,52 @@ N/A `- -` config 设置配置文件路径
margin_multiplier: 1
# 在模拟交易和实盘交易中,RQAlpha支持策略的pause && resume,该选项表示开启 resume 功能
resume_mode: false
# 在模拟交易和实盘交易中,RQAlpha支持策略的pause && resume,该选项表示开启 persist 功能呢,其会在每个bar结束对进行策略的持仓、账户信息,用户的代码上线文等内容进行持久化
# 在模拟交易和实盘交易中,RQAlpha支持策略的pause && resume,该选项表示开启 persist 功能呢,
# 其会在每个bar结束对进行策略的持仓、账户信息,用户的代码上线文等内容进行持久化
persist: false
persist_mode: real_time
# 选择是否开启自动处理, 默认不开启
handle_split: false
# 选择是否开启Alpha/Beta 等风险指标的实时计算,默认开启
cal_risk_grid: true
extra:
# 指定回测结束时将回测数据输出到指定文件中
output_file: ~
# 选择日期的输出等级,有 `verbose` | `info` | `warning` | `error` 等选项,您可以通过设置 `verbose` 来查看最详细的日志,或者设置 `error` 只查看错误级别的日志输出
# 选择日期的输出等级,有 `verbose` | `info` | `warning` | `error` 等选项,您可以通过设置 `verbose` 来查看最详细的日志,
# 或者设置 `error` 只查看错误级别的日志输出
log_level: info
user_system_log_disabled: false
# 在回测结束后,选择是否查看图形化的收益曲线
plot: false
context_vars: ~
plot_save_file: ~
report_save_path: ~
# force_run_init_when_pt_resume: 在PT的resume模式时,是否强制执行用户init。主要用于用户改代码。
force_run_init_when_pt_resume: false
# enable_profiler: 是否启动性能分析
enable_profiler: false
is_hold: false
service:
username: rqalpha@ricequant.com
validator:
# fast_match: 快速撮合,开启后,不进行队列等待,直接撮合
fast_match: false
# cash_return_by_stock_delisted: 开启该项,当持仓股票退市时,按照退市价格返还现金
cash_return_by_stock_delisted: false
# on_matching: 事中风控,默认开启
on_matching: true
# limit_order: 对LimitOrder进行撮合验证,主要验证其价格是否合理,默认开启
limit_order: true
# volume: 对volume进行撮合验证,默认开启
volume: true
# available_cash: 查可用资金是否充足,默认开启
available_cash: true
# available_position: 检查可平仓位是否充足,默认开启
available_position: true
# close_amount: 在执行order_value操作时,进行实际下单数量的校验和scale,默认开启
close_amount: true
# bar_limit: 在处于涨跌停时,无法买进/卖出,默认开启
bar_limit: true
warning:
before_trading: true
mod:
# 回测 / 模拟交易 支持 Mod
simulation:
lib: 'rqalpha.mod.simulation'
enabled: true
priority: 100
# 技术分析API
funcat_api:
lib: 'rqalpha.mod.funcat_api'
enabled: false
priority: 100
priority: 200
# 开启该选项,可以在命令行查看回测进度
progress:
lib: 'rqalpha.mod.progress'
enabled: false
priority: 400
# 接受实时行情运行
# 接收实时行情运行
simple_stock_realtime_trade:
lib: 'rqalpha.mod.simple_stock_realtime_trade'
persist_path: "./persist/strategy/"
Expand All @@ -187,6 +171,24 @@ N/A `- -` config 设置配置文件路径
enabled: false
output_path: "./"
priority: 600
risk_manager:
lib: 'rqalpha.mod.risk_manager'
enabled: true
priority: 700
# available_cash: 查可用资金是否充足,默认开启
available_cash: true
# available_position: 检查可平仓位是否充足,默认开启
available_position: true
analyser:
priority: 100
enabled: true
lib: 'rqalpha.mod.analyser'
record: true
output_file: ~
plot: ~
plot_save_file: ~
report_save_path: ~
通过策略代码的方式
------------------------------------------------------
Expand Down
16 changes: 8 additions & 8 deletions docs/source/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@
FAQ
==================

1. 运行回测时,matplotlib 报错怎么办?RuntimeError: Python is not installed as a framework.
1. 运行回测时,matplotlib 报错怎么办?:code:`RuntimeError: Python is not installed as a framework`.

解决方案:创建文件 ~/.matplotlib/matplotlibrc,并加入代码`backend: TkAgg`
解决方案:创建文件 :code:`~/.matplotlib/matplotlibrc`,并加入代码 :code:`backend: TkAgg`

2. 在Windows运行报`Error on import matplotlib.pyplot`
2. 在Windows运行报 :code:`Error on import matplotlib.pyplot`

请访问 `Error on import matplotlib.pyplot (on Anaconda3 for Windows 10 Home 64-bit PC) <http://stackoverflow.com/questions/34004063/error-on-import-matplotlib-pyplot-on-anaconda3-for-windows-10-home-64-bit-pc>`_ 解决。

3. 在Windows出现缺失`cl.exe`
3. 在Windows出现缺失 :code:`cl.exe`

请访问 https://wiki.python.org/moin/WindowsCompilers 下载VC并且安装。

4. Windows 安装时报 `error: Microsoft Visual C++ 14.0 is required.`
4. Windows 安装时报 :code:`error: Microsoft Visual C++ 14.0 is required.`

请访问 https://wiki.python.org/moin/WindowsCompilers 下载VC并且安装。

5. 出现安装 `bcolz` 编译失败
5. 出现安装 :code:`bcolz` 编译失败

在 Windows 环境下编译 `bcolz` 需要 Cython 和 VC,请参考 FAQ 3 & 4
在 Windows 环境下编译 :code:`bcolz` 需要 :code:`Cython`:code:`VC`,请参考 FAQ 3 & 4

或者不进行编译安装,访问 http://www.lfd.uci.edu/~gohlke/pythonlibs/#bcolz 下载 `bcolz` 直接进行安装。
或者不进行编译安装,访问 http://www.lfd.uci.edu/~gohlke/pythonlibs/#bcolz 下载 :code:`bcolz` 直接进行安装。
12 changes: 6 additions & 6 deletions docs/source/intro/detail_install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ For CentOS

.. code-block:: bash
echo "backend: Agg" > ~/.config/matplotlib/matplotlibrc
echo "backend: Agg" > ~/.config/matplotlib/matplotlibrc
安装中文字体: 将 WenQuanYi Micro Hei.ttf 放到 /usr/share/fonts/chinese
安装中文字体: 将 :code:`WenQuanYi Micro Hei.ttf` 放到 :code:`/usr/share/fonts/chinese`

.. code-block:: bash
Expand All @@ -90,7 +90,7 @@ echo "backend: Agg" > ~/.config/matplotlib/matplotlibrc
更改 Anaconda 源,提高下载速度
------------------------------------

conda 官方的服务器在国外,因此国内的网络环境使用 `conda` 可能会比较慢,建议您根据自己的网络环境选择是否更换 `conda` 源。
conda 官方的服务器在国外,因此国内的网络环境使用 :code:`conda` 可能会比较慢,建议您根据自己的网络环境选择是否更换 `conda` 源。

清华大学提供了Anaconda的仓库镜像,我们只需要配置Anaconda的配置文件,添加清华的镜像源,然后将其设置为第一搜索渠道即可:
运行以下命令行:
Expand All @@ -100,7 +100,7 @@ conda 官方的服务器在国外,因此国内的网络环境使用 `conda`
conda config --add channels 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/'
conda config --set show_channel_urls yes
设置好源后,就可以使用 `conda install 【包名】` 安装需要的 Python 库了。大部分情况下,建议使用 `conda` 来安装 Python 数据分析相关的库,因为 conda 做了很多的优化和版本依赖关系的管理。如果没有相关的库,则使用 `pip install 【包名】` 的方式来安装。
设置好源后,就可以使用 :code:`conda install 【包名】` 安装需要的 Python 库了。大部分情况下,建议使用 :code:`conda` 来安装 Python 数据分析相关的库,因为 conda 做了很多的优化和版本依赖关系的管理。如果没有相关的库,则使用 :code:`pip install 【包名】` 的方式来安装。

conda 虚拟环境
------------------------------------
Expand All @@ -109,7 +109,7 @@ conda 虚拟环境

我们强烈建议您去创建并使用Python虚拟环境,因为这样才能让您的开发环境更加独立,不会因为安装不同的包而出现问题,造成运行失败等。

目前流行的Python虚拟环境有两种:conda 和 pyenv, 由于大部分的量化开发都是基于 Anaconda 的 python 技术栈,因此我们建议您使用 conda 作为默认的虚拟环境开发。
目前流行的Python虚拟环境有两种::code:`conda`:code:`pyenv`, 由于大部分的量化开发都是基于 Anaconda 的 python 技术栈,因此我们建议您使用 conda 作为默认的虚拟环境开发。

一下有几个常用的虚拟环境命令可以使用:

Expand Down Expand Up @@ -155,4 +155,4 @@ RQAlpha 的相关安装 请参考 :ref:`intro-install`
如果发现无法通过 pip 安装,请访问 https://mrjbq7.github.io/ta-lib/install.html 解决。

对于 Windows 用户,如果编译困难,可以根据您本地的Python版本下载指定的whl包,然后 `pip install TA_Lib-0.4.9-cp27-none-win_amd64.whl` 来完成安装。
对于 Windows 用户,如果编译困难,可以根据您本地的Python版本下载指定的whl包,然后 :code:`pip install TA_Lib-0.4.9-cp27-none-win_amd64.whl` 来完成安装。
10 changes: 5 additions & 5 deletions docs/source/intro/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ RQAlpha目前只支持 python 3.4+ && Python 2.7+

我们强烈建议您在安装 RQAlpha 前,首先单独安装 bcolz 库,因为其编译时间较长,并且中间比较容易失败,单独安装好以后再继续安装RQAlpha。

Windows 环境下编译安装 bcolz 需要使用Visual C++ Compiler,需要自行下载并安装 visual-cpp-build-tools,
Windows 环境下编译安装 bcolz 需要使用 :code:`Visual C++ Compiler`,需要自行下载并安装 visual-cpp-build-tools,

如果觉得麻烦,也可以直接去 http://www.lfd.uci.edu/~gohlke/pythonlibs/#bcolz 下载相应版本的 bcolz wheel 包,直接安装编译后的 bcolz 版本。
如果觉得麻烦,也可以直接去 http://www.lfd.uci.edu/~gohlke/pythonlibs/#bcolz 下载相应版本的 :code:`bcolz wheel` 包,直接安装编译后的 bcolz 版本。

安装
==================
Expand All @@ -40,7 +40,7 @@ Windows 环境下编译安装 bcolz 需要使用Visual C++ Compiler,需要自
$ pip install rqalpha
如果执行 `pip install` 安装依赖库网络速度比较慢的话,推荐使用国内镜像来进行加速:
如果执行 :code:`pip install` 安装依赖库网络速度比较慢的话,推荐使用国内镜像来进行加速:

.. code-block:: bash
Expand All @@ -63,7 +63,7 @@ RiceQuant 免费提供日级别的股票和期货数据供回测使用,可以
$ rqalpha update_bundle
bundle 默认存放在 `~/.rqalpha` 下,您也可以指定 bundle 的存放位置,
bundle 默认存放在 :code:`~/.rqalpha` 下,您也可以指定 bundle 的存放位置,

.. code-block:: bash
Expand All @@ -80,7 +80,7 @@ bundle 默认存放在 `~/.rqalpha` 下,您也可以指定 bundle 的存放位
获取配置文件
==================

如果运行 RQAlpha 时不指定配置文件,会在 `~/.rqalpha/` 文件夹下创建 `config.yml` 文件作为默认配置文件。
如果运行 RQAlpha 时不指定配置文件,会在 :code:`~/.rqalpha/` 文件夹下创建 :code:`config.yml` 文件作为默认配置文件。

如果您想要直接获得一份配置文件,也可以通过如下命令来获得。

Expand Down
8 changes: 4 additions & 4 deletions docs/source/intro/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,30 @@
* 起始资金
* Benchmark

假如我们的策略存放在了 `./rqalpha/examples/buy_and_hold.py` 路径下, 数据源存放在 `./rqalpha/bundle/` 路径下,回测的起始时间为 `2016-06-01`, 结束时间为 `2016-12-01`,我们给策略分配的起始资金为 `100000`, Benchmark 设置为 `000300.XSHG`
假如我们的策略存放在了 :code:`./rqalpha/examples/buy_and_hold.py` 路径下, 数据源存放在 :code:`./rqalpha/bundle/` 路径下,回测的起始时间为 :code:`2016-06-01`, 结束时间为 :code:`2016-12-01`,我们给策略分配的起始资金为 :code:`100000`, Benchmark 设置为 :code:`000300.XSHG`

那么我们通过如下命令来运行回测

.. code-block:: bash
rqalpha run -f ./rqalpha/examples/buy_and_hold.py -d ./rqalpha/bundle/ -s 2016-06-01 -e 2016-12-01 --stock-starting-cash 100000 --benchmark 000300.XSHG
如果我们想要以图形的方式查看回测的结果, 则增加 `--plot` 参数
如果我们想要以图形的方式查看回测的结果, 则增加 :code:`--plot` 参数

.. code-block:: bash
rqalpha run -f ./rqalpha/examples/buy_and_hold.py -d ./rqalpha/bundle/ -s 2016-06-01 -e 2016-12-01 --stock-starting-cash 100000 --benchmark 000300.XSHG --plot
.. image:: ../_static/buy_and_hold.png

如果想把回测的数据保存下来,可以通过 `-o` 参数将结果保存成 `pkl` 文件。
如果想把回测的数据保存下来,可以通过 :code:`-o` 参数将结果保存成 :code:`pkl` 文件。

.. code-block:: bash
rqalpha run -f ./rqalpha/examples/buy_and_hold.py -d ./rqalpha/bundle/ -s 2016-06-01 -e 2016-12-01 --stock-starting-cash 100000 --benchmark 000300.XSHG --plot -o result.pkl
等回测结束后可以通过 `pandas.read_pickle` 函数来读取数据进行之后的数据分析。
等回测结束后可以通过 :code:`pandas.read_pickle` 函数来读取数据进行之后的数据分析。

.. code-block:: python3
:linenos:
Expand Down

0 comments on commit a11e5b9

Please sign in to comment.