This project is a full-stack trading system that analyzes and automates a Gap-Up Trading Strategy. It includes real-time Telegram alerts whenever a trade is executed or failed, so users stay informed even without opening the dashboard.
| Layer | Tech |
|---|---|
| UI Dashboard | Streamlit |
| Scheduling | AWS Lambda + CloudWatch Cron |
| Broker API | Fyers API |
| Data Storage | MongoDB Atlas |
| Notifications | Telegram Bot |
| Language | Python |
- AWS Lambda Cron triggers strategy at market open.
- Strategy checks gap-up conditions and places trades via Fyers API.
- PNL and trade data is saved in MongoDB Atlas.
- Telegram bot sends trade execution alerts.
- Streamlit app displays historical PNL and stats.
-
Sends message for:
- Trade executed (buy/sell)
- Trade skipped (gap condition not met)
- Any execution error (for debugging)
-
Real-time alerts to your Telegram account or group.
-
Create Telegram Bot
- Talk to @BotFather
- Use
/newbotto create a bot and getBOT_TOKEN
-
Get Chat ID
-
Send message to your bot
-
Use this URL to get chat ID:
https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates -
Note down your
chat_id
-
-
Code Example (
telegram_alert.py):
import requests
def send_telegram_alert(message, bot_token, chat_id):
url = f"https://api.telegram.org/bot{bot_token}/sendMessage"
payload = {
"chat_id": chat_id,
"text": message,
"parse_mode": "Markdown"
}
try:
res = requests.post(url, json=payload)
return res.status_code == 200
except Exception as e:
print("Failed to send Telegram alert:", e)
return False- Use in Strategy Execution:
from telegram_alert import send_telegram_alert
# Example alert after placing a trade
send_telegram_alert(
f"📈 Trade Executed:\nSymbol: {symbol}\nSide: BUY\nPrice: {entry_price}",
bot_token="YOUR_BOT_TOKEN",
chat_id="YOUR_CHAT_ID"
)In GitHub's "Edit repository details":
-
Description:
Automated Gap-Up Trading Strategy with Fyers API, Streamlit, AWS Lambda, and Telegram alerts -
Topics:
trading fyers-api telegram-alerts streamlit aws-lambda mongodb
-
Store
BOT_TOKEN,chat_id, Fyers token, Mongo URI securely using:.env+python-dotenv- AWS Secrets Manager (for Lambda)
-
Add interactive controls to execute backtests
-
Notify via Telegram on:
- Daily summary
- Unexpected losses
-
Add retry logic for order failures
-
Telegram command support (e.g.,
/pnl,/last_trade)