Skip to content

Commit

Permalink
Merge pull request chrisleekr#5 from chrisleekr/upgrade-with-frontend
Browse files Browse the repository at this point in the history
- Removed unused methods - Bollinger Bands, MACD Stop Chaser
- Support maximum purchase amount per symbol
- Develop backend to send cache values for frontend
- Develop simple frontend to see statistics
  • Loading branch information
chrisleekr authored Feb 5, 2021
2 parents e9510e3 + f1020b4 commit 2c749f1
Show file tree
Hide file tree
Showing 90 changed files with 8,073 additions and 21,562 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ indent_size = 2
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 120
max_line_length = 150
9 changes: 5 additions & 4 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
module.exports = {
printWidth: 120,
printWidth: 80,
tabWidth: 2,
useTabs: false,
semi: true,
singleQuote: true,
trailingComma: 'none',
bracketSpacing: true,
jsxBracketSameLine: false,
jsxBracketSameLine: true,
arrowParens: 'avoid',
proseWrap: 'never',
proseWrap: 'always',
htmlWhitespaceSensitivity: 'strict',
endOfLine: 'lf'
endOfLine: 'lf',
jsxSingleQuote: true
};
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ RUN npm install

COPY . .

EXPOSE 3000
EXPOSE 80
EXPOSE 81

CMD [ "npm", "run", "dev" ]

Expand All @@ -37,4 +38,7 @@ WORKDIR /srv

COPY --from=build-stage /srv /srv

EXPOSE 80
EXPOSE 81

CMD [ "npm", "start"]
94 changes: 58 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,56 +1,62 @@
# Binance Auto Trading Bot

[![Build](https://github.com/chrisleekr/binance-trading-bot/workflows/main/badge.svg)](https://github.com/chrisleekr/binance-trading-bot/actions?query=workflow%3Amain) [![CodeCov](https://codecov.io/gh/chrisleekr/binance-trading-bot/branch/master/graph/badge.svg)](https://codecov.io/gh/chrisleekr/binance-trading-bot) [![MIT License](https://img.shields.io/github/license/chrisleekr/binance-trading-bot)](https://github.com/chrisleekr/binance-trading-bot/blob/master/LICENSE)
[![Build](https://github.com/chrisleekr/binance-trading-bot/workflows/main/badge.svg)](https://github.com/chrisleekr/binance-trading-bot/actions?query=workflow%3Amain)
[![CodeCov](https://codecov.io/gh/chrisleekr/binance-trading-bot/branch/master/graph/badge.svg)](https://codecov.io/gh/chrisleekr/binance-trading-bot)
[![MIT License](https://img.shields.io/github/license/chrisleekr/binance-trading-bot)](https://github.com/chrisleekr/binance-trading-bot/blob/master/LICENSE)

This is a test project. I am just testing my code. **I cannot guarantee whether you can make money or not.**
This is a test project. I am just testing my code. **I cannot guarantee whether
you can make money or not.**

**So use it at your own risk! I have no responsibility for any loss or hardship incurred directly or indirectly by using this code.**
**So use it at your own risk! I have no responsibility for any loss or hardship
incurred directly or indirectly by using this code.**

## How it works

### Simple-Stop-Chaser

This method is buying at lowest price without any indicator, never sell under purchase price. And chase rising money. I have found MACD indicators often mislead buying signal. In box pattern market, buy signal with lowest price is effective than using MACD indicators.
This method is buying at lowest price without any indicator, never sell under
purchase price. And chase rising money. Stop chaser methodology was the idea
from [@d0x2f](https://github.com/d0x2f). I have found MACD indicators often
mislead buying signal. In box pattern market, buy signal with lowest price is
effective than using MACD indicators.

**This method can monitor multiple symbols.**
#### Note

- This method is only tested and working with USDT pair in the FIAT market such
as BTCUSDT, ETHUSDT.
- This method can monitor multiple symbols.

#### Process

1. Get next symbol

2. Detect buy signal

- Get lowest closed price with period
- If current closed price is lower than lowest closed price, then **buy NOW.**
- If current closed price is higher than lowest closed price, then _do not buy._
- If current closed price is lower than lowest closed price, then **buy
NOW.**
- It will only purchase maximum purchase amount or less.
- It will not purchase if base asset, such as BTC, has enough balance to
place stop loss limit order.
- If current closed price is higher than lowest closed price, then _do not
buy._

3. Chase Stop-Loss-Limit order

- If there is no open order but have coins that bought by the buy signal, then check
- If there is no open order but have coins that bought by the buy signal,
then check
- Get last purchase price
- If current closed price is higher than minimum profit percentage \* last purchase price, then **place Stop-Loss-Limit order.**
- If current closed price is higher than minimum profit percentage \* last
purchase price, then **place Stop-Loss-Limit order.**
- Otherwise, _do not place Stop-Loss-Limit order._
- If there is an open Stop-Loss-Limit order, then check current closed price.
- If current closed price is higher than stop price, then cancel the open order. So it can be place new Stop-Loss-Limit order.

### MACD-Stop-Chaser

The concept of MACD-Stop-Chaser is simple. Buy at low price, never sell under purchase price. Chase rising money. Stop chaser methodology was the idea from [@d0x2f](https://github.com/d0x2f)
- If current closed price is higher than stop price, then cancel the open
order. So it can be place new Stop-Loss-Limit order.

1. Detect buy signal

- Get previous MACD trend (Rising/Falling or Unknown)
- Get last two MACD trend (All rising or all falling)
- If previous MACD trend is falling and last two MACD trend is all rising, then check
- If current closed price is higher than lowest price within 24 hours, then _do not buy._
- If current closed price is lower or similar than lowest price within 24 hours, then **buy NOW.**
## Environment Parameters

2. Chase Stop-Loss-Limit order

- If there is no open order but have coins that bought by the buy signal, then check
- Get last purchase price
- If current closed price is higher than minimum profit percentage \* last purchase price, then **place Stop-Loss-Limit order.**
- Otherwise, _do not place Stop-Loss-Limit order._
- If there is an open Stop-Loss-Limit order, then check current closed price.
- If current closed price is higher than stop price, then cancel the open order. So it can be place new Stop-Loss-Limit order.
Use environment parameter to adjust parameters. Checkout
`/config/custom-environment-variables.json`

## How to use

Expand All @@ -72,25 +78,41 @@ The concept of MACD-Stop-Chaser is simple. Buy at low price, never sell under pu

[![asciicast](https://asciinema.org/a/371137.png)](https://asciinema.org/a/371137)

## Environment Parameters
4. Open browser `http://0.0.0.0:8080` to see frontend statistics

## Frontend + WebSocket

React.js based frontend communicating via Web Socket

- List monitoring coins with buy/sell signals
- Manage settings

| Frontend Mobile | Setting |
| --------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| ![Screenshot1](https://user-images.githubusercontent.com/5715919/106989986-77250600-67c7-11eb-97c7-3383dccd45b4.jpeg) | ![Screenshot2](https://user-images.githubusercontent.com/5715919/106989983-75f3d900-67c7-11eb-94f0-fdf6d3256c11.jpeg) |

Use environment parameter to adjust parameters. Checkout `/config/custom-environment-variables.json`
| Frontend Desktop |
| ------------------------------------------------------------------------------------------------------------------- |
| ![Screenshot](https://user-images.githubusercontent.com/5715919/106990244-f6b2d500-67c7-11eb-8f63-9603649f9d7d.png) |

## Trades

### First trade

| Chart | Order History |
| --- | --- |
| Chart | Order History |
| -------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| ![Screenshot1](https://user-images.githubusercontent.com/5715919/99874214-f7f94a80-2c39-11eb-9f6d-92fa7b4cb000.jpeg) | ![Screenshot2](https://user-images.githubusercontent.com/5715919/99874212-f465c380-2c39-11eb-8185-dce0d6d21e27.jpeg) |

### Last 30 days trade

| Trade History | PNL Analysis |
| --- | --- |
| Trade History | PNL Analysis |
| -------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| ![Screenshot3](https://user-images.githubusercontent.com/5715919/104917671-d4f3d880-59e7-11eb-87ea-b73a8e75f725.jpg) | ![Screenshot4](https://user-images.githubusercontent.com/5715919/104917674-d6250580-59e7-11eb-911f-9d5491fdfdcb.jpg) |

## Todo

- [x] Support multiple symbols
- [ ] Frontend to see statistics
- [x] Removed unused methods - Bollinger Bands, MACD Stop Chaser
- [x] Support maximum purchase amount per symbol
- [x] Develop backend to send cache values for frontend
- [x] Develop simple frontend to see statistics
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"configuration": "{\"enabled\":true,\"cronTime\":\"* * * * * *\",\"symbols\":[\"BTCUSDT\",\"ETHUSDT\",\"LTCUSDT\",\"XRPUSDT\",\"BNBUSDT\"],\"candles\":{\"interval\":\"1d\",\"limit\":6},\"maxPurchaseAmount\":104,\"stopLossLimit\":{\"lastBuyPercentage\":2.01,\"stopPercentage\":1.99,\"limitPercentage\":1.98}}",
"account-info": "{\"makerCommission\":0,\"takerCommission\":0,\"buyerCommission\":0,\"sellerCommission\":0,\"canTrade\":true,\"canWithdraw\":false,\"canDeposit\":false,\"updateTime\":1612477745287,\"accountType\":\"SPOT\",\"balances\":[{\"asset\":\"BTC\",\"free\":\"0.00089800\",\"locked\":\"0.79411700\"},{\"asset\":\"BUSD\",\"free\":\"10000.00000000\",\"locked\":\"0.00000000\"},{\"asset\":\"ETH\",\"free\":\"0.09648000\",\"locked\":\"95.66082000\"},{\"asset\":\"LTC\",\"free\":\"0.50000000\",\"locked\":\"499.50000000\"},{\"asset\":\"TRX\",\"free\":\"500000.00000000\",\"locked\":\"0.00000000\"},{\"asset\":\"USDT\",\"free\":\"193479.92919565\",\"locked\":\"0.00000000\"},{\"asset\":\"XRP\",\"free\":\"50.00000000\",\"locked\":\"46115.50000000\"}],\"permissions\":[\"SPOT\"]}",
"last-processed": "{\"timeUTC\":\"2021-02-04T22:37:39.002Z\",\"symbol\":\"XRPUSDT\"}",
"last-symbol": "XRPUSDT"
}
Loading

0 comments on commit 2c749f1

Please sign in to comment.