Menu
  • Home
  • About Me
  • Blog
  • Github
  • LinkedIn

Measuring Reward and Risk of an Investment

February 7, 2022

Let’s load the msft.csv dataframe and make it chart:

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
pd.options.display.float_format = '{:.4f}'.format
plt.style.use("seaborn")

msft = pd.read_csv("msft.csv", index_col = "Date", parse_dates = ["Date"])
msft

msft.Price.plot(figsize = (15, 8), fontsize = 13)
plt.legend(fontsize = 13)
plt.show()

we can get some summary statistics by using this commnad:

msft.describe()

Mean return is the performance metric for the reward so we have daily mean return of 11 percent. The standard deviation of returns is the metric for the risk (volatility) which is 1.72

Calculate daily returns for Bitcoin

import pandas as pd
pd.options.display.float_format = '{:.4f}'.format

close = pd.read_csv("close.csv", index_col = "Date", parse_dates = ["Date"])
btc = close["BTC-USD"].dropna().to_frame().copy()

Calculate the arithmetic mean return and the standard deviation of returns for Bitcoin.

btc["Returns"] = btc.pct_change(periods = 1) * 100
print(btc)
mu = btc.Returns.mean() 
sigma = btc.Returns.std()

print(mu)
print(sigma)

Compare Bitcoin with Microsoft (mu = 0.116, sigma = 1.726). Bitcoin is higher risk and reward.

2 thoughts on “Measuring Reward and Risk of an Investment”

  1. Dolly Sotto says:
    April 9, 2022 at 8:59 pm

    its fantastic as your other blog posts : D, regards for posting.

    Reply
  2. Buy Cheap Private Proxy says:
    April 11, 2022 at 9:17 am

    Thank you, I’ve been hunting for info about this topic for ages and yours is the best I’ve located so far.

    Reply

Leave a Reply to Buy Cheap Private Proxy Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts
  • ChinguTalkBot v0.1.0: Setting up AWS Cognito with CDK for User Authentication
  • Phoenix & Elixir: Fix PostgreSQL connection refused
  • Demo: Git Log with Shell script to create a release notes
  • Metasploit
  • CyberSecurity Lab – Online Password Attack

Archives
  • March 2024
  • May 2023
  • April 2023
  • February 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
Categories
  • Amazon Interview (3)
  • Ansible (3)
  • AWS (9)
  • Azure (9)
  • Certification (2)
  • ChinguTalkBot Project (1)
  • cybersecurity (3)
  • Data analytics (6)
  • Demo Videos (6)
  • Docker (5)
  • Git (1)
  • GitLab (1)
  • Golang (3)
  • JavaScript (2)
  • Jenkins (4)
  • PowerShell (1)
  • Python (10)
  • Terraform (11)
  • Uncategorized (9)

©2025 | Powered by WordPress and Superb Themes!