Skip to content

Commit

Permalink
Merge pull request #40 from patbaumgartner/master
Browse files Browse the repository at this point in the history
Major Refactoring
  • Loading branch information
brianleect authored Aug 16, 2021
2 parents f96d33c + 8df8893 commit cd1428a
Show file tree
Hide file tree
Showing 18 changed files with 982 additions and 696 deletions.
100 changes: 73 additions & 27 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Created by https://www.toptal.com/developers/gitignore/api/python,intellij,visualstudiocode
# Edit at https://www.toptal.com/developers/gitignore?templates=python,intellij,visualstudiocode

### Intellij ###
config.dev.yml

# Created by https://www.toptal.com/developers/gitignore/api/python,pycharm+all,intellij+all,visualstudiocode
# Edit at https://www.toptal.com/developers/gitignore?templates=python,pycharm+all,intellij+all,visualstudiocode

### Intellij+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

Expand Down Expand Up @@ -77,35 +80,78 @@ fabric.properties
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### Intellij Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
### Intellij+all Patch ###
# Ignores the whole .idea folder and all .iml files
# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360

.idea/

# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023

*.iml
modules.xml
.idea/misc.xml
*.ipr

# Sonarlint plugin
.idea/sonarlint

### PyCharm+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff

# AWS User-specific

# Generated files

# Sensitive or high-churn files

# Gradle

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr

# CMake

# Mongo Explorer plugin

# File-based project format

# IntelliJ

# mpeltonen/sbt-idea plugin

# JIRA plugin

# Cursive Clojure plugin

# Crashlytics plugin (for Android Studio and IntelliJ)

# Editor-based Rest Client

# Android studio 3.1+ serialized cache file

### PyCharm+all Patch ###
# Ignores the whole .idea folder and all .iml files
# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360


# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023


# Sonarlint plugin
# https://plugins.jetbrains.com/plugin/7973-sonarlint
.idea/**/sonarlint/

# SonarQube Plugin
# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
.idea/**/sonarIssues.xml

# Markdown Navigator plugin
# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
.idea/**/markdown-navigator.xml
.idea/**/markdown-navigator-enh.xml
.idea/**/markdown-navigator/

# Cache file creation bug
# See https://youtrack.jetbrains.com/issue/JBR-2257
.idea/$CACHE_FILE$

# CodeStream plugin
# https://plugins.jetbrains.com/plugin/12206-codestream
.idea/codestream.xml

### Python ###
# Byte-compiled / optimized / DLL files
Expand Down
5 changes: 1 addition & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.9.6-slim-buster as base
FROM python:3.9-slim-buster as base

# Setup env
ENV LANG C.UTF-8
Expand Down Expand Up @@ -45,6 +45,3 @@ USER bpauser
COPY --chown=bpauser:bpauser . /binance-pump-alerts/

ENTRYPOINT ["./entrypoint.sh", "python", "pumpAlerts.py"]

# Entrypoint for debugging purposes
# ENTRYPOINT ["tail", "-f", "/dev/null"]
109 changes: 56 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,82 +1,85 @@
# Binance-pump-alerts
# Binance Pump Alerts

Simple application which gets price data from binance API and sends telegram message based on parameters set used to detect pumps in Binance.
BPA is a simple application which gets the price data from Binance Spot or Futures API and sends Telegram messages based on parameters set used to detect pumps and dumps on the Binance Exchange.

Working demo telegram channel: https://t.me/binance_pump_alerts (Hosted on AWS ec2 running latest version 24/7)
[Demo Telegram Channel](https://t.me/binance_pump_alerts) hosted on AWS ec2 running the latest version 24/7.

![image](https://user-images.githubusercontent.com/63389110/128601355-4be90b36-5e54-4be6-bf85-00fc395645de.png)

## Usage
## Manual Setup

1. In command line run `pip install -r requirements.txt` while located at folder with code.
2. Get telegram bot token from @botfather https://t.me/BotFather
3. Get telegram chatId from @get_id_bot https://telegram.me/get_id_bot (Alternatively channel id can be used as well which is shown in demo)
4. Add pairs to watch into watchlist or leave it empty to monitor all tickers on binance
5. Run "pumpAlerts.py" with command `python pumpAlerts.py`
1. On the command-line, run the command `pip install -r requirements.txt` while located at folder with code.
1. Create a new telegram bot token from [@botfather](https://t.me/BotFather).
1. Get telegram `chat_id` from [@get_id_bot](https://telegram.me/get_id_bot).
- Alternatively, a `channel_id` can be used as well.
1. Add pairs to watch into the watchlist or leave it empty to monitor all tickers on Binance.
1. Run the script with the command `python pumpAlerts.py`.

## Docker Setup

### Mandatory Params

1. TelegramToken: Telegram bot telegramToken obtained from @BotFather
2. TelegramChatId: Bot will send message to this id, it can be a group or channel as well. To get personal telegramChatId, get it from @get_id_bot


## Main Customizable Params
1. Use environment variables in the `docker-compse.yml` file to provide your config.
- See `entrypoint.sh` for environment variable names and the config possibilities.
- You can also use a `.env` file during development.
- If changing the config parameters, you have to make sure that search and replace will place the right parameter in the `config.yml`
- Emojis are more tricky therefore defining it with some tricks e.g. `PUMP_EMOJI="! \"\\\\U0001F4B9\""`
1. On the command line run `docker-compose up -d --build` to create and run the docker image/container.

1. chartIntervals: Can be modified to consider other timeframes, follow the format of 's' for second, 'm' for minute, 'h' for hour
2. Outlier param: (0.01 -> 1% , 0.10 -> 10%), modify accordingly based on needs. Avoid setting it too low to avoid noise
3. extractInterval: Default '1s' , interval at which we get the price information from Binance
4. Pairs of interest: Default is USDT (Other options include BTC, ETH etc)
## Configuration

### Mandatory Params

### Alert Interval Params
1. `telegramToken`: The token obtained from[@botfather](https://t.me/BotFather).
2. `telegramChatId`: The bot will send the messages to this `chat_id`. It can be a group or channel as well.

1. hardAlertIntervalEnabled: (Main) Prevents triggering of same interval for the timeframe of the interval. E.g. '5m' triggers. Will not trigger intervals >= '5m' for 5 minutes. Other intervals < '5m' such as '1s' , '5s' will continue being triggered.
2. HardAlertMin: (Legacy) Set hardAlertIntervalEnabled to false to enable this. Does not trigger another alert within same pair for the specified duration
## Main Customizable Params

1. `chartIntervals`: Can be modified to consider other timeframes, follow the format of 's' for seconds, 'm' for minutes, 'h' for hours.
1. `outlierIntervals`: (0.01 -> 1% , 0.1 -> 10%), modify accordingly based on needs. Avoid setting it too low to avoid noise.
1. `extractInterval`: Default is `1s`, Interval at which we retrieve the price information from Binance.
1. `pairsOfInterest`: Default is _USDT_. Other options include BUSD, BTC, ETH etc.
1. `topReportIntervals`: Default is `1h`,`3h`and `6h` Intervals for top pump and dump reports to be sent, ensure it is in chartIntervals + outlierIntervals as well.

### Optional features to enable

1. Watchlist: Default if left empty it'll look at ALL symbols after filtering by pairs of interest. If pairs are added to watchlist, program will **only track the pairs specified**.
2. FuturesEnabled: If true program will monitor **future** market else it will monitor **spot** market.
3. DumpEnabled: If true program will alert on **DUMP** as well.
1. `watchlist`: Default if left empty it'll look at ALL symbols after filtering by pairs of interest. If pairs are added to the watchlist, the application will _only track the pairs specified_.
1. `dumpEnabled`: If `True`, the application will alert on dumps as well.

#### Top Pump & Dump Params

1. TopPumpEnabled: If true program will send top X pumps at defined interval
2. TopDumpEnabled: If true program will send top X dumps at defined interval (Together with pump information if enabled)
3. ViewNumber: Top X amount of coins shown, adjust to show more or less within the timeframe
4. TelegramAlertChatId: Insert Chat ID for top pump dump alert, if left at 0 it'll send to telegramChatId
1. `topPumpEnabled`: If `True`, the application will send the Top X pumps at the defined interval.
1. `topDumpEnabled`: If `True`, the application will send the Top X dumps at the defined interval.
- Together with pump information, if enabled.
1. `noOfReportedCoins`: Top X amount of coins shown, adjust to show more or less within the timeframe.
1. `telegramAlertChatId`: Insert the alert chat_id for top pump dump alert, if left at `0`, it'll send messages to the telegram `chat_Id`.
For params not indicated above, refer to comments besides parameter for its use.

#### Debug Params (Avoid modifying if possible)
1. Debug: Default 'False', only enable for debugging. Logging set to info level message and above
2. ResetInterval: Default '12h', clears the array used to store data points to prevent MEM ERROR
3. priceRetryInterval: Default '1s' # In the case of get price fail, this is the time delay before re-attempt
4. telegramRetryInterval: Default '1s' # If telegram message fails to send, this is the time delay before re-attempt
5. tdpaInitialBuffer: Default '5m' # Initial buffer before we trigger TDPA. Prevents all 0% output due to lack of data points
6. checkNewListingEnabled: True # Disables checking and adding of new listing pairs.

#### Debug Params (Avoid modifying if possible!)

---
1. `debug`: Default is `False`. Please, only enable for debugging purposes. Default logging set to info level.
1. `resetInterval`: Default `12h`. It clears the array used to store data price points to prevent memory issues.
1. `priceRetryInterval`: Default `5s`. In the case of get price fail, this is the time delay before re-attempt
1. `telegramRetryInterval`: Default `2s` # If telegram message fails to send, this is the time delay before re-attempt.
1. `checkNewListingEnabled`: Default `True`. Enables checking and adding of new listing pairs.

## Todo

1. Integrate with binance API to make trades on pumps
2. Integrate with listing-predictor to monitor movements for potential listings
1. Integrate with Binance API to make trades on pumps.
1. Integrate with Binance Websocket API to get volume information.
1. Integrate with listing-predictor to monitor movements for potential listings.

## Completed features

1. Telegram integration
2. Price Update every 1s
3. Adjustable alert % param
4. Watchlist feature
5. Monitor future markets
6. Optional alert on dumps
7. Customizable minimum alert interval for spam prevention
8. Option to disable print debugs on extraction
9. [Test] Volume Change Updates (TEST_VOL version)
10. Allows long period of running without MEM ERROR
11. Send periodic Top X dumped / pumped coins
12. Docker Integration (Thanks to @patbaumgartner)
13. Logging Integration (Thanks to @patbaumgartner)
1. Price update every 1s
1. Adjustable alert % param (outliers)
1. Watchlist feature
1. Monitor future markets
1. Optional alert on dumps
1. Customizable minimum alert interval for spam prevention
1. Option to disable print debugs on extraction
1. [Test] Volume Change Updates (TEST_VOL version)
1. Allows long period of running without memory issues
1. Send periodic Top X Pump & Dump reports
1. Docker integration (Thanks to [@patbaumgartner](https://github.com/patbaumgartner))
1. Logging integration (Thanks to [@patbaumgartner](https://github.com/patbaumgartner))
1. Major Refactoring and cleanup (Thanks to [@patbaumgartner](https://github.com/patbaumgartner))
Loading

0 comments on commit cd1428a

Please sign in to comment.