{"id":31600298,"url":"https://github.com/robertfmath/asset-class-hierarchical-clustering","last_synced_at":"2026-05-08T19:32:27.061Z","repository":{"id":220585542,"uuid":"559387391","full_name":"robertfmath/Asset-Class-Hierarchical-Clustering","owner":"robertfmath","description":"Hierarchically clustering major asset classes in the investment landscape","archived":false,"fork":false,"pushed_at":"2023-02-07T02:01:21.000Z","size":1283,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-06T06:58:27.999Z","etag":null,"topics":["clustering","etfs","hierarchical-clustering","investing","machine-learning","python","scipy"],"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/robertfmath.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}},"created_at":"2022-10-30T00:24:16.000Z","updated_at":"2024-09-18T14:10:01.000Z","dependencies_parsed_at":"2024-02-02T22:43:29.987Z","dependency_job_id":null,"html_url":"https://github.com/robertfmath/Asset-Class-Hierarchical-Clustering","commit_stats":null,"previous_names":["robertfmath/asset-class-hierarchical-clustering"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/robertfmath/Asset-Class-Hierarchical-Clustering","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertfmath%2FAsset-Class-Hierarchical-Clustering","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertfmath%2FAsset-Class-Hierarchical-Clustering/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertfmath%2FAsset-Class-Hierarchical-Clustering/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertfmath%2FAsset-Class-Hierarchical-Clustering/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robertfmath","download_url":"https://codeload.github.com/robertfmath/Asset-Class-Hierarchical-Clustering/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertfmath%2FAsset-Class-Hierarchical-Clustering/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32794620,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-08T08:22:46.396Z","status":"ssl_error","status_checked_at":"2026-05-08T08:22:45.650Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["clustering","etfs","hierarchical-clustering","investing","machine-learning","python","scipy"],"created_at":"2025-10-06T06:56:07.801Z","updated_at":"2026-05-08T19:32:27.044Z","avatar_url":"https://github.com/robertfmath.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Asset Class Hierarchical Clustering\n\n## Description\n\nIn this project, I hierarchically cluster major asset classes in the investment landscape, using their correlations to derive a measure of distance. These correlations\u0026mdash;both monthly and quarterly\u0026mdash;are derived using the historical return streams of various ETFs, which serve as proxies for these asset classes; using ETFs as opposed to actual indices allows historical data to be easily retrieved with an open-source API (here, I used Alpha Vantage's). After converting the correlation matrix into a distance matrix, agglomerative clustering is performed by SciPy's ```linkage``` function, which, as opposed to scikit-learn's AgglomerativeClustering class, is natively plottable as a dendrogram. Average linkage is the metric by which distances between clusters are updated as they grow. Ultimately, the results of this work provide a clearer picture of how different asset classes relate to one another; this can in turn lead to better investing, as possessing a range of uncorrelated assets mitigates downside risk and provides additional robustness to an overall investment strategy.\n\n## Dependencies\n\n- NumPy\n- Pandas\n- SciPy\n- Matplotlib\n- Seaborn\n- Requests (only if fetching updated stock data)\n\nFor a full list of dependencies—both direct and transitive—please refer to the provided requirements.txt file.\n\n## Usage\n\nThe analysis itself is located at ```/model/Asset-Class-Hierarchical-Clustering.ipynb```. This file walks you through the overall process from beginning to end, from fetching the data using an API to deriving the distance matrix and finally to constructing hierarchical trees and sorted correlation matrices. The underlying historical stock price data can be found at ```/data/total_ticker_prices_df.csv```; with this file, the data-fetching section of the .ipynb file can be skipped.\n\n## Data Sources\n\nHistorical stock price data: API from [Alpha Vantage](https://www.alphavantage.co/)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobertfmath%2Fasset-class-hierarchical-clustering","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobertfmath%2Fasset-class-hierarchical-clustering","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobertfmath%2Fasset-class-hierarchical-clustering/lists"}