Skip to content

Repository files navigation

Python Jupyter TensorFlow Binance Telegram Discord

📈 Time-Series Forecasting & Crypto Analysis

Bots · Telegram · Discord · Binance

End-to-end crypto analytics, forecasting, and automation
Time-series ML (ARIMA, SARIMAX, LSTM), Binance spot & futures bots, Discord message relay, and Telegram tools — all in one repo.

OverviewFeaturesStructureTech StackGetting StartedUsageSecurity


📋 Overview

This repository is a unified toolkit for cryptocurrency analysis, time-series forecasting, and messaging automation. It combines:

Pillar Description
Crypto Task Time-series forecasting on Binance OHLCV data (e.g. ADA) with bottom-up segmentation, ARIMA, Auto ARIMA, SARIMAX, and LSTM — train/test on 2018–2019 vs 2020, with RMSE/MAE evaluation.
Discord Bot Listens to selected Discord channels via WebSocket and forwards messages (including image URLs) to another channel using the Discord HTTP API.
Telegram Chat Bot (tkinter UI for multi-group/channel links and per-user messages with delay) and Add Members (Telethon-based invite flow and session handling).
Trading Bots Spot and Futures bots on Binance using Heikin Ashi candles, trend detection (isUP), and market buy/sell (with optional leverage for futures).

Ideal for quant research, automated trading experiments, and community/messaging automation — all in Python with Jupyter notebooks and minimal config.


✨ Features

🔮 Time-Series & Forecasting (Crypto Task/)

  • Bottom-up segmentation — Line-fitting and piecewise approximation of price series (segment.py, fit.py, wrappers.py).
  • Classical models — ARIMA, Auto ARIMA, SARIMAX with seasonal decomposition and ADF tests.
  • Deep learning — LSTM (TensorFlow/Keras) for next-step and multi-step forecasting.
  • Evaluation — Train on 2018–2019, test on 2020; RMSE, MAE, and visualizations.
  • Multi-asset — Datasets for ADA, LINK, LTC, TRX, XRP (Binance USDT pairs, hourly and daily).

🤖 Discord Message Relay (Discord Messaging API Bot/)

  • Real-time listening — WebSocket connection to Discord Gateway; heartbeat and event handling.
  • Channel routing — Forward messages from specific channels (e.g. trades, active futures) to a target channel.
  • Rich content — Forwards text and attachment URLs (e.g. images).
  • Labeling — Optional prefixes like "This is from trades channel" / "This is from active futures channel".

📱 Telegram Tools

  • Chat Bot (Telegram_Chat_Bot.ipynb) — Tkinter UI to configure up to 5 group/channel links, per-user messages (e.g. Zeeshan, Chris, Reddit_Promoter, Simon), and a send delay.
  • Add Members (TelegramAddMembers/) — Telethon client, string sessions, and invite-to-channel flow with rate limiting and error handling.

📊 Binance Trading Bots

  • Spot (SpotTradeSheikhBot.ipynb) — Heikin Ashi candles, trend detection, market buy/sell on Binance Spot.
  • Futures (TradeBotFuturesUpdate.ipynb) — Same logic with leverage, futures klines, and long/short (UP_BUY/UP_SELL, DOWN_BUY/DOWN_SELL).
  • Heikin Ashi (Heiken Ashi.ipynb) — Binance client setup, balance/price checks, and HA candle utilities (e.g. BETAUSDT).

📁 Project Structure

.
├── Crypto Task/
│   ├── Computational Task.ipynb    # Full pipeline: segmentation, ARIMA, SARIMAX, LSTM
│   ├── segment.py                 # Bottom-up segmentation
│   ├── fit.py                     # Regression / interpolate segments
│   ├── wrappers.py                # Least-squares line fit
│   ├── homestatic.html            # Static landing template
│   ├── Binance_ADAUSDT_*.csv      # Sample ADA data
│   └── Datasets/
│       ├── ADA/, LINK/, LTC/, TRX/, XRP/
│       └── Binance_*USDT_1h.csv, Binance_*USDT_d.csv
├── Discord Messaging API Bot/
│   ├── discord.py                 # WebSocket + HTTP relay bot
│   └── README.md                  # Bot-specific setup
├── TelegramAddMembers/
│   ├── TelegramAddMembers.ipynb   # Telethon add-members flow
│   └── daud.py                    # Alternate Discord relay (reference)
├── SpotTradeSheikhBot.ipynb       # Binance spot + Heikin Ashi
├── TradeBotFuturesUpdate.ipynb   # Binance futures + Heikin Ashi
├── Heiken Ashi.ipynb              # Binance API + Heikin Ashi helpers
├── Telegram_Chat_Bot.ipynb        # Telegram multi-group UI (tkinter)
├── requirements.txt               # Python dependencies
└── README.md                      # This file

🛠 Tech Stack

Category Technologies
Language Python 3.7+
Notebooks Jupyter
Data & ML pandas, numpy, scipy, scikit-learn, statsmodels (ARIMA, SARIMAX, seasonal_decompose, adfuller), pmdarima (auto_arima), TensorFlow/Keras (LSTM)
Visualization matplotlib, seaborn
APIs Binance (python-binance: spot + futures, klines, orders), Discord (WebSocket gateway + REST), Telegram (Telethon)
Other requests, websocket-client, tkinter, PIL, nest_asyncio

🚀 Getting Started

Prerequisites

  • Python 3.7 or higher
  • Jupyter (for notebooks)
  • Binance API keys (for trading and optional data)
  • Discord bot/user token and channel IDs (for Discord bot)
  • Telegram API credentials (for Telegram tools)

Installation

  1. Clone the repository
git clone https://github.com/your-username/Time-Series-Forecasting-and-Crypto-Analysis-Bots-and-Telegram-Discord-Bots.git
cd Time-Series-Forecasting-and-Crypto-Analysis-Bots-and-Telegram-Discord-Bots
  1. Create a virtual environment (recommended)
python -m venv venv
source venv/bin/activate   # On Windows: venv\Scripts\activate
  1. Install dependencies
pip install -r requirements.txt

Tip: For a minimal setup (e.g. only the Discord relay), run:
pip install requests websocket-client


⚡ Quick reference

Time-series segmentation (Crypto Task):

import segment
import fit

# Bottom-up segmentation with linear regression and max_error threshold
segments = segment.bottomupsegment(
    sequence=close_prices,
    create_segment=fit.regression,
    compute_error=fit.sumsquared_error,
    max_error=1e-4
)

Discord relay (conceptual): Run python discord.py in Discord Messaging API Bot/ after setting your token and channel IDs — the script connects via WebSocket and forwards selected channel messages to a target channel.

Binance + Heikin Ashi (Spot bot): In SpotTradeSheikhBot.ipynb, instantiate TradeBot(user_key, secret_key, symbol), then use bot.isUP(interval='1h') for trend and bot.UP_BUY(quantity) / bot.UP_SELL(quantity) for market orders.


📖 Usage

1. Time-Series Forecasting (Crypto Task)

Open Crypto Task/Computational Task.ipynb and run the cells in order. The notebook:

  • Loads Binance-style OHLCV CSV (e.g. Binance_ADAUSDT_d.csv).
  • Runs bottom-up segmentation and classical + LSTM forecasting.
  • Uses 2018–2019 for training and 2020 for testing; reports RMSE/MAE.

Data: Place CSVs in Crypto Task/ or Crypto Task/Datasets/<SYMBOL>/. Schema: unix, date, symbol, open, high, low, close, Volume {ASSET}, Volume USDT, tradecount.

Quick run from project root:

cd "Crypto Task"
jupyter notebook "Computational Task.ipynb"

2. Discord Message Relay Bot

  1. Set your Discord tokens and channel IDs in Discord Messaging API Bot/discord.py (replace placeholders).
  2. Run:
cd "Discord Messaging API Bot"
python discord.py

The bot keeps a WebSocket connection, listens for messages in the configured channels, and posts them (with optional labels and image URLs) to the target channel via the Discord API.


3. Telegram Chat Bot (Multi-Group Messenger)

  1. Open Telegram_Chat_Bot.ipynb in Jupyter.
  2. Run all cells to launch the tkinter window.
  3. Enter up to 5 group/channel links and per-user messages (e.g. Zeeshan, Chris, etc.) and set the time delay.
  4. Use the UI to send messages to the configured groups.

4. Telegram Add Members

  1. Open TelegramAddMembers/TelegramAddMembers.ipynb.
  2. Configure API id, API hash, and phone (and optionally string session).
  3. Run the cells to connect via Telethon and use the invite-to-channel flow (respect Telegram rate limits).

5. Binance Spot Trading Bot

  1. Open SpotTradeSheikhBot.ipynb.
  2. Set your Binance API key and secret in the notebook.
  3. Choose a symbol (e.g. BTCUSDT).
  4. Run the notebook; the bot uses Heikin Ashi to determine trend (isUP) and places market buy/sell on Binance Spot.

6. Binance Futures Trading Bot

  1. Open TradeBotFuturesUpdate.ipynb.
  2. Set Binance API key, secret, symbol, and leverage.
  3. Run the notebook; the bot uses Heikin Ashi and places futures market orders (long/short).

7. Heikin Ashi & Binance API

Use Heiken Ashi.ipynb to:

  • Connect to Binance with your API keys.
  • Check balance (e.g. USDT) and symbol prices.
  • Build and inspect Heikin Ashi candles for any pair (e.g. BETAUSDT).

🔐 Security

  • Never commit real API keys, secrets, or tokens. Use environment variables or a local config file listed in .gitignore.
  • Replace all placeholders in code (e.g. token of the user..., channel id) before running.
  • Discord and Telegram credentials grant access to your accounts; keep them private and rotate if exposed.
  • Binance keys can move funds; use restricted keys (e.g. trading-only, no withdrawals) for bots.

📄 License

This project is provided as-is. If you use or adapt it, please attribute the source and comply with any applicable terms for third-party APIs (Binance, Discord, Telegram).


🤝 Contributing

Contributions are welcome. Please open an issue first to discuss changes, then submit a pull request. Ensure code style and tests (if any) are consistent with the project.


⭐ If this repo helps you, consider giving it a star.

Built with Python · Jupyter · Binance · Discord · Telegram

About

Cryptocurrency price forecasting (ARIMA, LSTM, Prophet) with automated Telegram and Discord trading bots

Topics

Resources

Stars

4 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages