{"id":21026600,"url":"https://github.com/jmoussa/macd-stock-analyzer","last_synced_at":"2026-05-20T15:39:40.632Z","repository":{"id":113274065,"uuid":"359631227","full_name":"jmoussa/macd-stock-analyzer","owner":"jmoussa","description":"Small stock analysis tool that implements Moving Average Convergence Divergence (MACD) and gives recommendations based on the MACD and it's signal line crossovers.","archived":false,"fork":false,"pushed_at":"2021-04-22T00:10:58.000Z","size":3433,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-20T14:34:51.624Z","etag":null,"topics":["finance","macd","python","stock","stock-analysis","stock-analyzer","stock-market","tool"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jmoussa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2021-04-20T00:01:56.000Z","updated_at":"2025-01-11T07:40:59.000Z","dependencies_parsed_at":"2023-03-13T13:21:58.048Z","dependency_job_id":null,"html_url":"https://github.com/jmoussa/macd-stock-analyzer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmoussa%2Fmacd-stock-analyzer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmoussa%2Fmacd-stock-analyzer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmoussa%2Fmacd-stock-analyzer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmoussa%2Fmacd-stock-analyzer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jmoussa","download_url":"https://codeload.github.com/jmoussa/macd-stock-analyzer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243463439,"owners_count":20295106,"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","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":["finance","macd","python","stock","stock-analysis","stock-analyzer","stock-market","tool"],"created_at":"2024-11-19T11:45:28.191Z","updated_at":"2025-12-28T15:56:10.162Z","avatar_url":"https://github.com/jmoussa.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MACD Stock Analyzer\n\u003e Analyze specific stocks' MACD and gain further insight into stock trends\n\n\n\n## The Goal\n\nThe goal with this analyzer is to gain better insight and to identify strong and weak movements in a stock's price.\nTo do this we use the MACD and it's Signal Line to identify crossovers and classify them as bullish \"buy\" or bearish \"sell\" (more seen in the outputted csv files and plots).\n\n## What is MACD?\n\nMoving Average Convergence Divergence (MACD) is a trend following indicator.\nMACD can be calculated very simply by subtracting the 26 period EMA (exponential moving average) from the 12 period EMA. \nThe EMA is a type of moving average (MA) that places a greater weight and significance on the most recent data points.\nMACD is commonly used by analyzing crossovers, divergences, and periods of steep slope (positive or negative). \nAlong with the MACD line (from subtracting the 12 period EMA from the 16 period EMA) the chart commonly will include a signal line plotted on top of the MACD. \nThis signal line is a 9 day EMA of the MACD.\n\n## The analyzer\n\nThe analyzer script grabs the historical info for a select set of stocks by their tickers (the stocks are denoted in the `analyzer.py` script and can be edited to add any tickers).\nThen runs analysis to graph out the MACD and mark the different buy/sell dates.\n\nFinal analysis that gets outputted shows a set number of days back (Default 5) and the consensus decision (\"buy\" or \"sell\") from those days as well as the latest decision.\n\nThe decisions come off of a few very simple principals:\n- A bullish \"buy\" signal occurs when the MACD crosses above the signal line.\n- A bearish \"sell\" signal occurs when MACD crosses below the signal line. \n**Useful info:** If a crossover occurs with a high sloping MACD, this can be a sign of an overbought or oversold condition, depending on if the crossover is bullish or bearish respectively. MACD is a great indicator for understanding if movement in the price is strong or weak. A weak movement is likely to correct and a strong movement is likely to continue.\n\n## Setup\n\nThere are two ways to setup the environment:\n\n- Using requirements.txt (pip with no environments)\n- Using environment.yml (Anaconda/Conda Environments)\n\nBoth setup methods are shown below, you can choose either, or both. I'm not going to tell you how to live your life.\n\n### Setup with Python Pip\nFirst you'll need to have python (which I think comes with MacOS) and pip installed [install pip here](https://pip.pypa.io/en/stable/installing/).\n\nOpen up a terinal and follow the directions below:\n```bash\n# change directories to get into the folder of this project's directory\ncd ~/\u003cpath_to_directory\u003e/macd-stock-analyzer\n\n# Install requirments\npip install -r requirements.txt\n```\n\n### Setup with Conda Python Virtual Environments\n\nYou'll need access to the conda command as this is packaged into an Anaconda python virtual environment\n[Install Anaconda here](https://docs.anaconda.com/anaconda/install/).\n\nThen open up a terminal and follow the instructions below:\n```bash\n# change directories to get into the folder of this project's directory\ncd ~/\u003cpath_to_directory\u003e/macd-stock-analyzer\n\n# Initialize Conda\nconda init bash\n\n# Create the environment from the template supplied in the repository (this handles all pip installs too)\nconda env create -f environment.yml\n\n# Activate the environment\nconda activate finance\n```\n\n## To Run\n\nIn the repo's directory:\n\n```bash\npython analyzer.py\n```\nYou should see the logging output in the terminal as shown below, and you can check the `files/` folder for charts and csv's for further analysis.\n![Terminal Screenshot](./screenshots/screenshot.jpg?raw=true)\n\nHere is an example of what a chart and csv might look like (found in the `files/` folder after running `analyzer.py`). \nIt should be noted that these are both for the stock of Coca Cola (KO), and that ticker is used as the filename for easy identification.\n![Plot Screenshot](./screenshots/example_plot.jpg?raw=true)\n![CSV Screenshot](./screenshots/example_csv.jpg?raw=true)\n\n## Configuration Tweaks\n\nIn addition to modifying the `stocks` variable in `analyzer.py`, there are two other factors of the calculation that you can edit.\n\nBelow are the defaults:\n```python\nHOW_FAR_TO_LOOK_BACK = 5  # in years\nHOW_MANY_DAYS_TO_CONSIDER = 14  # Changes the Mode of X days to look back when showing final decisions\n```\n\n**HOW_FAR_TO_LOOK_BACK**: Total number of years back, to fetch the stock data from. Default is set to 5 years back.\n*Please note: the farther back you choose to look, the longer the script will take to finish.*\n\n**HOW_MANY_DAYS_TO_CONSIDER**: When calculating the final decisions (those that are printed out in the terminal as the result), the script will take into consideration the most common decision (the mode) from a few days prior in order for the user to get a sense of what the previous inclinations (or declinations) toward this stock looked like. \nThis variable adjusts the number of days to check back. Default is set to 14 days back.\n\n## Credit where credit is due\n\nI can't take credit for all of this amazing information, so here's the link to Luke Posey's article that I based this on.\nhttps://towardsdatascience.com/implementing-macd-in-python-cc9b2280126a\n\n\n## DISCLAIMER\n\nThe results presented here are not to be taken as financial advice with regards to how and when to pick your stocks. \nThese are outputs based on an alogrithm, and any actions taken as a result of these outputs should not be done without conducting proper research and consulting professionals.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmoussa%2Fmacd-stock-analyzer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjmoussa%2Fmacd-stock-analyzer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmoussa%2Fmacd-stock-analyzer/lists"}