{ "cells": [ { "cell_type": "code", "execution_count": 36, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import math\n", "from datetime import datetime\n", "import hvplot.pandas\n", "import math\n", "import numpy as np\n", "# load data\n", "profile_df = pd.read_pickle('../data/portfolio_portfile.pkl')\n", "benchmark_df = pd.read_pickle('../data/benchmark_portfolio.pkl')\n", "portfolio_df = pd.read_pickle('../data/portfolio_data.pkl')" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## This section transfrom benchmark_df and creat an benchmark profile to accomadate current pipeline" ] }, { "cell_type": "code", "execution_count": 37, "metadata": {}, "outputs": [], "source": [ "# drop weight\n", "# benchmark_df = benchmark_df.drop(columns=['weight'])\n", "\n", "## simulate update potfolio weigth at 2021-01-10\n", "update_profile_df = profile_df.copy()\n", "update_profile_df['date'] = datetime(2021,1,10)\n", "update_profile_df['weight'] = [50,100,200,300,400,500]\n", "profile_df = pd.concat([profile_df, update_profile_df])\n" ] }, { "cell_type": "code", "execution_count": 38, "metadata": {}, "outputs": [], "source": [ "## create a profile for benchmark\n", "b_profile = benchmark_df.drop_duplicates(subset=['ticker', 'actual_data'])\n", "# df_unique[df_unique.ticker == \"000008.XSHE\"]\n", "# only keep ticker\tdate\tweight\tdisplay_name\tname\tsector\taggregate_sector column\n", "b_profile = b_profile[['ticker','date','weight','name','sector','aggregate_sector','display_name_x']]\n", "b_profile.rename(columns={'display_name_x': 'display_name'}, inplace=True)" ] }, { "cell_type": "code", "execution_count": 39, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | date | \n", "ticker | \n", "open | \n", "close | \n", "high | \n", "low | \n", "volume | \n", "money | \n", "
---|---|---|---|---|---|---|---|---|
0 | \n", "2021-01-05 | \n", "000008.XSHE | \n", "2.52 | \n", "2.57 | \n", "2.67 | \n", "2.49 | \n", "33215803.0 | \n", "85358605.99 | \n", "