diff --git a/clustering/clustering.py b/clustering/clustering.py new file mode 100644 index 0000000..ac82f63 --- /dev/null +++ b/clustering/clustering.py @@ -0,0 +1,29 @@ +from sklearn.preprocessing import RobustScaler +from sklearn.cluster import KMeans + +def run_clustering_pipeline(feature_df, n_clusters=4): + """ + Scales features and clusters clients. + """ + # 1. Preprocessing + # Fill missing sensitivities with 0 (neutral) for clients with insufficient history + df_clean = feature_df.fillna(0) + + # Scaling: RobustScaler is preferred over StandardScaler for financial data + # because it is less influenced by 'Whale' clients (outliers). + scaler = RobustScaler() + scaled_data = scaler.fit_transform(df_clean) + + # 2. Clustering + kmeans = KMeans(n_clusters=n_clusters, random_state=42, n_init=10) + labels = kmeans.fit_predict(scaled_data) + + # 3. Attach labels + results = df_clean.copy() + results['Cluster'] = labels + + return results, kmeans.cluster_centers_ + +def get_cluster_profiles(results_df): + """Returns the average profile of each cluster.""" + return results_df.groupby('Cluster').mean() \ No newline at end of file diff --git a/clustering/data_loader.py b/clustering/data_loader.py new file mode 100644 index 0000000..1b06a54 --- /dev/null +++ b/clustering/data_loader.py @@ -0,0 +1,27 @@ +import pandas as pd + +def load_and_clean_data(flows_path, aum_path, rates_path, gov_path): + """ + Loads raw CSVs and parses dates for consistent time-series analysis. + """ + # 1. Load Flows + flows = pd.read_csv(flows_path) + flows['Centralisation Date'] = pd.to_datetime(flows['Centralisation Date']) + + # 2. Load AUM + aum = pd.read_csv(aum_path) + aum['Centralisation Date'] = pd.to_datetime(aum['Centralisation Date']) + + # 3. Load Market Data (STR Rates) + # Handling potential dd/mm/yyyy formats common in EU data + rates = pd.read_csv(rates_path) + try: + rates['Date'] = pd.to_datetime(rates['Date'], dayfirst=True) + except: + rates['Date'] = pd.to_datetime(rates['Date']) + + # 4. Load Gov Indices + gov = pd.read_csv(gov_path) + gov['Date'] = pd.to_datetime(gov['Date']) + + return flows, aum, rates, gov \ No newline at end of file diff --git a/clustering/features.py b/clustering/features.py new file mode 100644 index 0000000..b9201d2 --- /dev/null +++ b/clustering/features.py @@ -0,0 +1,91 @@ +import pandas as pd +import statsmodels.api as sm + +def compute_static_features(flows_df, aum_df): + """Generates descriptive features from Flows and AUM.""" + + # --- 1. Flow Dynamics --- + flow_stats = flows_df.groupby('Registrar Account - ID').agg( + total_subs=('Value € - Subscription', 'sum'), + total_reds=('Value € - Redemption', 'sum'), + net_flow_vol=('Value € - NetFlows', 'sum'), + txn_count=('Agreement - Code', 'count'), + # Tenure: Days between first and last activity + tenure_days=('Centralisation Date', lambda x: (x.max() - x.min()).days) + ) + + # Flow Ratio: -1 (Pure Seller) to +1 (Pure Buyer) + flow_stats['buy_sell_ratio'] = (flow_stats['total_subs'] - flow_stats['total_reds']) / \ + (flow_stats['total_subs'] + flow_stats['total_reds'] + 1e-6) + + # --- 2. Product Preferences --- + # Calculate % of flows going to each Asset Type + asset_pivot = flows_df.groupby(['Registrar Account - ID', 'Product - Asset Type'])['Value € - Subscription'].sum().unstack(fill_value=0) + asset_pct = asset_pivot.div(asset_pivot.sum(axis=1) + 1e-6, axis=0).add_prefix('pct_flow_') + + # --- 3. AUM Stats --- + aum_stats = aum_df.groupby('Registrar Account - ID').agg( + avg_aum=('Value - AUM €', 'mean'), + aum_volatility=('Value - AUM €', 'std') + ) + + # Merge all static features + features = flow_stats.join(asset_pct).join(aum_stats, how='outer').fillna(0) + return features + +def compute_market_sensitivities(flows_df, rates_df, gov_df, freq='M'): + """ + Computes Beta sensitivity to Rates and Gov Bonds. + Freq: 'M' (Monthly) recommended for long history. + """ + # 1. Prepare Market Factors + # Resample Rates (Take last value of period) + rates_res = rates_df.set_index('Date').resample(freq)['Yld to Maturity'].last() + delta_rates = rates_res.diff().rename('Delta_Rate') + + # Resample Gov Bonds (Using 'EG04' 7-10Y Euro Gov as proxy) + gov_target = gov_df[gov_df['Bond/Index'] == 'EG04'].set_index('Date') + gov_target = gov_target[~gov_target.index.duplicated(keep='first')] # Dedup + # Calculate return over period + gov_res = gov_target['Total Return % 1-wk-LOC'].resample(freq).apply(lambda x: (1 + x/100).prod() - 1) + gov_res = gov_res.rename('Bond_Return') + + market_factors = pd.concat([delta_rates, gov_res], axis=1).dropna() + + # 2. Prepare Client Flows (Aggregated by same frequency) + flows_df['Period'] = flows_df['Centralisation Date'].dt.to_period(freq).dt.to_timestamp() + + client_betas = [] + + # Only analyze clients with sufficient activity (>5 transactions) + active_clients = flows_df['Registrar Account - ID'].value_counts() + active_clients = active_clients[active_clients >= 5].index + + for client in active_clients: + c_flows = flows_df[flows_df['Registrar Account - ID'] == client] + c_ts = c_flows.groupby('Period')['Quantity - NetFlows'].sum() + + # Inner join to align dates (Client Activity vs Market Data) + merged = pd.concat([c_ts, market_factors], axis=1, join='inner') + + # Need enough points for regression + if len(merged) >= 5: + Y = merged['Quantity - NetFlows'] + X = merged[['Delta_Rate', 'Bond_Return']] + X = sm.add_constant(X) + + try: + model = sm.OLS(Y, X).fit() + client_betas.append({ + 'Registrar Account - ID': client, + 'beta_rate': model.params.get('Delta_Rate', 0), + 'beta_bond': model.params.get('Bond_Return', 0), + 'r_squared': model.rsquared + }) + except: + continue + + if not client_betas: + return pd.DataFrame(columns=['Registrar Account - ID', 'beta_rate', 'beta_bond', 'r_squared']) + + return pd.DataFrame(client_betas).set_index('Registrar Account - ID') \ No newline at end of file diff --git a/clustering/main.py b/clustering/main.py new file mode 100644 index 0000000..e8d8f98 --- /dev/null +++ b/clustering/main.py @@ -0,0 +1,43 @@ +import pandas as pd +from data_loader import load_and_clean_data +from features import compute_static_features, compute_market_sensitivities +from clustering import run_clustering_pipeline, get_cluster_profiles + +def main(): + print("--- Starting Carmignac Client Clustering Pipeline ---") + + # 1. Load Data + print("Loading data...") + flows, aum, rates, gov = load_and_clean_data( + 'flows_sample.csv', + 'aum_sample.csv', + 'str_rates.csv', + 'eur_gov_indices.csv' + ) + + # 2. Feature Engineering + print("Computing static features...") + static_feats = compute_static_features(flows, aum) + + print("Computing market sensitivities (Betas)...") + # Note: Using 'W' (Weekly) to maximize points for the sample. + # Use 'M' (Monthly) for the full dataset. + sensitivity_feats = compute_market_sensitivities(flows, rates, gov, freq='W') + + # Merge features + full_features = static_feats.join(sensitivity_feats, how='left') + + # 3. Clustering + print(f"Running Clustering on {len(full_features)} clients...") + clustered_df, centers = run_clustering_pipeline(full_features, n_clusters=3) + + # 4. Results + print("\n--- Cluster Profiles (Mean Values) ---") + profiles = get_cluster_profiles(clustered_df) + print(profiles.T) + + clustered_df.to_csv('client_clusters.csv') + print("\nResults saved to 'client_clusters.csv'") + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/data_exploration/dataloader.ipynb b/data_exploration/dataloader.ipynb index c980923..3ebab3e 100644 --- a/data_exploration/dataloader.ipynb +++ b/data_exploration/dataloader.ipynb @@ -10,7 +10,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 1, "id": "126c8a80-d9ad-4816-84f0-0c3d580f62c8", "metadata": {}, "outputs": [ @@ -18,10 +18,17 @@ "name": "stdout", "output_type": "stream", "text": [ - "Requirement already satisfied: openpyxl in /opt/python/lib/python3.13/site-packages (3.1.5)\n", - "Requirement already satisfied: et-xmlfile in /opt/python/lib/python3.13/site-packages (from openpyxl) (2.0.0)\n", + "Collecting openpyxl\n", + " Downloading openpyxl-3.1.5-py2.py3-none-any.whl.metadata (2.5 kB)\n", + "Collecting et-xmlfile (from openpyxl)\n", + " Downloading et_xmlfile-2.0.0-py3-none-any.whl.metadata (2.7 kB)\n", + "Downloading openpyxl-3.1.5-py2.py3-none-any.whl (250 kB)\n", + "Downloading et_xmlfile-2.0.0-py3-none-any.whl (18 kB)\n", + "Installing collected packages: et-xmlfile, openpyxl\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m2/2\u001b[0m [openpyxl]1/2\u001b[0m [openpyxl]\n", + "\u001b[1A\u001b[2KSuccessfully installed et-xmlfile-2.0.0 openpyxl-3.1.5\n", "\n", - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m25.2\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m25.3\u001b[0m\n", + "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m25.3\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m26.0\u001b[0m\n", "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n" ] } @@ -2822,7 +2829,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.13.8" + "version": "3.13.11" } }, "nbformat": 4, diff --git a/data_exploration/eur_gov_indices.csv b/data_exploration/eur_gov_indices.csv new file mode 100644 index 0000000..c1f018c --- /dev/null +++ b/data_exploration/eur_gov_indices.csv @@ -0,0 +1,61 @@ +Bond/Index,Description,Date,Total Return % 1-wk-LOC,Yield to Maturity (s.a.),Yield to Maturity (conv.) +G0D0,ICE BofA German Government Index,2008-08-22,-0.302,4.21,4.25 +G0D0,ICE BofA German Government Index,2008-08-29,0.304,4.18,4.22 +G0D0,ICE BofA German Government Index,2008-09-05,0.978,3.99,4.03 +G0D0,ICE BofA German Government Index,2008-09-12,-1.058,4.17,4.21 +G0D0,ICE BofA German Government Index,2008-09-19,-0.286,4.22,4.27 +G0D0,ICE BofA German Government Index,2008-09-26,0.661,4.05,4.09 +G0D0,ICE BofA German Government Index,2008-10-03,1.89,3.71,3.75 +G0D0,ICE BofA German Government Index,2008-10-10,0.094,3.61,3.65 +G0D0,ICE BofA German Government Index,2008-10-17,-0.355,3.67,3.7 +G0D0,ICE BofA German Government Index,2008-10-24,1.637,3.39,3.42 +G0D0,ICE BofA German Government Index,2008-10-31,-0.535,3.41,3.44 +G0D0,ICE BofA German Government Index,2008-11-07,1.325,3.2,3.23 +G0D0,ICE BofA German Government Index,2008-11-14,0.449,3.07,3.1 +G0D0,ICE BofA German Government Index,2008-11-21,1.356,2.89,2.92 +G0D0,ICE BofA German Government Index,2008-11-28,0.778,2.86,2.88 +G0D0,ICE BofA German Government Index,2008-12-05,1.466,2.69,2.7 +G0D0,ICE BofA German Government Index,2008-12-12,-1.91,2.96,2.98 +G0D0,ICE BofA German Government Index,2008-12-19,1.798,2.65,2.67 +G0D0,ICE BofA German Government Index,2008-12-26,0.312,2.6,2.62 +G0D0,ICE BofA German Government Index,2009-01-02,0.264,2.56,2.57 +EG04,ICE BofA 7-10 Year Euro Government Index,2011-03-11,0.375,4.17,4.21 +EG04,ICE BofA 7-10 Year Euro Government Index,2011-03-18,0.8,4.07,4.1 +EG04,ICE BofA 7-10 Year Euro Government Index,2011-03-25,-0.685,4.17,4.21 +EG04,ICE BofA 7-10 Year Euro Government Index,2011-04-01,-0.785,4.31,4.35 +EG04,ICE BofA 7-10 Year Euro Government Index,2011-04-08,0.023,4.33,4.37 +EG04,ICE BofA 7-10 Year Euro Government Index,2011-04-15,0.168,4.31,4.35 +EG04,ICE BofA 7-10 Year Euro Government Index,2011-04-22,0.3205,4.265,4.305 +EG04,ICE BofA 7-10 Year Euro Government Index,2011-04-29,0.473,4.22,4.26 +EG04,ICE BofA 7-10 Year Euro Government Index,2011-05-06,0.455,4.22,4.26 +EG04,ICE BofA 7-10 Year Euro Government Index,2011-05-13,0.517,4.15,4.19 +EG04,ICE BofA 7-10 Year Euro Government Index,2011-05-20,-0.18,4.19,4.23 +EG04,ICE BofA 7-10 Year Euro Government Index,2011-05-27,0.494,4.12,4.16 +EG04,ICE BofA 7-10 Year Euro Government Index,2011-06-03,0.297,4.11,4.15 +EG04,ICE BofA 7-10 Year Euro Government Index,2011-06-10,-0.326,4.16,4.2 +EG04,ICE BofA 7-10 Year Euro Government Index,2011-06-17,-0.217,4.17,4.21 +EG04,ICE BofA 7-10 Year Euro Government Index,2011-06-24,-0.135,4.18,4.23 +EG04,ICE BofA 7-10 Year Euro Government Index,2011-07-01,-0.055,4.18,4.22 +EG04,ICE BofA 7-10 Year Euro Government Index,2011-07-08,-0.699,4.24,4.29 +EG04,ICE BofA 7-10 Year Euro Government Index,2011-07-15,-0.923,4.35,4.4 +EG04,ICE BofA 7-10 Year Euro Government Index,2011-07-22,1.181,4.25,4.29 +EG04,ICE BofA 7-10 Year Euro Government Index,2016-01-15,0.122,0.85,0.85 +EG04,ICE BofA 7-10 Year Euro Government Index,2016-01-22,0.269,0.82,0.82 +EG04,ICE BofA 7-10 Year Euro Government Index,2016-01-29,1.123,0.67,0.67 +EG04,ICE BofA 7-10 Year Euro Government Index,2016-02-05,-0.268,0.72,0.72 +EG04,ICE BofA 7-10 Year Euro Government Index,2016-02-12,-0.209,0.75,0.75 +EG04,ICE BofA 7-10 Year Euro Government Index,2016-02-19,0.454,0.69,0.69 +EG04,ICE BofA 7-10 Year Euro Government Index,2016-02-26,0.547,0.62,0.62 +EG04,ICE BofA 7-10 Year Euro Government Index,2016-03-04,-0.154,0.64,0.65 +EG04,ICE BofA 7-10 Year Euro Government Index,2016-03-11,0.28,0.61,0.61 +EG04,ICE BofA 7-10 Year Euro Government Index,2016-03-18,0.357,0.56,0.57 +EG04,ICE BofA 7-10 Year Euro Government Index,2016-03-25,0.41100000000000003,0.535,0.54 +EG04,ICE BofA 7-10 Year Euro Government Index,2016-04-01,0.465,0.51,0.51 +EG04,ICE BofA 7-10 Year Euro Government Index,2016-04-08,-0.114,0.53,0.53 +EG04,ICE BofA 7-10 Year Euro Government Index,2016-04-15,-0.097,0.54,0.54 +EG04,ICE BofA 7-10 Year Euro Government Index,2016-04-22,-0.66,0.63,0.63 +EG04,ICE BofA 7-10 Year Euro Government Index,2016-04-29,-0.338,0.68,0.68 +EG04,ICE BofA 7-10 Year Euro Government Index,2016-05-06,0.65,0.6,0.6 +EG04,ICE BofA 7-10 Year Euro Government Index,2016-05-13,0.211,0.57,0.57 +EG04,ICE BofA 7-10 Year Euro Government Index,2016-05-20,-0.142,0.59,0.59 +EG04,ICE BofA 7-10 Year Euro Government Index,2016-05-27,0.471,0.53,0.53 diff --git a/data_exploration/explore.ipynb b/data_exploration/explore.ipynb index cb8f390..4121094 100644 --- a/data_exploration/explore.ipynb +++ b/data_exploration/explore.ipynb @@ -10,7 +10,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 1, "id": "127753ac", "metadata": {}, "outputs": [], @@ -20,7 +20,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 2, "id": "ae3c64fe", "metadata": {}, "outputs": [], @@ -36,7 +36,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 3, "id": "84b9ac42", "metadata": {}, "outputs": [], @@ -62,34 +62,802 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 12, "id": "83472648", "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/tmp/ipykernel_10061/1081306672.py:2: DtypeWarning: Columns (0,1,2,3) have mixed types. Specify dtype option on import or set low_memory=False.\n", - " df = pd.read_csv(f, sep=\";\")\n" - ] - } - ], + "outputs": [], "source": [ - "with fs.open('s3://projet-bdc-data/carmignac/AUM ENSAE V2 -20251105.csv', 'rb') as f:\n", - " df = pd.read_csv(f, sep=\";\")\n", + "with fs.open('s3://projet-bdc-data/carmignac/Data Modélisation/market data/Eur Gov Indices Weekly Step.xlsx', 'rb') as f:\n", + " df = pd.read_excel(f)\n", "\n", - "sample_df = sample_by_blocks(df, block_size=10, num_blocks=10, random_state=42)" + "sample_df = sample_by_blocks(df, block_size=20, num_blocks=3, random_state=42)" ] }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 13, + "id": "79af063e", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
Bond/IndexDescriptionDateTotal Return % 1-wk-LOCYield to Maturity (s.a.)Yield to Maturity (conv.)
0G0D0ICE BofA German Government Index2008-08-22-0.30204.2104.250
1G0D0ICE BofA German Government Index2008-08-290.30404.1804.220
2G0D0ICE BofA German Government Index2008-09-050.97803.9904.030
3G0D0ICE BofA German Government Index2008-09-12-1.05804.1704.210
4G0D0ICE BofA German Government Index2008-09-19-0.28604.2204.270
5G0D0ICE BofA German Government Index2008-09-260.66104.0504.090
6G0D0ICE BofA German Government Index2008-10-031.89003.7103.750
7G0D0ICE BofA German Government Index2008-10-100.09403.6103.650
8G0D0ICE BofA German Government Index2008-10-17-0.35503.6703.700
9G0D0ICE BofA German Government Index2008-10-241.63703.3903.420
10G0D0ICE BofA German Government Index2008-10-31-0.53503.4103.440
11G0D0ICE BofA German Government Index2008-11-071.32503.2003.230
12G0D0ICE BofA German Government Index2008-11-140.44903.0703.100
13G0D0ICE BofA German Government Index2008-11-211.35602.8902.920
14G0D0ICE BofA German Government Index2008-11-280.77802.8602.880
15G0D0ICE BofA German Government Index2008-12-051.46602.6902.700
16G0D0ICE BofA German Government Index2008-12-12-1.91002.9602.980
17G0D0ICE BofA German Government Index2008-12-191.79802.6502.670
18G0D0ICE BofA German Government Index2008-12-260.31202.6002.620
19G0D0ICE BofA German Government Index2009-01-020.26402.5602.570
20EG04ICE BofA 7-10 Year Euro Government Index2011-03-110.37504.1704.210
21EG04ICE BofA 7-10 Year Euro Government Index2011-03-180.80004.0704.100
22EG04ICE BofA 7-10 Year Euro Government Index2011-03-25-0.68504.1704.210
23EG04ICE BofA 7-10 Year Euro Government Index2011-04-01-0.78504.3104.350
24EG04ICE BofA 7-10 Year Euro Government Index2011-04-080.02304.3304.370
25EG04ICE BofA 7-10 Year Euro Government Index2011-04-150.16804.3104.350
26EG04ICE BofA 7-10 Year Euro Government Index2011-04-220.32054.2654.305
27EG04ICE BofA 7-10 Year Euro Government Index2011-04-290.47304.2204.260
28EG04ICE BofA 7-10 Year Euro Government Index2011-05-060.45504.2204.260
29EG04ICE BofA 7-10 Year Euro Government Index2011-05-130.51704.1504.190
30EG04ICE BofA 7-10 Year Euro Government Index2011-05-20-0.18004.1904.230
31EG04ICE BofA 7-10 Year Euro Government Index2011-05-270.49404.1204.160
32EG04ICE BofA 7-10 Year Euro Government Index2011-06-030.29704.1104.150
33EG04ICE BofA 7-10 Year Euro Government Index2011-06-10-0.32604.1604.200
34EG04ICE BofA 7-10 Year Euro Government Index2011-06-17-0.21704.1704.210
35EG04ICE BofA 7-10 Year Euro Government Index2011-06-24-0.13504.1804.230
36EG04ICE BofA 7-10 Year Euro Government Index2011-07-01-0.05504.1804.220
37EG04ICE BofA 7-10 Year Euro Government Index2011-07-08-0.69904.2404.290
38EG04ICE BofA 7-10 Year Euro Government Index2011-07-15-0.92304.3504.400
39EG04ICE BofA 7-10 Year Euro Government Index2011-07-221.18104.2504.290
40EG04ICE BofA 7-10 Year Euro Government Index2016-01-150.12200.8500.850
41EG04ICE BofA 7-10 Year Euro Government Index2016-01-220.26900.8200.820
42EG04ICE BofA 7-10 Year Euro Government Index2016-01-291.12300.6700.670
43EG04ICE BofA 7-10 Year Euro Government Index2016-02-05-0.26800.7200.720
44EG04ICE BofA 7-10 Year Euro Government Index2016-02-12-0.20900.7500.750
45EG04ICE BofA 7-10 Year Euro Government Index2016-02-190.45400.6900.690
46EG04ICE BofA 7-10 Year Euro Government Index2016-02-260.54700.6200.620
47EG04ICE BofA 7-10 Year Euro Government Index2016-03-04-0.15400.6400.650
48EG04ICE BofA 7-10 Year Euro Government Index2016-03-110.28000.6100.610
49EG04ICE BofA 7-10 Year Euro Government Index2016-03-180.35700.5600.570
50EG04ICE BofA 7-10 Year Euro Government Index2016-03-250.41100.5350.540
51EG04ICE BofA 7-10 Year Euro Government Index2016-04-010.46500.5100.510
52EG04ICE BofA 7-10 Year Euro Government Index2016-04-08-0.11400.5300.530
53EG04ICE BofA 7-10 Year Euro Government Index2016-04-15-0.09700.5400.540
54EG04ICE BofA 7-10 Year Euro Government Index2016-04-22-0.66000.6300.630
55EG04ICE BofA 7-10 Year Euro Government Index2016-04-29-0.33800.6800.680
56EG04ICE BofA 7-10 Year Euro Government Index2016-05-060.65000.6000.600
57EG04ICE BofA 7-10 Year Euro Government Index2016-05-130.21100.5700.570
58EG04ICE BofA 7-10 Year Euro Government Index2016-05-20-0.14200.5900.590
59EG04ICE BofA 7-10 Year Euro Government Index2016-05-270.47100.5300.530
\n", + "
" + ], + "text/plain": [ + " Bond/Index Description Date \\\n", + "0 G0D0 ICE BofA German Government Index 2008-08-22 \n", + "1 G0D0 ICE BofA German Government Index 2008-08-29 \n", + "2 G0D0 ICE BofA German Government Index 2008-09-05 \n", + "3 G0D0 ICE BofA German Government Index 2008-09-12 \n", + "4 G0D0 ICE BofA German Government Index 2008-09-19 \n", + "5 G0D0 ICE BofA German Government Index 2008-09-26 \n", + "6 G0D0 ICE BofA German Government Index 2008-10-03 \n", + "7 G0D0 ICE BofA German Government Index 2008-10-10 \n", + "8 G0D0 ICE BofA German Government Index 2008-10-17 \n", + "9 G0D0 ICE BofA German Government Index 2008-10-24 \n", + "10 G0D0 ICE BofA German Government Index 2008-10-31 \n", + "11 G0D0 ICE BofA German Government Index 2008-11-07 \n", + "12 G0D0 ICE BofA German Government Index 2008-11-14 \n", + "13 G0D0 ICE BofA German Government Index 2008-11-21 \n", + "14 G0D0 ICE BofA German Government Index 2008-11-28 \n", + "15 G0D0 ICE BofA German Government Index 2008-12-05 \n", + "16 G0D0 ICE BofA German Government Index 2008-12-12 \n", + "17 G0D0 ICE BofA German Government Index 2008-12-19 \n", + "18 G0D0 ICE BofA German Government Index 2008-12-26 \n", + "19 G0D0 ICE BofA German Government Index 2009-01-02 \n", + "20 EG04 ICE BofA 7-10 Year Euro Government Index 2011-03-11 \n", + "21 EG04 ICE BofA 7-10 Year Euro Government Index 2011-03-18 \n", + "22 EG04 ICE BofA 7-10 Year Euro Government Index 2011-03-25 \n", + "23 EG04 ICE BofA 7-10 Year Euro Government Index 2011-04-01 \n", + "24 EG04 ICE BofA 7-10 Year Euro Government Index 2011-04-08 \n", + "25 EG04 ICE BofA 7-10 Year Euro Government Index 2011-04-15 \n", + "26 EG04 ICE BofA 7-10 Year Euro Government Index 2011-04-22 \n", + "27 EG04 ICE BofA 7-10 Year Euro Government Index 2011-04-29 \n", + "28 EG04 ICE BofA 7-10 Year Euro Government Index 2011-05-06 \n", + "29 EG04 ICE BofA 7-10 Year Euro Government Index 2011-05-13 \n", + "30 EG04 ICE BofA 7-10 Year Euro Government Index 2011-05-20 \n", + "31 EG04 ICE BofA 7-10 Year Euro Government Index 2011-05-27 \n", + "32 EG04 ICE BofA 7-10 Year Euro Government Index 2011-06-03 \n", + "33 EG04 ICE BofA 7-10 Year Euro Government Index 2011-06-10 \n", + "34 EG04 ICE BofA 7-10 Year Euro Government Index 2011-06-17 \n", + "35 EG04 ICE BofA 7-10 Year Euro Government Index 2011-06-24 \n", + "36 EG04 ICE BofA 7-10 Year Euro Government Index 2011-07-01 \n", + "37 EG04 ICE BofA 7-10 Year Euro Government Index 2011-07-08 \n", + "38 EG04 ICE BofA 7-10 Year Euro Government Index 2011-07-15 \n", + "39 EG04 ICE BofA 7-10 Year Euro Government Index 2011-07-22 \n", + "40 EG04 ICE BofA 7-10 Year Euro Government Index 2016-01-15 \n", + "41 EG04 ICE BofA 7-10 Year Euro Government Index 2016-01-22 \n", + "42 EG04 ICE BofA 7-10 Year Euro Government Index 2016-01-29 \n", + "43 EG04 ICE BofA 7-10 Year Euro Government Index 2016-02-05 \n", + "44 EG04 ICE BofA 7-10 Year Euro Government Index 2016-02-12 \n", + "45 EG04 ICE BofA 7-10 Year Euro Government Index 2016-02-19 \n", + "46 EG04 ICE BofA 7-10 Year Euro Government Index 2016-02-26 \n", + "47 EG04 ICE BofA 7-10 Year Euro Government Index 2016-03-04 \n", + "48 EG04 ICE BofA 7-10 Year Euro Government Index 2016-03-11 \n", + "49 EG04 ICE BofA 7-10 Year Euro Government Index 2016-03-18 \n", + "50 EG04 ICE BofA 7-10 Year Euro Government Index 2016-03-25 \n", + "51 EG04 ICE BofA 7-10 Year Euro Government Index 2016-04-01 \n", + "52 EG04 ICE BofA 7-10 Year Euro Government Index 2016-04-08 \n", + "53 EG04 ICE BofA 7-10 Year Euro Government Index 2016-04-15 \n", + "54 EG04 ICE BofA 7-10 Year Euro Government Index 2016-04-22 \n", + "55 EG04 ICE BofA 7-10 Year Euro Government Index 2016-04-29 \n", + "56 EG04 ICE BofA 7-10 Year Euro Government Index 2016-05-06 \n", + "57 EG04 ICE BofA 7-10 Year Euro Government Index 2016-05-13 \n", + "58 EG04 ICE BofA 7-10 Year Euro Government Index 2016-05-20 \n", + "59 EG04 ICE BofA 7-10 Year Euro Government Index 2016-05-27 \n", + "\n", + " Total Return % 1-wk-LOC Yield to Maturity (s.a.) \\\n", + "0 -0.3020 4.210 \n", + "1 0.3040 4.180 \n", + "2 0.9780 3.990 \n", + "3 -1.0580 4.170 \n", + "4 -0.2860 4.220 \n", + "5 0.6610 4.050 \n", + "6 1.8900 3.710 \n", + "7 0.0940 3.610 \n", + "8 -0.3550 3.670 \n", + "9 1.6370 3.390 \n", + "10 -0.5350 3.410 \n", + "11 1.3250 3.200 \n", + "12 0.4490 3.070 \n", + "13 1.3560 2.890 \n", + "14 0.7780 2.860 \n", + "15 1.4660 2.690 \n", + "16 -1.9100 2.960 \n", + "17 1.7980 2.650 \n", + "18 0.3120 2.600 \n", + "19 0.2640 2.560 \n", + "20 0.3750 4.170 \n", + "21 0.8000 4.070 \n", + "22 -0.6850 4.170 \n", + "23 -0.7850 4.310 \n", + "24 0.0230 4.330 \n", + "25 0.1680 4.310 \n", + "26 0.3205 4.265 \n", + "27 0.4730 4.220 \n", + "28 0.4550 4.220 \n", + "29 0.5170 4.150 \n", + "30 -0.1800 4.190 \n", + "31 0.4940 4.120 \n", + "32 0.2970 4.110 \n", + "33 -0.3260 4.160 \n", + "34 -0.2170 4.170 \n", + "35 -0.1350 4.180 \n", + "36 -0.0550 4.180 \n", + "37 -0.6990 4.240 \n", + "38 -0.9230 4.350 \n", + "39 1.1810 4.250 \n", + "40 0.1220 0.850 \n", + "41 0.2690 0.820 \n", + "42 1.1230 0.670 \n", + "43 -0.2680 0.720 \n", + "44 -0.2090 0.750 \n", + "45 0.4540 0.690 \n", + "46 0.5470 0.620 \n", + "47 -0.1540 0.640 \n", + "48 0.2800 0.610 \n", + "49 0.3570 0.560 \n", + "50 0.4110 0.535 \n", + "51 0.4650 0.510 \n", + "52 -0.1140 0.530 \n", + "53 -0.0970 0.540 \n", + "54 -0.6600 0.630 \n", + "55 -0.3380 0.680 \n", + "56 0.6500 0.600 \n", + "57 0.2110 0.570 \n", + "58 -0.1420 0.590 \n", + "59 0.4710 0.530 \n", + "\n", + " Yield to Maturity (conv.) \n", + "0 4.250 \n", + "1 4.220 \n", + "2 4.030 \n", + "3 4.210 \n", + "4 4.270 \n", + "5 4.090 \n", + "6 3.750 \n", + "7 3.650 \n", + "8 3.700 \n", + "9 3.420 \n", + "10 3.440 \n", + "11 3.230 \n", + "12 3.100 \n", + "13 2.920 \n", + "14 2.880 \n", + "15 2.700 \n", + "16 2.980 \n", + "17 2.670 \n", + "18 2.620 \n", + "19 2.570 \n", + "20 4.210 \n", + "21 4.100 \n", + "22 4.210 \n", + "23 4.350 \n", + "24 4.370 \n", + "25 4.350 \n", + "26 4.305 \n", + "27 4.260 \n", + "28 4.260 \n", + "29 4.190 \n", + "30 4.230 \n", + "31 4.160 \n", + "32 4.150 \n", + "33 4.200 \n", + "34 4.210 \n", + "35 4.230 \n", + "36 4.220 \n", + "37 4.290 \n", + "38 4.400 \n", + "39 4.290 \n", + "40 0.850 \n", + "41 0.820 \n", + "42 0.670 \n", + "43 0.720 \n", + "44 0.750 \n", + "45 0.690 \n", + "46 0.620 \n", + "47 0.650 \n", + "48 0.610 \n", + "49 0.570 \n", + "50 0.540 \n", + "51 0.510 \n", + "52 0.530 \n", + "53 0.540 \n", + "54 0.630 \n", + "55 0.680 \n", + "56 0.600 \n", + "57 0.570 \n", + "58 0.590 \n", + "59 0.530 " + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sample_df" + ] + }, + { + "cell_type": "code", + "execution_count": 14, "id": "36ec4312", "metadata": {}, "outputs": [], "source": [ - "sample_df.to_csv('aum_sample.csv', index=False)" + "sample_df.to_csv('eur_gov_indices.csv', index=False)" ] } ], diff --git a/data_exploration/str_rates.csv b/data_exploration/str_rates.csv new file mode 100644 index 0000000..fcdf970 --- /dev/null +++ b/data_exploration/str_rates.csv @@ -0,0 +1,101 @@ +Date,Yld to Maturity +04/12/2015,-0.138 +07/12/2015,-0.142 +08/12/2015,-0.147 +09/12/2015,-0.235 +10/12/2015,-0.232 +11/12/2015,-0.231 +14/12/2015,-0.23 +15/12/2015,-0.239 +16/12/2015,-0.241 +17/12/2015,-0.238 +18/12/2015,-0.237 +21/12/2015,-0.231 +22/12/2015,-0.231 +23/12/2015,-0.234 +24/12/2015,-0.244 +28/12/2015,-0.238 +29/12/2015,-0.223 +30/12/2015,-0.14 +31/12/2015,-0.127 +04/01/2016,-0.241 +05/01/2016,-0.251 +06/01/2016,-0.253 +07/01/2016,-0.233 +08/01/2016,-0.235 +11/01/2016,-0.236 +12/01/2016,-0.233 +13/01/2016,-0.237 +14/01/2016,-0.24 +15/01/2016,-0.239 +18/01/2016,-0.24 +19/01/2016,-0.239 +20/01/2016,-0.238 +21/01/2016,-0.24 +22/01/2016,-0.241 +25/01/2016,-0.238 +26/01/2016,-0.236 +27/01/2016,-0.237 +28/01/2016,-0.239 +29/01/2016,-0.228 +31/01/2016,-0.228 +01/02/2016,-0.237 +02/02/2016,-0.232 +03/02/2016,-0.247 +04/02/2016,-0.231 +05/02/2016,-0.236 +08/02/2016,-0.242 +09/02/2016,-0.237 +10/02/2016,-0.237 +11/02/2016,-0.239 +12/02/2016,-0.24 +15/02/2016,-0.243 +16/02/2016,-0.242 +17/02/2016,-0.244 +18/02/2016,-0.244 +19/02/2016,-0.243 +22/02/2016,-0.242 +23/02/2016,-0.246 +24/02/2016,-0.247 +25/02/2016,-0.249 +26/02/2016,-0.243 +29/02/2016,-0.227 +01/03/2016,-0.238 +02/03/2016,-0.234 +03/03/2016,-0.238 +04/03/2016,-0.236 +07/03/2016,-0.239 +08/03/2016,-0.234 +09/03/2016,-0.236 +10/03/2016,-0.242 +11/03/2016,-0.242 +14/03/2016,-0.243 +15/03/2016,-0.248 +16/03/2016,-0.339 +17/03/2016,-0.347 +18/03/2016,-0.345 +21/03/2016,-0.345 +22/03/2016,-0.344 +23/03/2016,-0.346 +24/03/2016,-0.349 +28/03/2016,-0.349 +29/03/2016,-0.347 +30/03/2016,-0.347 +31/03/2016,-0.303 +01/04/2016,-0.335 +04/04/2016,-0.331 +05/04/2016,-0.332 +06/04/2016,-0.334 +07/04/2016,-0.33 +08/04/2016,-0.334 +11/04/2016,-0.333 +12/04/2016,-0.341 +13/04/2016,-0.337 +14/04/2016,-0.34 +15/04/2016,-0.341 +18/04/2016,-0.348 +19/04/2016,-0.34 +20/04/2016,-0.343 +21/04/2016,-0.342 +22/04/2016,-0.34 +25/04/2016,-0.341