HUB
Sign inSign up

cuongle313/stock-bot

By cuongle313

•Updated over 1 year ago

Stock Prediction Bot with LSTM

Image
Machine learning & AI
Web analytics
0

1.0K

cuongle313/stock-bot repository overview

⁠Stock Prediction Bot with LSTM

This Docker image runs a stock prediction bot powered by an LSTM model. It fetches historical stock data using yfinance, predicts the next day's closing price, generates buy/sell signals, and sends the results via Telegram at a user-specified time.

⁠Prerequisites

  • Docker installed on your system.
  • A Telegram bot token and chat ID for receiving notifications.

⁠Getting TELEGRAM_TOKEN and CHAT_ID

  1. Get TELEGRAM_TOKEN:

    • Open Telegram and search for "BotFather".
    • Send /start to BotFather.
    • Send /newbot to create a new bot.
    • Follow the prompts to name your bot and get a token.
    • Save this token as TELEGRAM_TOKEN.
  2. Get TELEGRAM_CHAT_ID:

    • Start a chat with your bot (send any message).
    • Open a browser and go to: https://api.telegram.org/bot⁠<YourTELEGRAM_TOKEN>/getUpdates Replace <YourTELEGRAM_TOKEN> with your bot token (e.g., https://api.telegram.org/bot⁠<YourTELEGRAM_TOKEN>/getUpdates).
    • Look for "chat":{"id": in the response. The (e.g., 123456789) is your CHAT_ID.
    • Save this number as TELEGRAM_CHAT_ID.

⁠Usage

  1. Pull the Image docker pull cuongle313/stock-bot:latest

  2. Run the Container Use the following command to run the bot. Customize the variables as needed:

    docker run --name stock-bot-container -d
    -e TICKERS="CMG,MBB,SHB,ENV"
    -e SCHEDULE_TIME="09:00"
    -e TELEGRAM_TOKEN="your_telegram_bot_token"
    -e TELEGRAM_CHAT_ID="your_chat_id"
    cuongle313/stock-bot:latest

    • TICKERS: Comma-separated list of stock tickers (e.g., CMG,MBB). .VN will be automatically appended for Vietnamese stocks (HOSE). Use full ticker if targeting other markets (e.g., AAPL for Apple).
    • SCHEDULE_TIME: Time to send Telegram messages daily (24-hour format, HH:MM, e.g., 09:00 for 9 AM Vietnam time). Default: 09:00.
    • TELEGRAM_TOKEN: Your Telegram bot token (obtained from BotFather).
    • TELEGRAM_CHAT_ID: Your Telegram chat ID (obtained from getUpdates).
  3. Check Logs docker logs stock-bot-container Look for "Assistant is running, sending notifications at [SCHEDULE_TIME]..." to confirm.

⁠Example

Run predictions for Vietnamese stocks CMG, MBB, SHB, ENV at 9 AM: docker run --name stock-bot-container -d
-e TICKERS="CMG,MBB,SHB,ENV"
-e SCHEDULE_TIME="09:00"
-e TELEGRAM_TOKEN=""
-e TELEGRAM_CHAT_ID=""
cuongle313/stock-bot:latest

⁠Notes

  • Data Source: Uses yfinance. If data for Vietnamese stocks (e.g., CMG.VN) is unavailable, consider alternative sources (CSV, API).
  • LSTM Model: Trained on 1 year of historical closing prices. First run may take 1-2 minutes per ticker to train the model.
  • Security: Avoid using the default TELEGRAM_TOKEN in production. Pass your own via -e.
  • Time Zone: Set to Vietnam time (Asia/Ho_Chi_Minh).

⁠Troubleshooting

  • If Telegram messages aren't sent, verify TELEGRAM_TOKEN and CHAT_ID.
  • If "denied" error occurs during push, ensure you're logged into Docker Hub (docker login) and the repository exists.
Tag summary
Recent tags
Content type
Image
Digest
sha256:a4c83c168…
Size
472.2 MB
Last updated
over 1 year ago
docker pull cuongle313/stock-bot:latest