Clustering temporel
This commit is contained in:
parent
9fad80e04d
commit
c6e0266fb7
|
|
@ -1,634 +0,0 @@
|
||||||
{
|
|
||||||
"cells": [
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 1,
|
|
||||||
"id": "4287b380-5359-49c7-ab95-ad346a3ad17a",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"Fichiers Flows : ['projet-bdc-data/carmignac/Flows ENSAE V1 -20251027.csv', 'projet-bdc-data/carmignac/Flows ENSAE V2 -20251105.csv']\n",
|
|
||||||
"Fichiers AUM : ['projet-bdc-data/carmignac/AUM ENSAE V1 -20251027.csv', 'projet-bdc-data/carmignac/AUM ENSAE V2 -20251105.csv']\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"# Import des données\n",
|
|
||||||
"\n",
|
|
||||||
"import os\n",
|
|
||||||
"import s3fs\n",
|
|
||||||
"import pandas as pd\n",
|
|
||||||
"\n",
|
|
||||||
"s3_ENDPOINT_URL = \"https://\" + os.environ[\"AWS_S3_ENDPOINT\"]\n",
|
|
||||||
"\n",
|
|
||||||
"fs = s3fs.S3FileSystem(client_kwargs={'endpoint_url': s3_ENDPOINT_URL})\n",
|
|
||||||
"\n",
|
|
||||||
"BUCKET = \"projet-bdc-data\"\n",
|
|
||||||
"carmignac_path = \"projet-bdc-data/carmignac\"\n",
|
|
||||||
"\n",
|
|
||||||
"# Liste des fichiers FLOWS\n",
|
|
||||||
"all_files = fs.ls(carmignac_path)\n",
|
|
||||||
"flows_files = [f for f in all_files if \"Flows\" in f and f.endswith(\".csv\")]\n",
|
|
||||||
"print(\"Fichiers Flows :\", flows_files)\n",
|
|
||||||
"\n",
|
|
||||||
"# Lire tous les fichiers dans un dictionnaire\n",
|
|
||||||
"flows_data = {}\n",
|
|
||||||
"for file_path in flows_files:\n",
|
|
||||||
" with fs.open(file_path, 'r') as f:\n",
|
|
||||||
" df = pd.read_csv(f, sep=';',low_memory=False)\n",
|
|
||||||
" flows_data[os.path.basename(file_path)] = df\n",
|
|
||||||
"\n",
|
|
||||||
"\n",
|
|
||||||
"# Liste des fichiers AUM\n",
|
|
||||||
"all_files = fs.ls(carmignac_path)\n",
|
|
||||||
"aum_files = [f for f in all_files if \"AUM\" in f and f.endswith(\".csv\")]\n",
|
|
||||||
"print(\"Fichiers AUM :\", aum_files)\n",
|
|
||||||
"\n",
|
|
||||||
"# Lire tous les fichiers dans un dictionnaire\n",
|
|
||||||
"aum_data = {}\n",
|
|
||||||
"for file_path in aum_files:\n",
|
|
||||||
" with fs.open(file_path, 'r') as f:\n",
|
|
||||||
" df = pd.read_csv(f, sep=';',low_memory=False)\n",
|
|
||||||
" aum_data[os.path.basename(file_path)] = df\n",
|
|
||||||
"\n",
|
|
||||||
"df = aum_data['AUM ENSAE V2 -20251105.csv']\n",
|
|
||||||
"dg = flows_data['Flows ENSAE V2 -20251105.csv']"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 2,
|
|
||||||
"id": "0b66aee0-b726-4a57-9461-6a4550a625a8",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"data": {
|
|
||||||
"text/html": [
|
|
||||||
"<div>\n",
|
|
||||||
"<style scoped>\n",
|
|
||||||
" .dataframe tbody tr th:only-of-type {\n",
|
|
||||||
" vertical-align: middle;\n",
|
|
||||||
" }\n",
|
|
||||||
"\n",
|
|
||||||
" .dataframe tbody tr th {\n",
|
|
||||||
" vertical-align: top;\n",
|
|
||||||
" }\n",
|
|
||||||
"\n",
|
|
||||||
" .dataframe thead th {\n",
|
|
||||||
" text-align: right;\n",
|
|
||||||
" }\n",
|
|
||||||
"</style>\n",
|
|
||||||
"<table border=\"1\" class=\"dataframe\">\n",
|
|
||||||
" <thead>\n",
|
|
||||||
" <tr style=\"text-align: right;\">\n",
|
|
||||||
" <th></th>\n",
|
|
||||||
" <th>Agreement - Code</th>\n",
|
|
||||||
" <th>Company - Id</th>\n",
|
|
||||||
" <th>Company - Ultimate Parent Id</th>\n",
|
|
||||||
" <th>Registrar Account - ID</th>\n",
|
|
||||||
" <th>Registrar Account - Region</th>\n",
|
|
||||||
" <th>RegistrarAccount - Country</th>\n",
|
|
||||||
" <th>Product - Asset Type</th>\n",
|
|
||||||
" <th>Product - Strategy</th>\n",
|
|
||||||
" <th>Product - Legal Status</th>\n",
|
|
||||||
" <th>Product - Is Dedie ?</th>\n",
|
|
||||||
" <th>Product - Fund</th>\n",
|
|
||||||
" <th>Product - Shareclass Type</th>\n",
|
|
||||||
" <th>Product - Shareclass Currency</th>\n",
|
|
||||||
" <th>Product - Isin</th>\n",
|
|
||||||
" <th>Centralisation Date</th>\n",
|
|
||||||
" <th>Quantity - AUM</th>\n",
|
|
||||||
" <th>Value - AUM CCY</th>\n",
|
|
||||||
" <th>Value - AUM €</th>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" </thead>\n",
|
|
||||||
" <tbody>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>0</th>\n",
|
|
||||||
" <td>003</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>200000647</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>Diversified</td>\n",
|
|
||||||
" <td>Patrimoine</td>\n",
|
|
||||||
" <td>FCP</td>\n",
|
|
||||||
" <td>NO</td>\n",
|
|
||||||
" <td>Carmignac Patrimoine</td>\n",
|
|
||||||
" <td>A</td>\n",
|
|
||||||
" <td>EUR</td>\n",
|
|
||||||
" <td>FR0010135103</td>\n",
|
|
||||||
" <td>2015-03-31</td>\n",
|
|
||||||
" <td>35.368</td>\n",
|
|
||||||
" <td>24648.6666</td>\n",
|
|
||||||
" <td>24648.6666</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>1</th>\n",
|
|
||||||
" <td>003</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>200000647</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>Diversified</td>\n",
|
|
||||||
" <td>Patrimoine</td>\n",
|
|
||||||
" <td>FCP</td>\n",
|
|
||||||
" <td>NO</td>\n",
|
|
||||||
" <td>Carmignac Patrimoine</td>\n",
|
|
||||||
" <td>A</td>\n",
|
|
||||||
" <td>EUR</td>\n",
|
|
||||||
" <td>FR0010135103</td>\n",
|
|
||||||
" <td>2015-11-30</td>\n",
|
|
||||||
" <td>35.368</td>\n",
|
|
||||||
" <td>22413.0553</td>\n",
|
|
||||||
" <td>22413.0553</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>2</th>\n",
|
|
||||||
" <td>003</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>200000647</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>Diversified</td>\n",
|
|
||||||
" <td>Patrimoine</td>\n",
|
|
||||||
" <td>FCP</td>\n",
|
|
||||||
" <td>NO</td>\n",
|
|
||||||
" <td>Carmignac Patrimoine</td>\n",
|
|
||||||
" <td>A</td>\n",
|
|
||||||
" <td>EUR</td>\n",
|
|
||||||
" <td>FR0010135103</td>\n",
|
|
||||||
" <td>2015-12-31</td>\n",
|
|
||||||
" <td>35.368</td>\n",
|
|
||||||
" <td>22051.2406</td>\n",
|
|
||||||
" <td>22051.2406</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>3</th>\n",
|
|
||||||
" <td>003</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>200000647</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>Diversified</td>\n",
|
|
||||||
" <td>Patrimoine</td>\n",
|
|
||||||
" <td>FCP</td>\n",
|
|
||||||
" <td>NO</td>\n",
|
|
||||||
" <td>Carmignac Patrimoine</td>\n",
|
|
||||||
" <td>A</td>\n",
|
|
||||||
" <td>EUR</td>\n",
|
|
||||||
" <td>FR0010135103</td>\n",
|
|
||||||
" <td>2016-03-31</td>\n",
|
|
||||||
" <td>35.368</td>\n",
|
|
||||||
" <td>21626.1173</td>\n",
|
|
||||||
" <td>21626.1173</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>4</th>\n",
|
|
||||||
" <td>003</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>200000647</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>Diversified</td>\n",
|
|
||||||
" <td>Patrimoine</td>\n",
|
|
||||||
" <td>FCP</td>\n",
|
|
||||||
" <td>NO</td>\n",
|
|
||||||
" <td>Carmignac Patrimoine</td>\n",
|
|
||||||
" <td>A</td>\n",
|
|
||||||
" <td>EUR</td>\n",
|
|
||||||
" <td>FR0010135103</td>\n",
|
|
||||||
" <td>2016-11-30</td>\n",
|
|
||||||
" <td>35.368</td>\n",
|
|
||||||
" <td>22489.4502</td>\n",
|
|
||||||
" <td>22489.4502</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" </tbody>\n",
|
|
||||||
"</table>\n",
|
|
||||||
"</div>"
|
|
||||||
],
|
|
||||||
"text/plain": [
|
|
||||||
" Agreement - Code Company - Id Company - Ultimate Parent Id \\\n",
|
|
||||||
"0 003 166 166 \n",
|
|
||||||
"1 003 166 166 \n",
|
|
||||||
"2 003 166 166 \n",
|
|
||||||
"3 003 166 166 \n",
|
|
||||||
"4 003 166 166 \n",
|
|
||||||
"\n",
|
|
||||||
" Registrar Account - ID Registrar Account - Region \\\n",
|
|
||||||
"0 200000647 France \n",
|
|
||||||
"1 200000647 France \n",
|
|
||||||
"2 200000647 France \n",
|
|
||||||
"3 200000647 France \n",
|
|
||||||
"4 200000647 France \n",
|
|
||||||
"\n",
|
|
||||||
" RegistrarAccount - Country Product - Asset Type Product - Strategy \\\n",
|
|
||||||
"0 France Diversified Patrimoine \n",
|
|
||||||
"1 France Diversified Patrimoine \n",
|
|
||||||
"2 France Diversified Patrimoine \n",
|
|
||||||
"3 France Diversified Patrimoine \n",
|
|
||||||
"4 France Diversified Patrimoine \n",
|
|
||||||
"\n",
|
|
||||||
" Product - Legal Status Product - Is Dedie ? Product - Fund \\\n",
|
|
||||||
"0 FCP NO Carmignac Patrimoine \n",
|
|
||||||
"1 FCP NO Carmignac Patrimoine \n",
|
|
||||||
"2 FCP NO Carmignac Patrimoine \n",
|
|
||||||
"3 FCP NO Carmignac Patrimoine \n",
|
|
||||||
"4 FCP NO Carmignac Patrimoine \n",
|
|
||||||
"\n",
|
|
||||||
" Product - Shareclass Type Product - Shareclass Currency Product - Isin \\\n",
|
|
||||||
"0 A EUR FR0010135103 \n",
|
|
||||||
"1 A EUR FR0010135103 \n",
|
|
||||||
"2 A EUR FR0010135103 \n",
|
|
||||||
"3 A EUR FR0010135103 \n",
|
|
||||||
"4 A EUR FR0010135103 \n",
|
|
||||||
"\n",
|
|
||||||
" Centralisation Date Quantity - AUM Value - AUM CCY Value - AUM € \n",
|
|
||||||
"0 2015-03-31 35.368 24648.6666 24648.6666 \n",
|
|
||||||
"1 2015-11-30 35.368 22413.0553 22413.0553 \n",
|
|
||||||
"2 2015-12-31 35.368 22051.2406 22051.2406 \n",
|
|
||||||
"3 2016-03-31 35.368 21626.1173 21626.1173 \n",
|
|
||||||
"4 2016-11-30 35.368 22489.4502 22489.4502 "
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"execution_count": 2,
|
|
||||||
"metadata": {},
|
|
||||||
"output_type": "execute_result"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"df.head()"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 3,
|
|
||||||
"id": "a5509e6e-ff10-4388-9fee-5cd49d01b60a",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"data": {
|
|
||||||
"text/html": [
|
|
||||||
"<div>\n",
|
|
||||||
"<style scoped>\n",
|
|
||||||
" .dataframe tbody tr th:only-of-type {\n",
|
|
||||||
" vertical-align: middle;\n",
|
|
||||||
" }\n",
|
|
||||||
"\n",
|
|
||||||
" .dataframe tbody tr th {\n",
|
|
||||||
" vertical-align: top;\n",
|
|
||||||
" }\n",
|
|
||||||
"\n",
|
|
||||||
" .dataframe thead th {\n",
|
|
||||||
" text-align: right;\n",
|
|
||||||
" }\n",
|
|
||||||
"</style>\n",
|
|
||||||
"<table border=\"1\" class=\"dataframe\">\n",
|
|
||||||
" <thead>\n",
|
|
||||||
" <tr style=\"text-align: right;\">\n",
|
|
||||||
" <th></th>\n",
|
|
||||||
" <th>Agreement - Code</th>\n",
|
|
||||||
" <th>Company - Id</th>\n",
|
|
||||||
" <th>Company - Ultimate Parent Id</th>\n",
|
|
||||||
" <th>Registrar Account - ID</th>\n",
|
|
||||||
" <th>Registrar Account - Region</th>\n",
|
|
||||||
" <th>RegistrarAccount - Country</th>\n",
|
|
||||||
" <th>Product - Asset Type</th>\n",
|
|
||||||
" <th>Product - Strategy</th>\n",
|
|
||||||
" <th>Product - Legal Status</th>\n",
|
|
||||||
" <th>Product - Is Dedie ?</th>\n",
|
|
||||||
" <th>...</th>\n",
|
|
||||||
" <th>Centralisation Date</th>\n",
|
|
||||||
" <th>Quantity - Subscription</th>\n",
|
|
||||||
" <th>Quantity - Redemption</th>\n",
|
|
||||||
" <th>Quantity - NetFlows</th>\n",
|
|
||||||
" <th>Value Ccy - Subscription</th>\n",
|
|
||||||
" <th>Value Ccy - Redemption</th>\n",
|
|
||||||
" <th>Value Ccy - NetFlows</th>\n",
|
|
||||||
" <th>Value € - Subscription</th>\n",
|
|
||||||
" <th>Value € - Redemption</th>\n",
|
|
||||||
" <th>Value € - NetFlows</th>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" </thead>\n",
|
|
||||||
" <tbody>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>0</th>\n",
|
|
||||||
" <td>003</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>200127202</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>Equity</td>\n",
|
|
||||||
" <td>Investissement</td>\n",
|
|
||||||
" <td>SICAV</td>\n",
|
|
||||||
" <td>NO</td>\n",
|
|
||||||
" <td>...</td>\n",
|
|
||||||
" <td>2020-11-05</td>\n",
|
|
||||||
" <td>1636.00</td>\n",
|
|
||||||
" <td>0.000</td>\n",
|
|
||||||
" <td>1636.000</td>\n",
|
|
||||||
" <td>280983.00</td>\n",
|
|
||||||
" <td>0.00</td>\n",
|
|
||||||
" <td>280983.00</td>\n",
|
|
||||||
" <td>280983.00</td>\n",
|
|
||||||
" <td>0.00</td>\n",
|
|
||||||
" <td>280983.00</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>1</th>\n",
|
|
||||||
" <td>003</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>406533</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>Diversified</td>\n",
|
|
||||||
" <td>Patrimoine</td>\n",
|
|
||||||
" <td>FCP</td>\n",
|
|
||||||
" <td>NO</td>\n",
|
|
||||||
" <td>...</td>\n",
|
|
||||||
" <td>2015-03-09</td>\n",
|
|
||||||
" <td>144.69</td>\n",
|
|
||||||
" <td>0.000</td>\n",
|
|
||||||
" <td>144.690</td>\n",
|
|
||||||
" <td>99985.13</td>\n",
|
|
||||||
" <td>0.00</td>\n",
|
|
||||||
" <td>99985.13</td>\n",
|
|
||||||
" <td>99985.13</td>\n",
|
|
||||||
" <td>0.00</td>\n",
|
|
||||||
" <td>99985.13</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>2</th>\n",
|
|
||||||
" <td>003</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>406533</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>Equity</td>\n",
|
|
||||||
" <td>Investissement</td>\n",
|
|
||||||
" <td>FCP</td>\n",
|
|
||||||
" <td>NO</td>\n",
|
|
||||||
" <td>...</td>\n",
|
|
||||||
" <td>2016-10-26</td>\n",
|
|
||||||
" <td>0.00</td>\n",
|
|
||||||
" <td>-8.321</td>\n",
|
|
||||||
" <td>-8.321</td>\n",
|
|
||||||
" <td>0.00</td>\n",
|
|
||||||
" <td>-9384.76</td>\n",
|
|
||||||
" <td>-9384.76</td>\n",
|
|
||||||
" <td>0.00</td>\n",
|
|
||||||
" <td>-9384.76</td>\n",
|
|
||||||
" <td>-9384.76</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>3</th>\n",
|
|
||||||
" <td>003</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>406533</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>Equity</td>\n",
|
|
||||||
" <td>Investissement</td>\n",
|
|
||||||
" <td>FCP</td>\n",
|
|
||||||
" <td>NO</td>\n",
|
|
||||||
" <td>...</td>\n",
|
|
||||||
" <td>2018-10-18</td>\n",
|
|
||||||
" <td>0.00</td>\n",
|
|
||||||
" <td>-22.083</td>\n",
|
|
||||||
" <td>-22.083</td>\n",
|
|
||||||
" <td>0.00</td>\n",
|
|
||||||
" <td>-25227.40</td>\n",
|
|
||||||
" <td>-25227.40</td>\n",
|
|
||||||
" <td>0.00</td>\n",
|
|
||||||
" <td>-25227.40</td>\n",
|
|
||||||
" <td>-25227.40</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>4</th>\n",
|
|
||||||
" <td>003</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>406533</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>Equity</td>\n",
|
|
||||||
" <td>Investissement</td>\n",
|
|
||||||
" <td>FCP</td>\n",
|
|
||||||
" <td>NO</td>\n",
|
|
||||||
" <td>...</td>\n",
|
|
||||||
" <td>2019-04-08</td>\n",
|
|
||||||
" <td>0.00</td>\n",
|
|
||||||
" <td>-465.992</td>\n",
|
|
||||||
" <td>-465.992</td>\n",
|
|
||||||
" <td>0.00</td>\n",
|
|
||||||
" <td>-563775.76</td>\n",
|
|
||||||
" <td>-563775.76</td>\n",
|
|
||||||
" <td>0.00</td>\n",
|
|
||||||
" <td>-563775.76</td>\n",
|
|
||||||
" <td>-563775.76</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" </tbody>\n",
|
|
||||||
"</table>\n",
|
|
||||||
"<p>5 rows × 24 columns</p>\n",
|
|
||||||
"</div>"
|
|
||||||
],
|
|
||||||
"text/plain": [
|
|
||||||
" Agreement - Code Company - Id Company - Ultimate Parent Id \\\n",
|
|
||||||
"0 003 166 166 \n",
|
|
||||||
"1 003 166 166 \n",
|
|
||||||
"2 003 166 166 \n",
|
|
||||||
"3 003 166 166 \n",
|
|
||||||
"4 003 166 166 \n",
|
|
||||||
"\n",
|
|
||||||
" Registrar Account - ID Registrar Account - Region \\\n",
|
|
||||||
"0 200127202 France \n",
|
|
||||||
"1 406533 France \n",
|
|
||||||
"2 406533 France \n",
|
|
||||||
"3 406533 France \n",
|
|
||||||
"4 406533 France \n",
|
|
||||||
"\n",
|
|
||||||
" RegistrarAccount - Country Product - Asset Type Product - Strategy \\\n",
|
|
||||||
"0 France Equity Investissement \n",
|
|
||||||
"1 France Diversified Patrimoine \n",
|
|
||||||
"2 France Equity Investissement \n",
|
|
||||||
"3 France Equity Investissement \n",
|
|
||||||
"4 France Equity Investissement \n",
|
|
||||||
"\n",
|
|
||||||
" Product - Legal Status Product - Is Dedie ? ... Centralisation Date \\\n",
|
|
||||||
"0 SICAV NO ... 2020-11-05 \n",
|
|
||||||
"1 FCP NO ... 2015-03-09 \n",
|
|
||||||
"2 FCP NO ... 2016-10-26 \n",
|
|
||||||
"3 FCP NO ... 2018-10-18 \n",
|
|
||||||
"4 FCP NO ... 2019-04-08 \n",
|
|
||||||
"\n",
|
|
||||||
" Quantity - Subscription Quantity - Redemption Quantity - NetFlows \\\n",
|
|
||||||
"0 1636.00 0.000 1636.000 \n",
|
|
||||||
"1 144.69 0.000 144.690 \n",
|
|
||||||
"2 0.00 -8.321 -8.321 \n",
|
|
||||||
"3 0.00 -22.083 -22.083 \n",
|
|
||||||
"4 0.00 -465.992 -465.992 \n",
|
|
||||||
"\n",
|
|
||||||
" Value Ccy - Subscription Value Ccy - Redemption Value Ccy - NetFlows \\\n",
|
|
||||||
"0 280983.00 0.00 280983.00 \n",
|
|
||||||
"1 99985.13 0.00 99985.13 \n",
|
|
||||||
"2 0.00 -9384.76 -9384.76 \n",
|
|
||||||
"3 0.00 -25227.40 -25227.40 \n",
|
|
||||||
"4 0.00 -563775.76 -563775.76 \n",
|
|
||||||
"\n",
|
|
||||||
" Value € - Subscription Value € - Redemption Value € - NetFlows \n",
|
|
||||||
"0 280983.00 0.00 280983.00 \n",
|
|
||||||
"1 99985.13 0.00 99985.13 \n",
|
|
||||||
"2 0.00 -9384.76 -9384.76 \n",
|
|
||||||
"3 0.00 -25227.40 -25227.40 \n",
|
|
||||||
"4 0.00 -563775.76 -563775.76 \n",
|
|
||||||
"\n",
|
|
||||||
"[5 rows x 24 columns]"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"execution_count": 3,
|
|
||||||
"metadata": {},
|
|
||||||
"output_type": "execute_result"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"dg.head()"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 6,
|
|
||||||
"id": "d4c6dc0e-a5bc-495c-a54b-96dd238f46e3",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"# Filtrer les comptes techniques\n",
|
|
||||||
"\n",
|
|
||||||
"import pandas as pd\n",
|
|
||||||
"import numpy as np\n",
|
|
||||||
"\n",
|
|
||||||
"df['Centralisation Date'] = pd.to_datetime(df['Centralisation Date'])\n",
|
|
||||||
"dg['Centralisation Date'] = pd.to_datetime(dg['Centralisation Date'])\n",
|
|
||||||
"df = df[~df['Registrar Account - ID'].isin(['Off Distribution','Private Clients'])]\n",
|
|
||||||
"dg = dg[~dg['Registrar Account - ID'].isin(['Off Distribution','Private Clients'])]"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 5,
|
|
||||||
"id": "a19cbae9-636f-4dc7-882c-6857daca8a11",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"data": {
|
|
||||||
"text/plain": [
|
|
||||||
"(4880297, 18)"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"execution_count": 5,
|
|
||||||
"metadata": {},
|
|
||||||
"output_type": "execute_result"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"df.shape"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 7,
|
|
||||||
"id": "81845380-2c3f-4bf5-81d4-4a89a3732df3",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"data": {
|
|
||||||
"text/plain": [
|
|
||||||
"(4836569, 18)"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"execution_count": 7,
|
|
||||||
"metadata": {},
|
|
||||||
"output_type": "execute_result"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"df.shape"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 8,
|
|
||||||
"id": "c7abd838-cb2d-41dc-a280-6622b0937672",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"# Date de référence\n",
|
|
||||||
"\n",
|
|
||||||
"ref_date = pd.Timestamp('2025-10-31')\n",
|
|
||||||
"\n",
|
|
||||||
"df_ref = df[df['Centralisation Date'] == ref_date]"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 9,
|
|
||||||
"id": "688f3641-67ff-49a4-b6b0-65b64b110ff3",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"data": {
|
|
||||||
"text/plain": [
|
|
||||||
"(24736, 18)"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"execution_count": 9,
|
|
||||||
"metadata": {},
|
|
||||||
"output_type": "execute_result"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"df_ref.shape"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"id": "1efb0610-4eaf-427c-a15c-d926d423db76",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"metadata": {
|
|
||||||
"kernelspec": {
|
|
||||||
"display_name": "Python 3 (ipykernel)",
|
|
||||||
"language": "python",
|
|
||||||
"name": "python3"
|
|
||||||
},
|
|
||||||
"language_info": {
|
|
||||||
"codemirror_mode": {
|
|
||||||
"name": "ipython",
|
|
||||||
"version": 3
|
|
||||||
},
|
|
||||||
"file_extension": ".py",
|
|
||||||
"mimetype": "text/x-python",
|
|
||||||
"name": "python",
|
|
||||||
"nbconvert_exporter": "python",
|
|
||||||
"pygments_lexer": "ipython3",
|
|
||||||
"version": "3.13.12"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nbformat": 4,
|
|
||||||
"nbformat_minor": 5
|
|
||||||
}
|
|
||||||
|
|
@ -1,74 +0,0 @@
|
||||||
{
|
|
||||||
"cells": [
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"id": "7aa09644-4d17-4a7a-841e-3bfcfb8a8901",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"# Import des données\n",
|
|
||||||
"\n",
|
|
||||||
"import os\n",
|
|
||||||
"import s3fs\n",
|
|
||||||
"import pandas as pd\n",
|
|
||||||
"\n",
|
|
||||||
"s3_ENDPOINT_URL = \"https://\" + os.environ[\"AWS_S3_ENDPOINT\"]\n",
|
|
||||||
"\n",
|
|
||||||
"fs = s3fs.S3FileSystem(client_kwargs={'endpoint_url': s3_ENDPOINT_URL})\n",
|
|
||||||
"\n",
|
|
||||||
"BUCKET = \"projet-bdc-data\"\n",
|
|
||||||
"carmignac_path = \"projet-bdc-data/carmignac\"\n",
|
|
||||||
"\n",
|
|
||||||
"# Liste des fichiers FLOWS\n",
|
|
||||||
"all_files = fs.ls(carmignac_path)\n",
|
|
||||||
"flows_files = [f for f in all_files if \"Flows\" in f and f.endswith(\".csv\")]\n",
|
|
||||||
"print(\"Fichiers Flows :\", flows_files)\n",
|
|
||||||
"\n",
|
|
||||||
"# Lire tous les fichiers dans un dictionnaire\n",
|
|
||||||
"flows_data = {}\n",
|
|
||||||
"for file_path in flows_files:\n",
|
|
||||||
" with fs.open(file_path, 'r') as f:\n",
|
|
||||||
" df = pd.read_csv(f, sep=';',low_memory=False)\n",
|
|
||||||
" flows_data[os.path.basename(file_path)] = df\n",
|
|
||||||
"\n",
|
|
||||||
"\n",
|
|
||||||
"# Liste des fichiers AUM\n",
|
|
||||||
"all_files = fs.ls(carmignac_path)\n",
|
|
||||||
"aum_files = [f for f in all_files if \"AUM\" in f and f.endswith(\".csv\")]\n",
|
|
||||||
"print(\"Fichiers AUM :\", aum_files)\n",
|
|
||||||
"\n",
|
|
||||||
"# Lire tous les fichiers dans un dictionnaire\n",
|
|
||||||
"aum_data = {}\n",
|
|
||||||
"for file_path in aum_files:\n",
|
|
||||||
" with fs.open(file_path, 'r') as f:\n",
|
|
||||||
" df = pd.read_csv(f, sep=';',low_memory=False)\n",
|
|
||||||
" aum_data[os.path.basename(file_path)] = df\n",
|
|
||||||
"\n",
|
|
||||||
"df = aum_data['AUM ENSAE V2 -20251105.csv']\n",
|
|
||||||
"dg = flows_data['Flows ENSAE V2 -20251105.csv']"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"metadata": {
|
|
||||||
"kernelspec": {
|
|
||||||
"display_name": "Python 3 (ipykernel)",
|
|
||||||
"language": "python",
|
|
||||||
"name": "python3"
|
|
||||||
},
|
|
||||||
"language_info": {
|
|
||||||
"codemirror_mode": {
|
|
||||||
"name": "ipython",
|
|
||||||
"version": 3
|
|
||||||
},
|
|
||||||
"file_extension": ".py",
|
|
||||||
"mimetype": "text/x-python",
|
|
||||||
"name": "python",
|
|
||||||
"nbconvert_exporter": "python",
|
|
||||||
"pygments_lexer": "ipython3",
|
|
||||||
"version": "3.13.12"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nbformat": 4,
|
|
||||||
"nbformat_minor": 5
|
|
||||||
}
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
{
|
|
||||||
"cells": [
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"id": "beb29e50-e6ef-4cf9-a355-45fbd2f4f08d",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"metadata": {
|
|
||||||
"kernelspec": {
|
|
||||||
"display_name": "Python 3 (ipykernel)",
|
|
||||||
"language": "python",
|
|
||||||
"name": "python3"
|
|
||||||
},
|
|
||||||
"language_info": {
|
|
||||||
"codemirror_mode": {
|
|
||||||
"name": "ipython",
|
|
||||||
"version": 3
|
|
||||||
},
|
|
||||||
"file_extension": ".py",
|
|
||||||
"mimetype": "text/x-python",
|
|
||||||
"name": "python",
|
|
||||||
"nbconvert_exporter": "python",
|
|
||||||
"pygments_lexer": "ipython3",
|
|
||||||
"version": "3.13.12"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nbformat": 4,
|
|
||||||
"nbformat_minor": 5
|
|
||||||
}
|
|
||||||
|
|
@ -1,281 +0,0 @@
|
||||||
{
|
|
||||||
"cells": [
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 25,
|
|
||||||
"id": "dad4ac5b-b66f-4eab-acbf-51dc708616ef",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"Fichiers AUM : ['projet-bdc-data/carmignac/AUM ENSAE V1 -20251027.csv', 'projet-bdc-data/carmignac/AUM ENSAE V2 -20251105.csv']\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"import os\n",
|
|
||||||
"import s3fs\n",
|
|
||||||
"\n",
|
|
||||||
"s3_ENDPOINT_URL = \"https://\" + os.environ[\"AWS_S3_ENDPOINT\"]\n",
|
|
||||||
"\n",
|
|
||||||
"fs = s3fs.S3FileSystem(client_kwargs={'endpoint_url': s3_ENDPOINT_URL})\n",
|
|
||||||
"\n",
|
|
||||||
"BUCKET = \"projet-bdc-data\"\n",
|
|
||||||
"carmignac_path = \"projet-bdc-data/carmignac\"\n",
|
|
||||||
"\n",
|
|
||||||
"# Liste des fichiers AUM\n",
|
|
||||||
"all_files = fs.ls(carmignac_path)\n",
|
|
||||||
"aum_files = [f for f in all_files if \"AUM\" in f and f.endswith(\".csv\")]\n",
|
|
||||||
"print(\"Fichiers AUM :\", aum_files)\n",
|
|
||||||
"\n",
|
|
||||||
"# Lire tous les fichiers dans un dictionnaire\n",
|
|
||||||
"aum_data = {}\n",
|
|
||||||
"for file_path in aum_files:\n",
|
|
||||||
" with fs.open(file_path, 'r') as f:\n",
|
|
||||||
" df = pd.read_csv(f, sep=';',low_memory=False)\n",
|
|
||||||
" aum_data[os.path.basename(file_path)] = df\n"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 27,
|
|
||||||
"id": "68903172-d4f8-4c6e-96f8-578c5b1afe23",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"data": {
|
|
||||||
"text/html": [
|
|
||||||
"<div>\n",
|
|
||||||
"<style scoped>\n",
|
|
||||||
" .dataframe tbody tr th:only-of-type {\n",
|
|
||||||
" vertical-align: middle;\n",
|
|
||||||
" }\n",
|
|
||||||
"\n",
|
|
||||||
" .dataframe tbody tr th {\n",
|
|
||||||
" vertical-align: top;\n",
|
|
||||||
" }\n",
|
|
||||||
"\n",
|
|
||||||
" .dataframe thead th {\n",
|
|
||||||
" text-align: right;\n",
|
|
||||||
" }\n",
|
|
||||||
"</style>\n",
|
|
||||||
"<table border=\"1\" class=\"dataframe\">\n",
|
|
||||||
" <thead>\n",
|
|
||||||
" <tr style=\"text-align: right;\">\n",
|
|
||||||
" <th></th>\n",
|
|
||||||
" <th>Agreement - Code</th>\n",
|
|
||||||
" <th>Company - Id</th>\n",
|
|
||||||
" <th>Company - Ultimate Parent Id</th>\n",
|
|
||||||
" <th>Registrar Account - ID</th>\n",
|
|
||||||
" <th>Registrar Account - Region</th>\n",
|
|
||||||
" <th>RegistrarAccount - Country</th>\n",
|
|
||||||
" <th>Product - Asset Type</th>\n",
|
|
||||||
" <th>Product - Strategy</th>\n",
|
|
||||||
" <th>Product - Legal Status</th>\n",
|
|
||||||
" <th>Product - Is Dedie ?</th>\n",
|
|
||||||
" <th>Product - Fund</th>\n",
|
|
||||||
" <th>Product - Shareclass Type</th>\n",
|
|
||||||
" <th>Product - Shareclass Currency</th>\n",
|
|
||||||
" <th>Product - Isin</th>\n",
|
|
||||||
" <th>Centralisation Date</th>\n",
|
|
||||||
" <th>Quantity - AUM</th>\n",
|
|
||||||
" <th>Value - AUM CCY</th>\n",
|
|
||||||
" <th>Value - AUM €</th>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" </thead>\n",
|
|
||||||
" <tbody>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>0</th>\n",
|
|
||||||
" <td>003</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>200000647</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>Diversified</td>\n",
|
|
||||||
" <td>Patrimoine</td>\n",
|
|
||||||
" <td>FCP</td>\n",
|
|
||||||
" <td>NO</td>\n",
|
|
||||||
" <td>Carmignac Patrimoine</td>\n",
|
|
||||||
" <td>A</td>\n",
|
|
||||||
" <td>EUR</td>\n",
|
|
||||||
" <td>FR0010135103</td>\n",
|
|
||||||
" <td>2015-03-31</td>\n",
|
|
||||||
" <td>35.368</td>\n",
|
|
||||||
" <td>24648.6666</td>\n",
|
|
||||||
" <td>24648.6666</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>1</th>\n",
|
|
||||||
" <td>003</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>200000647</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>Diversified</td>\n",
|
|
||||||
" <td>Patrimoine</td>\n",
|
|
||||||
" <td>FCP</td>\n",
|
|
||||||
" <td>NO</td>\n",
|
|
||||||
" <td>Carmignac Patrimoine</td>\n",
|
|
||||||
" <td>A</td>\n",
|
|
||||||
" <td>EUR</td>\n",
|
|
||||||
" <td>FR0010135103</td>\n",
|
|
||||||
" <td>2015-11-30</td>\n",
|
|
||||||
" <td>35.368</td>\n",
|
|
||||||
" <td>22413.0553</td>\n",
|
|
||||||
" <td>22413.0553</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>2</th>\n",
|
|
||||||
" <td>003</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>200000647</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>Diversified</td>\n",
|
|
||||||
" <td>Patrimoine</td>\n",
|
|
||||||
" <td>FCP</td>\n",
|
|
||||||
" <td>NO</td>\n",
|
|
||||||
" <td>Carmignac Patrimoine</td>\n",
|
|
||||||
" <td>A</td>\n",
|
|
||||||
" <td>EUR</td>\n",
|
|
||||||
" <td>FR0010135103</td>\n",
|
|
||||||
" <td>2015-12-31</td>\n",
|
|
||||||
" <td>35.368</td>\n",
|
|
||||||
" <td>22051.2406</td>\n",
|
|
||||||
" <td>22051.2406</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>3</th>\n",
|
|
||||||
" <td>003</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>200000647</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>Diversified</td>\n",
|
|
||||||
" <td>Patrimoine</td>\n",
|
|
||||||
" <td>FCP</td>\n",
|
|
||||||
" <td>NO</td>\n",
|
|
||||||
" <td>Carmignac Patrimoine</td>\n",
|
|
||||||
" <td>A</td>\n",
|
|
||||||
" <td>EUR</td>\n",
|
|
||||||
" <td>FR0010135103</td>\n",
|
|
||||||
" <td>2016-03-31</td>\n",
|
|
||||||
" <td>35.368</td>\n",
|
|
||||||
" <td>21626.1173</td>\n",
|
|
||||||
" <td>21626.1173</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>4</th>\n",
|
|
||||||
" <td>003</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>200000647</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>Diversified</td>\n",
|
|
||||||
" <td>Patrimoine</td>\n",
|
|
||||||
" <td>FCP</td>\n",
|
|
||||||
" <td>NO</td>\n",
|
|
||||||
" <td>Carmignac Patrimoine</td>\n",
|
|
||||||
" <td>A</td>\n",
|
|
||||||
" <td>EUR</td>\n",
|
|
||||||
" <td>FR0010135103</td>\n",
|
|
||||||
" <td>2016-11-30</td>\n",
|
|
||||||
" <td>35.368</td>\n",
|
|
||||||
" <td>22489.4502</td>\n",
|
|
||||||
" <td>22489.4502</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" </tbody>\n",
|
|
||||||
"</table>\n",
|
|
||||||
"</div>"
|
|
||||||
],
|
|
||||||
"text/plain": [
|
|
||||||
" Agreement - Code Company - Id Company - Ultimate Parent Id \\\n",
|
|
||||||
"0 003 166 166 \n",
|
|
||||||
"1 003 166 166 \n",
|
|
||||||
"2 003 166 166 \n",
|
|
||||||
"3 003 166 166 \n",
|
|
||||||
"4 003 166 166 \n",
|
|
||||||
"\n",
|
|
||||||
" Registrar Account - ID Registrar Account - Region \\\n",
|
|
||||||
"0 200000647 France \n",
|
|
||||||
"1 200000647 France \n",
|
|
||||||
"2 200000647 France \n",
|
|
||||||
"3 200000647 France \n",
|
|
||||||
"4 200000647 France \n",
|
|
||||||
"\n",
|
|
||||||
" RegistrarAccount - Country Product - Asset Type Product - Strategy \\\n",
|
|
||||||
"0 France Diversified Patrimoine \n",
|
|
||||||
"1 France Diversified Patrimoine \n",
|
|
||||||
"2 France Diversified Patrimoine \n",
|
|
||||||
"3 France Diversified Patrimoine \n",
|
|
||||||
"4 France Diversified Patrimoine \n",
|
|
||||||
"\n",
|
|
||||||
" Product - Legal Status Product - Is Dedie ? Product - Fund \\\n",
|
|
||||||
"0 FCP NO Carmignac Patrimoine \n",
|
|
||||||
"1 FCP NO Carmignac Patrimoine \n",
|
|
||||||
"2 FCP NO Carmignac Patrimoine \n",
|
|
||||||
"3 FCP NO Carmignac Patrimoine \n",
|
|
||||||
"4 FCP NO Carmignac Patrimoine \n",
|
|
||||||
"\n",
|
|
||||||
" Product - Shareclass Type Product - Shareclass Currency Product - Isin \\\n",
|
|
||||||
"0 A EUR FR0010135103 \n",
|
|
||||||
"1 A EUR FR0010135103 \n",
|
|
||||||
"2 A EUR FR0010135103 \n",
|
|
||||||
"3 A EUR FR0010135103 \n",
|
|
||||||
"4 A EUR FR0010135103 \n",
|
|
||||||
"\n",
|
|
||||||
" Centralisation Date Quantity - AUM Value - AUM CCY Value - AUM € \n",
|
|
||||||
"0 2015-03-31 35.368 24648.6666 24648.6666 \n",
|
|
||||||
"1 2015-11-30 35.368 22413.0553 22413.0553 \n",
|
|
||||||
"2 2015-12-31 35.368 22051.2406 22051.2406 \n",
|
|
||||||
"3 2016-03-31 35.368 21626.1173 21626.1173 \n",
|
|
||||||
"4 2016-11-30 35.368 22489.4502 22489.4502 "
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"execution_count": 27,
|
|
||||||
"metadata": {},
|
|
||||||
"output_type": "execute_result"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"aum_data['AUM ENSAE V2 -20251105.csv'].head()"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"id": "22042f8f-1492-44a4-a492-5074ef1dc9f6",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"metadata": {
|
|
||||||
"kernelspec": {
|
|
||||||
"display_name": "Python 3 (ipykernel)",
|
|
||||||
"language": "python",
|
|
||||||
"name": "python3"
|
|
||||||
},
|
|
||||||
"language_info": {
|
|
||||||
"codemirror_mode": {
|
|
||||||
"name": "ipython",
|
|
||||||
"version": 3
|
|
||||||
},
|
|
||||||
"file_extension": ".py",
|
|
||||||
"mimetype": "text/x-python",
|
|
||||||
"name": "python",
|
|
||||||
"nbconvert_exporter": "python",
|
|
||||||
"pygments_lexer": "ipython3",
|
|
||||||
"version": "3.13.8"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nbformat": 4,
|
|
||||||
"nbformat_minor": 5
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
{
|
|
||||||
"cells": [],
|
|
||||||
"metadata": {},
|
|
||||||
"nbformat": 4,
|
|
||||||
"nbformat_minor": 5
|
|
||||||
}
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
{
|
|
||||||
"cells": [
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"id": "5e49fa70-05e3-4d9a-82db-e36ab3c993c7",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"metadata": {
|
|
||||||
"kernelspec": {
|
|
||||||
"display_name": "Python 3 (ipykernel)",
|
|
||||||
"language": "python",
|
|
||||||
"name": "python3"
|
|
||||||
},
|
|
||||||
"language_info": {
|
|
||||||
"codemirror_mode": {
|
|
||||||
"name": "ipython",
|
|
||||||
"version": 3
|
|
||||||
},
|
|
||||||
"file_extension": ".py",
|
|
||||||
"mimetype": "text/x-python",
|
|
||||||
"name": "python",
|
|
||||||
"nbconvert_exporter": "python",
|
|
||||||
"pygments_lexer": "ipython3",
|
|
||||||
"version": "3.13.8"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nbformat": 4,
|
|
||||||
"nbformat_minor": 5
|
|
||||||
}
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -1,551 +0,0 @@
|
||||||
{
|
|
||||||
"cells": [
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 7,
|
|
||||||
"id": "f996e528-002f-4856-a67a-5120e8af86ad",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"Fichiers Flows : ['projet-bdc-data/carmignac/Flows ENSAE V1 -20251027.csv', 'projet-bdc-data/carmignac/Flows ENSAE V2 -20251105.csv']\n",
|
|
||||||
"Fichiers AUM : ['projet-bdc-data/carmignac/AUM ENSAE V1 -20251027.csv', 'projet-bdc-data/carmignac/AUM ENSAE V2 -20251105.csv']\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"import os\n",
|
|
||||||
"import s3fs\n",
|
|
||||||
"import pandas as pd\n",
|
|
||||||
"\n",
|
|
||||||
"s3_ENDPOINT_URL = \"https://\" + os.environ[\"AWS_S3_ENDPOINT\"]\n",
|
|
||||||
"\n",
|
|
||||||
"fs = s3fs.S3FileSystem(client_kwargs={'endpoint_url': s3_ENDPOINT_URL})\n",
|
|
||||||
"\n",
|
|
||||||
"BUCKET = \"projet-bdc-data\"\n",
|
|
||||||
"carmignac_path = \"projet-bdc-data/carmignac\"\n",
|
|
||||||
"\n",
|
|
||||||
"# Liste des fichiers FLOWS\n",
|
|
||||||
"all_files = fs.ls(carmignac_path)\n",
|
|
||||||
"flows_files = [f for f in all_files if \"Flows\" in f and f.endswith(\".csv\")]\n",
|
|
||||||
"print(\"Fichiers Flows :\", flows_files)\n",
|
|
||||||
"\n",
|
|
||||||
"# Lire tous les fichiers dans un dictionnaire\n",
|
|
||||||
"flows_data = {}\n",
|
|
||||||
"for file_path in flows_files:\n",
|
|
||||||
" with fs.open(file_path, 'r') as f:\n",
|
|
||||||
" df = pd.read_csv(f, sep=';',low_memory=False)\n",
|
|
||||||
" flows_data[os.path.basename(file_path)] = df\n",
|
|
||||||
"\n",
|
|
||||||
"\n",
|
|
||||||
"# Liste des fichiers AUM\n",
|
|
||||||
"all_files = fs.ls(carmignac_path)\n",
|
|
||||||
"aum_files = [f for f in all_files if \"AUM\" in f and f.endswith(\".csv\")]\n",
|
|
||||||
"print(\"Fichiers AUM :\", aum_files)\n",
|
|
||||||
"\n",
|
|
||||||
"# Lire tous les fichiers dans un dictionnaire\n",
|
|
||||||
"aum_data = {}\n",
|
|
||||||
"for file_path in aum_files:\n",
|
|
||||||
" with fs.open(file_path, 'r') as f:\n",
|
|
||||||
" df = pd.read_csv(f, sep=';',low_memory=False)\n",
|
|
||||||
" aum_data[os.path.basename(file_path)] = df"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 8,
|
|
||||||
"id": "bdfc2afe-c3aa-41b6-bb40-3a7bf2a39d9a",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"data": {
|
|
||||||
"text/html": [
|
|
||||||
"<div>\n",
|
|
||||||
"<style scoped>\n",
|
|
||||||
" .dataframe tbody tr th:only-of-type {\n",
|
|
||||||
" vertical-align: middle;\n",
|
|
||||||
" }\n",
|
|
||||||
"\n",
|
|
||||||
" .dataframe tbody tr th {\n",
|
|
||||||
" vertical-align: top;\n",
|
|
||||||
" }\n",
|
|
||||||
"\n",
|
|
||||||
" .dataframe thead th {\n",
|
|
||||||
" text-align: right;\n",
|
|
||||||
" }\n",
|
|
||||||
"</style>\n",
|
|
||||||
"<table border=\"1\" class=\"dataframe\">\n",
|
|
||||||
" <thead>\n",
|
|
||||||
" <tr style=\"text-align: right;\">\n",
|
|
||||||
" <th></th>\n",
|
|
||||||
" <th>Agreement - Code</th>\n",
|
|
||||||
" <th>Company - Id</th>\n",
|
|
||||||
" <th>Company - Ultimate Parent Id</th>\n",
|
|
||||||
" <th>Registrar Account - ID</th>\n",
|
|
||||||
" <th>Registrar Account - Region</th>\n",
|
|
||||||
" <th>RegistrarAccount - Country</th>\n",
|
|
||||||
" <th>Product - Asset Type</th>\n",
|
|
||||||
" <th>Product - Strategy</th>\n",
|
|
||||||
" <th>Product - Legal Status</th>\n",
|
|
||||||
" <th>Product - Is Dedie ?</th>\n",
|
|
||||||
" <th>...</th>\n",
|
|
||||||
" <th>Centralisation Date</th>\n",
|
|
||||||
" <th>Quantity - Subscription</th>\n",
|
|
||||||
" <th>Quantity - Redemption</th>\n",
|
|
||||||
" <th>Quantity - NetFlows</th>\n",
|
|
||||||
" <th>Value Ccy - Subscription</th>\n",
|
|
||||||
" <th>Value Ccy - Redemption</th>\n",
|
|
||||||
" <th>Value Ccy - NetFlows</th>\n",
|
|
||||||
" <th>Value € - Subscription</th>\n",
|
|
||||||
" <th>Value € - Redemption</th>\n",
|
|
||||||
" <th>Value € - NetFlows</th>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" </thead>\n",
|
|
||||||
" <tbody>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>0</th>\n",
|
|
||||||
" <td>003</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>200127202</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>Equity</td>\n",
|
|
||||||
" <td>Investissement</td>\n",
|
|
||||||
" <td>SICAV</td>\n",
|
|
||||||
" <td>NO</td>\n",
|
|
||||||
" <td>...</td>\n",
|
|
||||||
" <td>2020-11-05</td>\n",
|
|
||||||
" <td>1636.00</td>\n",
|
|
||||||
" <td>0.000</td>\n",
|
|
||||||
" <td>1636.000</td>\n",
|
|
||||||
" <td>280983.00</td>\n",
|
|
||||||
" <td>0.00</td>\n",
|
|
||||||
" <td>280983.00</td>\n",
|
|
||||||
" <td>280983.00</td>\n",
|
|
||||||
" <td>0.00</td>\n",
|
|
||||||
" <td>280983.00</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>1</th>\n",
|
|
||||||
" <td>003</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>406533</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>Diversified</td>\n",
|
|
||||||
" <td>Patrimoine</td>\n",
|
|
||||||
" <td>FCP</td>\n",
|
|
||||||
" <td>NO</td>\n",
|
|
||||||
" <td>...</td>\n",
|
|
||||||
" <td>2015-03-09</td>\n",
|
|
||||||
" <td>144.69</td>\n",
|
|
||||||
" <td>0.000</td>\n",
|
|
||||||
" <td>144.690</td>\n",
|
|
||||||
" <td>99985.13</td>\n",
|
|
||||||
" <td>0.00</td>\n",
|
|
||||||
" <td>99985.13</td>\n",
|
|
||||||
" <td>99985.13</td>\n",
|
|
||||||
" <td>0.00</td>\n",
|
|
||||||
" <td>99985.13</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>2</th>\n",
|
|
||||||
" <td>003</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>406533</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>Equity</td>\n",
|
|
||||||
" <td>Investissement</td>\n",
|
|
||||||
" <td>FCP</td>\n",
|
|
||||||
" <td>NO</td>\n",
|
|
||||||
" <td>...</td>\n",
|
|
||||||
" <td>2016-10-26</td>\n",
|
|
||||||
" <td>0.00</td>\n",
|
|
||||||
" <td>-8.321</td>\n",
|
|
||||||
" <td>-8.321</td>\n",
|
|
||||||
" <td>0.00</td>\n",
|
|
||||||
" <td>-9384.76</td>\n",
|
|
||||||
" <td>-9384.76</td>\n",
|
|
||||||
" <td>0.00</td>\n",
|
|
||||||
" <td>-9384.76</td>\n",
|
|
||||||
" <td>-9384.76</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>3</th>\n",
|
|
||||||
" <td>003</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>406533</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>Equity</td>\n",
|
|
||||||
" <td>Investissement</td>\n",
|
|
||||||
" <td>FCP</td>\n",
|
|
||||||
" <td>NO</td>\n",
|
|
||||||
" <td>...</td>\n",
|
|
||||||
" <td>2018-10-18</td>\n",
|
|
||||||
" <td>0.00</td>\n",
|
|
||||||
" <td>-22.083</td>\n",
|
|
||||||
" <td>-22.083</td>\n",
|
|
||||||
" <td>0.00</td>\n",
|
|
||||||
" <td>-25227.40</td>\n",
|
|
||||||
" <td>-25227.40</td>\n",
|
|
||||||
" <td>0.00</td>\n",
|
|
||||||
" <td>-25227.40</td>\n",
|
|
||||||
" <td>-25227.40</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>4</th>\n",
|
|
||||||
" <td>003</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>406533</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>Equity</td>\n",
|
|
||||||
" <td>Investissement</td>\n",
|
|
||||||
" <td>FCP</td>\n",
|
|
||||||
" <td>NO</td>\n",
|
|
||||||
" <td>...</td>\n",
|
|
||||||
" <td>2019-04-08</td>\n",
|
|
||||||
" <td>0.00</td>\n",
|
|
||||||
" <td>-465.992</td>\n",
|
|
||||||
" <td>-465.992</td>\n",
|
|
||||||
" <td>0.00</td>\n",
|
|
||||||
" <td>-563775.76</td>\n",
|
|
||||||
" <td>-563775.76</td>\n",
|
|
||||||
" <td>0.00</td>\n",
|
|
||||||
" <td>-563775.76</td>\n",
|
|
||||||
" <td>-563775.76</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" </tbody>\n",
|
|
||||||
"</table>\n",
|
|
||||||
"<p>5 rows × 24 columns</p>\n",
|
|
||||||
"</div>"
|
|
||||||
],
|
|
||||||
"text/plain": [
|
|
||||||
" Agreement - Code Company - Id Company - Ultimate Parent Id \\\n",
|
|
||||||
"0 003 166 166 \n",
|
|
||||||
"1 003 166 166 \n",
|
|
||||||
"2 003 166 166 \n",
|
|
||||||
"3 003 166 166 \n",
|
|
||||||
"4 003 166 166 \n",
|
|
||||||
"\n",
|
|
||||||
" Registrar Account - ID Registrar Account - Region \\\n",
|
|
||||||
"0 200127202 France \n",
|
|
||||||
"1 406533 France \n",
|
|
||||||
"2 406533 France \n",
|
|
||||||
"3 406533 France \n",
|
|
||||||
"4 406533 France \n",
|
|
||||||
"\n",
|
|
||||||
" RegistrarAccount - Country Product - Asset Type Product - Strategy \\\n",
|
|
||||||
"0 France Equity Investissement \n",
|
|
||||||
"1 France Diversified Patrimoine \n",
|
|
||||||
"2 France Equity Investissement \n",
|
|
||||||
"3 France Equity Investissement \n",
|
|
||||||
"4 France Equity Investissement \n",
|
|
||||||
"\n",
|
|
||||||
" Product - Legal Status Product - Is Dedie ? ... Centralisation Date \\\n",
|
|
||||||
"0 SICAV NO ... 2020-11-05 \n",
|
|
||||||
"1 FCP NO ... 2015-03-09 \n",
|
|
||||||
"2 FCP NO ... 2016-10-26 \n",
|
|
||||||
"3 FCP NO ... 2018-10-18 \n",
|
|
||||||
"4 FCP NO ... 2019-04-08 \n",
|
|
||||||
"\n",
|
|
||||||
" Quantity - Subscription Quantity - Redemption Quantity - NetFlows \\\n",
|
|
||||||
"0 1636.00 0.000 1636.000 \n",
|
|
||||||
"1 144.69 0.000 144.690 \n",
|
|
||||||
"2 0.00 -8.321 -8.321 \n",
|
|
||||||
"3 0.00 -22.083 -22.083 \n",
|
|
||||||
"4 0.00 -465.992 -465.992 \n",
|
|
||||||
"\n",
|
|
||||||
" Value Ccy - Subscription Value Ccy - Redemption Value Ccy - NetFlows \\\n",
|
|
||||||
"0 280983.00 0.00 280983.00 \n",
|
|
||||||
"1 99985.13 0.00 99985.13 \n",
|
|
||||||
"2 0.00 -9384.76 -9384.76 \n",
|
|
||||||
"3 0.00 -25227.40 -25227.40 \n",
|
|
||||||
"4 0.00 -563775.76 -563775.76 \n",
|
|
||||||
"\n",
|
|
||||||
" Value € - Subscription Value € - Redemption Value € - NetFlows \n",
|
|
||||||
"0 280983.00 0.00 280983.00 \n",
|
|
||||||
"1 99985.13 0.00 99985.13 \n",
|
|
||||||
"2 0.00 -9384.76 -9384.76 \n",
|
|
||||||
"3 0.00 -25227.40 -25227.40 \n",
|
|
||||||
"4 0.00 -563775.76 -563775.76 \n",
|
|
||||||
"\n",
|
|
||||||
"[5 rows x 24 columns]"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"execution_count": 8,
|
|
||||||
"metadata": {},
|
|
||||||
"output_type": "execute_result"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"df = flows_data['Flows ENSAE V2 -20251105.csv']\n",
|
|
||||||
"df.head()"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 9,
|
|
||||||
"id": "6af3bcd9-0a54-4087-a8cf-203fb6f8a947",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"data": {
|
|
||||||
"text/html": [
|
|
||||||
"<div>\n",
|
|
||||||
"<style scoped>\n",
|
|
||||||
" .dataframe tbody tr th:only-of-type {\n",
|
|
||||||
" vertical-align: middle;\n",
|
|
||||||
" }\n",
|
|
||||||
"\n",
|
|
||||||
" .dataframe tbody tr th {\n",
|
|
||||||
" vertical-align: top;\n",
|
|
||||||
" }\n",
|
|
||||||
"\n",
|
|
||||||
" .dataframe thead th {\n",
|
|
||||||
" text-align: right;\n",
|
|
||||||
" }\n",
|
|
||||||
"</style>\n",
|
|
||||||
"<table border=\"1\" class=\"dataframe\">\n",
|
|
||||||
" <thead>\n",
|
|
||||||
" <tr style=\"text-align: right;\">\n",
|
|
||||||
" <th></th>\n",
|
|
||||||
" <th>Agreement - Code</th>\n",
|
|
||||||
" <th>Company - Id</th>\n",
|
|
||||||
" <th>Company - Ultimate Parent Id</th>\n",
|
|
||||||
" <th>Registrar Account - ID</th>\n",
|
|
||||||
" <th>Registrar Account - Region</th>\n",
|
|
||||||
" <th>RegistrarAccount - Country</th>\n",
|
|
||||||
" <th>Product - Asset Type</th>\n",
|
|
||||||
" <th>Product - Strategy</th>\n",
|
|
||||||
" <th>Product - Legal Status</th>\n",
|
|
||||||
" <th>Product - Is Dedie ?</th>\n",
|
|
||||||
" <th>Product - Fund</th>\n",
|
|
||||||
" <th>Product - Shareclass Type</th>\n",
|
|
||||||
" <th>Product - Shareclass Currency</th>\n",
|
|
||||||
" <th>Product - Isin</th>\n",
|
|
||||||
" <th>Centralisation Date</th>\n",
|
|
||||||
" <th>Quantity - AUM</th>\n",
|
|
||||||
" <th>Value - AUM CCY</th>\n",
|
|
||||||
" <th>Value - AUM €</th>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" </thead>\n",
|
|
||||||
" <tbody>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>0</th>\n",
|
|
||||||
" <td>003</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>200000647</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>Diversified</td>\n",
|
|
||||||
" <td>Patrimoine</td>\n",
|
|
||||||
" <td>FCP</td>\n",
|
|
||||||
" <td>NO</td>\n",
|
|
||||||
" <td>Carmignac Patrimoine</td>\n",
|
|
||||||
" <td>A</td>\n",
|
|
||||||
" <td>EUR</td>\n",
|
|
||||||
" <td>FR0010135103</td>\n",
|
|
||||||
" <td>2015-03-31</td>\n",
|
|
||||||
" <td>35.368</td>\n",
|
|
||||||
" <td>24648.6666</td>\n",
|
|
||||||
" <td>24648.6666</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>1</th>\n",
|
|
||||||
" <td>003</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>200000647</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>Diversified</td>\n",
|
|
||||||
" <td>Patrimoine</td>\n",
|
|
||||||
" <td>FCP</td>\n",
|
|
||||||
" <td>NO</td>\n",
|
|
||||||
" <td>Carmignac Patrimoine</td>\n",
|
|
||||||
" <td>A</td>\n",
|
|
||||||
" <td>EUR</td>\n",
|
|
||||||
" <td>FR0010135103</td>\n",
|
|
||||||
" <td>2015-11-30</td>\n",
|
|
||||||
" <td>35.368</td>\n",
|
|
||||||
" <td>22413.0553</td>\n",
|
|
||||||
" <td>22413.0553</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>2</th>\n",
|
|
||||||
" <td>003</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>200000647</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>Diversified</td>\n",
|
|
||||||
" <td>Patrimoine</td>\n",
|
|
||||||
" <td>FCP</td>\n",
|
|
||||||
" <td>NO</td>\n",
|
|
||||||
" <td>Carmignac Patrimoine</td>\n",
|
|
||||||
" <td>A</td>\n",
|
|
||||||
" <td>EUR</td>\n",
|
|
||||||
" <td>FR0010135103</td>\n",
|
|
||||||
" <td>2015-12-31</td>\n",
|
|
||||||
" <td>35.368</td>\n",
|
|
||||||
" <td>22051.2406</td>\n",
|
|
||||||
" <td>22051.2406</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>3</th>\n",
|
|
||||||
" <td>003</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>200000647</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>Diversified</td>\n",
|
|
||||||
" <td>Patrimoine</td>\n",
|
|
||||||
" <td>FCP</td>\n",
|
|
||||||
" <td>NO</td>\n",
|
|
||||||
" <td>Carmignac Patrimoine</td>\n",
|
|
||||||
" <td>A</td>\n",
|
|
||||||
" <td>EUR</td>\n",
|
|
||||||
" <td>FR0010135103</td>\n",
|
|
||||||
" <td>2016-03-31</td>\n",
|
|
||||||
" <td>35.368</td>\n",
|
|
||||||
" <td>21626.1173</td>\n",
|
|
||||||
" <td>21626.1173</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>4</th>\n",
|
|
||||||
" <td>003</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>200000647</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>Diversified</td>\n",
|
|
||||||
" <td>Patrimoine</td>\n",
|
|
||||||
" <td>FCP</td>\n",
|
|
||||||
" <td>NO</td>\n",
|
|
||||||
" <td>Carmignac Patrimoine</td>\n",
|
|
||||||
" <td>A</td>\n",
|
|
||||||
" <td>EUR</td>\n",
|
|
||||||
" <td>FR0010135103</td>\n",
|
|
||||||
" <td>2016-11-30</td>\n",
|
|
||||||
" <td>35.368</td>\n",
|
|
||||||
" <td>22489.4502</td>\n",
|
|
||||||
" <td>22489.4502</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" </tbody>\n",
|
|
||||||
"</table>\n",
|
|
||||||
"</div>"
|
|
||||||
],
|
|
||||||
"text/plain": [
|
|
||||||
" Agreement - Code Company - Id Company - Ultimate Parent Id \\\n",
|
|
||||||
"0 003 166 166 \n",
|
|
||||||
"1 003 166 166 \n",
|
|
||||||
"2 003 166 166 \n",
|
|
||||||
"3 003 166 166 \n",
|
|
||||||
"4 003 166 166 \n",
|
|
||||||
"\n",
|
|
||||||
" Registrar Account - ID Registrar Account - Region \\\n",
|
|
||||||
"0 200000647 France \n",
|
|
||||||
"1 200000647 France \n",
|
|
||||||
"2 200000647 France \n",
|
|
||||||
"3 200000647 France \n",
|
|
||||||
"4 200000647 France \n",
|
|
||||||
"\n",
|
|
||||||
" RegistrarAccount - Country Product - Asset Type Product - Strategy \\\n",
|
|
||||||
"0 France Diversified Patrimoine \n",
|
|
||||||
"1 France Diversified Patrimoine \n",
|
|
||||||
"2 France Diversified Patrimoine \n",
|
|
||||||
"3 France Diversified Patrimoine \n",
|
|
||||||
"4 France Diversified Patrimoine \n",
|
|
||||||
"\n",
|
|
||||||
" Product - Legal Status Product - Is Dedie ? Product - Fund \\\n",
|
|
||||||
"0 FCP NO Carmignac Patrimoine \n",
|
|
||||||
"1 FCP NO Carmignac Patrimoine \n",
|
|
||||||
"2 FCP NO Carmignac Patrimoine \n",
|
|
||||||
"3 FCP NO Carmignac Patrimoine \n",
|
|
||||||
"4 FCP NO Carmignac Patrimoine \n",
|
|
||||||
"\n",
|
|
||||||
" Product - Shareclass Type Product - Shareclass Currency Product - Isin \\\n",
|
|
||||||
"0 A EUR FR0010135103 \n",
|
|
||||||
"1 A EUR FR0010135103 \n",
|
|
||||||
"2 A EUR FR0010135103 \n",
|
|
||||||
"3 A EUR FR0010135103 \n",
|
|
||||||
"4 A EUR FR0010135103 \n",
|
|
||||||
"\n",
|
|
||||||
" Centralisation Date Quantity - AUM Value - AUM CCY Value - AUM € \n",
|
|
||||||
"0 2015-03-31 35.368 24648.6666 24648.6666 \n",
|
|
||||||
"1 2015-11-30 35.368 22413.0553 22413.0553 \n",
|
|
||||||
"2 2015-12-31 35.368 22051.2406 22051.2406 \n",
|
|
||||||
"3 2016-03-31 35.368 21626.1173 21626.1173 \n",
|
|
||||||
"4 2016-11-30 35.368 22489.4502 22489.4502 "
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"execution_count": 9,
|
|
||||||
"metadata": {},
|
|
||||||
"output_type": "execute_result"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"dg = aum_data['AUM ENSAE V2 -20251105.csv']\n",
|
|
||||||
"dg.head()"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"id": "1d9cd20d-2e79-47b8-91f1-09fee4962dc6",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"df_ids = set(df['Registrar Account - ID'].unique())\n",
|
|
||||||
"dg_ids = set(dg['Registrar Account - ID'].unique())\n",
|
|
||||||
"\n",
|
|
||||||
"intersect = df_ids & dg_ids # comptes dans les deux\n",
|
|
||||||
"only_df = df_ids - dg_ids # comptes seulement dans df\n",
|
|
||||||
"only_dg = dg_ids - df_ids # comptes seulement dans dg\n"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"id": "1a374690-119e-4bbb-a12d-13d0305780ad",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"metadata": {
|
|
||||||
"kernelspec": {
|
|
||||||
"display_name": "Python 3 (ipykernel)",
|
|
||||||
"language": "python",
|
|
||||||
"name": "python3"
|
|
||||||
},
|
|
||||||
"language_info": {
|
|
||||||
"codemirror_mode": {
|
|
||||||
"name": "ipython",
|
|
||||||
"version": 3
|
|
||||||
},
|
|
||||||
"file_extension": ".py",
|
|
||||||
"mimetype": "text/x-python",
|
|
||||||
"name": "python",
|
|
||||||
"nbconvert_exporter": "python",
|
|
||||||
"pygments_lexer": "ipython3",
|
|
||||||
"version": "3.13.8"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nbformat": 4,
|
|
||||||
"nbformat_minor": 5
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
{
|
|
||||||
"cells": [],
|
|
||||||
"metadata": {},
|
|
||||||
"nbformat": 4,
|
|
||||||
"nbformat_minor": 5
|
|
||||||
}
|
|
||||||
|
|
@ -1,86 +0,0 @@
|
||||||
import pandas as pd
|
|
||||||
|
|
||||||
def detect_ruptures(df, epsilon=0.05):
|
|
||||||
# Colonnes clés pour identifier les comptes
|
|
||||||
key_cols = [
|
|
||||||
'Agreement - Code',
|
|
||||||
'Company - Id',
|
|
||||||
'Company - Ultimate Parent Id',
|
|
||||||
'Registrar Account - Region',
|
|
||||||
'RegistrarAccount - Country',
|
|
||||||
'Registrar Account - ID'
|
|
||||||
]
|
|
||||||
|
|
||||||
# Travailler sur une copie
|
|
||||||
df_temp = df.copy()
|
|
||||||
|
|
||||||
# Colonnes de dates
|
|
||||||
df_temp['Centralisation Date'] = pd.to_datetime(df_temp['Centralisation Date'])
|
|
||||||
|
|
||||||
# Dates distinctes
|
|
||||||
full_dates = (
|
|
||||||
pd.Series(df_temp['Centralisation Date'].unique())
|
|
||||||
.sort_values()
|
|
||||||
.reset_index(drop=True)
|
|
||||||
)
|
|
||||||
|
|
||||||
# Combinaisons comptes × dates
|
|
||||||
accounts = df_temp[key_cols].drop_duplicates()
|
|
||||||
full_index = accounts.merge(
|
|
||||||
pd.DataFrame({'Centralisation Date': full_dates}),
|
|
||||||
how='cross'
|
|
||||||
)
|
|
||||||
|
|
||||||
# Agréger les AUM par clé
|
|
||||||
agg_cols = key_cols + ['Centralisation Date']
|
|
||||||
df_agg = (
|
|
||||||
df_temp.groupby(agg_cols)['Value - AUM €']
|
|
||||||
.sum()
|
|
||||||
.reset_index()
|
|
||||||
)
|
|
||||||
|
|
||||||
# Merge sur toutes les combinaisons
|
|
||||||
df_full = pd.merge(full_index, df_agg, on=agg_cols, how='left')
|
|
||||||
|
|
||||||
# Remplissage des trous par 0
|
|
||||||
df_full['Value - AUM €'] = df_full['Value - AUM €'].fillna(0)
|
|
||||||
|
|
||||||
# Tri
|
|
||||||
df_full = df_full.sort_values(key_cols + ['Centralisation Date'])
|
|
||||||
|
|
||||||
# Variation et valeur précédente
|
|
||||||
df_full['AUM_diff'] = df_full.groupby(key_cols)['Value - AUM €'].diff().fillna(0)
|
|
||||||
df_full['prev_value'] = df_full.groupby(key_cols)['Value - AUM €'].shift(1).fillna(0)
|
|
||||||
|
|
||||||
# Comptes qui perdent tout
|
|
||||||
df_zero = df_full[(df_full['AUM_diff'] < 0) & (df_full['Value - AUM €'] == 0)].copy()
|
|
||||||
|
|
||||||
# Comptes qui partent de 0
|
|
||||||
df_from_zero = df_full[(df_full['AUM_diff'] > 0) & (df_full['prev_value'] == 0)].copy()
|
|
||||||
|
|
||||||
# Colonnes pour le merge (sans ID)
|
|
||||||
merge_cols = [
|
|
||||||
'Centralisation Date',
|
|
||||||
'Agreement - Code',
|
|
||||||
'Company - Id',
|
|
||||||
'Company - Ultimate Parent Id',
|
|
||||||
'Registrar Account - Region',
|
|
||||||
'RegistrarAccount - Country'
|
|
||||||
]
|
|
||||||
|
|
||||||
# Détection des ruptures
|
|
||||||
ruptures = pd.merge(df_zero, df_from_zero, on=merge_cols, suffixes=('_old','_new'))
|
|
||||||
|
|
||||||
# Calcul de la différence relative selon epsilon
|
|
||||||
ruptures['diff_rel'] = abs(ruptures['AUM_diff_old'] + ruptures['AUM_diff_new']) / (
|
|
||||||
(abs(ruptures['AUM_diff_old']) + abs(ruptures['AUM_diff_new'])) / 2
|
|
||||||
)
|
|
||||||
|
|
||||||
# Filtrage avec epsilon
|
|
||||||
ruptures = ruptures[ruptures['diff_rel'] <= epsilon].drop(columns=['diff_rel'])
|
|
||||||
|
|
||||||
# Colonnes finales
|
|
||||||
ruptures_df = ruptures[['Centralisation Date','Registrar Account - ID_old','Registrar Account - ID_new','AUM_diff_new']]
|
|
||||||
ruptures_df.columns = ['date','old_account','new_account','value']
|
|
||||||
|
|
||||||
return ruptures_df
|
|
||||||
|
|
@ -1,103 +0,0 @@
|
||||||
import matplotlib.pyplot as plt
|
|
||||||
import pandas as pd
|
|
||||||
|
|
||||||
|
|
||||||
def evolution_compte(df, id1, id = 'Registrar Account - ID'):
|
|
||||||
def prepare_df(idt):
|
|
||||||
df_id = df[df[id] == idt].copy()
|
|
||||||
df_id['Centralisation Date'] = pd.to_datetime(df_id['Centralisation Date'])
|
|
||||||
df_agg = (
|
|
||||||
df_id
|
|
||||||
.groupby('Centralisation Date')['Quantity - AUM']
|
|
||||||
.sum()
|
|
||||||
.reset_index()
|
|
||||||
.sort_values('Centralisation Date')
|
|
||||||
)
|
|
||||||
return df_agg
|
|
||||||
|
|
||||||
df1 = prepare_df(id1)
|
|
||||||
|
|
||||||
plt.figure(figsize=(12, 6))
|
|
||||||
|
|
||||||
# Courbe du compte
|
|
||||||
plt.plot(df1['Centralisation Date'], df1['Quantity - AUM'],
|
|
||||||
marker='.', linestyle='-', label=f'Account {id1}')
|
|
||||||
|
|
||||||
plt.title(f"Évolution AUM pour le compte {id1}")
|
|
||||||
plt.xlabel("Date")
|
|
||||||
plt.ylabel("Quantity - AUM")
|
|
||||||
plt.grid(True)
|
|
||||||
plt.legend()
|
|
||||||
plt.tight_layout()
|
|
||||||
plt.show()
|
|
||||||
|
|
||||||
def evolution_2_comptes(df, id1, id2):
|
|
||||||
def prepare_df(id):
|
|
||||||
df_id = df[df['Registrar Account - ID'] == id].copy()
|
|
||||||
df_id['Centralisation Date'] = pd.to_datetime(df_id['Centralisation Date'])
|
|
||||||
df_agg = (
|
|
||||||
df_id
|
|
||||||
.groupby('Centralisation Date')['Quantity - AUM']
|
|
||||||
.sum()
|
|
||||||
.reset_index()
|
|
||||||
.sort_values('Centralisation Date')
|
|
||||||
)
|
|
||||||
return df_agg
|
|
||||||
|
|
||||||
df1 = prepare_df(id1)
|
|
||||||
df2 = prepare_df(id2)
|
|
||||||
|
|
||||||
plt.figure(figsize=(12, 6))
|
|
||||||
|
|
||||||
# Courbe du premier compte
|
|
||||||
plt.plot(df1['Centralisation Date'], df1['Quantity - AUM'],
|
|
||||||
marker='.', linestyle='-', label=f'Account {id1}')
|
|
||||||
|
|
||||||
# Courbe du second compte
|
|
||||||
plt.plot(df2['Centralisation Date'], df2['Quantity - AUM'],
|
|
||||||
marker='.', linestyle='-', label=f'Account {id2}')
|
|
||||||
|
|
||||||
plt.title("Évolution des AUM pour deux comptes")
|
|
||||||
plt.xlabel("Date")
|
|
||||||
plt.ylabel("Quantity - AUM")
|
|
||||||
plt.grid(True)
|
|
||||||
plt.legend() # <- important pour distinguer les comptes
|
|
||||||
plt.tight_layout()
|
|
||||||
plt.show()
|
|
||||||
|
|
||||||
|
|
||||||
def evolution_3_comptes(df, id1, id2, id3):
|
|
||||||
def prepare_df(id):
|
|
||||||
df_id = df[df['Registrar Account - ID'] == id].copy()
|
|
||||||
df_id['Centralisation Date'] = pd.to_datetime(df_id['Centralisation Date'])
|
|
||||||
df_agg = (
|
|
||||||
df_id
|
|
||||||
.groupby('Centralisation Date')['Quantity - AUM']
|
|
||||||
.sum()
|
|
||||||
.reset_index()
|
|
||||||
.sort_values('Centralisation Date')
|
|
||||||
)
|
|
||||||
return df_agg
|
|
||||||
|
|
||||||
df1 = prepare_df(id1)
|
|
||||||
df2 = prepare_df(id2)
|
|
||||||
df3 = prepare_df(id3)
|
|
||||||
|
|
||||||
plt.figure(figsize=(12, 6))
|
|
||||||
|
|
||||||
plt.plot(df1['Centralisation Date'], df1['Quantity - AUM'],
|
|
||||||
marker='.', linestyle='-', label=f'Account {id1}')
|
|
||||||
|
|
||||||
plt.plot(df2['Centralisation Date'], df2['Quantity - AUM'],
|
|
||||||
marker='.', linestyle='-', label=f'Account {id2}')
|
|
||||||
|
|
||||||
plt.plot(df3['Centralisation Date'], df3['Quantity - AUM'],
|
|
||||||
marker='.', linestyle='-', label=f'Account {id3}')
|
|
||||||
|
|
||||||
plt.title("Evolution of AUM for three accounts")
|
|
||||||
plt.xlabel("Date")
|
|
||||||
plt.ylabel("Quantity - AUM")
|
|
||||||
plt.grid(True)
|
|
||||||
plt.legend()
|
|
||||||
plt.tight_layout()
|
|
||||||
plt.show()
|
|
||||||
|
|
@ -1,58 +0,0 @@
|
||||||
{
|
|
||||||
"cells": [
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"id": "132a1aa1-4cb9-49e7-9f45-c09dd8fd57c1",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"import os\n",
|
|
||||||
"import s3fs\n",
|
|
||||||
"import pandas as pd\n",
|
|
||||||
"\n",
|
|
||||||
"s3_ENDPOINT_URL = \"https://\" + os.environ[\"AWS_S3_ENDPOINT\"]\n",
|
|
||||||
"\n",
|
|
||||||
"fs = s3fs.S3FileSystem(client_kwargs={'endpoint_url': s3_ENDPOINT_URL})\n",
|
|
||||||
"\n",
|
|
||||||
"BUCKET = \"projet-bdc-data\"\n",
|
|
||||||
"carmignac_path = \"projet-bdc-data/carmignac\"\n",
|
|
||||||
"\n",
|
|
||||||
"# Liste des fichiers AUM\n",
|
|
||||||
"all_files = fs.ls(carmignac_path)\n",
|
|
||||||
"aum_files = [f for f in all_files if \"AUM\" in f and f.endswith(\".csv\")]\n",
|
|
||||||
"print(\"Fichiers AUM :\", aum_files)\n",
|
|
||||||
"\n",
|
|
||||||
"# Lire tous les fichiers dans un dictionnaire\n",
|
|
||||||
"aum_data = {}\n",
|
|
||||||
"for file_path in aum_files:\n",
|
|
||||||
" with fs.open(file_path, 'r') as f:\n",
|
|
||||||
" df = pd.read_csv(f, sep=';',low_memory=False)\n",
|
|
||||||
" aum_data[os.path.basename(file_path)] = df\n",
|
|
||||||
"\n",
|
|
||||||
"df = aum_data['AUM ENSAE V2 -20251105.csv']"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"metadata": {
|
|
||||||
"kernelspec": {
|
|
||||||
"display_name": "Python 3 (ipykernel)",
|
|
||||||
"language": "python",
|
|
||||||
"name": "python3"
|
|
||||||
},
|
|
||||||
"language_info": {
|
|
||||||
"codemirror_mode": {
|
|
||||||
"name": "ipython",
|
|
||||||
"version": 3
|
|
||||||
},
|
|
||||||
"file_extension": ".py",
|
|
||||||
"mimetype": "text/x-python",
|
|
||||||
"name": "python",
|
|
||||||
"nbconvert_exporter": "python",
|
|
||||||
"pygments_lexer": "ipython3",
|
|
||||||
"version": "3.13.8"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nbformat": 4,
|
|
||||||
"nbformat_minor": 5
|
|
||||||
}
|
|
||||||
File diff suppressed because one or more lines are too long
5115
Clustering.ipynb
5115
Clustering.ipynb
File diff suppressed because one or more lines are too long
5000
Clustering2.ipynb
5000
Clustering2.ipynb
File diff suppressed because one or more lines are too long
904
Essai.ipynb
904
Essai.ipynb
File diff suppressed because one or more lines are too long
1458
Migration.ipynb
1458
Migration.ipynb
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -1,597 +0,0 @@
|
||||||
{
|
|
||||||
"cells": [
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 1,
|
|
||||||
"id": "f996e528-002f-4856-a67a-5120e8af86ad",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"Fichiers Flows : ['projet-bdc-data/carmignac/Flows ENSAE V1 -20251027.csv', 'projet-bdc-data/carmignac/Flows ENSAE V2 -20251105.csv']\n",
|
|
||||||
"Fichiers AUM : ['projet-bdc-data/carmignac/AUM ENSAE V1 -20251027.csv', 'projet-bdc-data/carmignac/AUM ENSAE V2 -20251105.csv']\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"import os\n",
|
|
||||||
"import s3fs\n",
|
|
||||||
"import pandas as pd\n",
|
|
||||||
"\n",
|
|
||||||
"s3_ENDPOINT_URL = \"https://\" + os.environ[\"AWS_S3_ENDPOINT\"]\n",
|
|
||||||
"\n",
|
|
||||||
"fs = s3fs.S3FileSystem(client_kwargs={'endpoint_url': s3_ENDPOINT_URL})\n",
|
|
||||||
"\n",
|
|
||||||
"BUCKET = \"projet-bdc-data\"\n",
|
|
||||||
"carmignac_path = \"projet-bdc-data/carmignac\"\n",
|
|
||||||
"\n",
|
|
||||||
"# Liste des fichiers FLOWS\n",
|
|
||||||
"all_files = fs.ls(carmignac_path)\n",
|
|
||||||
"flows_files = [f for f in all_files if \"Flows\" in f and f.endswith(\".csv\")]\n",
|
|
||||||
"print(\"Fichiers Flows :\", flows_files)\n",
|
|
||||||
"\n",
|
|
||||||
"# Lire tous les fichiers dans un dictionnaire\n",
|
|
||||||
"flows_data = {}\n",
|
|
||||||
"for file_path in flows_files:\n",
|
|
||||||
" with fs.open(file_path, 'r') as f:\n",
|
|
||||||
" df = pd.read_csv(f, sep=';',low_memory=False)\n",
|
|
||||||
" flows_data[os.path.basename(file_path)] = df\n",
|
|
||||||
"\n",
|
|
||||||
"\n",
|
|
||||||
"# Liste des fichiers AUM\n",
|
|
||||||
"all_files = fs.ls(carmignac_path)\n",
|
|
||||||
"aum_files = [f for f in all_files if \"AUM\" in f and f.endswith(\".csv\")]\n",
|
|
||||||
"print(\"Fichiers AUM :\", aum_files)\n",
|
|
||||||
"\n",
|
|
||||||
"# Lire tous les fichiers dans un dictionnaire\n",
|
|
||||||
"aum_data = {}\n",
|
|
||||||
"for file_path in aum_files:\n",
|
|
||||||
" with fs.open(file_path, 'r') as f:\n",
|
|
||||||
" df = pd.read_csv(f, sep=';',low_memory=False)\n",
|
|
||||||
" aum_data[os.path.basename(file_path)] = df"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 2,
|
|
||||||
"id": "bdfc2afe-c3aa-41b6-bb40-3a7bf2a39d9a",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"data": {
|
|
||||||
"text/html": [
|
|
||||||
"<div>\n",
|
|
||||||
"<style scoped>\n",
|
|
||||||
" .dataframe tbody tr th:only-of-type {\n",
|
|
||||||
" vertical-align: middle;\n",
|
|
||||||
" }\n",
|
|
||||||
"\n",
|
|
||||||
" .dataframe tbody tr th {\n",
|
|
||||||
" vertical-align: top;\n",
|
|
||||||
" }\n",
|
|
||||||
"\n",
|
|
||||||
" .dataframe thead th {\n",
|
|
||||||
" text-align: right;\n",
|
|
||||||
" }\n",
|
|
||||||
"</style>\n",
|
|
||||||
"<table border=\"1\" class=\"dataframe\">\n",
|
|
||||||
" <thead>\n",
|
|
||||||
" <tr style=\"text-align: right;\">\n",
|
|
||||||
" <th></th>\n",
|
|
||||||
" <th>Agreement - Code</th>\n",
|
|
||||||
" <th>Company - Id</th>\n",
|
|
||||||
" <th>Company - Ultimate Parent Id</th>\n",
|
|
||||||
" <th>Registrar Account - ID</th>\n",
|
|
||||||
" <th>Registrar Account - Region</th>\n",
|
|
||||||
" <th>RegistrarAccount - Country</th>\n",
|
|
||||||
" <th>Product - Asset Type</th>\n",
|
|
||||||
" <th>Product - Strategy</th>\n",
|
|
||||||
" <th>Product - Legal Status</th>\n",
|
|
||||||
" <th>Product - Is Dedie ?</th>\n",
|
|
||||||
" <th>...</th>\n",
|
|
||||||
" <th>Centralisation Date</th>\n",
|
|
||||||
" <th>Quantity - Subscription</th>\n",
|
|
||||||
" <th>Quantity - Redemption</th>\n",
|
|
||||||
" <th>Quantity - NetFlows</th>\n",
|
|
||||||
" <th>Value Ccy - Subscription</th>\n",
|
|
||||||
" <th>Value Ccy - Redemption</th>\n",
|
|
||||||
" <th>Value Ccy - NetFlows</th>\n",
|
|
||||||
" <th>Value € - Subscription</th>\n",
|
|
||||||
" <th>Value € - Redemption</th>\n",
|
|
||||||
" <th>Value € - NetFlows</th>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" </thead>\n",
|
|
||||||
" <tbody>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>0</th>\n",
|
|
||||||
" <td>003</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>200127202</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>Equity</td>\n",
|
|
||||||
" <td>Investissement</td>\n",
|
|
||||||
" <td>SICAV</td>\n",
|
|
||||||
" <td>NO</td>\n",
|
|
||||||
" <td>...</td>\n",
|
|
||||||
" <td>2020-11-05</td>\n",
|
|
||||||
" <td>1636.00</td>\n",
|
|
||||||
" <td>0.000</td>\n",
|
|
||||||
" <td>1636.000</td>\n",
|
|
||||||
" <td>280983.00</td>\n",
|
|
||||||
" <td>0.00</td>\n",
|
|
||||||
" <td>280983.00</td>\n",
|
|
||||||
" <td>280983.00</td>\n",
|
|
||||||
" <td>0.00</td>\n",
|
|
||||||
" <td>280983.00</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>1</th>\n",
|
|
||||||
" <td>003</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>406533</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>Diversified</td>\n",
|
|
||||||
" <td>Patrimoine</td>\n",
|
|
||||||
" <td>FCP</td>\n",
|
|
||||||
" <td>NO</td>\n",
|
|
||||||
" <td>...</td>\n",
|
|
||||||
" <td>2015-03-09</td>\n",
|
|
||||||
" <td>144.69</td>\n",
|
|
||||||
" <td>0.000</td>\n",
|
|
||||||
" <td>144.690</td>\n",
|
|
||||||
" <td>99985.13</td>\n",
|
|
||||||
" <td>0.00</td>\n",
|
|
||||||
" <td>99985.13</td>\n",
|
|
||||||
" <td>99985.13</td>\n",
|
|
||||||
" <td>0.00</td>\n",
|
|
||||||
" <td>99985.13</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>2</th>\n",
|
|
||||||
" <td>003</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>406533</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>Equity</td>\n",
|
|
||||||
" <td>Investissement</td>\n",
|
|
||||||
" <td>FCP</td>\n",
|
|
||||||
" <td>NO</td>\n",
|
|
||||||
" <td>...</td>\n",
|
|
||||||
" <td>2016-10-26</td>\n",
|
|
||||||
" <td>0.00</td>\n",
|
|
||||||
" <td>-8.321</td>\n",
|
|
||||||
" <td>-8.321</td>\n",
|
|
||||||
" <td>0.00</td>\n",
|
|
||||||
" <td>-9384.76</td>\n",
|
|
||||||
" <td>-9384.76</td>\n",
|
|
||||||
" <td>0.00</td>\n",
|
|
||||||
" <td>-9384.76</td>\n",
|
|
||||||
" <td>-9384.76</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>3</th>\n",
|
|
||||||
" <td>003</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>406533</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>Equity</td>\n",
|
|
||||||
" <td>Investissement</td>\n",
|
|
||||||
" <td>FCP</td>\n",
|
|
||||||
" <td>NO</td>\n",
|
|
||||||
" <td>...</td>\n",
|
|
||||||
" <td>2018-10-18</td>\n",
|
|
||||||
" <td>0.00</td>\n",
|
|
||||||
" <td>-22.083</td>\n",
|
|
||||||
" <td>-22.083</td>\n",
|
|
||||||
" <td>0.00</td>\n",
|
|
||||||
" <td>-25227.40</td>\n",
|
|
||||||
" <td>-25227.40</td>\n",
|
|
||||||
" <td>0.00</td>\n",
|
|
||||||
" <td>-25227.40</td>\n",
|
|
||||||
" <td>-25227.40</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>4</th>\n",
|
|
||||||
" <td>003</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>406533</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>Equity</td>\n",
|
|
||||||
" <td>Investissement</td>\n",
|
|
||||||
" <td>FCP</td>\n",
|
|
||||||
" <td>NO</td>\n",
|
|
||||||
" <td>...</td>\n",
|
|
||||||
" <td>2019-04-08</td>\n",
|
|
||||||
" <td>0.00</td>\n",
|
|
||||||
" <td>-465.992</td>\n",
|
|
||||||
" <td>-465.992</td>\n",
|
|
||||||
" <td>0.00</td>\n",
|
|
||||||
" <td>-563775.76</td>\n",
|
|
||||||
" <td>-563775.76</td>\n",
|
|
||||||
" <td>0.00</td>\n",
|
|
||||||
" <td>-563775.76</td>\n",
|
|
||||||
" <td>-563775.76</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" </tbody>\n",
|
|
||||||
"</table>\n",
|
|
||||||
"<p>5 rows × 24 columns</p>\n",
|
|
||||||
"</div>"
|
|
||||||
],
|
|
||||||
"text/plain": [
|
|
||||||
" Agreement - Code Company - Id Company - Ultimate Parent Id \\\n",
|
|
||||||
"0 003 166 166 \n",
|
|
||||||
"1 003 166 166 \n",
|
|
||||||
"2 003 166 166 \n",
|
|
||||||
"3 003 166 166 \n",
|
|
||||||
"4 003 166 166 \n",
|
|
||||||
"\n",
|
|
||||||
" Registrar Account - ID Registrar Account - Region \\\n",
|
|
||||||
"0 200127202 France \n",
|
|
||||||
"1 406533 France \n",
|
|
||||||
"2 406533 France \n",
|
|
||||||
"3 406533 France \n",
|
|
||||||
"4 406533 France \n",
|
|
||||||
"\n",
|
|
||||||
" RegistrarAccount - Country Product - Asset Type Product - Strategy \\\n",
|
|
||||||
"0 France Equity Investissement \n",
|
|
||||||
"1 France Diversified Patrimoine \n",
|
|
||||||
"2 France Equity Investissement \n",
|
|
||||||
"3 France Equity Investissement \n",
|
|
||||||
"4 France Equity Investissement \n",
|
|
||||||
"\n",
|
|
||||||
" Product - Legal Status Product - Is Dedie ? ... Centralisation Date \\\n",
|
|
||||||
"0 SICAV NO ... 2020-11-05 \n",
|
|
||||||
"1 FCP NO ... 2015-03-09 \n",
|
|
||||||
"2 FCP NO ... 2016-10-26 \n",
|
|
||||||
"3 FCP NO ... 2018-10-18 \n",
|
|
||||||
"4 FCP NO ... 2019-04-08 \n",
|
|
||||||
"\n",
|
|
||||||
" Quantity - Subscription Quantity - Redemption Quantity - NetFlows \\\n",
|
|
||||||
"0 1636.00 0.000 1636.000 \n",
|
|
||||||
"1 144.69 0.000 144.690 \n",
|
|
||||||
"2 0.00 -8.321 -8.321 \n",
|
|
||||||
"3 0.00 -22.083 -22.083 \n",
|
|
||||||
"4 0.00 -465.992 -465.992 \n",
|
|
||||||
"\n",
|
|
||||||
" Value Ccy - Subscription Value Ccy - Redemption Value Ccy - NetFlows \\\n",
|
|
||||||
"0 280983.00 0.00 280983.00 \n",
|
|
||||||
"1 99985.13 0.00 99985.13 \n",
|
|
||||||
"2 0.00 -9384.76 -9384.76 \n",
|
|
||||||
"3 0.00 -25227.40 -25227.40 \n",
|
|
||||||
"4 0.00 -563775.76 -563775.76 \n",
|
|
||||||
"\n",
|
|
||||||
" Value € - Subscription Value € - Redemption Value € - NetFlows \n",
|
|
||||||
"0 280983.00 0.00 280983.00 \n",
|
|
||||||
"1 99985.13 0.00 99985.13 \n",
|
|
||||||
"2 0.00 -9384.76 -9384.76 \n",
|
|
||||||
"3 0.00 -25227.40 -25227.40 \n",
|
|
||||||
"4 0.00 -563775.76 -563775.76 \n",
|
|
||||||
"\n",
|
|
||||||
"[5 rows x 24 columns]"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"execution_count": 2,
|
|
||||||
"metadata": {},
|
|
||||||
"output_type": "execute_result"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"df = flows_data['Flows ENSAE V2 -20251105.csv']\n",
|
|
||||||
"df.head()"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 3,
|
|
||||||
"id": "6af3bcd9-0a54-4087-a8cf-203fb6f8a947",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"data": {
|
|
||||||
"text/html": [
|
|
||||||
"<div>\n",
|
|
||||||
"<style scoped>\n",
|
|
||||||
" .dataframe tbody tr th:only-of-type {\n",
|
|
||||||
" vertical-align: middle;\n",
|
|
||||||
" }\n",
|
|
||||||
"\n",
|
|
||||||
" .dataframe tbody tr th {\n",
|
|
||||||
" vertical-align: top;\n",
|
|
||||||
" }\n",
|
|
||||||
"\n",
|
|
||||||
" .dataframe thead th {\n",
|
|
||||||
" text-align: right;\n",
|
|
||||||
" }\n",
|
|
||||||
"</style>\n",
|
|
||||||
"<table border=\"1\" class=\"dataframe\">\n",
|
|
||||||
" <thead>\n",
|
|
||||||
" <tr style=\"text-align: right;\">\n",
|
|
||||||
" <th></th>\n",
|
|
||||||
" <th>Agreement - Code</th>\n",
|
|
||||||
" <th>Company - Id</th>\n",
|
|
||||||
" <th>Company - Ultimate Parent Id</th>\n",
|
|
||||||
" <th>Registrar Account - ID</th>\n",
|
|
||||||
" <th>Registrar Account - Region</th>\n",
|
|
||||||
" <th>RegistrarAccount - Country</th>\n",
|
|
||||||
" <th>Product - Asset Type</th>\n",
|
|
||||||
" <th>Product - Strategy</th>\n",
|
|
||||||
" <th>Product - Legal Status</th>\n",
|
|
||||||
" <th>Product - Is Dedie ?</th>\n",
|
|
||||||
" <th>Product - Fund</th>\n",
|
|
||||||
" <th>Product - Shareclass Type</th>\n",
|
|
||||||
" <th>Product - Shareclass Currency</th>\n",
|
|
||||||
" <th>Product - Isin</th>\n",
|
|
||||||
" <th>Centralisation Date</th>\n",
|
|
||||||
" <th>Quantity - AUM</th>\n",
|
|
||||||
" <th>Value - AUM CCY</th>\n",
|
|
||||||
" <th>Value - AUM €</th>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" </thead>\n",
|
|
||||||
" <tbody>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>0</th>\n",
|
|
||||||
" <td>003</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>200000647</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>Diversified</td>\n",
|
|
||||||
" <td>Patrimoine</td>\n",
|
|
||||||
" <td>FCP</td>\n",
|
|
||||||
" <td>NO</td>\n",
|
|
||||||
" <td>Carmignac Patrimoine</td>\n",
|
|
||||||
" <td>A</td>\n",
|
|
||||||
" <td>EUR</td>\n",
|
|
||||||
" <td>FR0010135103</td>\n",
|
|
||||||
" <td>2015-03-31</td>\n",
|
|
||||||
" <td>35.368</td>\n",
|
|
||||||
" <td>24648.6666</td>\n",
|
|
||||||
" <td>24648.6666</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>1</th>\n",
|
|
||||||
" <td>003</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>200000647</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>Diversified</td>\n",
|
|
||||||
" <td>Patrimoine</td>\n",
|
|
||||||
" <td>FCP</td>\n",
|
|
||||||
" <td>NO</td>\n",
|
|
||||||
" <td>Carmignac Patrimoine</td>\n",
|
|
||||||
" <td>A</td>\n",
|
|
||||||
" <td>EUR</td>\n",
|
|
||||||
" <td>FR0010135103</td>\n",
|
|
||||||
" <td>2015-11-30</td>\n",
|
|
||||||
" <td>35.368</td>\n",
|
|
||||||
" <td>22413.0553</td>\n",
|
|
||||||
" <td>22413.0553</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>2</th>\n",
|
|
||||||
" <td>003</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>200000647</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>Diversified</td>\n",
|
|
||||||
" <td>Patrimoine</td>\n",
|
|
||||||
" <td>FCP</td>\n",
|
|
||||||
" <td>NO</td>\n",
|
|
||||||
" <td>Carmignac Patrimoine</td>\n",
|
|
||||||
" <td>A</td>\n",
|
|
||||||
" <td>EUR</td>\n",
|
|
||||||
" <td>FR0010135103</td>\n",
|
|
||||||
" <td>2015-12-31</td>\n",
|
|
||||||
" <td>35.368</td>\n",
|
|
||||||
" <td>22051.2406</td>\n",
|
|
||||||
" <td>22051.2406</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>3</th>\n",
|
|
||||||
" <td>003</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>200000647</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>Diversified</td>\n",
|
|
||||||
" <td>Patrimoine</td>\n",
|
|
||||||
" <td>FCP</td>\n",
|
|
||||||
" <td>NO</td>\n",
|
|
||||||
" <td>Carmignac Patrimoine</td>\n",
|
|
||||||
" <td>A</td>\n",
|
|
||||||
" <td>EUR</td>\n",
|
|
||||||
" <td>FR0010135103</td>\n",
|
|
||||||
" <td>2016-03-31</td>\n",
|
|
||||||
" <td>35.368</td>\n",
|
|
||||||
" <td>21626.1173</td>\n",
|
|
||||||
" <td>21626.1173</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>4</th>\n",
|
|
||||||
" <td>003</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>166</td>\n",
|
|
||||||
" <td>200000647</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>France</td>\n",
|
|
||||||
" <td>Diversified</td>\n",
|
|
||||||
" <td>Patrimoine</td>\n",
|
|
||||||
" <td>FCP</td>\n",
|
|
||||||
" <td>NO</td>\n",
|
|
||||||
" <td>Carmignac Patrimoine</td>\n",
|
|
||||||
" <td>A</td>\n",
|
|
||||||
" <td>EUR</td>\n",
|
|
||||||
" <td>FR0010135103</td>\n",
|
|
||||||
" <td>2016-11-30</td>\n",
|
|
||||||
" <td>35.368</td>\n",
|
|
||||||
" <td>22489.4502</td>\n",
|
|
||||||
" <td>22489.4502</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" </tbody>\n",
|
|
||||||
"</table>\n",
|
|
||||||
"</div>"
|
|
||||||
],
|
|
||||||
"text/plain": [
|
|
||||||
" Agreement - Code Company - Id Company - Ultimate Parent Id \\\n",
|
|
||||||
"0 003 166 166 \n",
|
|
||||||
"1 003 166 166 \n",
|
|
||||||
"2 003 166 166 \n",
|
|
||||||
"3 003 166 166 \n",
|
|
||||||
"4 003 166 166 \n",
|
|
||||||
"\n",
|
|
||||||
" Registrar Account - ID Registrar Account - Region \\\n",
|
|
||||||
"0 200000647 France \n",
|
|
||||||
"1 200000647 France \n",
|
|
||||||
"2 200000647 France \n",
|
|
||||||
"3 200000647 France \n",
|
|
||||||
"4 200000647 France \n",
|
|
||||||
"\n",
|
|
||||||
" RegistrarAccount - Country Product - Asset Type Product - Strategy \\\n",
|
|
||||||
"0 France Diversified Patrimoine \n",
|
|
||||||
"1 France Diversified Patrimoine \n",
|
|
||||||
"2 France Diversified Patrimoine \n",
|
|
||||||
"3 France Diversified Patrimoine \n",
|
|
||||||
"4 France Diversified Patrimoine \n",
|
|
||||||
"\n",
|
|
||||||
" Product - Legal Status Product - Is Dedie ? Product - Fund \\\n",
|
|
||||||
"0 FCP NO Carmignac Patrimoine \n",
|
|
||||||
"1 FCP NO Carmignac Patrimoine \n",
|
|
||||||
"2 FCP NO Carmignac Patrimoine \n",
|
|
||||||
"3 FCP NO Carmignac Patrimoine \n",
|
|
||||||
"4 FCP NO Carmignac Patrimoine \n",
|
|
||||||
"\n",
|
|
||||||
" Product - Shareclass Type Product - Shareclass Currency Product - Isin \\\n",
|
|
||||||
"0 A EUR FR0010135103 \n",
|
|
||||||
"1 A EUR FR0010135103 \n",
|
|
||||||
"2 A EUR FR0010135103 \n",
|
|
||||||
"3 A EUR FR0010135103 \n",
|
|
||||||
"4 A EUR FR0010135103 \n",
|
|
||||||
"\n",
|
|
||||||
" Centralisation Date Quantity - AUM Value - AUM CCY Value - AUM € \n",
|
|
||||||
"0 2015-03-31 35.368 24648.6666 24648.6666 \n",
|
|
||||||
"1 2015-11-30 35.368 22413.0553 22413.0553 \n",
|
|
||||||
"2 2015-12-31 35.368 22051.2406 22051.2406 \n",
|
|
||||||
"3 2016-03-31 35.368 21626.1173 21626.1173 \n",
|
|
||||||
"4 2016-11-30 35.368 22489.4502 22489.4502 "
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"execution_count": 3,
|
|
||||||
"metadata": {},
|
|
||||||
"output_type": "execute_result"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"dg = aum_data['AUM ENSAE V2 -20251105.csv']\n",
|
|
||||||
"dg.head()"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 4,
|
|
||||||
"id": "1d9cd20d-2e79-47b8-91f1-09fee4962dc6",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"df_ids = set(df['Registrar Account - ID'].unique())\n",
|
|
||||||
"dg_ids = set(dg['Registrar Account - ID'].unique())\n",
|
|
||||||
"\n",
|
|
||||||
"intersect = df_ids & dg_ids # comptes dans les deux\n",
|
|
||||||
"only_df = df_ids - dg_ids # comptes seulement dans df\n",
|
|
||||||
"only_dg = dg_ids - df_ids # comptes seulement dans dg\n"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 5,
|
|
||||||
"id": "1a374690-119e-4bbb-a12d-13d0305780ad",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
" Comptes présents\n",
|
|
||||||
"Seulement dans df 118\n",
|
|
||||||
"Seulement dans dg 5777\n",
|
|
||||||
"Dans les deux 6724\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"summary = pd.DataFrame({\n",
|
|
||||||
" \"Comptes présents\": [\n",
|
|
||||||
" len(only_df),\n",
|
|
||||||
" len(only_dg),\n",
|
|
||||||
" len(intersect)\n",
|
|
||||||
" ]\n",
|
|
||||||
"}, index=[\"Seulement dans df\", \"Seulement dans dg\", \"Dans les deux\"])\n",
|
|
||||||
"\n",
|
|
||||||
"print(summary)\n"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 9,
|
|
||||||
"id": "1b35a706-e94b-4bbb-8255-be5de03cb33b",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"Nombre de comptes seulement dans dg de stocks indentiquements nuls : 4657\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"aum_max = dg.groupby('Registrar Account - ID')['Quantity - AUM'].max()\n",
|
|
||||||
"accounts_always_zero = aum_max[aum_max == 0].index\n",
|
|
||||||
"\n",
|
|
||||||
"accounts_always_zero_set = set(accounts_always_zero)\n",
|
|
||||||
"\n",
|
|
||||||
"intersection = accounts_always_zero_set & only_dg\n",
|
|
||||||
"\n",
|
|
||||||
"print(\"Nombre de comptes seulement dans dg de stocks indentiquements nuls :\", len(intersection))"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"metadata": {
|
|
||||||
"kernelspec": {
|
|
||||||
"display_name": "Python 3 (ipykernel)",
|
|
||||||
"language": "python",
|
|
||||||
"name": "python3"
|
|
||||||
},
|
|
||||||
"language_info": {
|
|
||||||
"codemirror_mode": {
|
|
||||||
"name": "ipython",
|
|
||||||
"version": 3
|
|
||||||
},
|
|
||||||
"file_extension": ".py",
|
|
||||||
"mimetype": "text/x-python",
|
|
||||||
"name": "python",
|
|
||||||
"nbconvert_exporter": "python",
|
|
||||||
"pygments_lexer": "ipython3",
|
|
||||||
"version": "3.13.11"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nbformat": 4,
|
|
||||||
"nbformat_minor": 5
|
|
||||||
}
|
|
||||||
201
dataloader.ipynb
201
dataloader.ipynb
|
|
@ -1,201 +0,0 @@
|
||||||
{
|
|
||||||
"cells": [
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 1,
|
|
||||||
"id": "126c8a80-d9ad-4816-84f0-0c3d580f62c8",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"import pandas as pd"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 2,
|
|
||||||
"id": "ff2261fb-9516-4410-b42d-3acc8dc1a460",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"import os\n",
|
|
||||||
"import s3fs\n",
|
|
||||||
"os.environ[\"AWS_ACCESS_KEY_ID\"] = 'N1DBJCHI7YTK9AVMG6XT'\n",
|
|
||||||
"os.environ[\"AWS_SECRET_ACCESS_KEY\"] = 'SRCPMh8a1eQxX6Z09GeDxZoD55MBpnkJzyBctLII'\n",
|
|
||||||
"os.environ[\"AWS_SESSION_TOKEN\"] = 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhY2Nlc3NLZXkiOiJOMURCSkNISTdZVEs5QVZNRzZYVCIsImFjciI6IjAiLCJhbGxvd2VkLW9yaWdpbnMiOlsiKiJdLCJhdWQiOlsibWluaW8iLCJhY2NvdW50Il0sImF1dGhfdGltZSI6MTc2MzEzMTgzNiwiYXpwIjoib255eGlhLW1pbmlvIiwiZW1haWwiOiJzYXJhaC50aG91bXlyZUBlbnNhZS5mciIsImVtYWlsX3ZlcmlmaWVkIjp0cnVlLCJleHAiOjE3NjQzNDE0MzksImZhbWlseV9uYW1lIjoiVEhPVU1ZUkUiLCJnaXZlbl9uYW1lIjoiU2FyYWgiLCJncm91cHMiOlsiYmRjLWRhdGEiLCJiZGMtY2FybWlnbmFjLWczIl0sImlhdCI6MTc2MzEzMTgzOCwiaXNzIjoiaHR0cHM6Ly9hdXRoLmdyb3VwZS1nZW5lcy5mci9yZWFsbXMvZ2VuZXMiLCJqdGkiOiJkY2I2MWJiZi1lZjU4LTRhMTItOGYyZS1jYTI0ZmUyNTA2YzEiLCJuYW1lIjoiU2FyYWggVEhPVU1ZUkUiLCJwb2xpY3kiOiJzdHNvbmx5IiwicHJlZmVycmVkX3VzZXJuYW1lIjoic3Rob3VteXJlLWVuc2FlIiwicmVhbG1fYWNjZXNzIjp7InJvbGVzIjpbIm9mZmxpbmVfYWNjZXNzIiwiZGVmYXVsdC1yb2xlcy1nZW5lcyIsInVtYV9hdXRob3JpemF0aW9uIl19LCJyZXNvdXJjZV9hY2Nlc3MiOnsiYWNjb3VudCI6eyJyb2xlcyI6WyJtYW5hZ2UtYWNjb3VudCIsIm1hbmFnZS1hY2NvdW50LWxpbmtzIiwidmlldy1wcm9maWxlIl19fSwic2NvcGUiOiJvcGVuaWQgcHJvZmlsZSBlbWFpbCIsInNpZCI6ImQxMDI0NGVlLWE3ZDMtNDA5MC04ZDA3LWNlOWY3YjM5MDRkNCIsInN1YiI6ImVhYWVkN2QyLWM4MjYtNGIxNC05MzczLTYwYjNhODhlMWFiNiIsInR5cCI6IkJlYXJlciJ9.sLXOE8w930_dXU0yNWroaDvaTvcUUCONMcbgbKeMEduQebXQjOS7gEQxo-I7Q2oqLFb_dhg1zBlwx5VpNjyTMA'\n",
|
|
||||||
"os.environ[\"AWS_DEFAULT_REGION\"] = 'us-east-1'\n",
|
|
||||||
"fs = s3fs.S3FileSystem(\n",
|
|
||||||
" client_kwargs={'endpoint_url': 'https://'+'minio-simple.lab.groupe-genes.fr'},\n",
|
|
||||||
" key = os.environ[\"AWS_ACCESS_KEY_ID\"], \n",
|
|
||||||
" secret = os.environ[\"AWS_SECRET_ACCESS_KEY\"], \n",
|
|
||||||
" token = os.environ[\"AWS_SESSION_TOKEN\"])"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 3,
|
|
||||||
"id": "dc546698-76dc-4eaf-b9e2-7602953bf8f5",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"data": {
|
|
||||||
"text/html": [
|
|
||||||
"<div>\n",
|
|
||||||
"<style scoped>\n",
|
|
||||||
" .dataframe tbody tr th:only-of-type {\n",
|
|
||||||
" vertical-align: middle;\n",
|
|
||||||
" }\n",
|
|
||||||
"\n",
|
|
||||||
" .dataframe tbody tr th {\n",
|
|
||||||
" vertical-align: top;\n",
|
|
||||||
" }\n",
|
|
||||||
"\n",
|
|
||||||
" .dataframe thead th {\n",
|
|
||||||
" text-align: right;\n",
|
|
||||||
" }\n",
|
|
||||||
"</style>\n",
|
|
||||||
"<table border=\"1\" class=\"dataframe\">\n",
|
|
||||||
" <thead>\n",
|
|
||||||
" <tr style=\"text-align: right;\">\n",
|
|
||||||
" <th></th>\n",
|
|
||||||
" <th>Morningstar Global Asset Class</th>\n",
|
|
||||||
" <th>Morningstar Global Category</th>\n",
|
|
||||||
" <th>Morningstar Category</th>\n",
|
|
||||||
" <th>Combined Country</th>\n",
|
|
||||||
" <th>Combined Channel Type</th>\n",
|
|
||||||
" <th>Combined Type</th>\n",
|
|
||||||
" <th>Month/Year (Record Date)</th>\n",
|
|
||||||
" <th>Combined Net Assets</th>\n",
|
|
||||||
" <th>Combined Net Sales</th>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" </thead>\n",
|
|
||||||
" <tbody>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>0</th>\n",
|
|
||||||
" <td>NaN</td>\n",
|
|
||||||
" <td>NaN</td>\n",
|
|
||||||
" <td>NaN</td>\n",
|
|
||||||
" <td>Luxembourg</td>\n",
|
|
||||||
" <td>Proprietary</td>\n",
|
|
||||||
" <td>Domestic</td>\n",
|
|
||||||
" <td>Jan 2015</td>\n",
|
|
||||||
" <td>11170000.0</td>\n",
|
|
||||||
" <td>799301.47</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>1</th>\n",
|
|
||||||
" <td>NaN</td>\n",
|
|
||||||
" <td>NaN</td>\n",
|
|
||||||
" <td>NaN</td>\n",
|
|
||||||
" <td>Luxembourg</td>\n",
|
|
||||||
" <td>Proprietary</td>\n",
|
|
||||||
" <td>Domestic</td>\n",
|
|
||||||
" <td>Feb 2015</td>\n",
|
|
||||||
" <td>21210000.0</td>\n",
|
|
||||||
" <td>8922456.46</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>2</th>\n",
|
|
||||||
" <td>NaN</td>\n",
|
|
||||||
" <td>NaN</td>\n",
|
|
||||||
" <td>NaN</td>\n",
|
|
||||||
" <td>Luxembourg</td>\n",
|
|
||||||
" <td>Proprietary</td>\n",
|
|
||||||
" <td>Domestic</td>\n",
|
|
||||||
" <td>Mar 2015</td>\n",
|
|
||||||
" <td>23670000.0</td>\n",
|
|
||||||
" <td>1718627.81</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>3</th>\n",
|
|
||||||
" <td>NaN</td>\n",
|
|
||||||
" <td>NaN</td>\n",
|
|
||||||
" <td>NaN</td>\n",
|
|
||||||
" <td>Luxembourg</td>\n",
|
|
||||||
" <td>Proprietary</td>\n",
|
|
||||||
" <td>Domestic</td>\n",
|
|
||||||
" <td>Apr 2015</td>\n",
|
|
||||||
" <td>22720000.0</td>\n",
|
|
||||||
" <td>-670097.35</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>4</th>\n",
|
|
||||||
" <td>NaN</td>\n",
|
|
||||||
" <td>NaN</td>\n",
|
|
||||||
" <td>NaN</td>\n",
|
|
||||||
" <td>Luxembourg</td>\n",
|
|
||||||
" <td>Proprietary</td>\n",
|
|
||||||
" <td>Domestic</td>\n",
|
|
||||||
" <td>May 2015</td>\n",
|
|
||||||
" <td>23550000.0</td>\n",
|
|
||||||
" <td>204625.93</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" </tbody>\n",
|
|
||||||
"</table>\n",
|
|
||||||
"</div>"
|
|
||||||
],
|
|
||||||
"text/plain": [
|
|
||||||
" Morningstar Global Asset Class Morningstar Global Category \\\n",
|
|
||||||
"0 NaN NaN \n",
|
|
||||||
"1 NaN NaN \n",
|
|
||||||
"2 NaN NaN \n",
|
|
||||||
"3 NaN NaN \n",
|
|
||||||
"4 NaN NaN \n",
|
|
||||||
"\n",
|
|
||||||
" Morningstar Category Combined Country Combined Channel Type Combined Type \\\n",
|
|
||||||
"0 NaN Luxembourg Proprietary Domestic \n",
|
|
||||||
"1 NaN Luxembourg Proprietary Domestic \n",
|
|
||||||
"2 NaN Luxembourg Proprietary Domestic \n",
|
|
||||||
"3 NaN Luxembourg Proprietary Domestic \n",
|
|
||||||
"4 NaN Luxembourg Proprietary Domestic \n",
|
|
||||||
"\n",
|
|
||||||
" Month/Year (Record Date) Combined Net Assets Combined Net Sales \n",
|
|
||||||
"0 Jan 2015 11170000.0 799301.47 \n",
|
|
||||||
"1 Feb 2015 21210000.0 8922456.46 \n",
|
|
||||||
"2 Mar 2015 23670000.0 1718627.81 \n",
|
|
||||||
"3 Apr 2015 22720000.0 -670097.35 \n",
|
|
||||||
"4 May 2015 23550000.0 204625.93 "
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"execution_count": 3,
|
|
||||||
"metadata": {},
|
|
||||||
"output_type": "execute_result"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"with fs.open('projet-bdc-data/carmignac/Data Modélisation/market data/broadridge_Global Market data MS.csv', 'rb') as f:\n",
|
|
||||||
" df = pd.read_csv(f)\n",
|
|
||||||
"\n",
|
|
||||||
"df.head()"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"id": "7494bffd-83b5-42e2-b17e-d04c90f3b59e",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"metadata": {
|
|
||||||
"kernelspec": {
|
|
||||||
"display_name": "Python 3 (ipykernel)",
|
|
||||||
"language": "python",
|
|
||||||
"name": "python3"
|
|
||||||
},
|
|
||||||
"language_info": {
|
|
||||||
"codemirror_mode": {
|
|
||||||
"name": "ipython",
|
|
||||||
"version": 3
|
|
||||||
},
|
|
||||||
"file_extension": ".py",
|
|
||||||
"mimetype": "text/x-python",
|
|
||||||
"name": "python",
|
|
||||||
"nbconvert_exporter": "python",
|
|
||||||
"pygments_lexer": "ipython3",
|
|
||||||
"version": "3.13.11"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nbformat": 4,
|
|
||||||
"nbformat_minor": 5
|
|
||||||
}
|
|
||||||
|
|
@ -1,153 +0,0 @@
|
||||||
import pandas as pd
|
|
||||||
|
|
||||||
def detect_ruptures(df, epsilon=0.05):
|
|
||||||
# Colonnes clés pour identifier les comptes
|
|
||||||
key_cols = [
|
|
||||||
'Agreement - Code',
|
|
||||||
'Company - Id',
|
|
||||||
'Company - Ultimate Parent Id',
|
|
||||||
'Registrar Account - Region',
|
|
||||||
'RegistrarAccount - Country',
|
|
||||||
'Registrar Account - ID'
|
|
||||||
]
|
|
||||||
|
|
||||||
# Travailler sur une copie
|
|
||||||
df_temp = df.copy()
|
|
||||||
|
|
||||||
# Colonnes de dates
|
|
||||||
df_temp['Centralisation Date'] = pd.to_datetime(df_temp['Centralisation Date'])
|
|
||||||
|
|
||||||
# Dates distinctes
|
|
||||||
full_dates = (
|
|
||||||
pd.Series(df_temp['Centralisation Date'].unique())
|
|
||||||
.sort_values()
|
|
||||||
.reset_index(drop=True)
|
|
||||||
)
|
|
||||||
|
|
||||||
# Combinaisons comptes × dates
|
|
||||||
accounts = df_temp[key_cols].drop_duplicates()
|
|
||||||
full_index = accounts.merge(
|
|
||||||
pd.DataFrame({'Centralisation Date': full_dates}),
|
|
||||||
how='cross'
|
|
||||||
)
|
|
||||||
|
|
||||||
# Agréger les AUM par clé
|
|
||||||
agg_cols = key_cols + ['Centralisation Date']
|
|
||||||
df_agg = (
|
|
||||||
df_temp.groupby(agg_cols)['Value - AUM €']
|
|
||||||
.sum()
|
|
||||||
.reset_index()
|
|
||||||
)
|
|
||||||
|
|
||||||
# Merge sur toutes les combinaisons
|
|
||||||
df_full = pd.merge(full_index, df_agg, on=agg_cols, how='left')
|
|
||||||
|
|
||||||
# Remplissage des trous par 0
|
|
||||||
df_full['Value - AUM €'] = df_full['Value - AUM €'].fillna(0)
|
|
||||||
|
|
||||||
# Tri
|
|
||||||
df_full = df_full.sort_values(key_cols + ['Centralisation Date'])
|
|
||||||
|
|
||||||
# Variation et valeur précédente
|
|
||||||
df_full['AUM_diff'] = df_full.groupby(key_cols)['Value - AUM €'].diff().fillna(0)
|
|
||||||
df_full['prev_value'] = df_full.groupby(key_cols)['Value - AUM €'].shift(1).fillna(0)
|
|
||||||
|
|
||||||
# Comptes qui perdent tout
|
|
||||||
df_zero = df_full[(df_full['AUM_diff'] < 0) & (df_full['Value - AUM €'] == 0)].copy()
|
|
||||||
|
|
||||||
# Comptes qui partent de 0
|
|
||||||
df_from_zero = df_full[(df_full['AUM_diff'] > 0) & (df_full['prev_value'] == 0)].copy()
|
|
||||||
|
|
||||||
# Colonnes pour le merge (sans ID)
|
|
||||||
merge_cols = [
|
|
||||||
'Centralisation Date',
|
|
||||||
'Agreement - Code',
|
|
||||||
'Company - Id',
|
|
||||||
'Company - Ultimate Parent Id',
|
|
||||||
'Registrar Account - Region',
|
|
||||||
'RegistrarAccount - Country'
|
|
||||||
]
|
|
||||||
|
|
||||||
# Détection des ruptures
|
|
||||||
ruptures = pd.merge(df_zero, df_from_zero, on=merge_cols, suffixes=('_old','_new'))
|
|
||||||
|
|
||||||
# Calcul de la différence relative selon epsilon
|
|
||||||
ruptures['diff_rel'] = abs(ruptures['AUM_diff_old'] + ruptures['AUM_diff_new']) / (
|
|
||||||
(abs(ruptures['AUM_diff_old']) + abs(ruptures['AUM_diff_new'])) / 2
|
|
||||||
)
|
|
||||||
|
|
||||||
# Filtrage avec epsilon
|
|
||||||
ruptures = ruptures[ruptures['diff_rel'] <= epsilon].drop(columns=['diff_rel'])
|
|
||||||
|
|
||||||
# Colonnes finales
|
|
||||||
ruptures_df = ruptures[['Centralisation Date','Registrar Account - ID_old','Registrar Account - ID_new','AUM_diff_new']]
|
|
||||||
ruptures_df.columns = ['date','old_account','new_account','value']
|
|
||||||
|
|
||||||
return ruptures_df
|
|
||||||
|
|
||||||
|
|
||||||
def check_isin_continuity(df, rupture, tol=0.05):
|
|
||||||
"""
|
|
||||||
Vérifie que les ISIN évoluent continuellement entre old_account et new_account.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
df
|
|
||||||
rupture (pd.DataFrame): Table avec colonnes ['date', 'old_account', 'new_account', 'value']
|
|
||||||
tol (float): Tolérance relative maximale (5%)
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
pd.DataFrame: Table avec colonnes supplémentaires :
|
|
||||||
'isin', 'old_value', 'new_value', 'relative_change', 'check'
|
|
||||||
"""
|
|
||||||
df['Centralisation Date'] = pd.to_datetime(df['Centralisation Date'])
|
|
||||||
rupture['date'] = pd.to_datetime(rupture['date'])
|
|
||||||
|
|
||||||
# Dictionnaire des dates disponibles par compte pour trouver la date précédente
|
|
||||||
dates_by_account = df.groupby('Registrar Account - ID')['Centralisation Date'].unique().to_dict()
|
|
||||||
|
|
||||||
records = []
|
|
||||||
|
|
||||||
for _, row in rupture.iterrows():
|
|
||||||
date = row['date']
|
|
||||||
old_account = row['old_account']
|
|
||||||
new_account = row['new_account']
|
|
||||||
|
|
||||||
# Date précédente pour l'ancien compte
|
|
||||||
past_dates = [d for d in dates_by_account.get(old_account, []) if d < date]
|
|
||||||
if not past_dates:
|
|
||||||
continue
|
|
||||||
prev_date = max(past_dates)
|
|
||||||
|
|
||||||
# Filtrer df pour old_account à date précédente et new_account à date de rupture
|
|
||||||
df_old = df[(df['Registrar Account - ID'] == old_account) &
|
|
||||||
(df['Centralisation Date'] == prev_date)]
|
|
||||||
df_new = df[(df['Registrar Account - ID'] == new_account) &
|
|
||||||
(df['Centralisation Date'] == date)]
|
|
||||||
|
|
||||||
# Tous les ISIN concernés
|
|
||||||
isins = set(df_old['Product - Isin']).union(df_new['Product - Isin'])
|
|
||||||
|
|
||||||
for isin in isins:
|
|
||||||
old_val = df_old[df_old['Product - Isin'] == isin]['Quantity - AUM'].sum()
|
|
||||||
new_val = df_new[df_new['Product - Isin'] == isin]['Quantity - AUM'].sum()
|
|
||||||
old = df_old['Quantity - AUM'].sum()
|
|
||||||
|
|
||||||
if old_val == 0:
|
|
||||||
rel_change = None
|
|
||||||
check = True
|
|
||||||
else:
|
|
||||||
rel_change = (new_val - old_val) / old
|
|
||||||
check = abs(rel_change) <= tol
|
|
||||||
|
|
||||||
records.append({
|
|
||||||
'date': date,
|
|
||||||
'old_account': old_account,
|
|
||||||
'new_account': new_account,
|
|
||||||
'isin': isin,
|
|
||||||
'old_value': old_val,
|
|
||||||
'new_value': new_val,
|
|
||||||
'relative_change': rel_change,
|
|
||||||
'check': check
|
|
||||||
})
|
|
||||||
|
|
||||||
return pd.DataFrame(records)
|
|
||||||
103
function.py
103
function.py
|
|
@ -1,103 +0,0 @@
|
||||||
import matplotlib.pyplot as plt
|
|
||||||
import pandas as pd
|
|
||||||
|
|
||||||
|
|
||||||
def evolution_compte(df, id1, id = 'Registrar Account - ID'):
|
|
||||||
def prepare_df(idt):
|
|
||||||
df_id = df[df[id] == idt].copy()
|
|
||||||
df_id['Centralisation Date'] = pd.to_datetime(df_id['Centralisation Date'])
|
|
||||||
df_agg = (
|
|
||||||
df_id
|
|
||||||
.groupby('Centralisation Date')['Quantity - AUM']
|
|
||||||
.sum()
|
|
||||||
.reset_index()
|
|
||||||
.sort_values('Centralisation Date')
|
|
||||||
)
|
|
||||||
return df_agg
|
|
||||||
|
|
||||||
df1 = prepare_df(id1)
|
|
||||||
|
|
||||||
plt.figure(figsize=(12, 6))
|
|
||||||
|
|
||||||
# Courbe du compte
|
|
||||||
plt.plot(df1['Centralisation Date'], df1['Quantity - AUM'],
|
|
||||||
marker='.', linestyle='-', label=f'Account {id1}')
|
|
||||||
|
|
||||||
plt.title(f"Évolution AUM pour le compte {id1}")
|
|
||||||
plt.xlabel("Date")
|
|
||||||
plt.ylabel("Quantity - AUM")
|
|
||||||
plt.grid(True)
|
|
||||||
plt.legend()
|
|
||||||
plt.tight_layout()
|
|
||||||
plt.show()
|
|
||||||
|
|
||||||
def evolution_2_comptes(df, id1, id2):
|
|
||||||
def prepare_df(id):
|
|
||||||
df_id = df[df['Registrar Account - ID'] == id].copy()
|
|
||||||
df_id['Centralisation Date'] = pd.to_datetime(df_id['Centralisation Date'])
|
|
||||||
df_agg = (
|
|
||||||
df_id
|
|
||||||
.groupby('Centralisation Date')['Quantity - AUM']
|
|
||||||
.sum()
|
|
||||||
.reset_index()
|
|
||||||
.sort_values('Centralisation Date')
|
|
||||||
)
|
|
||||||
return df_agg
|
|
||||||
|
|
||||||
df1 = prepare_df(id1)
|
|
||||||
df2 = prepare_df(id2)
|
|
||||||
|
|
||||||
plt.figure(figsize=(12, 6))
|
|
||||||
|
|
||||||
# Courbe du premier compte
|
|
||||||
plt.plot(df1['Centralisation Date'], df1['Quantity - AUM'],
|
|
||||||
marker='.', linestyle='-', label=f'Account {id1}')
|
|
||||||
|
|
||||||
# Courbe du second compte
|
|
||||||
plt.plot(df2['Centralisation Date'], df2['Quantity - AUM'],
|
|
||||||
marker='.', linestyle='-', label=f'Account {id2}')
|
|
||||||
|
|
||||||
plt.title("Évolution des AUM pour deux comptes")
|
|
||||||
plt.xlabel("Date")
|
|
||||||
plt.ylabel("Quantity - AUM")
|
|
||||||
plt.grid(True)
|
|
||||||
plt.legend() # <- important pour distinguer les comptes
|
|
||||||
plt.tight_layout()
|
|
||||||
plt.show()
|
|
||||||
|
|
||||||
|
|
||||||
def evolution_3_comptes(df, id1, id2, id3):
|
|
||||||
def prepare_df(id):
|
|
||||||
df_id = df[df['Registrar Account - ID'] == id].copy()
|
|
||||||
df_id['Centralisation Date'] = pd.to_datetime(df_id['Centralisation Date'])
|
|
||||||
df_agg = (
|
|
||||||
df_id
|
|
||||||
.groupby('Centralisation Date')['Quantity - AUM']
|
|
||||||
.sum()
|
|
||||||
.reset_index()
|
|
||||||
.sort_values('Centralisation Date')
|
|
||||||
)
|
|
||||||
return df_agg
|
|
||||||
|
|
||||||
df1 = prepare_df(id1)
|
|
||||||
df2 = prepare_df(id2)
|
|
||||||
df3 = prepare_df(id3)
|
|
||||||
|
|
||||||
plt.figure(figsize=(12, 6))
|
|
||||||
|
|
||||||
plt.plot(df1['Centralisation Date'], df1['Quantity - AUM'],
|
|
||||||
marker='.', linestyle='-', label=f'Account {id1}')
|
|
||||||
|
|
||||||
plt.plot(df2['Centralisation Date'], df2['Quantity - AUM'],
|
|
||||||
marker='.', linestyle='-', label=f'Account {id2}')
|
|
||||||
|
|
||||||
plt.plot(df3['Centralisation Date'], df3['Quantity - AUM'],
|
|
||||||
marker='.', linestyle='-', label=f'Account {id3}')
|
|
||||||
|
|
||||||
plt.title("Evolution of AUM for three accounts")
|
|
||||||
plt.xlabel("Date")
|
|
||||||
plt.ylabel("Quantity - AUM")
|
|
||||||
plt.grid(True)
|
|
||||||
plt.legend()
|
|
||||||
plt.tight_layout()
|
|
||||||
plt.show()
|
|
||||||
1238
rupture.ipynb
1238
rupture.ipynb
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user