Blog PyBot

Configuring Logging in Python Scripts

Logging is crucial for debugging and monitoring code execution in applications.

Read more

Making a mini-game in Telegram: Bot for collecting resources and fighting

Script description: This Python script implements a Telegram bot for a simple mini-game where players collect resources, upgrade their character, fight enemies, view rewards, referrals, and spin a wheel of fortune. Uses the python-telegram-bot library to handle commands and buttons. Startup instructions: Install python-telegram-bot: pip install python-telegram-bot. Replace "your_token" with the real token from BotFather. Run the script: python script.py. In Telegram, type /start to start the game.

Read more

AI Trading Bot: Developing an Algorithm for Long Trades in Python Using CCXT (Machine Learning for Trading: Predicting Trend Reversals in the Crypto Market)

Script description: The script downloads OHLCV data from Binance for the specified pair (e.g. BTC-USDT), adds technical indicators (RSI, SMA, ATR, etc.), trains the RandomForestClassifier model to predict a sustainable price increase (target: 3 candles increase). Uses SMOTE for class balance. If the model exists, downloads it; otherwise, trains it. Predicts the probability of entering a long (>70% - signal). Recommendations for running: Install Python 3.12+ and libraries: pandas, numpy, scikit-learn, imblearn, joblib, ccxt, logging. Create settings.ini with sections [SETTINGS_PAIR] (count_day, pair) and [BINANCE] (api_key, secret if needed). Create a "models" folder to store the models. Run the script: python script.py. Make sure you have a connection to the Binance API. Logs in the console.

Read more

Export all Bitcoin historical candles from Binance

Simple Python script on CCXT to download BTC/USDT OHLCV data since August 1, 2017, with logging and saving to JSON

Read more

Automatically relay messages to Telegram from a selected channel by key phrase: Telethon script for monitoring and forwarding

The script using Telethon monitors the selected Telegram chat, detects messages with the keyphrase from the config, processes the text (removes '/' and '💵') and forwards to the target chat. Includes logging, chat selection via console and error handling. Additional preparations for use Install the libraries: pip install telethon configparser psutil. Create a settings.ini file with sections: [API_TELEGRAMM]: api_id=YOUR_ID, api_hash=YOUR_HASH (get it from my.telegram.org). [SETTINGS]: start_say=KEYPHRASES (for the message trigger). Run the script in the console to authorize and select chats. Where to get anon.session The anon.session file is generated automatically the first time you run the script and successfully authorize in Telegram (enter your phone number and code). Stored in the script directory. If missing, the script will ask for login. Do not share the file - it contains the account session.

Read more

Binance Auto Trader: Creating a Crypto Bot Using CCXT (Detecting Drawdowns on a Positive Trend)

Brief Description This is a Binance spot trading bot built on the CCXT library. It analyzes thousands of USDT-quoted pairs, filtering by daily volume (minimum 10 million USDT), identifies positive trends on hourly candles and enters positions when there is a drawdown of more than 2% from the SMA on the minute chart. The bot automatically places orders with a fixed take profit (+1%) and stop loss (-3%), managing risks based on the deposit or configuration. Ideal for automating strategies in a volatile crypto market, with support for a test mode for safe testing. This bot is provided for informational and educational purposes only. Cryptocurrency trading on Binance or any other platform involves significant financial risks, including possible loss of all capital. Do not use this code for real trading without thorough testing and understanding of how it works. The author and developer do not bear any responsibility for any losses incurred as a result of using this bot. Use at your own risk.

Read more

Creating a Crypto Bot Using CCXT (to capture the upper shadows of candles on a positive trend)

Brief Description of the Bot This is a Binance spot trading bot implemented on the CCXT library. It scans USDT spot pairs, filtering by daily volume (minimum 10 million USDT), identifies positive trends on hourly candles and focuses on pairs with the highest volume and trend strength. A position is entered when the upper shadow of a candle is detected more than 3% of SMA3 on a minute chart, with an immediate market buy, fixed take profit (+1%) and stop loss (-3%). The bot dynamically manages the number of simultaneous trades based on the deposit or configuration, providing risk management in a volatile cryptocurrency market. Supports a test mode for safe experimentation. This bot is provided for informational and educational purposes only. Cryptocurrency trading on the Binance exchange or any other platform involves significant financial risks, including the possible loss of all capital. Do not use this code for real trading without careful testing and understanding of its operation. The author and developer do not bear any responsibility for any losses incurred as a result of using this bot. Use at your own risk.

Read more