TalaRad is a modular, class-based Telegram bot that provides real-time gold price information, investment advice, and price calculations for buying and selling gold. The project fetches data from external APIs and presents actionable investment insights via a user-friendly Telegram interface. Currently, only the Telegram interface is implemented. Contributors are welcome to develop additional interfaces (e.g., web or mobile) that leverage the core logic.
- Overview
- Features
- Installation
- Configuration
- Usage
- Project Structure
- Dependencies
- Contributing
- License
- Acknowledgments
TalaRad is designed to help investors obtain up-to-date information on gold prices and make informed investment decisions. The bot retrieves data on:
- Iranian Gold Price: Price per gram of Iranian gold.
- Coin Price (GCHEMM): Local gold coin price.
- USD Price: Current US Dollar price.
- International Gold Price (XAU): Global gold price data.
Using this data, the bot calculates a ratio (coin price divided by gold price) and provides investment advice (in Persian) along with detailed reasons. It also performs calculations for final buying and selling prices based on user inputs such as gold weight and wage percentage.
- Real-Time Data: Fetches current prices from external APIs.
- Investment Advice: Provides personalized recommendations (e.g., "Buy Coin", "Hold", "Buy Gold") in Persian based on the computed ratio.
- Price Calculations: Calculates final buying and selling prices using custom formulas.
- Modular, Class-Based Design: Organized into separate modules for price fetching, business logic, Telegram interface, and utilities.
- Extensible Interface: Currently, only the Telegram interface is implemented. Additional interfaces can be developed by contributors.
- Environment-Based Configuration: Uses environment variables to manage sensitive data such as the Telegram bot token.
Clone the repository and set up the environment. Run the following commands in your terminal:
git clone https://github.com/pooyeshtorabi/TalaRad.git
cd TalaRad
python -m venv venv
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate
pip install -r requirements.txt
- Create a file named
.envin the project root directory. - Add your Telegram bot token to the
.envfile:
TELEGRAM_TOKEN=your_telegram_bot_token_here
The config.py file will automatically load these environment variables using python-dotenv.
To run the bot, execute the following command:
python main.py
Then, open Telegram and start a conversation with your bot. Use the /start command to receive a welcome message. Available options include:
- Ψ±Ψ§ΩΩΩ Ψ§Ϋ Ψ³Ψ±Ω Ψ§ΫΩβΪ―Ψ°Ψ§Ψ±Ϋ π‘: Get investment advice.
- Ω ΨΨ§Ψ³Ψ¨Ω ΩΫΩ Ψͺ Ψ·ΩΨ§π°: Calculate buying/selling prices.
- ΩΩ Ψ§ΫΨ΄ ΩΫΩ ΨͺβΩΨ§ π: View current price data.
The project is organized into distinct modules for clear separation of concerns:
my_bot/
βββ .env // Environment variables file
βββ config.py // Loads environment variables
βββ main.py // Entry point for the application
βββ price/
β βββ __init__.py // Price module initializer
β βββ price_api.py // Contains the PriceAPI class for fetching prices
βββ logic/
β βββ __init__.py // Logic module initializer
β βββ investment.py // Contains the InvestmentAdvisor class for investment advice
β βββ calculator.py // Contains the Calculator class for price calculations
βββ telegram/
β βββ __init__.py // Telegram package initializer
β βββ bot.py // Contains the TelegramBotInterface class
β βββ handlers/
β βββ __init__.py // Handlers package initializer
β βββ main_handlers.py // Registers all Telegram message handlers
βββ utils/
βββ __init__.py // Utilities package initializer
βββ state_manager.py // Contains the StateManager class for user state management
The project requires the following Python packages:
All dependencies are specified in the requirements.txt file.
Contributions are welcome! This project is modular, and currently only the Telegram interface is implemented. Contributors are encouraged to develop additional interfaces (e.g., web or mobile) or extend existing functionality. To contribute:
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Follow the project's coding style, and include detailed docstrings and comments.
- Submit a pull request with a detailed description of your changes.
For major changes, please open an issue first to discuss your ideas.
This project is licensed under the MIT License.
Developed by PooyeshTorabi with βοΈ & β€οΈ
Enjoy using TalaRad and happy coding!

