From 6949f1562e3bd626d86279c9d0104d391ea15570 Mon Sep 17 00:00:00 2001 From: nanoric Date: Mon, 6 May 2019 02:43:40 -0400 Subject: [PATCH] =?UTF-8?q?[Add]=20=E6=B7=BB=E5=8A=A0=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E7=9A=84=E9=85=8D=E7=BD=AE=E8=AF=B4=E6=98=8E=E6=96=87?= =?UTF-8?q?=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/database.md | 85 ++++++++++++++++++++++++++++++++++++++++++++++++ docs/index.md | 8 ++--- 2 files changed, 88 insertions(+), 5 deletions(-) create mode 100644 docs/database.md diff --git a/docs/database.md b/docs/database.md new file mode 100644 index 00000000..282e0e20 --- /dev/null +++ b/docs/database.md @@ -0,0 +1,85 @@ +# 数据库配置 + +VN Trader目前支持以下四种数据库: + + * [SQLite](#sqlite)(默认) + * [MySQL](#sqlmysqlpostgresql) + * [PostgreSQL](#sqlmysqlpostgresql) + * [MongoDB](#mongodb) + +如果需要配置数据库,请点击配置。然后按照各个数据库所需的字段填入相对应的值即可。 + +--- +## SQLite +需要填写以下字段: + + | 字段名 | 值 | + --------- |---- | + database.driver | sqlite | + database.database | 数据库文件(相对于trader目录) | + +SQLite的例子: + + | 字段名 | 值 | + --------- |---- | + database.driver | sqlite | + database.database | database.db | + + +--- +## SQL(MySQL,PostgreSQL) + +需要填写以下字段: + + | 字段名 | 值 | + --------- |---- | + database.driver | "mysql"或"postgresql" | + database.host | 地址 | + database.port | 端口 | + database.database | 数据库名 | + database.user | 用户名 | + database.password | 密码 | + +MySQL的例子: + + | 字段名 | 值 | + --------- |---- | + database.driver | mysql | + database.host | localhost | + database.port | 3306 | + database.database | vnpy | + database.user | root | + database.password | .... | + +> vnpy不会主动为关系型数据库创建数据库,所以请确保你所填的database.database字段对应的数据库已经创建好了 +> 若未创建数据库,请手动连上数据库并运行该命令:```create database <你填的database.database>;``` + +--- +## MongoDB + +需要填写以下字段: + + | 字段名 | 值 | 是否必填| + --------- |---- | ---| + database.driver | "mysql"或"postgresql" | 必填 | + database.host | 地址| 必填 | + database.port | 端口| 必填 | + database.database | 数据库名| 必填 | + database.user | 用户名| 可选 | + database.password | 密码| 可选 | + database.authentication_source | [创建用户所用的数据库][AuthSource]| 可选 | + +MongoDB的带认证例子: + + | 字段名 | 值 | + --------- |---- | + database.driver | mongodb | + database.host | localhost | + database.port | 27017 | + database.database | vnpy | + database.user | root | + database.password | .... | + database.authentication_source | vnpy | + + +[AuthSource]: https://docs.mongodb.com/manual/core/security-users/#user-authentication-database \ No newline at end of file diff --git a/docs/index.md b/docs/index.md index 201c045e..8b60718b 100644 --- a/docs/index.md +++ b/docs/index.md @@ -27,7 +27,7 @@ * [应用模块](https://www.vnpy.com/docs/cn/quickstart.html#id14) * [CTA策略](https://www.vnpy.com/docs/cn/quickstart.html#cta) * [CSV载入](https://www.vnpy.com/docs/cn/quickstart.html#csv) - + * 应用模块 * [CSV载入](https://www.vnpy.com/docs/cn/csv_loader.html#csv) * [初始化配置](https://www.vnpy.com/docs/cn/csv_loader.html#id1) @@ -48,7 +48,6 @@ * [15分钟K线数据回报](https://www.vnpy.com/docs/cn/cta_strategy.html#id9) * [委托回报、成交回报、停止单回报](https://www.vnpy.com/docs/cn/cta_strategy.html#id10) - * [回测研究](https://www.vnpy.com/docs/cn/cta_strategy.html#id11) * [加载策略](https://www.vnpy.com/docs/cn/cta_strategy.html#id12) * [载入历史数据](https://www.vnpy.com/docs/cn/cta_strategy.html#id13) @@ -58,7 +57,6 @@ * [统计指标绘图](https://www.vnpy.com/docs/cn/cta_strategy.html#id17) * [回测引擎使用示例](https://www.vnpy.com/docs/cn/cta_strategy.html#id18) - * [参数优化](https://www.vnpy.com/docs/cn/cta_strategy.html#id19) * [参数设置](https://www.vnpy.com/docs/cn/cta_strategy.html#id20) * [参数对组合回测](https://www.vnpy.com/docs/cn/cta_strategy.html#id21) @@ -71,7 +69,6 @@ * [编辑策略](https://www.vnpy.com/docs/cn/cta_strategy.html#id28) * [移除策略](https://www.vnpy.com/docs/cn/cta_strategy.html#id29) - * [CTA回测](https://www.vnpy.com/docs/cn/cta_backtester.html#cta) * [加载启动](https://www.vnpy.com/docs/cn/cta_backtester.html#id1) * [下载数据](https://www.vnpy.com/docs/cn/cta_backtester.html#id2) @@ -84,4 +81,5 @@ * [交易接口](gateway.md) * [RPC应用](rpc.md) -* [贡献代码](contribution.md) \ No newline at end of file +* [贡献代码](contribution.md) +* [配置数据库](database.md) \ No newline at end of file