联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp

您当前位置:首页 >> C/C++编程C/C++编程

日期:2024-03-31 06:26

Data Science for Finance

Problem Set 1

Exercise 1:

Consider three variables A, B and C. Each variable has a specific value assigned.

Write a code so that B takes the value of A, C takes the value of B and A takes

the value of C

Example:

A=1, B=2, C=3.

Your Code …

A=3, B=1, C=2

Exercise 2:

a)  Create two variables, one containing a stock ticker and another

containing the current stock price. Display them using print. (You can

find the stock information using Yahoo finance website)

b)  Now transfer the variable values into a list and display the list.

c)  Take the variables and now store the values in a dictionary, using keys

‘ticker’ and ‘price’. Display dictionary values.

Exercise 3:

Create a python script. that allows users to input two names and compute the

similarity score between two names.

a)   Use the syntax var = input(“please enter a name: ”) to

ask the user to two names and assign them to two variables.

b)  Transform. the names to lowercase.

c)  Convert both names into two sets

d)  Generate the intersection and union of these two sets

e)  Compute the similarity score using the following formula:


Where S is the similarity score, |A n B| is the size of the intersection of

these two sets, |A n B| is the size of the union of these two sets.

Exercise 4:

A derivative asset (https://en.wikipedia.org/wiki/Derivative_(finance)) has the following valuation rule:

a)

?   If the stock priceS is greater than 50 dollars, then the intrinsic value of the asset is S-50.

?   If the stock price is less than or equal to 50 dollars, then the intrinsic value of the asset is 0.

Without using if statement which we will learn in the next lecture, write a program   that   inputs   the   stock   price   and   returns  the   intrinsic  value accordingly.

b)

?   If the stock priceS is greater than 50 dollars and less than 100 dollars, then the intrinsic value of the asset is S-50.

?   If the stock price is greater than or equal to 100 dollars, then the intrinsic value of the asset is 0.

?   If the stock price is less than or equal to 50 dollars, then the intrinsic value of the asset is 0.

Without using if statement which we will learn in the next lecture, write a program   that   inputs   the   stock   price   and   returns  the   intrinsic  value accordingly.

Exercise 5:


Write a program that computes the net present value (NPV) of a project, given a

discount rate, an initial investment and a stream of future cash flows.

Where I is the initial investment, CFi  is the cash flow received in year i, r is the

annualized discount rate, N is the total number of yearly cash flows.

Example:

.   r = 0.07

.   I = 100000

.   CF = (10000,25000,30000,50000)    You can use tuple for CF.

.   Output in the window:

Should we invest in the project?





版权所有:留学生编程辅导网 2020 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp