Skip to content

Commit

Permalink
feat: integrate with tradingview (chrisleekr#339)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisleekr authored Oct 22, 2021
1 parent 2ad3c71 commit 9d68735
Show file tree
Hide file tree
Showing 102 changed files with 10,572 additions and 5,652 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ docker-compose.yml
docker-compose.server.yml

.git

tradingview
12 changes: 12 additions & 0 deletions .github/workflows/release-and-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,15 @@ jobs:
tags: |
chrisleekr/binance-trading-bot:latest
chrisleekr/binance-trading-bot:${{ env.PACKAGE_VERSION }}
# https://github.com/docker/build-push-action#multi-platform-image
- name: Build/Push production docker image - tradingview
uses: docker/build-push-action@v2
with:
context: ./tradingview
file: Dockerfile
platforms: linux/amd64,linux/arm/v7,linux/arm64
push: true
tags: |
chrisleekr/binance-trading-bot:tradingview
chrisleekr/binance-trading-bot:tradingview-${{ env.PACKAGE_VERSION }}
34 changes: 34 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,37 @@ production:
GIT_HASH=$GIT_HASH --build-arg NODE_ENV=production --target
production-stage --pull --tag
$REGISTRY_DOMAIN/chrisleekr/binance-trading-bot:latest --push .

production-tradingview:
stage: build production
image: docker:20-dind
services:
- name: docker:20-dind
alias: docker
command: ['--tls=false']
variables:
DOCKER_HOST: tcp://docker:2375/
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ''
tags:
- dind
only:
- master
- development
before_script:
- apk add curl git
- mkdir -p ~/.docker/cli-plugins/
- BUILDX_LATEST_BIN_URI=$(curl -s -L
https://github.com/docker/buildx/releases/latest | grep 'linux-amd64' |
grep 'href' | sed 's/.*href="/https:\/\/github.com/g; s/amd64".*/amd64/g')
- curl -s -L ${BUILDX_LATEST_BIN_URI} -o ~/.docker/cli-plugins/docker-buildx
- chmod a+x ~/.docker/cli-plugins/docker-buildx
- docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER"
--password-stdin $CI_REGISTRY
- docker context create dind
- docker buildx create --driver docker-container --use dind
script:
- docker buildx build --progress plain --platform linux/amd64,linux/arm/v7
--pull --tag $REGISTRY_DOMAIN/chrisleekr/binance-trading-bot:tradingview
--push ./tradingview
10 changes: 9 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@
"**/coverage": true,
"**/node_modules": true
},
"cSpell.words": ["Bollinger", "MACD", "bbands", "chrisleekr", "mrkdwn", "tulind"],
"cSpell.words": [
"bbands",
"Bollinger",
"chrisleekr",
"MACD",
"mrkdwn",
"tradingview",
"tulind"
],
"eslint.format.enable": true,
"eslint.codeActionsOnSave.mode": "all"
}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ All notable changes to this project will be documented in this file.

- Enhanced auto-trigger buy feature - [#316](https://github.com/chrisleekr/binance-trading-bot/issues/316)
- Added TradingView Technical Analysis - [#327](https://github.com/chrisleekr/binance-trading-bot/issues/327)
- Updated buy/auto-buy trigger/sell action to integrate with TradingView Technical Analysis - [#327](https://github.com/chrisleekr/binance-trading-bot/issues/327)
- Fixed dust transfer base amount. Thanks [@ilbuonmarcio](https://github.com/ilbuonmarcio) - [#346](https://github.com/chrisleekr/binance-trading-bot/pull/346)
- Added `/status` endpoint. Thanks [@ilbuonmarcio](https://github.com/ilbuonmarcio) - [#347](https://github.com/chrisleekr/binance-trading-bot/pull/347)
- Added logging features for actions - [#362](https://github.com/chrisleekr/binance-trading-bot/pull/362)

## [0.0.79] - 2021-09-19

Expand Down
1 change: 1 addition & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ module.exports = grunt => {
'./public/dist/js/SymbolSettingIconGridBuy.min.js',
'./public/dist/js/SymbolSettingIconGridSell.min.js',
'./public/dist/js/SymbolSettingIcon.min.js',
'./public/dist/js/SymbolLogsIcon.min.js',
'./public/dist/js/CoinWrapperSymbol.min.js',
'./public/dist/js/CoinWrapperTradingView.min.js',
'./public/dist/js/CoinWrapper.min.js',
Expand Down
37 changes: 12 additions & 25 deletions README.ko.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@

- 최종 매수 가격: : ($50 + $100)/(0.5 COIN + 1.29 COIN) = $83.80

##### 매수 환경설정

상세한 매수 환경설정에 대한 설명은 아래에서 보실 수 있습니다.

[https://github.com/chrisleekr/binance-trading-bot/wiki/Buy-Scenario](https://github.com/chrisleekr/binance-trading-bot/wiki/Buy-Scenario)

### 매도 신호

만약 매도를 위한 충분한 코인이 있고 매수 가격(Last buy price)가 저장되었을 경우, 프로그램은 첫번째 그리드 트레이딩을 위한 매도 신호를 모니터링하기 시작합니다. 현재 가격이 매도 시작 가격에 도달한다면, 프로그램은 매도 STOP-LOSS-LIMIT 주문을 넣습니다. 만약 현재 가격이 계속 상승한다면, 프로그램은 이전 주문을 취소하고, 새 가격으로 매도 STOP-LOSS-LIMIT 주문을 넣습니다.
Expand Down Expand Up @@ -217,31 +223,11 @@
- 두번째 매도: $87.21 * 0.895 = $78.05295
- 최종 수익: $162 (8% 수익)

### 매도 스탑-로스 시나리오

예를 들어, 매도 스탑-로스 환경설정이 다음과 같이 되었다고 가정해봅시다:

- 최대 손실 퍼센트(Max loss percentage): 0.90 (-10%)
- 매수 중단 시간(분): 60

그리고 현재 마켓이 아래와 같다고 가정합니다:

- 현재 가격(Current price): $95
- 매수 가격(Last buy price): $100
- 스탑-로스 가격(Stop-Loss price): $90

이럴 경우 스탑-로스 가격($90)이 현재 가격($95)보다 낮기 때문에 프로그램은 매도 주문을 넣지 않습니다.

만약 현재 가격이 계속 하락한다면, 프로그램은 현재 가격이 스탑-로스 가격에 도달할때까지 계속 모니터링합니다.

시간이 지나, 마켓이 다음과 같이 변했다고 가정합니다:

- 현재 가격(Current price): $90
- 스탑-로스 가격(Stop-Loss price): $90
##### 매도 환경설정

현재 가격($90)이 스탑-로스 가격($90)과 같거나 낮기때문에 프로그램은 새로운 매도 MARKET 주문을 넣습니다. 실 거래시, 주문 수량은 다를 수 있습니다.
상세한 매도 환경설정에 대한 설명은 아래에서 보실 수 있습니다.

그리고 지속적인 매수/매도를 방지하기 위해서 해당 코인은 60분동안 임시로 거래가 중단됩니다. 프론트엔드는 중단 아이콘과 다시 거래 시작까지 얼마나 남았는지 시간을 보여줍니다. 거래를 바로 시작할려면 플레이 아이콘을 클릭하시면 됩니다.
[https://github.com/chrisleekr/binance-trading-bot/wiki/Sell-Scenario](https://github.com/chrisleekr/binance-trading-bot/wiki/Sell-Scenario)

### [기능](https://github.com/chrisleekr/binance-trading-bot/wiki/Features)

Expand All @@ -252,6 +238,7 @@
- 스탑-로스
- 최고가일 경우 매수 제한하기
- 매수/매도 그리드 트레이딩
- TradingView 기술적 지표 지원

### 프론트엔드 + 웹 소켓

Expand Down Expand Up @@ -324,15 +311,15 @@

| Password Protected | Frontend Mobile |
| ------------------ | --------------- |
| ![Password Protected](https://user-images.githubusercontent.com/5715919/133920104-49d1b590-c2ba-46d7-a294-eb6b24b459f5.png) | ![Frontend Mobile](https://user-images.githubusercontent.com/5715919/133920081-ce7da519-136a-4aca-841e-a85a9a5b249e.png) |
| ![Password Protected](https://user-images.githubusercontent.com/5715919/133920104-49d1b590-c2ba-46d7-a294-eb6b24b459f5.png) | ![Frontend Mobile](https://user-images.githubusercontent.com/5715919/137472107-4059fcdf-5174-4282-81af-80cea5b269a0.png) |

| Setting | Manual Trade |
| ------- | ------------ |
| ![Setting](https://user-images.githubusercontent.com/5715919/127318581-4e422ac9-b145-4e83-a90d-5c05c61d6e2f.png) | ![Manual Trade](https://user-images.githubusercontent.com/5715919/127318630-f2180e1b-3feb-48fa-a083-4cb7f90f743f.png) |

| Frontend Desktop | Closed Trades |
| ----------------- | ------------- |
| ![Frontend Desktop](https://user-images.githubusercontent.com/5715919/133920034-0889f631-f11c-4463-8f7f-39af070df60a.png) | ![Closed Trades](https://user-images.githubusercontent.com/5715919/133920059-a72972c8-18c4-4adb-9641-8dbe7ff3a14a.png) |
| ![Frontend Desktop](https://user-images.githubusercontent.com/5715919/137472148-7be1e19b-3ce5-4d5a-aa28-18c55b3b48aa.png) | ![Closed Trades](https://user-images.githubusercontent.com/5715919/137472190-a4c6ef0f-3399-44bb-852f-eedb7c67d629.png) |

### 샘플 거래

Expand Down
37 changes: 12 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ Then the bot will execute 2nd purchase for the coin. The last buy price will be

- Final last buy price: ($50 + $100)/(0.5 COIN + 1.29 COIN) = $83.80

##### In-depth Buy Configuration in-depth

The detailed document for buy configuration available here.

[https://github.com/chrisleekr/binance-trading-bot/wiki/Buy-Scenario](https://github.com/chrisleekr/binance-trading-bot/wiki/Buy-Scenario)

### Sell Signal

If there is enough balance for selling and the last buy price is recorded in the bot, then the bot will start monitoring the sell signal of the grid trade #1. Once the current price reaches the trigger price of the grid trade #1, then the bot will place a STOP-LOSS-LIMIT order to sell. If the current price continuously rises, then the bot will cancel the previous order and re-place the new STOP-LOSS-LIMIT order with the new price.
Expand Down Expand Up @@ -230,31 +236,11 @@ The final profit would be
- 2nd sell: $87.21 * 0.895 = $78.05295
- Final profit: $162 (8% profit)

#### Sell Stop-Loss Scenario

Let say, if the sell Stop-Loss configurations are set as below:

- Max loss percentage: 0.90
- Temporary disable for buying (minutes): 60

And the market is as below:

- Current price: $95
- Last buy price: $100
- Stop-Loss price: $90

Then the bot will not place a Stop-Loss order because the Stop-Loss price ($90) is less than the current price ($95).

If the price is continuously falling, then the bot will keep monitoring until the price reaches the Stop-Loss price.

In the next tick, the market changes as below:

- Current price: $90
- Stop-Loss price: $90
##### In-depth Sell Configuration

The bot will place new MARKET order for selling because the current price ($90) is less or equal than the Stop-Loss price ($90). In real trading, the quantity may be different.
The detailed document for buy configuration available here.

The bot will also set the symbol to be temporarily disabled for 60 minutes to avoid buying/sell continuously. In the frontend, the action will display the pause icon and how long left to be enabled again. The symbol can be enabled by clicking the play icon.
[https://github.com/chrisleekr/binance-trading-bot/wiki/Sell-Scenario](https://github.com/chrisleekr/binance-trading-bot/wiki/Sell-Scenario)

### [Features](https://github.com/chrisleekr/binance-trading-bot/wiki/Features)

Expand All @@ -265,6 +251,7 @@ The bot will also set the symbol to be temporarily disabled for 60 minutes to av
- Stop-Loss
- Restrict buying with ATH price
- Grid Trade for buy/sell
- Integrated with TradingView Technical Analysis

### Frontend + WebSocket

Expand Down Expand Up @@ -348,15 +335,15 @@ Or use the frontend to adjust configurations after launching the application.

| Password Protected | Frontend Mobile |
| ------------------ | --------------- |
| ![Password Protected](https://user-images.githubusercontent.com/5715919/133920104-49d1b590-c2ba-46d7-a294-eb6b24b459f5.png) | ![Frontend Mobile](https://user-images.githubusercontent.com/5715919/133920081-ce7da519-136a-4aca-841e-a85a9a5b249e.png) |
| ![Password Protected](https://user-images.githubusercontent.com/5715919/133920104-49d1b590-c2ba-46d7-a294-eb6b24b459f5.png) | ![Frontend Mobile](https://user-images.githubusercontent.com/5715919/137472107-4059fcdf-5174-4282-81af-80cea5b269a0.png) |

| Setting | Manual Trade |
| ------- | ------------ |
| ![Setting](https://user-images.githubusercontent.com/5715919/127318581-4e422ac9-b145-4e83-a90d-5c05c61d6e2f.png) | ![Manual Trade](https://user-images.githubusercontent.com/5715919/127318630-f2180e1b-3feb-48fa-a083-4cb7f90f743f.png) |

| Frontend Desktop | Closed Trades |
| ----------------- | ------------- |
| ![Frontend Desktop](https://user-images.githubusercontent.com/5715919/133920034-0889f631-f11c-4463-8f7f-39af070df60a.png) | ![Closed Trades](https://user-images.githubusercontent.com/5715919/133920059-a72972c8-18c4-4adb-9641-8dbe7ff3a14a.png) |
| ![Frontend Desktop](https://user-images.githubusercontent.com/5715919/137472148-7be1e19b-3ce5-4d5a-aa28-18c55b3b48aa.png) | ![Closed Trades](https://user-images.githubusercontent.com/5715919/137472190-a4c6ef0f-3399-44bb-852f-eedb7c67d629.png) |

### Sample Trade

Expand Down
17 changes: 15 additions & 2 deletions README.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ Then the bot will execute 2nd purchase for the coin. The last buy price will be

- Final last buy price: ($50 + $100)/(0.5 COIN + 1.29 COIN) = $83.80

##### In-depth Buy Configuration in-depth

The detailed document for buy configuration available here.

[https://github.com/chrisleekr/binance-trading-bot/wiki/Buy-Scenario](https://github.com/chrisleekr/binance-trading-bot/wiki/Buy-Scenario)

### 卖出信号

If there is enough balance for selling and the last buy price is recorded in the bot, then the bot will start monitoring the sell signal of the grid trade #1. Once the current price reaches the trigger price of the grid trade #1, then the bot will place a STOP-LOSS-LIMIT order to sell. If the current price continuously rises, then the bot will cancel the previous order and re-place the new STOP-LOSS-LIMIT order with the new price.
Expand Down Expand Up @@ -225,6 +231,12 @@ The final profit would be
- 2nd sell: $87.21 * 0.895 = $78.05295
- Final profit: $162 (8% profit)

##### In-depth Sell Configuration

The detailed document for buy configuration available here.

[https://github.com/chrisleekr/binance-trading-bot/wiki/Sell-Scenario](https://github.com/chrisleekr/binance-trading-bot/wiki/Sell-Scenario)

### [功能](https://github.com/chrisleekr/binance-trading-bot/wiki/Features)

- 手动交易
Expand All @@ -233,6 +245,7 @@ The final profit would be
- 同时监控多个硬币
- 止损
- 限制最高价格的购买次数
- Integrated with TradingView Technical Analysis

### 前端 + WebSocket

Expand Down Expand Up @@ -318,15 +331,15 @@ The final profit would be

| Password Protected | Frontend Mobile |
| ------------------ | --------------- |
| ![Password Protected](https://user-images.githubusercontent.com/5715919/133920104-49d1b590-c2ba-46d7-a294-eb6b24b459f5.png) | ![Frontend Mobile](https://user-images.githubusercontent.com/5715919/133920081-ce7da519-136a-4aca-841e-a85a9a5b249e.png) |
| ![Password Protected](https://user-images.githubusercontent.com/5715919/133920104-49d1b590-c2ba-46d7-a294-eb6b24b459f5.png) | ![Frontend Mobile](https://user-images.githubusercontent.com/5715919/137472107-4059fcdf-5174-4282-81af-80cea5b269a0.png) |

| Setting | Manual Trade |
| ------- | ------------ |
| ![Setting](https://user-images.githubusercontent.com/5715919/127318581-4e422ac9-b145-4e83-a90d-5c05c61d6e2f.png) | ![Manual Trade](https://user-images.githubusercontent.com/5715919/127318630-f2180e1b-3feb-48fa-a083-4cb7f90f743f.png) |

| Frontend Desktop | Closed Trades |
| ----------------- | ------------- |
| ![Frontend Desktop](https://user-images.githubusercontent.com/5715919/133920034-0889f631-f11c-4463-8f7f-39af070df60a.png) | ![Closed Trades](https://user-images.githubusercontent.com/5715919/133920059-a72972c8-18c4-4adb-9641-8dbe7ff3a14a.png) |
| ![Frontend Desktop](https://user-images.githubusercontent.com/5715919/137472148-7be1e19b-3ce5-4d5a-aa28-18c55b3b48aa.png) | ![Closed Trades](https://user-images.githubusercontent.com/5715919/137472190-a4c6ef0f-3399-44bb-852f-eedb7c67d629.png) |

### Sample Trade

Expand Down
30 changes: 18 additions & 12 deletions app/cronjob/__tests__/trailingTrade.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,6 @@ describe('trailingTrade', () => {
quoteAssetBalance: { quoteAsset: 'balance' },
buy: { should: 'buy?', actioned: 'yes' },
sell: { should: 'sell?', actioned: 'yes' },
order: {},
saveToCache: true,
overrideAction: { action: 'override-action' },
ensureManualOrder: { ensured: 'manual-buy-order' },
ensureGridTradeOrder: { ensured: 'grid-trade' },
Expand All @@ -341,6 +339,9 @@ describe('trailingTrade', () => {
cancelOrder: { cancelled: 'existing-order' },
stopLoss: 'processed',
removed: 'last-buy-price',
order: {},
canDisable: true,
saveToCache: true,
saved: 'data-to-cache'
}
},
Expand All @@ -367,8 +368,6 @@ describe('trailingTrade', () => {
quoteAssetBalance: { quoteAsset: 'balance' },
buy: { should: 'buy?', actioned: 'yes' },
sell: { should: 'sell?', actioned: 'yes' },
order: {},
saveToCache: true,
overrideAction: { action: 'override-action' },
ensureManualOrder: { ensured: 'manual-buy-order' },
ensureGridTradeOrder: { ensured: 'grid-trade' },
Expand All @@ -377,6 +376,9 @@ describe('trailingTrade', () => {
cancelOrder: { cancelled: 'existing-order' },
stopLoss: 'processed',
removed: 'last-buy-price',
canDisable: true,
order: {},
saveToCache: true,
saved: 'data-to-cache'
}
},
Expand All @@ -403,8 +405,6 @@ describe('trailingTrade', () => {
quoteAssetBalance: { quoteAsset: 'balance' },
buy: { should: 'buy?', actioned: 'yes' },
sell: { should: 'sell?', actioned: 'yes' },
order: {},
saveToCache: true,
overrideAction: { action: 'override-action' },
ensureManualOrder: { ensured: 'manual-buy-order' },
ensureGridTradeOrder: { ensured: 'grid-trade' },
Expand All @@ -413,6 +413,9 @@ describe('trailingTrade', () => {
cancelOrder: { cancelled: 'existing-order' },
stopLoss: 'processed',
removed: 'last-buy-price',
canDisable: true,
order: {},
saveToCache: true,
saved: 'data-to-cache'
}
},
Expand Down Expand Up @@ -703,9 +706,10 @@ describe('trailingTrade', () => {
cancelOrder: { cancelled: 'existing-order' },
stopLoss: 'processed',
removed: 'last-buy-price',
saved: 'data-to-cache',
order: {},
saveToCache: true
canDisable: true,
saveToCache: true,
saved: 'data-to-cache'
}
},
'TrailingTrade: Finish process...'
Expand Down Expand Up @@ -739,9 +743,10 @@ describe('trailingTrade', () => {
cancelOrder: { cancelled: 'existing-order' },
stopLoss: 'processed',
removed: 'last-buy-price',
saved: 'data-to-cache',
order: {},
saveToCache: true
canDisable: true,
saveToCache: true,
saved: 'data-to-cache'
}
},
'TrailingTrade: Finish process...'
Expand Down Expand Up @@ -775,9 +780,10 @@ describe('trailingTrade', () => {
cancelOrder: { cancelled: 'existing-order' },
stopLoss: 'processed',
removed: 'last-buy-price',
saved: 'data-to-cache',
order: {},
saveToCache: true
canDisable: true,
saveToCache: true,
saved: 'data-to-cache'
}
},
'TrailingTrade: Finish process...'
Expand Down
Loading

0 comments on commit 9d68735

Please sign in to comment.