emrpy
- class emrpy.TelegramTradingBot(bot_token, chat_id, chat_name=None)
Bases:
object
Lightweight Telegram bot for trading notifications.
Features:
Async-first design for minimal latency impact
Simple message sending
Formatted trade alerts
Bulk notifications support
Built-in error handling and logging
- async send_bulk_notifications(messages, parse_mode=None, disable_notification=False)
Send multiple messages concurrently for better performance.
- Parameters:
messages (
List
[str
]) – List of message texts to sendparse_mode (
Optional
[str
]) – ‘HTML’ or ‘Markdown’ for formatting (optional)disable_notification (
bool
) – Send silently without notification sound
- Returns:
List of success status for each message
- Return type:
List[bool]
- async send_message(text, parse_mode=None, disable_notification=False)
Send a text message to the configured chat.
- Parameters:
text (
str
) – Message text to sendparse_mode (
Optional
[str
]) – ‘HTML’ or ‘Markdown’ for formatting (optional)disable_notification (
bool
) – Send silently without notification sound
- Returns:
True if message sent successfully, False otherwise
- Return type:
bool
- async send_trade_alert(symbol, action, price, quantity, profit_loss=None, disable_notification=False)
Send a formatted trade alert with emoji and structured layout.
- Parameters:
symbol (
str
) – Trading symbol (e.g., ‘BTCUSD’, ‘AAPL’)action (
str
) – Trade action (‘BUY’, ‘SELL’, ‘CLOSE’)price (
float
) – Execution pricequantity (
float
) – Trade quantity/sizeprofit_loss (
Optional
[float
]) – P/L amount (optional, will show emoji based on sign)disable_notification (
bool
) – Send silently without notification sound
- Returns:
True if alert sent successfully, False otherwise
- Return type:
bool
- emrpy.get_root_path(fallback_levels=1)
Returns the root path of the current script or notebook.
If __file__ is defined (i.e., running in a script), uses it. If not (e.g., in a Jupyter notebook), goes up ‘fallback_levels’ from cwd.
- Parameters:
fallback_levels (int) – How many levels to go up from cwd if __file__ is undefined.
- Returns:
The resolved root path.
- Return type:
Path
Modules
Telegram Trading Bot Module |
|