{"id":24644930,"url":"https://github.com/s1dewalker/markov-model-for-stocks","last_synced_at":"2026-04-28T12:38:50.259Z","repository":{"id":273767184,"uuid":"920813276","full_name":"s1dewalker/Markov-Model-for-Stocks","owner":"s1dewalker","description":"Markov Model for Stocks in Python. Clustering in Time Series data | Model Development | Stochastic Models","archived":false,"fork":false,"pushed_at":"2025-02-07T07:58:25.000Z","size":1310,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-20T15:14:03.858Z","etag":null,"topics":["clustering","kmeans-clustering","machine-learning","markov-decision-process","markov-model","pandas","probabilistic-models","python","sklearn","stochastic-processes","time-series"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","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/s1dewalker.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":"2025-01-22T20:17:24.000Z","updated_at":"2025-02-20T14:39:03.000Z","dependencies_parsed_at":"2025-01-22T21:24:27.593Z","dependency_job_id":"f7596dcf-101e-4089-90f3-91bb28b1749e","html_url":"https://github.com/s1dewalker/Markov-Model-for-Stocks","commit_stats":null,"previous_names":["s1dewalker/markov-model-for-stocks"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s1dewalker%2FMarkov-Model-for-Stocks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s1dewalker%2FMarkov-Model-for-Stocks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s1dewalker%2FMarkov-Model-for-Stocks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s1dewalker%2FMarkov-Model-for-Stocks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/s1dewalker","download_url":"https://codeload.github.com/s1dewalker/Markov-Model-for-Stocks/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244637100,"owners_count":20485446,"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":["clustering","kmeans-clustering","machine-learning","markov-decision-process","markov-model","pandas","probabilistic-models","python","sklearn","stochastic-processes","time-series"],"created_at":"2025-01-25T14:13:39.441Z","updated_at":"2026-04-28T12:38:50.219Z","avatar_url":"https://github.com/s1dewalker.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Markov Model for Stocks\n\u003cimg src=\"sc/mm2.jpg\" alt=\"Description\" width=\"1000\"\u003e\n\u003cbr/\u003e\n\n\nBuilding Markov Model for Stocks after applying Clustering to Time Series data in Python\n\n\u003cbr/\u003e\n\n## 1. Applying k-means clustering to identify market states\n1. Data Preparation\n2. Feature Preparation\n3. **Check for Multicollinearity**\n4. **Normalize** (as some features might dominate due to larger scale) w/ `MinMaxScaler`\n5. **Finding Optimal k** w/ WCSS or **elbow method**\n6. Perform Silhouette analysis for different k\n7. Fit the model and identify the clusters\n8. Analyzing clusters\n9. Analyzing each cluster\n\n\u003cbr/\u003e\n\n**Finding Optimal k with elbow method**\n\n\u003cimg src=\"sc/elbow.JPG\" alt=\"Description\" width=\"500\"\u003e\n\u003cbr/\u003e\n\n**Pairwise Feature Relationships by Cluster**\n\n\u003cimg src=\"sc/pairwise.JPG\" alt=\"Description\" width=\"500\"\u003e\n\n\u003cbr/\u003e\n\n#### [View Clustering](https://github.com/s1dewalker/Markov-Model-for-Stocks/blob/main/py_files/MarkovModel1_Clustering2.ipynb)\n\u003cbr/\u003e\n\nPython libraries used: `pandas`, `yfinance`, `sklearn`, `matplotlib`, `seaborn`\n\n\u003cbr/\u003e\n\n## 2. Building Markov Model to create a Transition matrix\n1. Get previous state\n2. Create Transition State by combining previous and present states\n3. Grouping by Transition state and Counting their occurrences\n4. Separate the transition state\n5. Create Markov transition matrix \n6. Convert to row-wise percentages (%)\n\n\u003cbr/\u003e\n\u003cimg src=\"sc/trmat.JPG\" alt=\"Description\" width=\"300\"\u003e\n\n\u003cbr/\u003e\n\n\n#### [View Markov Model](https://github.com/s1dewalker/Markov-Model-for-Stocks/blob/main/py_files/MarkovModel2-Building_MarkovModel.ipynb)\n\u003cbr/\u003e\n\nPython libraries used: `pandas`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs1dewalker%2Fmarkov-model-for-stocks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fs1dewalker%2Fmarkov-model-for-stocks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs1dewalker%2Fmarkov-model-for-stocks/lists"}