Python Portfolio Calculator

You are the COO of a robo-advisory company, and you are to send an annual report to your client, to report the transactions carried out every year, since the inception of their portfolio. The details of the portfolio are defined in Figure 1.

Figure 1

Figure 1: At the end of each month, some units of stocks are acquired. Even though the portfolio is created on the 1-Mar-2010, the first acquisition of stock will happen on the last business day of Mar-2010. At the first acquisition of stock, an initial_amt is used to purchase some units of stock at the closing price on the last business day of Mar-2010. Subsequently, at the end of each business month from Apr-2010 onwards, a sum of monthly_amt is used to acquire some units of stocks at the month- end prices. The detail of the portfolio is queried on the date defined by query_dt. All stock transactions are to take place on the last business day of the month.


Assuming random stock prices, where the stock prices are assumed to vary between $100 to

$120, the transaction history of the portfolio defined in Figure 1 is reported in Figure 2.


Figure 2


Figure 2: Transaction history of the portfolio, using a random seed with a value of 22 to simulate month-end stock prices. The average transacted price is defined as the simple arithmetic average of the monthly stock prices from portfolio construction date to report date. The column units denotes the number of stocks acquired in the year. The columns high, low and average denote the high price, low price and the average price in that year. All floating point figures are reported to an accuracy of 2 decimal points.


Design and develop a Python script that creates and delivers information displayed in the format given in Figure 2. State clearly, any assumptions you have made in your implementation.


Given the details of various portfolios in Figure 3, use your Python script to appraise and print clearly the transaction histories of the portfolios in a similar format given in Figure 2.


Figure 3

Figure 3: Portfolio inputs to Python script. A random seed value of 22 is assumed for all portfolios.

Need a custom answer at your budget?

This assignment has been answered 5 times in private sessions.

© 2024 Codify Tutor. All rights reserved