Welcome to the Mrzaizai2k Stock Assistant bot! This bot is designed to assist you with various stock-related tasks and analyses. Whether you want to calculate the payback time for a stock, find support and resistance levels, or receive warnings about specific market conditions, this bot has you covered.
Available Commands
Available commands
/start: Initializes the bot and provides a welcome message.
/help: Displays a list of available commands and their descriptions.
/pbt: Calculates the payback time for a specific stock.
/snr: Finds the closest support and resistance levels for a stock.
/findpbt: Identifies stocks with favorable payback times.
/findmyfav: Recommends stocks based on specified criteria.
/risk: Calculates the number of stocks you can buy with a given loss/trade percentage and maximum loss/capital percentage.
/rate: Provides a general rating for a stock.
/mulpattern: Finds patterns of a stock on multiple dimensions (close, volume).
/pattern: Finds patterns of a stock based on closing prices.
/findbestmotif: Identifies the best motifs across all stocks.
/buysellanalyze: Picture of my Buy/Sell of a stock (FPTS data)
/winlossanalyze: Analyze my Win/Loss trading for the last 6 months (FPTS data)
/watchlist: See/change your watch list
/summarynewsurl: Summary news from arbitrary url
Only me commands
/remote: Open remote tunnel to vscode on my latop.
/log: Send the log file.
/scrape: Manually scraping trading data and news
How to Use
Start a command with a forward slash ("/") followed by the desired command.
Example: /pbt
Follow the bot's prompts to enter additional information, such as stock symbols or dates.
Wait for the bot to process your request. Some commands may take several minutes.
Review the bot's responses for the calculated results, warnings, or recommended stocks.
How to Set Up the Bot
Before running the Mrzaizai2k Stock Assistant Bot, follow these steps to set up the environment:
Clone the Repository:
Close the Git repository to your local machine:
git clone [repository_url]
Install Dependencies:
Navigate to the project directory and install the required packages using the provided setup_win.txt file:
You have to update the config in config/config.yaml file. i.e time to warning, data path,...
.txt file to save long text like the /start or /help commands
Run the Bot:
Execute the following command to run the Mrzaizai2k Stock Assistant Bot:
pythonsrc/stock_bot.py
- Or you can run with Makefile on Linux:
```makefile
make bot
```
Interact with the Bot:
Once the bot is running, open Telegram and start interacting with the bot using the available commands.
Warning Price
The bot can also warning you about the stock in watchlist in times that you have set in config/config.yaml. The time would be in format HH:MM. Note: '06:50' not '6:50'
warning_macd Function:
Purpose: This function generates warnings based on MACD (Moving Average Convergence Divergence) analysis for stocks in the provided watchlist.
Warnings: Detects if a stock has crossed up or down based on MACD with a specified offset.
warningbigday Function:
Purpose: Generates warnings for stocks with significant price movements (big days).
Warnings: Identifies powerful increases or decreases in stock prices.
warningpricevsma Function:
Purpose: Provides warnings based on the relationship between stock prices and Moving Averages (MA).
Warnings: Detects if a stock has crossed up or down in relation to its Moving Average with a specified offset.
warningsnr Function:
Purpose: Warns about stocks approaching or meeting support/resistance levels.
Warnings: Identifies if a stock is meeting support or resistance levels within a specified tolerance percentage.
Database
User database:
The chatbot utilizes a user database stored in ./memory. When a new user executes the /watchlist command, the chatbot automatically checks if the user is in the database. The database contains the following information:
- user_id: Unique identifier for users.
- watch_list: List of stocks associated with each user.
- step: User's progress step in the chatbot's functionality.
This user database is a crucial component, enabling seamless interactions and personalized experiences for users. The database is actively used in various functions throughout the bot.
Scrape data trading:
The chatbot employs Selenium to scrape trading data from FTPS. The scraped data provides insights into buy/sell periods and facilitates analysis of win/loss trading patterns. The code for this functionality is available in src/trading_record.py. This feature enhances the chatbot's capability to provide valuable trading analytics. The code can be found in src/trading_record.py
Scrape news:
The bot has the capability to scrape news specifically related to the stocks on your watchlist. Additionally, it can provide a brief summary of the top news, offering insights into the market before the trading session begins.
I have enhanced the crawling functionality using LangChain, allowing the bot to precisely extract news text from any given URL. This improvement ensures accurate and relevant information retrieval.
To quickly obtain a summary from a URL, you can utilize the /summarynewsurl command. This feature enhances user convenience and efficiency.
Currently, the news data is stored in a json file. However, I am planning to implement an update to MongoDB in the future. This transition aims to improve data management and accessibility.
Open VScode tunnel
As to this link, you need to first set up the tunnel in your code
Whenever you want to run your bot remotely, but got this issue: "make sure that only one bot instance is running". Please kill bot first
makekillmakebot
Summarize Sound
The bot is in development to summarize all sounds from audio or voice
.It can recognize sounds with various formats such as .mp3, .wav,.ogg,.m4a with Whisper
To setup Whisper
pip install git+https://github.com/openai/whisper.git
# on Ubuntu or Debiansudo apt update &&sudo apt install ffmpeg
Then I use Google Translate API to translate the text to English. All the code can be found src/summarize_text.py
Input: "I want to go shoppng at 8 o'clock and call my parents tomorrow"
Output: ["Go shopping at 8 o'clock", "Call my parents tomorrow"]
It has the capability to understand and fix tasks, such as when you mention a task incorrectly and want to correct it. For example:
Input: "I want to go shopping at 8 o'clock, uhm, I'm sorry, at 9 o'clock."
Output: ["Go shopping at 9 o'clock."]
Update: I have uoadted the model to chatgpt turbo 3.5 Instruct to get better result in no time!
Personally, I use the Microsoft To Do app, so the bot will sync those tasks to my app! The information can be found in tod0.
The tod0 package is originally designed for CLI usage. However, I have modified it for my personal usage in Python. The source code can be found in src/Microsofttodo.py. Remeber to take the token and client_id as this link
Summarize News
The bot has the capability to summarize news related to your watchlist stocks and the market. I utilize a lightweight Falconsai/text_summarization model and Langchain for summarization, enabling me to obtain a precise and swift summary from the news.
I leveraged Langchain and the beautifulsoup package to crawl top news and news related to your stocks from two sites: Cafef and VnExpress, bringing you the summary of the market trend.
If you prefer a more direct approach, simply use the command /summarynewsurl and paste the URL link. This will provide you with a summary of any site you desire.
Example Uses
Explore practical implementations and demonstrations of the chatbot's functions in the notebook folder. These examples showcase real-world scenarios, illustrating how the chatbot can be effectively utilized for stock market monitoring.
To-Do List
[ ] Update some features with langchain
[ ] Upgrade the security
[ ] Stock Prediction with TFT Model
[ ] Update DataBase using PostGreSQL and MongoDB
[ ] User_ID Encryption
[ ] Back Testing Bot
[ ] Make a youtube video about this bot
[ ] Update to do list function
Note: Ensure that you have Python installed on your machine and the necessary permissions to install packages and run scripts.
Feel free to explore the various commands and leverage the bot for your stock-related analyses. If you have any questions or encounter issues, type /help for assistance. Happy investing!
Welcome to the Mrzaizai2k Stock Assistant bot! This bot is designed to assist you with various stock-related tasks and analyses. Whether you want to calculate the payback time for a stock, find support and resistance levels, or receive warnings about specific market conditions, this bot has you covered.
Available Commands
Available commands
/start: Initializes the bot and provides a welcome message.
/help: Displays a list of available commands and their descriptions.
/pbt: Calculates the payback time for a specific stock.
/snr: Finds the closest support and resistance levels for a stock.
/findpbt: Identifies stocks with favorable payback times.
/findmyfav: Recommends stocks based on specified criteria.