{"id":6448,"date":"2025-07-15T05:28:14","date_gmt":"2025-07-15T05:28:14","guid":{"rendered":"https:\/\/eodhd.com\/financial-academy\/?p=6448"},"modified":"2025-07-15T05:28:20","modified_gmt":"2025-07-15T05:28:20","slug":"clustering-for-traders-boost-your-portfolios-performance-with-data-science","status":"publish","type":"post","link":"https:\/\/eodhd.com\/financial-academy\/stocks-data-processing-examples\/clustering-for-traders-boost-your-portfolios-performance-with-data-science","title":{"rendered":"Clustering for Traders: Boost Your Portfolio\u2019s Performance with Data Science"},"content":{"rendered":"\n<p>Clustering stocks can substantially enhance your trading strategies and assist in managing diversification with professionalism. The concept of clustering involves the grouping of stocks according to their fundamental characteristics and\/or their price movements.<\/p>\n\n\n\n<p>A common way to classify stocks is by sector. If you haven\u2019t already, consider making sector diversification a key part of your investment strategy. This involves holding stocks across different sectors to prevent over-reliance on one sector&#8217;s performance. While all these methods are used for risk management, clustering stocks by selecting our own features definitely adds another dimension to our trading style.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"64d5\">How to trade based on clusters<\/h2>\n\n\n\n<p id=\"9264\"><strong>Pairs Trading and Statistical Arbitrage<\/strong><\/p>\n\n\n\n<p id=\"38be\">This strategy is based on finding stocks that typically move in tandem but have temporarily diverged. When one stock (stock A) surges while the other (stock B) lags, you take a short position in stock A and a long position in stock B. Statistically, these stocks tend to converge again over time, allowing you to capture profits as their prices realign. While this approach is most commonly used with pairs of stocks, it can also be extended to a group by going long on those that have under-performed and short on those that have outperformed.<\/p>\n\n\n\n<p id=\"8c36\"><strong>Market Regime Detection<\/strong><\/p>\n\n\n\n<p id=\"d401\">Grouping can help you identify real-time market trends\u2014whether bullish, bearish, or sideways\u2014by clustering periods that share similar characteristics in price movement, volatility, or trading volume. Once a trend is recognised, you can adjust your trading strategy accordingly:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>In a bullish cluster, go for long positions or momentum strategies.<\/li>\n\n\n\n<li>In a bearish cluster, use shorting or protective hedges.<\/li>\n\n\n\n<li>In a sideways cluster, go for mean-reversion or range-bound strategies.<\/li>\n<\/ul>\n\n\n\n<p id=\"552d\"><strong>Identify opportunities<\/strong><\/p>\n\n\n\n<p id=\"82fb\">Cluster analysis can complement or even replace your existing stock screeners. If you already use specific criteria to filter stocks for potential opportunities, it\u2019s a good idea to also examine which stocks are grouped together with the one you\u2019re analysing. This approach might uncover promising stocks that you haven\u2019t considered yet or that your screener may have missed.<\/p>\n\n\n\n<p>But how can we do that?<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-gather-the-data\">Gather the data<\/h2>\n\n\n\n<p>We will use the <a href=\"https:\/\/eodhd.com\/lp\/historical-eod-api?via=phitzi\">EODHD APIs<\/a> for pricing and fundamentals, but before that let&#8217;s do the imports and get all the SP500 stocks:<\/p>\n\n\n\n            <div class=\"code__wrapper\">\n                <div class=\"code__content\">\n                    \n<pre class=\"wp-block-code\"><code class=\"\">import requests\nimport pandas as pd\nimport requests_cache\nimport os\nfrom matplotlib import pyplot as plt\nfrom tqdm import tqdm\nimport warnings\n\napi_token = os.environ.get('EODHD_API_TOKEN')\n\ndef get_sp500_tickers():\n\n    INDEX_NAME = 'GSPC.INDX'\n    url = f'https:\/\/eodhd.com\/api\/mp\/unicornbay\/spglobal\/comp\/{INDEX_NAME}'\n    query = {'api_token': api_token, \"fmt\": \"json\"}\n\n    data = requests.get(url, params=query)\n\n    if data.status_code != 200:\n        tqdm.write(f\"Error: {data.status_code}\")\n        tqdm.write(data.text)\n        return []\n\n    data = data.json()\n    df_stocks = pd.DataFrame(data['Components']).T.reset_index()\n\n    df_stocks.to_csv('csv\/stocks_universe.csv', index=False)\n    tickers = df_stocks['Code'].tolist()\n    return tickers\n\n\n# Get S&amp;P 500 tickers\nsp500_tickers = get_sp500_tickers()<\/code><\/pre>\n\n                <\/div>\n                <div class=\"code__btns\">\n                    <button class=\"code__copy\" class=\"copy\" title=\"Copy url\">\n                        <svg class=\"code__copy__icon\" width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\">\n                            <use xlink:href=\"\/img\/icons\/copy.svg#copy\"><\/use>\n                        <\/svg>\n                        <img decoding=\"async\" class=\"code__copy__approve\" alt=\"\" src=\"\/img\/approve_ico.svg\" loading=\"eager\">\n                    <\/button>\n                <\/div>\n            <\/div>\n        \n\n\n<p>Now lets get the prices of all the SP500 stocks from 2024 and store them in a dataframe named sp_500_prices_df<\/p>\n\n\n\n            <div class=\"code__wrapper\">\n                <div class=\"code__content\">\n                    \n<pre class=\"wp-block-code\"><code class=\"\">start_date = '2024-01-01'\nsp_500_prices_df = pd.DataFrame()\n\nfor ticker in tqdm(sp500_tickers, desc=\"Fetching ticker data\"):\n    try:\n        # Construct the API URL\n        ticker_code = f\"{ticker}.US\"\n        url = f'https:\/\/eodhd.com\/api\/eod\/{ticker_code}'\n\n        # Set query parameters\n        query = {\n            'api_token': api_token,\n            'fmt': 'json',\n            'from': start_date\n        }\n\n        response = requests.get(url, params=query)\n\n        if response.status_code == 200:\n            # Parse the JSON response\n            data = response.json()\n\n            # Convert to DataFrame\n            ticker_df = pd.DataFrame(data)\n\n            # Extract date and adjusted_close\n            if 'adjusted_close' in ticker_df.columns:\n                prices = ticker_df[['date', 'adjusted_close']].copy()\n                prices.set_index('date', inplace=True)\n\n                # Rename the column to the ticker symbol\n                prices.rename(columns={'adjusted_close': ticker}, inplace=True)\n\n                # Join with the main DataFrame\n                if sp_500_prices_df.empty:\n                    sp_500_prices_df = prices\n                else:\n                    sp_500_prices_df = sp_500_prices_df.join(prices, how='outer')\n\n            else:\n                tqdm.write(f\"No adjusted close data available for {ticker}\")\n        else:\n            tqdm.write(f\"Error fetching data for {ticker}: {response.status_code}\")\n            tqdm.write(response.text)\n    except Exception as e:\n        tqdm.write(f\"Exception occurred while processing {ticker}: {str(e)}\")\n\nreturns = sp_500_prices_df.pct_change().dropna()<\/code><\/pre>\n\n                <\/div>\n                <div class=\"code__btns\">\n                    <button class=\"code__copy\" class=\"copy\" title=\"Copy url\">\n                        <svg class=\"code__copy__icon\" width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\">\n                            <use xlink:href=\"\/img\/icons\/copy.svg#copy\"><\/use>\n                        <\/svg>\n                        <img decoding=\"async\" class=\"code__copy__approve\" alt=\"\" src=\"\/img\/approve_ico.svg\" loading=\"eager\">\n                    <\/button>\n                <\/div>\n            <\/div>\n        \n\n\n<p>The next step is to get into the fundamentals. We\u2019ll enrich our S&amp;P 500 stocks dataframe by adding columns for Sector, Industry, Market Capitalisation, and P\/E ratio\u2014details that will be essential for our grouping later on. For Market Capitalisation, you\u2019ll see that I categorize it into more intuitive groups, such as Mega, Large, and so on, to make the data easier to interpret.<\/p>\n\n\n\n            <div class=\"code__wrapper\">\n                <div class=\"code__content\">\n                    \n<pre class=\"wp-block-code\"><code class=\"\">df = pd.DataFrame()\n\n# Fetch fundamental data for each ticker\nfor ticker in tqdm(sp500_tickers, desc=\"Fetching fundamental data\"):\n    try:\n        # Construct the API URL\n        ticker_code = f\"{ticker}.US\"\n        url = f'https:\/\/eodhd.com\/api\/fundamentals\/{ticker_code}'\n\n        # Set query parameters\n        query = {\n            'api_token': api_token,\n            'fmt': 'json'\n        }\n\n        # Make the API request\n        response = requests.get(url, params=query)\n\n        # Check if the request was successful\n        if response.status_code == 200:\n            # Parse the JSON response\n            data = response.json()\n\n            # Extract the required metrics\n            metrics = {\n                'Ticker': ticker,\n                'Name': data.get('General', {}).get('Name', None),\n                'Sector': data.get('General', {}).get('Sector', None),\n                'Industry': data.get('General', {}).get('Industry', None),\n                'Market Capitalisation': data.get('Highlights', {}).get('MarketCapitalization', None),\n                'P\/E Ratio': data.get('Highlights', {}).get('PERatio', None)\n            }\n\n            # Add to the dataframe\n            df = pd.concat([df, pd.DataFrame([metrics])], ignore_index=True)\n        else:\n            tqdm.write(f\"Error fetching fundamental data for {ticker}: {response.status_code}\")\n            tqdm.write(response.text)\n    except Exception as e:\n        tqdm.write(f\"Exception occurred while processing fundamental data for {ticker}: {str(e)}\")\n\n# Define capitalization bins and labels\nbins = [0, 1e10, 1e11, 1e12, 1e13]\nlabels = ['Small (&lt;10B)', 'Medium (10B-100B)', 'Large (100B-1T)', 'Mega (&gt;1T)']\n\n# Create a new column for capitalization bins\ndf['Cap_Bin'] = pd.cut(df['Market Capitalisation'], bins=bins, labels=labels)<\/code><\/pre>\n\n                <\/div>\n                <div class=\"code__btns\">\n                    <button class=\"code__copy\" class=\"copy\" title=\"Copy url\">\n                        <svg class=\"code__copy__icon\" width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\">\n                            <use xlink:href=\"\/img\/icons\/copy.svg#copy\"><\/use>\n                        <\/svg>\n                        <img decoding=\"async\" class=\"code__copy__approve\" alt=\"\" src=\"\/img\/approve_ico.svg\" loading=\"eager\">\n                    <\/button>\n                <\/div>\n            <\/div>\n        \n\n\n<p>We will also add in the same dataframe the <span style=\", Times, serif;font-size: 20px;font-style: normal;font-weight: 400;letter-spacing: -0.06px;text-align: start;text-indent: 0px;text-transform: none;float: none\"><span>\u00a0<\/span>6-month volatility, which will later be used as a feature for grouping.<\/span><\/p>\n\n\n\n            <div class=\"code__wrapper\">\n                <div class=\"code__content\">\n                    \n<pre class=\"wp-block-code\"><code class=\"\">sp_500_prices_df.index = pd.to_datetime(sp_500_prices_df.index)\n\n# Sort by date\nsp_500_prices_df = sp_500_prices_df.sort_index()\n\n# Get the last 6 months of data\nsix_months_ago = sp_500_prices_df.index[-1] - pd.DateOffset(months=6)\nsix_month_prices = sp_500_prices_df[sp_500_prices_df.index &gt;= six_months_ago]\n\n# Calculate daily returns\ndaily_returns = six_month_prices.pct_change().dropna()\n\n# Calculate volatility (standard deviation of returns)\nvolatility = daily_returns.std() * (252 ** 0.5)  # Annualized volatility\n\n# Add volatility to the fundamentals dataframe\nfor ticker in sp500_tickers:\n    if ticker in volatility.index:\n        mask = df['Ticker'] == ticker\n        df.loc[mask, '6-Month Volatility'] = volatility[ticker]<\/code><\/pre>\n\n                <\/div>\n                <div class=\"code__btns\">\n                    <button class=\"code__copy\" class=\"copy\" title=\"Copy url\">\n                        <svg class=\"code__copy__icon\" width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\">\n                            <use xlink:href=\"\/img\/icons\/copy.svg#copy\"><\/use>\n                        <\/svg>\n                        <img decoding=\"async\" class=\"code__copy__approve\" alt=\"\" src=\"\/img\/approve_ico.svg\" loading=\"eager\">\n                    <\/button>\n                <\/div>\n            <\/div>\n        \n\n\n<h2 class=\"wp-block-heading\" id=\"h-clustering-with-fundamentals\">Clustering with fundamentals<\/h2>\n\n\n\n<p id=\"d467\">With all the required data in place, we\u2019ll now organise the stocks into 11 clusters. I selected this number because there are 11 sectors in the S&amp;P 500, and I\u2019m interested to see how closely our clusters will match the actual sector classifications.<\/p>\n\n\n\n<p id=\"7dfa\">In a nutshell:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>We define the features and normalise them<\/li>\n\n\n\n<li>In case there are missing data we impute them<\/li>\n\n\n\n<li>We use Principal Component Analysis (PCA) to reduce the complexity<\/li>\n\n\n\n<li>We use K-Means and group them into 11 clusters<\/li>\n<\/ul>\n\n\n\n            <div class=\"code__wrapper\">\n                <div class=\"code__content\">\n                    \n<pre class=\"wp-block-code\"><code class=\"\"># Preprocessing\nfeatures = df[['Market Capitalisation','P\/E Ratio','6-Month Volatility']]\n\n# Normalize features\nfrom sklearn.preprocessing import StandardScaler\n\nscaler = StandardScaler()\nscaled_data = scaler.fit_transform(features)\n\n# Impute Missing Data\n# The most common approach is to fill missing values with the mean, median, or another strategy using SimpleImputer from scikit-learn:\n\nfrom sklearn.impute import SimpleImputer\n\nimputer = SimpleImputer(strategy='mean')  # or 'median'\nimputed_data = imputer.fit_transform(features)\n\nfrom sklearn.preprocessing import StandardScaler\nfrom sklearn.decomposition import PCA\n\nscaler = StandardScaler()\nscaled_data = scaler.fit_transform(imputed_data)\n\npca = PCA(n_components=0.95)\nprincipal_components = pca.fit_transform(scaled_data)\n\nfrom sklearn.cluster import KMeans\n\nk = 11  # Typical for sector-based clustering\nmodel = KMeans(n_clusters=k)\nclusters = model.fit_predict(principal_components)\ndf['ClusterFeatures'] = clusters<\/code><\/pre>\n\n                <\/div>\n                <div class=\"code__btns\">\n                    <button class=\"code__copy\" class=\"copy\" title=\"Copy url\">\n                        <svg class=\"code__copy__icon\" width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\">\n                            <use xlink:href=\"\/img\/icons\/copy.svg#copy\"><\/use>\n                        <\/svg>\n                        <img decoding=\"async\" class=\"code__copy__approve\" alt=\"\" src=\"\/img\/approve_ico.svg\" loading=\"eager\">\n                    <\/button>\n                <\/div>\n            <\/div>\n        \n\n\n<p id=\"2e42\">Let\u2019s plot and see how the stocks are distributed per sector:<\/p>\n\n\n\n            <div class=\"code__wrapper\">\n                <div class=\"code__content\">\n                    \n<pre class=\"wp-block-code\"><code class=\"\"># Group by Sector and ClusterCorrelation, then count\nsector_cluster_counts = df.groupby(['Sector', 'ClusterFeatures']).size().reset_index(name='Count')\n\n# Pivot for a matrix view\npivot_table = sector_cluster_counts.pivot(index='Sector', columns='ClusterFeatures', values='Count').fillna(0).astype(int)\n\n# Create a stacked bar chart\nplt.figure(figsize=(14, 10))\npivot_table_percentage = pivot_table.div(pivot_table.sum(axis=1), axis=0) * 100\n\n# Plot stacked bar chart\npivot_table_percentage.T.plot(kind='bar', stacked=True, figsize=(14, 10), colormap='tab20')\nplt.title('Percentage Distribution of Sectors across Correlation Features', fontsize=16)\nplt.xlabel('Correlation Features', fontsize=14)\nplt.ylabel('Percentage', fontsize=14)\nplt.legend(title='Sector', bbox_to_anchor=(1.05, 1), loc='upper left')\nplt.tight_layout()\nplt.show()<\/code><\/pre>\n\n                <\/div>\n                <div class=\"code__btns\">\n                    <button class=\"code__copy\" class=\"copy\" title=\"Copy url\">\n                        <svg class=\"code__copy__icon\" width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\">\n                            <use xlink:href=\"\/img\/icons\/copy.svg#copy\"><\/use>\n                        <\/svg>\n                        <img decoding=\"async\" class=\"code__copy__approve\" alt=\"\" src=\"\/img\/approve_ico.svg\" loading=\"eager\">\n                    <\/button>\n                <\/div>\n            <\/div>\n        \n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"730\" src=\"https:\/\/eodhd.com\/financial-academy\/wp-content\/uploads\/2025\/07\/image-1024x730.png\" alt=\"\" class=\"wp-image-6449\" srcset=\"https:\/\/eodhd.com\/financial-academy\/wp-content\/uploads\/2025\/07\/image-1024x730.png 1024w, https:\/\/eodhd.com\/financial-academy\/wp-content\/uploads\/2025\/07\/image-300x214.png 300w, https:\/\/eodhd.com\/financial-academy\/wp-content\/uploads\/2025\/07\/image-768x547.png 768w, https:\/\/eodhd.com\/financial-academy\/wp-content\/uploads\/2025\/07\/image-60x43.png 60w, https:\/\/eodhd.com\/financial-academy\/wp-content\/uploads\/2025\/07\/image-150x107.png 150w, https:\/\/eodhd.com\/financial-academy\/wp-content\/uploads\/2025\/07\/image.png 1388w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>Not so insightful. The groups are unbalanced and not related to sector. So lets use some box plots:<\/p>\n\n\n\n            <div class=\"code__wrapper\">\n                <div class=\"code__content\">\n                    \n<pre class=\"wp-block-code\"><code class=\"\">import matplotlib.pyplot as plt\nimport seaborn as sns\n\n# Set up the figure with 3 subplots side by side\nfig, axes = plt.subplots(1, 3, figsize=(18, 6))\n\n# Boxplot for Market Capitalization\nsns.boxplot(x='ClusterFeatures', y='Market Capitalisation', data=df, ax=axes[0])\naxes[0].set_title('Market Cap by Correlation Cluster')\naxes[0].set_ylabel('Market Cap ($)')\naxes[0].set_xlabel('Correlation Cluster')\n# Use log scale for Market Cap due to wide range\naxes[0].set_yscale('log')\n\n# Boxplot for P\/E Ratio\nsns.boxplot(x='ClusterFeatures', y='P\/E Ratio', data=df, ax=axes[1])\naxes[1].set_title('P\/E Ratio by Correlation Cluster')\naxes[1].set_ylabel('P\/E Ratio')\naxes[1].set_xlabel('Correlation Cluster')\n# Set a reasonable y-limit to handle outliers\naxes[1].set_ylim(0, df['P\/E Ratio'].quantile(0.95))\n\n# Boxplot for 6-Month Volatility\nsns.boxplot(x='ClusterFeatures', y='6-Month Volatility', data=df, ax=axes[2])\naxes[2].set_title('6-Month Volatility by Correlation Cluster')\naxes[2].set_ylabel('Volatility (Annualized)')\naxes[2].set_xlabel('Correlation Cluster')\n\nplt.tight_layout()\nplt.show()<\/code><\/pre>\n\n                <\/div>\n                <div class=\"code__btns\">\n                    <button class=\"code__copy\" class=\"copy\" title=\"Copy url\">\n                        <svg class=\"code__copy__icon\" width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\">\n                            <use xlink:href=\"\/img\/icons\/copy.svg#copy\"><\/use>\n                        <\/svg>\n                        <img decoding=\"async\" class=\"code__copy__approve\" alt=\"\" src=\"\/img\/approve_ico.svg\" loading=\"eager\">\n                    <\/button>\n                <\/div>\n            <\/div>\n        \n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"338\" src=\"https:\/\/eodhd.com\/financial-academy\/wp-content\/uploads\/2025\/07\/image-1-1024x338.png\" alt=\"\" class=\"wp-image-6450\" srcset=\"https:\/\/eodhd.com\/financial-academy\/wp-content\/uploads\/2025\/07\/image-1-1024x338.png 1024w, https:\/\/eodhd.com\/financial-academy\/wp-content\/uploads\/2025\/07\/image-1-300x99.png 300w, https:\/\/eodhd.com\/financial-academy\/wp-content\/uploads\/2025\/07\/image-1-768x253.png 768w, https:\/\/eodhd.com\/financial-academy\/wp-content\/uploads\/2025\/07\/image-1-1536x507.png 1536w, https:\/\/eodhd.com\/financial-academy\/wp-content\/uploads\/2025\/07\/image-1-60x20.png 60w, https:\/\/eodhd.com\/financial-academy\/wp-content\/uploads\/2025\/07\/image-1-150x49.png 150w, https:\/\/eodhd.com\/financial-academy\/wp-content\/uploads\/2025\/07\/image-1.png 1789w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p id=\"3534\">What I can see from the box plots in a first glance is:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Group 4 consists of Apple, Nvidia, and Microsoft\u2014clearly representing the largest stocks by market capitalization. Group 5 features the next tier of giants, including Google, Amazon, and Meta, while Group 9 brings together Broadcom, Lilly, Oracle, and Tesla. The accompanying boxplot of P\/E Ratios shows that the algorithm effectively distinguished these mega-cap companies based on their P\/E Ratio.<\/li>\n\n\n\n<li>It\u2019s also noteworthy that groups 0, 1, 2, 7, and 10 are predominantly made up of small- and mid-cap stocks. Group 10 stands out with the highest P\/E ratio and shows moderate to low volatility, while the remaining four groups are mainly distinguished by their varying levels of volatility.<\/li>\n<\/ul>\n\n\n\n<p id=\"873d\">I use this method when I see a stock I like and want similar stocks with comparable features. I don\u2019t want to miss an opportunity if I\u2019m right, as other stocks in the same group could be even better options. This may seem like it could be done easily with a good screener. But with more features and groups, this method can quickly generate groups of stocks sharing the same features, expanding your search and providing better insights for decision-making.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"0fe4\">Clustering with price correlation<\/h2>\n\n\n\n<p id=\"1f02\">Now we move to something more interesting and familiar &#8211; the price action! We&#8217;ll perform and other clustering process using each stock&#8217;s correlation, grouping (again into 11 clusters) stocks based on their price movements.<\/p>\n\n\n\n<p id=\"a64b\">In a nutshell:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Calculate the correlation matrix.<\/li>\n\n\n\n<li>Convert the correlations into distances.<\/li>\n\n\n\n<li>Perform hierarchical clustering using the average linkage method.<\/li>\n<\/ul>\n\n\n\n            <div class=\"code__wrapper\">\n                <div class=\"code__content\">\n                    \n<pre class=\"wp-block-code\"><code class=\"\">import numpy as np\n\ncorr_matrix = returns.corr()\n\ndistance_matrix = np.sqrt(2 * (1 - corr_matrix))\ndistance_matrix\n\nfrom scipy.cluster.hierarchy import linkage, dendrogram\n\n# Average linkage often performs best for financial data[1][5]\nZ = linkage(distance_matrix, method='average')\n\nfrom scipy.cluster.hierarchy import fcluster\n\n# t is the number of clusters\nclusters = fcluster(Z, t=11, criterion='maxclust')\n\ndf.to_csv('csv\/sp500_clustered.csv', index=False)\ndf['ClusterCorrelation'] = clusters<\/code><\/pre>\n\n                <\/div>\n                <div class=\"code__btns\">\n                    <button class=\"code__copy\" class=\"copy\" title=\"Copy url\">\n                        <svg class=\"code__copy__icon\" width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\">\n                            <use xlink:href=\"\/img\/icons\/copy.svg#copy\"><\/use>\n                        <\/svg>\n                        <img decoding=\"async\" class=\"code__copy__approve\" alt=\"\" src=\"\/img\/approve_ico.svg\" loading=\"eager\">\n                    <\/button>\n                <\/div>\n            <\/div>\n        \n\n\n<p>Now let&#8217;s plot the same bar chart based on the sectors.<\/p>\n\n\n\n            <div class=\"code__wrapper\">\n                <div class=\"code__content\">\n                    \n<pre class=\"wp-block-code\"><code class=\"\"># Group by Sector and ClusterCorrelation, then count\nsector_cluster_counts = df.groupby(['Sector', 'ClusterCorrelation']).size().reset_index(name='Count')\n\n# Pivot for a matrix view\npivot_table = sector_cluster_counts.pivot(index='Sector', columns='ClusterCorrelation', values='Count').fillna(0).astype(int)\n\n# Create a stacked bar chart\nplt.figure(figsize=(14, 10))\npivot_table_percentage = pivot_table.div(pivot_table.sum(axis=1), axis=0) * 100\n\n# Plot stacked bar chart\npivot_table_percentage.T.plot(kind='bar', stacked=True, figsize=(14, 10), colormap='tab20')\nplt.title('Percentage Distribution of Sectors across Correlation Clusters', fontsize=16)\nplt.xlabel('Correlation Cluster', fontsize=14)\nplt.ylabel('Percentage', fontsize=14)\nplt.legend(title='Sector', bbox_to_anchor=(1.05, 1), loc='upper left')\nplt.tight_layout()\nplt.show()<\/code><\/pre>\n\n                <\/div>\n                <div class=\"code__btns\">\n                    <button class=\"code__copy\" class=\"copy\" title=\"Copy url\">\n                        <svg class=\"code__copy__icon\" width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\">\n                            <use xlink:href=\"\/img\/icons\/copy.svg#copy\"><\/use>\n                        <\/svg>\n                        <img decoding=\"async\" class=\"code__copy__approve\" alt=\"\" src=\"\/img\/approve_ico.svg\" loading=\"eager\">\n                    <\/button>\n                <\/div>\n            <\/div>\n        \n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"730\" src=\"https:\/\/eodhd.com\/financial-academy\/wp-content\/uploads\/2025\/07\/image-2-1024x730.png\" alt=\"\" class=\"wp-image-6451\" srcset=\"https:\/\/eodhd.com\/financial-academy\/wp-content\/uploads\/2025\/07\/image-2-1024x730.png 1024w, https:\/\/eodhd.com\/financial-academy\/wp-content\/uploads\/2025\/07\/image-2-300x214.png 300w, https:\/\/eodhd.com\/financial-academy\/wp-content\/uploads\/2025\/07\/image-2-768x547.png 768w, https:\/\/eodhd.com\/financial-academy\/wp-content\/uploads\/2025\/07\/image-2-60x43.png 60w, https:\/\/eodhd.com\/financial-academy\/wp-content\/uploads\/2025\/07\/image-2-150x107.png 150w, https:\/\/eodhd.com\/financial-academy\/wp-content\/uploads\/2025\/07\/image-2.png 1388w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p id=\"9fd9\">Let\u2019s discuss this bar chart:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u00a0<strong>Energy\u00a0<\/strong>stocks are one cluster, indicating that this is a highly distinctive sector that moves together!<\/li>\n\n\n\n<li>Most <strong>Utility <\/strong>stocks in group 2 are from the <strong>Regular Electric <\/strong>industry, highlighting its distinct behavior within the sector.<\/li>\n\n\n\n<li>All the <strong>Mega <\/strong>stocks are in Group 7, except Berkshire, which is in Group 9. Nearly all technology stocks are also in Group 7, underscoring tech\u2019s dominant role in the market.demonstrating that technology is the primary driver of the market.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-what-to-do-next\">What to do next<\/h2>\n\n\n\n<p>In the scope of this post, it is not so easy to examine all the possibilities of the clustering method. However, with some minor changes (or a bit more) of the above code, you can experiment and find insightful information that will guide you towards your personal trading edge:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Add more features: dividend yield, debt\/equity, revenue growth.<\/li>\n\n\n\n<li>Use technical indicators: RSI, MACD, moving averages.<\/li>\n\n\n\n<li>Incorporate alternative data: news sentiment, ESG scores.<\/li>\n\n\n\n<li>Apply clustering to rolling time windows.<\/li>\n\n\n\n<li>Build cluster-based stock screeners.<\/li>\n\n\n\n<li>Set up alerts for cluster composition changes.<\/li>\n\n\n\n<li>Automate clustering pipeline with scheduled updates.<\/li>\n<\/ul>\n\n\n\n<p>Thanks for reading!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Clustering stocks can substantially enhance your trading strategies and assist in managing diversification with professionalism. The concept of clustering involves the grouping of stocks according to their fundamental characteristics and\/or their price movements. A common way to classify stocks is by sector. If you haven\u2019t already, consider making sector diversification a key part of your [&hellip;]<\/p>\n","protected":false},"author":30,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[48],"tags":[],"coding-language":[],"ready-to-go-solution":[],"qualification":[],"financial-apis-category":[],"financial-apis-manuals":[],"class_list":["post-6448","post","type-post","status-publish","format-standard","hentry","category-stocks-data-processing-examples"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.9 (Yoast SEO v26.7) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Clustering for Traders: Boost Your Portfolio\u2019s Performance with Data Science | EODHD APIs Academy<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/eodhd.com\/financial-academy\/stocks-data-processing-examples\/clustering-for-traders-boost-your-portfolios-performance-with-data-science\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Clustering for Traders: Boost Your Portfolio\u2019s Performance with Data Science\" \/>\n<meta property=\"og:description\" content=\"Clustering stocks can substantially enhance your trading strategies and assist in managing diversification with professionalism. The concept of clustering involves the grouping of stocks according to their fundamental characteristics and\/or their price movements. A common way to classify stocks is by sector. If you haven\u2019t already, consider making sector diversification a key part of your [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/eodhd.com\/financial-academy\/stocks-data-processing-examples\/clustering-for-traders-boost-your-portfolios-performance-with-data-science\" \/>\n<meta property=\"og:site_name\" content=\"Financial Academy\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/eodhistoricaldata\" \/>\n<meta property=\"article:published_time\" content=\"2025-07-15T05:28:14+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-07-15T05:28:20+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/eodhd.com\/financial-academy\/wp-content\/uploads\/2025\/07\/image-1024x730.png\" \/>\n<meta name=\"author\" content=\"Filippos Tzimopoulos\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@EOD_data\" \/>\n<meta name=\"twitter:site\" content=\"@EOD_data\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Filippos Tzimopoulos\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/eodhd.com\/financial-academy\/stocks-data-processing-examples\/clustering-for-traders-boost-your-portfolios-performance-with-data-science#article\",\"isPartOf\":{\"@id\":\"https:\/\/eodhd.com\/financial-academy\/stocks-data-processing-examples\/clustering-for-traders-boost-your-portfolios-performance-with-data-science\"},\"author\":{\"name\":\"Filippos Tzimopoulos\",\"@id\":\"https:\/\/eodhd.com\/financial-academy\/#\/schema\/person\/62bea60a15bb6cf5f09511bbcad2c448\"},\"headline\":\"Clustering for Traders: Boost Your Portfolio\u2019s Performance with Data Science\",\"datePublished\":\"2025-07-15T05:28:14+00:00\",\"dateModified\":\"2025-07-15T05:28:20+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/eodhd.com\/financial-academy\/stocks-data-processing-examples\/clustering-for-traders-boost-your-portfolios-performance-with-data-science\"},\"wordCount\":1057,\"publisher\":{\"@id\":\"https:\/\/eodhd.com\/financial-academy\/#organization\"},\"image\":{\"@id\":\"https:\/\/eodhd.com\/financial-academy\/stocks-data-processing-examples\/clustering-for-traders-boost-your-portfolios-performance-with-data-science#primaryimage\"},\"thumbnailUrl\":\"https:\/\/eodhd.com\/financial-academy\/wp-content\/uploads\/2025\/07\/image-1024x730.png\",\"articleSection\":[\"Stocks Data Processing Examples\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/eodhd.com\/financial-academy\/stocks-data-processing-examples\/clustering-for-traders-boost-your-portfolios-performance-with-data-science\",\"url\":\"https:\/\/eodhd.com\/financial-academy\/stocks-data-processing-examples\/clustering-for-traders-boost-your-portfolios-performance-with-data-science\",\"name\":\"Clustering for Traders: Boost Your Portfolio\u2019s Performance with Data Science | EODHD APIs Academy\",\"isPartOf\":{\"@id\":\"https:\/\/eodhd.com\/financial-academy\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/eodhd.com\/financial-academy\/stocks-data-processing-examples\/clustering-for-traders-boost-your-portfolios-performance-with-data-science#primaryimage\"},\"image\":{\"@id\":\"https:\/\/eodhd.com\/financial-academy\/stocks-data-processing-examples\/clustering-for-traders-boost-your-portfolios-performance-with-data-science#primaryimage\"},\"thumbnailUrl\":\"https:\/\/eodhd.com\/financial-academy\/wp-content\/uploads\/2025\/07\/image-1024x730.png\",\"datePublished\":\"2025-07-15T05:28:14+00:00\",\"dateModified\":\"2025-07-15T05:28:20+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/eodhd.com\/financial-academy\/stocks-data-processing-examples\/clustering-for-traders-boost-your-portfolios-performance-with-data-science#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/eodhd.com\/financial-academy\/stocks-data-processing-examples\/clustering-for-traders-boost-your-portfolios-performance-with-data-science\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/eodhd.com\/financial-academy\/stocks-data-processing-examples\/clustering-for-traders-boost-your-portfolios-performance-with-data-science#primaryimage\",\"url\":\"https:\/\/eodhd.com\/financial-academy\/wp-content\/uploads\/2025\/07\/image.png\",\"contentUrl\":\"https:\/\/eodhd.com\/financial-academy\/wp-content\/uploads\/2025\/07\/image.png\",\"width\":1388,\"height\":989},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/eodhd.com\/financial-academy\/stocks-data-processing-examples\/clustering-for-traders-boost-your-portfolios-performance-with-data-science#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/eodhd.com\/financial-academy\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Clustering for Traders: Boost Your Portfolio\u2019s Performance with Data Science\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/eodhd.com\/financial-academy\/#website\",\"url\":\"https:\/\/eodhd.com\/financial-academy\/\",\"name\":\"Financial APIs Academy | EODHD\",\"description\":\"Financial Stock Market Academy\",\"publisher\":{\"@id\":\"https:\/\/eodhd.com\/financial-academy\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/eodhd.com\/financial-academy\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/eodhd.com\/financial-academy\/#organization\",\"name\":\"EODHD (EOD Historical Data)\",\"url\":\"https:\/\/eodhd.com\/financial-academy\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/eodhd.com\/financial-academy\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/eodhd.com\/financial-academy\/wp-content\/uploads\/2023\/12\/EODHD-Logo.png\",\"contentUrl\":\"https:\/\/eodhd.com\/financial-academy\/wp-content\/uploads\/2023\/12\/EODHD-Logo.png\",\"width\":159,\"height\":82,\"caption\":\"EODHD (EOD Historical Data)\"},\"image\":{\"@id\":\"https:\/\/eodhd.com\/financial-academy\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/eodhistoricaldata\",\"https:\/\/x.com\/EOD_data\",\"https:\/\/www.reddit.com\/r\/EODHistoricalData\/\",\"https:\/\/eod-historical-data.medium.com\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/eodhd.com\/financial-academy\/#\/schema\/person\/62bea60a15bb6cf5f09511bbcad2c448\",\"name\":\"Filippos Tzimopoulos\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/eodhd.com\/financial-academy\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/4c3f487ab4ce0733b492937a98b5f56bf39f6c2c5ff51e85f849f7d09d5405f2?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/4c3f487ab4ce0733b492937a98b5f56bf39f6c2c5ff51e85f849f7d09d5405f2?s=96&d=mm&r=g\",\"caption\":\"Filippos Tzimopoulos\"},\"description\":\"Seasoned Business and Data Analyst with over 30+ years of experience | Python advocate | Finance and Quantitative enthusiast\",\"sameAs\":[\"https:\/\/medium.com\/@phitzi\"],\"url\":\"https:\/\/eodhd.com\/financial-academy\/author\/filippos\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Clustering for Traders: Boost Your Portfolio\u2019s Performance with Data Science | EODHD APIs Academy","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/eodhd.com\/financial-academy\/stocks-data-processing-examples\/clustering-for-traders-boost-your-portfolios-performance-with-data-science","og_locale":"en_US","og_type":"article","og_title":"Clustering for Traders: Boost Your Portfolio\u2019s Performance with Data Science","og_description":"Clustering stocks can substantially enhance your trading strategies and assist in managing diversification with professionalism. The concept of clustering involves the grouping of stocks according to their fundamental characteristics and\/or their price movements. A common way to classify stocks is by sector. If you haven\u2019t already, consider making sector diversification a key part of your [&hellip;]","og_url":"https:\/\/eodhd.com\/financial-academy\/stocks-data-processing-examples\/clustering-for-traders-boost-your-portfolios-performance-with-data-science","og_site_name":"Financial Academy","article_publisher":"https:\/\/www.facebook.com\/eodhistoricaldata","article_published_time":"2025-07-15T05:28:14+00:00","article_modified_time":"2025-07-15T05:28:20+00:00","og_image":[{"url":"https:\/\/eodhd.com\/financial-academy\/wp-content\/uploads\/2025\/07\/image-1024x730.png","type":"","width":"","height":""}],"author":"Filippos Tzimopoulos","twitter_card":"summary_large_image","twitter_creator":"@EOD_data","twitter_site":"@EOD_data","twitter_misc":{"Written by":"Filippos Tzimopoulos","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/eodhd.com\/financial-academy\/stocks-data-processing-examples\/clustering-for-traders-boost-your-portfolios-performance-with-data-science#article","isPartOf":{"@id":"https:\/\/eodhd.com\/financial-academy\/stocks-data-processing-examples\/clustering-for-traders-boost-your-portfolios-performance-with-data-science"},"author":{"name":"Filippos Tzimopoulos","@id":"https:\/\/eodhd.com\/financial-academy\/#\/schema\/person\/62bea60a15bb6cf5f09511bbcad2c448"},"headline":"Clustering for Traders: Boost Your Portfolio\u2019s Performance with Data Science","datePublished":"2025-07-15T05:28:14+00:00","dateModified":"2025-07-15T05:28:20+00:00","mainEntityOfPage":{"@id":"https:\/\/eodhd.com\/financial-academy\/stocks-data-processing-examples\/clustering-for-traders-boost-your-portfolios-performance-with-data-science"},"wordCount":1057,"publisher":{"@id":"https:\/\/eodhd.com\/financial-academy\/#organization"},"image":{"@id":"https:\/\/eodhd.com\/financial-academy\/stocks-data-processing-examples\/clustering-for-traders-boost-your-portfolios-performance-with-data-science#primaryimage"},"thumbnailUrl":"https:\/\/eodhd.com\/financial-academy\/wp-content\/uploads\/2025\/07\/image-1024x730.png","articleSection":["Stocks Data Processing Examples"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/eodhd.com\/financial-academy\/stocks-data-processing-examples\/clustering-for-traders-boost-your-portfolios-performance-with-data-science","url":"https:\/\/eodhd.com\/financial-academy\/stocks-data-processing-examples\/clustering-for-traders-boost-your-portfolios-performance-with-data-science","name":"Clustering for Traders: Boost Your Portfolio\u2019s Performance with Data Science | EODHD APIs Academy","isPartOf":{"@id":"https:\/\/eodhd.com\/financial-academy\/#website"},"primaryImageOfPage":{"@id":"https:\/\/eodhd.com\/financial-academy\/stocks-data-processing-examples\/clustering-for-traders-boost-your-portfolios-performance-with-data-science#primaryimage"},"image":{"@id":"https:\/\/eodhd.com\/financial-academy\/stocks-data-processing-examples\/clustering-for-traders-boost-your-portfolios-performance-with-data-science#primaryimage"},"thumbnailUrl":"https:\/\/eodhd.com\/financial-academy\/wp-content\/uploads\/2025\/07\/image-1024x730.png","datePublished":"2025-07-15T05:28:14+00:00","dateModified":"2025-07-15T05:28:20+00:00","breadcrumb":{"@id":"https:\/\/eodhd.com\/financial-academy\/stocks-data-processing-examples\/clustering-for-traders-boost-your-portfolios-performance-with-data-science#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/eodhd.com\/financial-academy\/stocks-data-processing-examples\/clustering-for-traders-boost-your-portfolios-performance-with-data-science"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/eodhd.com\/financial-academy\/stocks-data-processing-examples\/clustering-for-traders-boost-your-portfolios-performance-with-data-science#primaryimage","url":"https:\/\/eodhd.com\/financial-academy\/wp-content\/uploads\/2025\/07\/image.png","contentUrl":"https:\/\/eodhd.com\/financial-academy\/wp-content\/uploads\/2025\/07\/image.png","width":1388,"height":989},{"@type":"BreadcrumbList","@id":"https:\/\/eodhd.com\/financial-academy\/stocks-data-processing-examples\/clustering-for-traders-boost-your-portfolios-performance-with-data-science#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/eodhd.com\/financial-academy\/"},{"@type":"ListItem","position":2,"name":"Clustering for Traders: Boost Your Portfolio\u2019s Performance with Data Science"}]},{"@type":"WebSite","@id":"https:\/\/eodhd.com\/financial-academy\/#website","url":"https:\/\/eodhd.com\/financial-academy\/","name":"Financial APIs Academy | EODHD","description":"Financial Stock Market Academy","publisher":{"@id":"https:\/\/eodhd.com\/financial-academy\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/eodhd.com\/financial-academy\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/eodhd.com\/financial-academy\/#organization","name":"EODHD (EOD Historical Data)","url":"https:\/\/eodhd.com\/financial-academy\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/eodhd.com\/financial-academy\/#\/schema\/logo\/image\/","url":"https:\/\/eodhd.com\/financial-academy\/wp-content\/uploads\/2023\/12\/EODHD-Logo.png","contentUrl":"https:\/\/eodhd.com\/financial-academy\/wp-content\/uploads\/2023\/12\/EODHD-Logo.png","width":159,"height":82,"caption":"EODHD (EOD Historical Data)"},"image":{"@id":"https:\/\/eodhd.com\/financial-academy\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/eodhistoricaldata","https:\/\/x.com\/EOD_data","https:\/\/www.reddit.com\/r\/EODHistoricalData\/","https:\/\/eod-historical-data.medium.com\/"]},{"@type":"Person","@id":"https:\/\/eodhd.com\/financial-academy\/#\/schema\/person\/62bea60a15bb6cf5f09511bbcad2c448","name":"Filippos Tzimopoulos","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/eodhd.com\/financial-academy\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/4c3f487ab4ce0733b492937a98b5f56bf39f6c2c5ff51e85f849f7d09d5405f2?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4c3f487ab4ce0733b492937a98b5f56bf39f6c2c5ff51e85f849f7d09d5405f2?s=96&d=mm&r=g","caption":"Filippos Tzimopoulos"},"description":"Seasoned Business and Data Analyst with over 30+ years of experience | Python advocate | Finance and Quantitative enthusiast","sameAs":["https:\/\/medium.com\/@phitzi"],"url":"https:\/\/eodhd.com\/financial-academy\/author\/filippos"}]}},"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pdOdVT-1G0","jetpack_sharing_enabled":true,"acf":[],"_links":{"self":[{"href":"https:\/\/eodhd.com\/financial-academy\/wp-json\/wp\/v2\/posts\/6448","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/eodhd.com\/financial-academy\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eodhd.com\/financial-academy\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eodhd.com\/financial-academy\/wp-json\/wp\/v2\/users\/30"}],"replies":[{"embeddable":true,"href":"https:\/\/eodhd.com\/financial-academy\/wp-json\/wp\/v2\/comments?post=6448"}],"version-history":[{"count":1,"href":"https:\/\/eodhd.com\/financial-academy\/wp-json\/wp\/v2\/posts\/6448\/revisions"}],"predecessor-version":[{"id":6452,"href":"https:\/\/eodhd.com\/financial-academy\/wp-json\/wp\/v2\/posts\/6448\/revisions\/6452"}],"wp:attachment":[{"href":"https:\/\/eodhd.com\/financial-academy\/wp-json\/wp\/v2\/media?parent=6448"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eodhd.com\/financial-academy\/wp-json\/wp\/v2\/categories?post=6448"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eodhd.com\/financial-academy\/wp-json\/wp\/v2\/tags?post=6448"},{"taxonomy":"coding-language","embeddable":true,"href":"https:\/\/eodhd.com\/financial-academy\/wp-json\/wp\/v2\/coding-language?post=6448"},{"taxonomy":"ready-to-go-solution","embeddable":true,"href":"https:\/\/eodhd.com\/financial-academy\/wp-json\/wp\/v2\/ready-to-go-solution?post=6448"},{"taxonomy":"qualification","embeddable":true,"href":"https:\/\/eodhd.com\/financial-academy\/wp-json\/wp\/v2\/qualification?post=6448"},{"taxonomy":"financial-apis-category","embeddable":true,"href":"https:\/\/eodhd.com\/financial-academy\/wp-json\/wp\/v2\/financial-apis-category?post=6448"},{"taxonomy":"financial-apis-manuals","embeddable":true,"href":"https:\/\/eodhd.com\/financial-academy\/wp-json\/wp\/v2\/financial-apis-manuals?post=6448"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}