diff --git a/.vs/ProjectSettings.json b/.vs/ProjectSettings.json new file mode 100644 index 0000000..f8b4888 --- /dev/null +++ b/.vs/ProjectSettings.json @@ -0,0 +1,3 @@ +{ + "CurrentProjectSetting": null +} \ No newline at end of file diff --git a/.vs/PythonSettings.json b/.vs/PythonSettings.json new file mode 100644 index 0000000..40738ec --- /dev/null +++ b/.vs/PythonSettings.json @@ -0,0 +1,3 @@ +{ + "Interpreter": "Global|PythonCore|3.11" +} \ No newline at end of file diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json new file mode 100644 index 0000000..6b319c4 --- /dev/null +++ b/.vs/VSWorkspaceState.json @@ -0,0 +1,7 @@ +{ + "ExpandedNodes": [ + "" + ], + "SelectedNode": "\\solution_skeleton.py", + "PreviewInSolutionExplorer": false +} \ No newline at end of file diff --git a/.vs/prescient-coding-challenge-2023/FileContentIndex/f8a43b83-3848-4967-9334-1f3ffc308a96.vsidx b/.vs/prescient-coding-challenge-2023/FileContentIndex/f8a43b83-3848-4967-9334-1f3ffc308a96.vsidx new file mode 100644 index 0000000..1f3e16a Binary files /dev/null and b/.vs/prescient-coding-challenge-2023/FileContentIndex/f8a43b83-3848-4967-9334-1f3ffc308a96.vsidx differ diff --git a/.vs/prescient-coding-challenge-2023/FileContentIndex/read.lock b/.vs/prescient-coding-challenge-2023/FileContentIndex/read.lock new file mode 100644 index 0000000..e69de29 diff --git a/.vs/prescient-coding-challenge-2023/v17/.wsuo b/.vs/prescient-coding-challenge-2023/v17/.wsuo new file mode 100644 index 0000000..ac689b5 Binary files /dev/null and b/.vs/prescient-coding-challenge-2023/v17/.wsuo differ diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite new file mode 100644 index 0000000..77190fc Binary files /dev/null and b/.vs/slnx.sqlite differ diff --git a/README.md b/README.md index 6f9e21d..5bb81bf 100644 --- a/README.md +++ b/README.md @@ -181,3 +181,409 @@ Assuming you have a Github account and git installed on your computer, follow th 3. [VS Code](https://code.visualstudio.com/download) 4. [R Base](https://cran.r-project.org/) 5. [R Studio](https://posit.co/downloads/) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/solution_skeleton.py b/solution_skeleton.py index 7fc2fa5..141f44d 100644 --- a/solution_skeleton.py +++ b/solution_skeleton.py @@ -5,6 +5,7 @@ import plotly.express as px + print('---Python script Start---', str(datetime.datetime.now())) # %% @@ -75,7 +76,7 @@ def generate_portfolio(df_train: pd.DataFrame, df_test: pd.DataFrame): list_stocks.remove('month_end') # <<--------------------- YOUR CODE GOES BELOW THIS LINE --------------------->> - + df_weights = df_weights*1.7 # This is your playground. Delete/modify any of the code here and replace with # your methodology. Below we provide a simple, naive estimation to illustrate # how we think you should go about structuring your submission and your comments: @@ -95,6 +96,7 @@ def generate_portfolio(df_train: pd.DataFrame, df_test: pd.DataFrame): df_w['inv_vol'] = 1/df_w['vol'] # calculate the inverse volatility df_w['tot_inv_vol'] = df_w['inv_vol'].sum() # calculate the total inverse volatility df_w['weight'] = df_w['inv_vol']/df_w['tot_inv_vol'] # calculate weight based on inverse volatility + df_w.reset_index(inplace=True, names='name') # add to all weights @@ -104,6 +106,7 @@ def generate_portfolio(df_train: pd.DataFrame, df_test: pd.DataFrame): # <<--------------------- YOUR CODE GOES ABOVE THIS LINE --------------------->> # 10% limit check + #print(df_w) if len(np.array(df_weights[list_stocks])[np.array(df_weights[list_stocks]) > 0.101]): raise Exception(r'---> 10% limit exceeded') @@ -170,4 +173,6 @@ def plot_total_return(df_returns: pd.DataFrame, df_weights_index: pd.DataFrame, df_weights_index = equalise_weights(df_returns) df_returns, df_weights_portfolio = generate_portfolio(df_returns_train, df_returns_test) fig1, df_rtn = plot_total_return(df_returns, df_weights_index=df_weights_index, df_weights_portfolio=df_weights_portfolio) -fig1 +fig1.show() + +