{"id":29635040,"url":"https://github.com/mscbuild/market-trend-analysis-agent","last_synced_at":"2025-07-21T16:09:25.572Z","repository":{"id":304066666,"uuid":"1017582110","full_name":"mscbuild/Market-Trend-Analysis-Agent","owner":"mscbuild","description":"Market Trend Analysis Agent. The Market Trend Analysis Agent is a machine learning-based agent designed to predict stock price movements using historical market data and technical indicators.","archived":false,"fork":false,"pushed_at":"2025-07-10T19:17:24.000Z","size":9,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-11T04:57:15.278Z","etag":null,"topics":["python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mscbuild.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-10T18:59:10.000Z","updated_at":"2025-07-10T19:18:54.000Z","dependencies_parsed_at":"2025-07-11T04:57:24.441Z","dependency_job_id":null,"html_url":"https://github.com/mscbuild/Market-Trend-Analysis-Agent","commit_stats":null,"previous_names":["mscbuild/market-trend-analysis-agent"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/mscbuild/Market-Trend-Analysis-Agent","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mscbuild%2FMarket-Trend-Analysis-Agent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mscbuild%2FMarket-Trend-Analysis-Agent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mscbuild%2FMarket-Trend-Analysis-Agent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mscbuild%2FMarket-Trend-Analysis-Agent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mscbuild","download_url":"https://codeload.github.com/mscbuild/Market-Trend-Analysis-Agent/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mscbuild%2FMarket-Trend-Analysis-Agent/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266332672,"owners_count":23912663,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-21T11:47:31.412Z","response_time":64,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python"],"created_at":"2025-07-21T16:09:24.797Z","updated_at":"2025-07-21T16:09:25.563Z","avatar_url":"https://github.com/mscbuild.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Market Trend Analysis Agent\n ![](https://komarev.com/ghpvc/?username=mscbuild) \n ![](https://img.shields.io/github/license/mscbuild/Market-Trend-Analysis-Agent) \n ![](https://img.shields.io/badge/PRs-Welcome-green)\n ![](https://img.shields.io/github/languages/code-size/mscbuild/Market-Trend-Analysis-Agent)\n![](https://img.shields.io/badge/code%20style-python-green)\n![](https://img.shields.io/github/stars/mscbuild)\n![](https://img.shields.io/badge/Topic-Github-lighred)\n![](https://img.shields.io/website?url=https%3A%2F%2Fgithub.com%2Fmscbuild)\n\n\n## Overview\n\nThe Market Trend Analysis Agent is a machine learning-based agent designed to predict stock price movements using historical market data and technical indicators. The agent uses a combination of Random Forest, XGBoost, and other machine learning models to forecast the next day's stock price movement (up or down). Additionally, various technical indicators like SMA, RSI, MACD, and Volatility Features are used to generate actionable insights.\n\n# Features\n\n- Data Collection: Real-time stock price data and historical price data fetched from Yahoo Finance using the `yfinance` library.\n\n- Feature Engineering: Common technical indicators like Moving Averages (SMA), RSI, MACD, and ATR to capture market trends.\n\n- Machine Learning Models: Uses Random Forest, XGBoost, and Logistic Regression to classify the next day's price movement (up or down).\n\n- Model Evaluation: Evaluates the model using accuracy, F1-score, and ROC-AUC score.\n\n- Prediction: Provides a prediction for the next day (Buy/Sell recommendation).\n\n  # Requirements\n\n  To run the project, you need to install the following Python libraries:\n  ~~~bash\n  pip install yfinance pandas numpy scikit-learn xgboost ta-lib imbalanced-learn matplotlib\n  ~~~\n\n  # Project Structure\n~~~bash\nmarket-trend-analysis/\n├── data/\n│   ├── AAPL.csv               # Example of historical data\n├── notebooks/\n│   ├── analysis.ipynb         # Jupyter notebook for data exploration and analysis\n├── src/\n│   ├── main.py                # Main script to train and evaluate models\n├── requirements.txt           # Python dependencies\n├── README.md                  # Project documentation (this file)\n~~~\n\n# Usage\n\n1.Data Collection: The script fetches stock data for a specific symbol from Yahoo Finance.\n\n2.Feature Engineering: Various technical indicators are calculated and used as features.\n\n3.Model Training: Random Forest, XGBoost, and other classifiers are trained on the dataset.\n\n4.Prediction: The trained model predicts whether the stock price will go up or down the next day.\n\n# Steps to Run\n\n1.Clone the repository or download the files.\n\n2.Run the main script `(main.py)` to fetch data, train models, and get predictions.\n\n3.Evaluate the model's performance using various metrics like accuracy, F1-score, and ROC-AUC.\n\n# Explanation\n\n## 1. Data Download:\n\nThe data for the stock symbol is fetched from Yahoo Finance using the `yfinance` library. You can modify the `ticker` and `dates` in the run_pipeline() function.\n\n## 2. Feature Engineering:\n\n- We calculate several technical indicators such as:\n\n- SMA (Simple Moving Average)\n\n- RSI (Relative Strength Index)\n\n- MACD (Moving Average Convergence Divergence)\n\n- ATR (Average True Range)\n\n- Lagged Returns: To capture recent market momentum\n\n  ## 3. Model Training:\n\n  The model used is a Random Forest classifier. We train it on the features derived from the stock price and technical indicators.\n\n  ## 4. Evaluation:\n\n  We evaluate the model using:\n\n- Accuracy\n\n- Classification Report (Precision, Recall, F1-score)\n\n- ROC-AUC score\n\n  ## 5. SMOTE for Class Imbalance:\n\n  Since stock price movements can often be imbalanced (e.g., more \"up\" days than \"down\"), we use SMOTE (Synthetic Minority Over-sampling Technique) to balance the classes.\n\n  # How to Run the Script\n\n1.Clone the repository or download the `src/main.py` file.\n\n2.Install required dependencies `(pip install -r requirements.txt)`.\n\n3.Run the script by executing:\n~~~bash\npython src/main.py\n~~~\n\n# Results\n\n- The script will output the accuracy of the model, along with the classification report and ROC-AUC score.\n\n- It will print a prediction for whether the stock will go up or down the next day based on the trained model.\n\n# Enhancements\n\n- Model Improvement: You can experiment with other models like XGBoost or LSTM for time-series predictions.\n\n- Sentiment Analysis Integration: Integrate sentiment scores from news or social media to refine predictions.\n\n- Real-time Prediction: Modify the script to fetch real-time stock data and predict price movements in real-time.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmscbuild%2Fmarket-trend-analysis-agent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmscbuild%2Fmarket-trend-analysis-agent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmscbuild%2Fmarket-trend-analysis-agent/lists"}