Skip to content

Commit

Permalink
doc: update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
HaoZhengZhao committed Nov 2, 2024
1 parent 544dc9c commit 7153616
Show file tree
Hide file tree
Showing 39 changed files with 305 additions and 60 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
### Change Log

## v0.0.32
- 更新 `自定义` 策略文档
- 修复数据库

## v0.0.31
- 合约交易升级,增加自定义策略规则
- 更新数据库
Expand Down
19 changes: 14 additions & 5 deletions README.CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@

# 币安交易机器人

# 免责申明
>!!!本项目不构成任何投资建议,投资者应独立决策并自行承担风险!!!
## 特色

# 实时推送
## 实时推送
> dingding, slack
- 钉钉
Expand All @@ -18,6 +17,15 @@
- slack
![slack](./img/zh/listen_slack.jpg)

## 自定义交易策略
> ![img1](./img/zh/te_001.jpg)
> ![alt text](./img/zh/strategy_001.png)
<a href="./STRATEGY.CN.md">自定义详情</a>

# 免责申明
>!!!本项目不构成任何投资建议,投资者应独立决策并自行承担风险!!!
# 功能

# Features <!-- omit in toc -->
Expand All @@ -35,7 +43,7 @@
- [系统设置](#系统设置)

## 合约交易
- 每个币种的单独配置
- 每个币种的单独配置(策略,数量,止盈,止损)
![交易币种](./img/zh/coins.jpg)
![钉钉推送1](./img/zh/dingding_future1.jpg)

Expand Down Expand Up @@ -70,7 +78,8 @@
### 合约监听
- k线变化监听
- 肯纳特通道信号监听
![合约监听](./img/zh/listen_feature.jpg)
- 自定义策略
![合约监听](./img/zh/listen_futures.jpg)
![合约监听chart1](./img/zh/listen_chat_kc.jpg)
![合约监听通知1](./img/zh/dingding_listen1.jpg)

Expand Down
30 changes: 20 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,9 @@

# Binance-trade-bot

# DISCLAIMER

```
I am not responsible for anything done with this bot.
You use it at your own risk.
There are no warranties or guarantees expressed or implied.
You assume all responsibility and liability.
```
## peculiarity

# Notification
## Pusher
> dingding, slack
- dingding
Expand All @@ -24,6 +17,21 @@ You assume all responsibility and liability.
- slack
![slack](./img/en/listen_slack.jpg)

## custom strategy
> ![img1](./img/en/te_001.jpg)
> ![alt text](./img/en/strategy_001.png)
<a href="./STRATEGY.md">custom strategy details</a>

# DISCLAIMER

```
I am not responsible for anything done with this bot.
You use it at your own risk.
There are no warranties or guarantees expressed or implied.
You assume all responsibility and liability.
```


# Features <!-- omit in toc -->

Expand All @@ -41,6 +49,7 @@ You assume all responsibility and liability.

## futures-trade
- Independent configuration for each coin
- <a href="./README.CN.md">custom strategy</a>
![交易币种](./img/en/coins.jpg)
![钉钉推送1](./img/en/dinding_future1.jpg)

Expand Down Expand Up @@ -75,6 +84,7 @@ You assume all responsibility and liability.
### futures-listen
- kline change listen
- kline keltner channels listen
- custom strategy
![合约监听](./img/en/listen_futures.jpg)
![合约监听chart1](./img/en/listen_chat_kc.jpg)
![合约监听通知1](./img/en/dingding_listen1.jpg)
Expand Down Expand Up @@ -253,7 +263,7 @@ The login account password is the `web.username` and `web.password` in the `app.
| ------------ | ------------ | ------------ | ------------ | ------------ | ------------ |------------ | ------------ |
| ABCUSDT | buy_long | futures | ISOLATED or CROSSED| 10|3 | 0.1(if you don't know, please fill in 0) | open |

#### 合约抢买做空配置例子
#### futures rush buy short
| coin | trade_type | coin_type |margin_type| usdt| leverage | step_size | enable |
| ------------ | ------------ | ------------ | ------------ | ------------ | ------------ |------------ | ------------ |
| ABCUSDT | buy_short | futures | ISOLATED or CROSSED | 10|3 | 0.1(if you don't know, please fill in 0) | open |
Expand Down
114 changes: 114 additions & 0 deletions STRATEGY.CN.md
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`
113 changes: 113 additions & 0 deletions STRATEGY.md
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`
11 changes: 11 additions & 0 deletions controllers/index.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package controllers

import (
"go_binance_futures/notify"

"github.com/beego/beego/v2/core/config"
"github.com/beego/beego/v2/server/web"
)
Expand Down Expand Up @@ -58,4 +60,13 @@ func (ctrl *IndexController) GetServiceConfig() {
},
"msg": "success",
})
}

func (ctrl *IndexController) TestPusher() {
var pusher = notify.GetNotifyChannel()
pusher.TestPusher()
ctrl.Ctx.Resp(map[string]interface{} {
"code": 200,
"msg": "success",
})
}
Binary file modified db/coin.db
Binary file not shown.
Binary file modified img/en/coins.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/en/custom_type1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/en/custom_type2.png
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 removed img/en/listen_feature.jpg
Binary file not shown.
Binary file added img/en/listen_futures.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/en/strategy_001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/en/te_001.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/en/te_002.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/en/te_003.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/zh/coins.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/zh/custom_type1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/zh/custom_type2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed img/zh/listen_feature.jpg
Binary file not shown.
Binary file added img/zh/listen_futures.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/zh/strategy_001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/zh/te_001.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/zh/te_002.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/zh/te_003.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func main() {
// feature.GoTestDeliveryAccount()
// feature.GoTestParse()
// feature.GoTestListen()
feature.GoTestLine()
// feature.GoTestLine()

// web
web.Run(":" + webPort)
Expand Down
Loading

0 comments on commit 7153616

Please sign in to comment.