-
-
Save EvanMarie/1bbc97c835b1f474cf7328fcf9dfc39a to your computer and use it in GitHub Desktop.
annualized_data.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"provenance": [], | |
"authorship_tag": "ABX9TyNON9ToWVPb/WEA23fikKHA", | |
"include_colab_link": true | |
}, | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3" | |
}, | |
"language_info": { | |
"name": "python" | |
} | |
}, | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "view-in-github", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"<a href=\"https://colab.research.google.com/gist/EvanMarie/1bbc97c835b1f474cf7328fcf9dfc39a/annualized_data.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"id": "3Pbhahof_7st" | |
}, | |
"outputs": [], | |
"source": [ | |
"def annualized_data(returns, title = None):\n", | |
" annualized = returns.agg(['mean', 'std']).T\n", | |
" annualized['return'] = annualized[\"mean\"] * 250\n", | |
" annualized['risk'] = annualized['std'] * np.sqrt(250)\n", | |
" annualized.drop(columns = ['mean', 'std'], inplace = True)\n", | |
" if title != None:\n", | |
" highlight(f\"💰 Annualized Return and Risk: {title}\", \n", | |
" \"lime\", \"black\",fontsize=3)\n", | |
" else:\n", | |
" highlight(f\"💰 Annualized Return and Risk\", \n", | |
" \"lime\", \"black\",fontsize=3)\n", | |
" display(annualized)\n", | |
" return annualized" | |
] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment