emrpy
- class emrpy.TelegramTradingBot(bot_token, chat_id, chat_name=None)
Bases:
objectLightweight Telegram bot for trading notifications.
Features:
Async-first design for minimal latency impact
Simple message sending
Formatted trade alerts with emoji
Bulk notifications support
Built-in error handling and logging
- async send_bulk_notifications(messages, parse_mode=None, disable_notification=False)
Send multiple messages concurrently to improve throughput.
- Return type:
List[bool]
Parameters:
- messagesList[str]
List of message texts to send.
- parse_modeOptional[str], default None
Formatting mode for all messages: ‘HTML’ or ‘Markdown’.
- disable_notificationbool, default False
If True, send all messages silently without notification sound.
Returns:
: List[bool]
List of booleans indicating success status for each message.
Examples:
>>> statuses = await bot.send_bulk_notifications( ... ["Alert 1", "Alert 2"], ... parse_mode="HTML" ... )
- async send_message(text, parse_mode=None, disable_notification=False)
Send a text message to the configured Telegram chat asynchronously.
- Return type:
bool
Parameters:
- textstr
Content of the message to send.
- parse_modeOptional[str], default None
Formatting mode: ‘HTML’ or ‘Markdown’. No formatting if None.
- disable_notificationbool, default False
If True, send silently without notification sound.
Returns:
: bool
True if the message was sent successfully; False otherwise.
Examples:
>>> success = await bot.send_message( ... "Bot is now live 🚀", ... parse_mode="Markdown" ... )
- async send_trade_alert(symbol, action, price, quantity, profit_loss=None, disable_notification=False)
Send a formatted trade alert with structured layout and emoji indicators.
- Return type:
bool
Parameters:
- symbolstr
Trading symbol (e.g., ‘BTCUSD’, ‘AAPL’).
- actionstr
Trade action: ‘BUY’, ‘SELL’, or ‘CLOSE’.
- pricefloat
Execution price of the trade.
- quantityfloat
Quantity or size of the trade.
- profit_lossOptional[float], default None
Profit or loss amount; if provided, shows 📈 for profit or 📉 for loss.
- disable_notificationbool, default False
If True, send silently without notification sound.
Returns:
: bool
True if the alert was sent successfully; False otherwise.
Examples:
>>> await bot.send_trade_alert( ... symbol="ETHUSD", ... action="BUY", ... price=1820.50, ... quantity=1.2, ... profit_loss=45.75 ... )
- emrpy.get_root_path(fallback_levels=0)
Resolve a root-like path from the current working directory.
- Return type:
Path
Parameters:
- fallback_levelsint, default 0
Number of parent directories to ascend from the current working directory (CWD). Must be >= 0. When 0, returns the resolved CWD.
Returns:
: Path
Absolute path obtained after moving up fallback_levels parents from the resolved CWD.
Notes:
- Typical usage:
Scripts: fallback_levels=0 usually suffices because scripts are run from the repository root (so CWD is already the root).
Notebooks: CWD is the notebook’s folder. Set fallback_levels to the depth from the notebook folder to the project root. Example: for <repo>/notebooks/notebook.ipynb, use fallback_levels=1 to return <repo>.
Examples:
>>> # CWD: /home/user/project/subdir >>> get_root_path() PosixPath('/home/user/project/subdir') >>> get_root_path(fallback_levels=1) PosixPath('/home/user/project')
Modules
Function Decorators |
|
Telegram Trading Bot Module |
|