Add market close updates and update deployment path for Compose Manager
Bot enhancements: - Add scheduled update at market close (4:00 PM ET on trading days) - Implement is_trading_day() method to check weekdays/holidays - Market close update sends PYPL price at end of trading day Deployment changes: - Update all scripts to use Docker Compose Manager plugin path - New path: /boot/config/plugins/compose.manager/projects/discord-stock-bot - Container now integrates with Unraid Docker UI Compose section - Update documentation with plugin integration details 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -298,9 +298,10 @@ git push
|
|||||||
#### Configuration Details
|
#### Configuration Details
|
||||||
|
|
||||||
- **Unraid Host**: `root@192.168.2.61`
|
- **Unraid Host**: `root@192.168.2.61`
|
||||||
- **Deployment Path**: `/mnt/user/docker/custom-dockers/discord-stock-bot`
|
- **Deployment Path**: `/boot/config/plugins/compose.manager/projects/discord-stock-bot`
|
||||||
- **Git Repository**: `git@git.michaelsimard.ca:msimard/discord-stock-bot.git`
|
- **Git Repository**: `git@git.michaelsimard.ca:msimard/discord-stock-bot.git`
|
||||||
- **Git Server Port**: 28 (configured in SSH config)
|
- **Git Server Port**: 28 (configured in SSH config)
|
||||||
|
- **Integration**: Docker Compose Manager plugin (stack appears in Unraid Docker tab)
|
||||||
|
|
||||||
#### Troubleshooting Automated Deployment
|
#### Troubleshooting Automated Deployment
|
||||||
|
|
||||||
@@ -325,10 +326,12 @@ ssh root@192.168.2.61 "git ls-remote git@git.michaelsimard.ca:msimard/discord-st
|
|||||||
**Container Won't Start:**
|
**Container Won't Start:**
|
||||||
```bash
|
```bash
|
||||||
# Check .env exists on Unraid
|
# Check .env exists on Unraid
|
||||||
ssh root@192.168.2.61 "cat /mnt/user/docker/custom-dockers/discord-stock-bot/.env"
|
ssh root@192.168.2.61 "cat /boot/config/plugins/compose.manager/projects/discord-stock-bot/.env"
|
||||||
|
|
||||||
# View detailed logs
|
# View detailed logs
|
||||||
./manage.sh logs
|
./manage.sh logs
|
||||||
|
|
||||||
|
# Check in Unraid UI: Docker tab > Compose section
|
||||||
```
|
```
|
||||||
|
|
||||||
### Method 1: Docker Compose
|
### Method 1: Docker Compose
|
||||||
|
|||||||
19
bot.py
19
bot.py
@@ -52,8 +52,16 @@ class StockBot(commands.Bot):
|
|||||||
name='Hourly Stock Price Update'
|
name='Hourly Stock Price Update'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Schedule market close update at 4:00 PM ET on weekdays
|
||||||
|
self.scheduler.add_job(
|
||||||
|
self.send_market_close_update,
|
||||||
|
CronTrigger(hour=16, minute=0, day_of_week='mon-fri', timezone=MarketHours.NYSE_TIMEZONE),
|
||||||
|
id='market_close_update',
|
||||||
|
name='Market Close Update'
|
||||||
|
)
|
||||||
|
|
||||||
self.scheduler.start()
|
self.scheduler.start()
|
||||||
logger.info("Scheduler started for hourly updates")
|
logger.info("Scheduler started for hourly updates and market close")
|
||||||
|
|
||||||
async def on_ready(self):
|
async def on_ready(self):
|
||||||
"""Called when bot successfully connects to Discord."""
|
"""Called when bot successfully connects to Discord."""
|
||||||
@@ -77,6 +85,15 @@ class StockBot(commands.Bot):
|
|||||||
logger.info(f"Sending hourly update for {self.primary_ticker}")
|
logger.info(f"Sending hourly update for {self.primary_ticker}")
|
||||||
await self.send_stock_update(self.primary_ticker, self.target_channel_id)
|
await self.send_stock_update(self.primary_ticker, self.target_channel_id)
|
||||||
|
|
||||||
|
async def send_market_close_update(self):
|
||||||
|
"""Send stock price update at market close on trading days."""
|
||||||
|
if not MarketHours.is_trading_day():
|
||||||
|
logger.info("Not a trading day, skipping market close update")
|
||||||
|
return
|
||||||
|
|
||||||
|
logger.info(f"Sending market close update for {self.primary_ticker}")
|
||||||
|
await self.send_stock_update(self.primary_ticker, self.target_channel_id)
|
||||||
|
|
||||||
async def send_stock_update(self, ticker: str, channel_id: int):
|
async def send_stock_update(self, ticker: str, channel_id: int):
|
||||||
"""
|
"""
|
||||||
Fetch stock data and send formatted embed to specified channel.
|
Fetch stock data and send formatted embed to specified channel.
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ set -e
|
|||||||
|
|
||||||
# Configuration
|
# Configuration
|
||||||
UNRAID_HOST="${UNRAID_HOST:-root@192.168.2.61}"
|
UNRAID_HOST="${UNRAID_HOST:-root@192.168.2.61}"
|
||||||
REMOTE_PATH="/mnt/user/docker/custom-dockers/discord-stock-bot"
|
REMOTE_PATH="/boot/config/plugins/compose.manager/projects/discord-stock-bot"
|
||||||
GIT_REPO="git@git.michaelsimard.ca:msimard/discord-stock-bot.git"
|
GIT_REPO="git@git.michaelsimard.ca:msimard/discord-stock-bot.git"
|
||||||
|
|
||||||
echo "Deploying discord-stock-bot to ${UNRAID_HOST}..."
|
echo "Deploying discord-stock-bot to ${UNRAID_HOST}..."
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
# manage.sh - Manage discord-stock-bot on Unraid
|
# manage.sh - Manage discord-stock-bot on Unraid
|
||||||
|
|
||||||
UNRAID_HOST="${UNRAID_HOST:-root@192.168.2.61}"
|
UNRAID_HOST="${UNRAID_HOST:-root@192.168.2.61}"
|
||||||
REMOTE_PATH="/mnt/user/docker/custom-dockers/discord-stock-bot"
|
REMOTE_PATH="/boot/config/plugins/compose.manager/projects/discord-stock-bot"
|
||||||
|
|
||||||
CMD="$1"
|
CMD="$1"
|
||||||
|
|
||||||
|
|||||||
@@ -79,6 +79,34 @@ class MarketHours:
|
|||||||
logger.debug(f"Market closed: Outside trading hours ({current_time})")
|
logger.debug(f"Market closed: Outside trading hours ({current_time})")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def is_trading_day(cls, check_time: datetime = None) -> bool:
|
||||||
|
"""
|
||||||
|
Determine if the given date is a trading day (weekday, not a holiday).
|
||||||
|
|
||||||
|
Args:
|
||||||
|
check_time: Datetime to check (defaults to now)
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
True if it's a trading day, False otherwise
|
||||||
|
"""
|
||||||
|
if check_time is None:
|
||||||
|
check_time = datetime.now(cls.NYSE_TIMEZONE)
|
||||||
|
else:
|
||||||
|
check_time = check_time.astimezone(cls.NYSE_TIMEZONE)
|
||||||
|
|
||||||
|
# Check if weekend
|
||||||
|
if check_time.weekday() >= 5: # Saturday = 5, Sunday = 6
|
||||||
|
return False
|
||||||
|
|
||||||
|
# Check if holiday
|
||||||
|
check_date = check_time.date()
|
||||||
|
all_holidays = cls.HOLIDAYS_2024 + cls.HOLIDAYS_2025
|
||||||
|
if any(holiday.date() == check_date for holiday in all_holidays):
|
||||||
|
return False
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_next_market_open(cls, from_time: datetime = None) -> datetime:
|
def get_next_market_open(cls, from_time: datetime = None) -> datetime:
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
UNRAID_HOST="${UNRAID_HOST:-root@192.168.2.61}"
|
UNRAID_HOST="${UNRAID_HOST:-root@192.168.2.61}"
|
||||||
REMOTE_PATH="/mnt/user/docker/custom-dockers/discord-stock-bot"
|
REMOTE_PATH="/boot/config/plugins/compose.manager/projects/discord-stock-bot"
|
||||||
|
|
||||||
echo "Setting up Unraid server for git-based deployment..."
|
echo "Setting up Unraid server for git-based deployment..."
|
||||||
echo ""
|
echo ""
|
||||||
|
|||||||
Reference in New Issue
Block a user