-
Notifications
You must be signed in to change notification settings - Fork 18
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
544dc9c
commit 7153616
Showing
39 changed files
with
305 additions
and
60 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
### Change Log | ||
|
||
## v0.0.32 | ||
- 更新 `自定义` 策略文档 | ||
- 修复数据库 | ||
|
||
## v0.0.31 | ||
- 合约交易升级,增加自定义策略规则 | ||
- 更新数据库 | ||
|
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 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 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 |
---|---|---|
@@ -0,0 +1,114 @@ | ||
# 如何使用自定义策略 | ||
|
||
## 首先类型需要选择为自定义 | ||
|
||
![alt text](./img/zh/custom_type1.jpg) | ||
![alt text](./img/zh/custom_type2.jpg) | ||
|
||
## 然后需要定义技术指标 | ||
> 目前支持的指标有 `ma`, `ema`, `rsi`, `kc(肯纳特通道)`, `boll(布林带)` | ||
- 示例图 | ||
![img1](./img/zh/te_001.jpg) | ||
![img2](./img/zh/te_002.jpg) | ||
![img3](./img/zh/te_003.jpg) | ||
|
||
### 名称 | ||
> 当前指标起一个名字 `必须在当前栏目下唯一`(写策略时需要用到) | ||
### k线类型 | ||
> k线的周期类型选择 | ||
### 其它输入 | ||
> 指标相关的标准参数 | ||
### 启用 | ||
> 只有选择了开启的指标才可以在策略中使用 | ||
## 最后编写策略 | ||
|
||
- 示例图 | ||
![alt text](./img/zh/strategy_001.png) | ||
|
||
### 名称 | ||
> 策略起一个名字 | ||
### 代码 | ||
> 自定的策略逻辑, 后面会讲如何编写 | ||
### 类型 | ||
> 做多 或 做空 | ||
### 启用 | ||
> 有选择了开启,才会真正使用 | ||
## 指标和代码逻辑说明 | ||
|
||
### ema 指标实例说明 | ||
> 假如我们在 ema 的栏目下面定义了 2 行数据如下: | ||
|
||
| 名称 | k线类型 | 周期 | 启用 | | ||
| ------------ | ------------ | ------------ | ------------ | | ||
| ema_4h_3 | 4h | 4 | true | | ||
| ema_4h_7 | 4h | 7 | true | | ||
|
||
>代表程序会创建 `ema["ema_4h_3"] = [32.3, 43.3, ...]` 和 `ema["ema_4h_7"] = [32.3, 33.3, ...]` 的 `150` 条数据的变量,分别对应 `ema` 的每个时刻点的数据,排序方式从时间维度来说,从最新到最旧(`ema["ema_4h_3"][0]` 是当前时刻的 `ema` 数据) | ||
### 策略实例说明 | ||
> 根据上面的 `ema` 实例,我们来写一个简单的策略,具体如下 | ||
``` | ||
ema["ema_4h_3"][1] < ema["ema_4h_7"][1] && ema["ema_4h_3"][0] > ema["ema_4h_7"][0] | ||
``` | ||
|
||
> 我们来解释一下,`ema_4h_3` 是一条 `ema` 的短线,`ema_4h_7` 是一条 ema 的长线(相对于 `ema_4h_3` 来说),所以上面这个策略的的含义就是前一个时刻的`短线`在`长线`下方,当前时刻的`短线`在`长线`上方, 从术语上来说这是一个金叉,是一个`做多`的趋势策略 | ||
### 所有指标实例说明 | ||
|
||
#### nowPrice | ||
> 内置变量: 可以在策略中使用 `nowPrice` 来代指某个币的当前价格 | ||
#### ma | ||
|
||
| 名称 | k线类型 | 周期 | 启用 | | ||
| ------------ | ------------ | ------------ | ------------ | | ||
| ma1 | 4h | 14 | true | | ||
|
||
> 程序创建 `ma["ma1"] = [23.2, 34.2, ...]` 的 `150` 条数据变量,使用方式是 `ma["xxx_name"]` | ||
#### ema | ||
|
||
| 名称 | k线类型 | 周期 | 启用 | | ||
| ------------ | ------------ | ------------ | ------------ | | ||
| ema1 | 4h | 14 | true | | ||
|
||
> 程序创建 `ema["ema1"] = [23.2, 34.2, ...]` 的 `150` 条数据变量,使用方式是 `ema["xxx_name"]` | ||
#### rsi | ||
|
||
| 名称 | k线类型 | 周期 | 启用 | | ||
| ------------ | ------------ | ------------ | ------------ | | ||
| rsi1 | 4h | 14 | true | | ||
|
||
> 程序创建 `rsi["rsi1"] = [67.2, 82.2, ...]` 的 `150` 条数据变量,使用方式是 `ema["xxx_name"]` | ||
#### kc | ||
|
||
| 名称 | k线类型 | 周期 | 多元 | 启用 | | ||
| ------------ | ------------ | ------------ | ------------ | ------------ | | ||
| kc_1 | 4h | 50 | 2.75 | true | | ||
|
||
|
||
> 程序创建 `kc["kc_1"].High = [67.2, 82.2, ...]` , `kc["kc_1"].Mid = [57.2, 77.2, ...]` , `kc["kc_1"].Low = [47.2, 42.2, ...]` 的 `150` 条数据的 3 个变量 | ||
> 使用方式: 上轨数据 `kc["xxx_name"].High`, 中轨数据 `kc["xxx_name"].Mid`, 下轨数据 `kc["xxx_name"].Low` | ||
#### boll | ||
|
||
| 名称 | k线类型 | 周期 | 带宽 | 启用 | | ||
| ------------ | ------------ | ------------ | ------------ | ------------ | | ||
| boll_1 | 4h | 21 | 2 | true | | ||
|
||
|
||
> 程序创建 `boll["boll_1"].High = [67.2, 82.2, ...]` , `boll["boll_1"].Mid = [57.2, 77.2, ...]` , `boll["boll_1"].Low = [47.2, 42.2, ...]` 的 `150` 条数据的 3 个变量 | ||
> 使用方式: 上轨数据 `boll["xxx_name"].High`, 中轨数据 `boll["xxx_name"].Mid`, 下轨数据 `boll["xxx_name"].Low` |
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 |
---|---|---|
@@ -0,0 +1,113 @@ | ||
# How to use custom strategy | ||
|
||
## Firstly, the type needs to be selected as custom | ||
|
||
![alt text](./img/en/custom_type1.png) | ||
![alt text](./img/en/custom_type2.png) | ||
|
||
## Then it is necessary to define technical indicators | ||
> The currently supported indicators are: `ma`, `ema`, `rsi`, `kc(keltner channels)`, `boll` | ||
- example | ||
![img1](./img/en/te_001.jpg) | ||
![img2](./img/en/te_002.jpg) | ||
![img3](./img/en/te_003.jpg) | ||
|
||
### name | ||
> The name of the current indicator must be unique in the current column (required when writing strategies) | ||
### kline_interval | ||
> kline_interval | ||
### other params | ||
> other params | ||
### enable | ||
> Only indicators that have been enabled can be used in the strategy | ||
## Finally write the strategy | ||
|
||
- example | ||
![alt text](./img/en/strategy_001.png) | ||
|
||
### name | ||
> Give a name to the strategy | ||
### code | ||
> Customize policy logic, we will explain how to write it later | ||
### type | ||
> long or short | ||
### 启用 | ||
> Only when there is a choice to activate, can it truly be used | ||
## technical indicator and code logic explanation | ||
|
||
### ema technology demo | ||
> If we define 2 rows of data under the column of EMA as follows: | ||
|
||
| name | kline_interval | period | enable | | ||
| ------------ | ------------ | ------------ | ------------ | | ||
| ema_4h_3 | 4h | 4 | true | | ||
| ema_4h_7 | 4h | 7 | true | | ||
|
||
>The program will create 150 element length variables representing `ema["ema_4h_3"] = [32.3, 43.3, ...]` and `ema["ema_4h_7"] = [32.3, 33.3, ...]`, corresponding to each time point of `ema`, the sorting method is from the latest to the oldest in terms of time dimension (`ema["ema_4h_3"][0]` is the `ema` data at the current time) | ||
### strategy demo | ||
> Based on the `ema` technology demo above, let's write a simple strategy as follows: | ||
``` | ||
ema["ema_4h_3"][1] < ema["ema_4h_7"][1] && ema["ema_4h_3"][0] > ema["ema_4h_7"][0] | ||
``` | ||
|
||
>Let's explain that `ema_4h_3` is a short line of `ema`, and `ema_4h_7` is a long line of `ema` (relative to `ema_4h_3`). Therefore, the meaning of the above strategy is that the `short line` at the previous moment is below the `long line`, and the `short line` at the current moment is above the `long line`. In terms of terminology, this is a golden cross and a trend strategy of `long` | ||
### Explanation of all technology indicator examples | ||
|
||
#### nowPrice | ||
> Built in variable: `nowPrice` can be used in the strategy to refer to the current price of a coin | ||
#### ma | ||
|
||
| 名称 | k线类型 | 周期 | 启用 | | ||
| ------------ | ------------ | ------------ | ------------ | | ||
| ma1 | 4h | 14 | true | | ||
|
||
> The program will create 150 element length variables representing `ma["ma1"] = [23.2, 34.2, ...]`, the usage method is `ma["xxx_name"]` | ||
#### ema | ||
|
||
| 名称 | k线类型 | 周期 | 启用 | | ||
| ------------ | ------------ | ------------ | ------------ | | ||
| ema1 | 4h | 14 | true | | ||
|
||
> 程序创建 `rsi["ema1"] = [23.2, 34.2, ...]` 的 `150` 条数据变量,可以供策略使用, the usage method is `ema["xxx_name"]` | ||
#### rsi | ||
|
||
| 名称 | k线类型 | 周期 | 启用 | | ||
| ------------ | ------------ | ------------ | ------------ | | ||
| rsi1 | 4h | 14 | true | | ||
|
||
> The program will create 150 element length variables representing `rsi["rsi1"] = [67.2, 82.2, ...]`, the usage method is `rsi["xxx_name"]` | ||
#### kc | ||
|
||
| 名称 | k线类型 | 周期 | 多元 | 启用 | | ||
| ------------ | ------------ | ------------ | ------------ | ------------ | | ||
| kc_1 | 4h | 50 | 2.75 | true | | ||
|
||
> The program will create 150 element length variables representing `kc["kc_1"].High = [67.2, 82.2, ...]` , `kc["kc_1"].Mid = [57.2, 77.2, ...]` , `kc["kc_1"].Low = [47.2, 42.2, ...]` | ||
> Usage: Track data `kc["xxx_name"].High`, middle track data `kc["xxx_name"].Mid`, down track data `kc["xxx_name"].Low` | ||
#### boll | ||
|
||
| 名称 | k线类型 | 周期 | 带宽 | 启用 | | ||
| ------------ | ------------ | ------------ | ------------ | ------------ | | ||
| boll_1 | 4h | 21 | 2| true | | ||
|
||
|
||
> The program will create 150 element length variables representing `ma["boll_1"].High = [67.2, 82.2, ...]` , `ma["boll_1"].Mid = [57.2, 77.2, ...]` , `ma["boll_1"].Low = [47.2, 42.2, ...]` | ||
> Usage: Track data `boll["xxx_name"].High`, middle track data `boll["xxx_name"].Mid`, down track data `boll["xxx_name"].Low` |
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
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Oops, something went wrong.