讲解MSF 503、Python语言讲解
- 首页 >> Python编程MSF 503 Financial Modeling Fall, 2019
PROJECT 2
1.) Recall LAB 2.1 that we did in class. This time assume the average inter-trade time (or
scale) is equal to (say) 5 seconds. Write a Python program that finds the probability that
the next trade will occur between 2 and 3 seconds. Recall that the cumulative distribution
function (cdf) is F( x ) = P( X < x ). So, you will need to Google “python exponential
distribution cdf”. If you are unfamiliar with Python, use trial and error to get the right
answer for LAB 2.1 first.
2.) Suppose that a trading firm believes that a particular strategy will generate somewhere
between $-2000 and $5000 dollars in trading profits per day with a most likely estimate
of $1000? What is the triangular probability density function that corresponds to these
estimates? What is the cumulative distribution function? What are the mean and
variance?
EXTRA CREDIT: Write a Python program that calculates the mean and variance for this
distribution and plots the pdf on a graph. Hint: a = loc, b = loc + scale, m = loc + c ⸱
scale. You’ll probably want to create a “frozen RV object.”
3.) Create a Python program that prints the answers to the following questions.
Assuming normally distributed data, what is the probability that X < 2 if µ = 0 and
σ = 3?
Assuming normally distributed data, what is the probability that X > 16 if µ = 5
and σ = 20?
Assuming normally distributed data, what is the probability that -5 < X < 5 if µ =
0 and σ = 5?
Assuming normally distributed data, what is the probability that X < -3 or X > 3 if
µ = 0 and σ = 1?
4.) Consider the following data on trade sizes:
1,1,1,2,1,2,5,1,10,2,4,3,2,1,5,1,3,2,1,10,1,1,4,3,2,1,2,1,4,5,1,1,2,15,1,2,3
Create a grid as in LAB 2.4.
If the future is like the past, what is the probability that the next trade will have a size
equal to 3?
What is the probability that the next trade will have a size greater than 1 and less than5?
What is the probability that the next trade will have a size greater than 3?
5.) Assume we have a trading strategy where there is a 51% probability of making $1 and a
49% probability of losing $1. If I do 1000 of these trades per day, what is my expected
profit per day? What is my standard deviation of profit per day? What is the probability
of me making more than $20 today?