WOW,buy, XXXXXXXXXX,500,24.3 CCL,buy, XXXXXXXXXX,625,8.15 CBA,buy, XXXXXXXXXX,812,60.25 WOW,sell, XXXXXXXXXX,335,30.63 TLS,buy, XXXXXXXXXX,5560,2.70 BHP,buy, XXXXXXXXXX,509,39.24 TLS,sell,...

1 answer below »
I have attached the assignment file with assignment description because it is too lengthy and has some pictures that can not be posted here.
WOW,buy,2011-08-09,500,24.3CCL,buy,2012-01-31,625,8.15CBA,buy,2012-11-25,812,60.25WOW,sell,2012-11-29,335,30.63TLS,buy,2013-06-20,5560,2.70BHP,buy,2013-07-20,509,39.24TLS,sell,2013-10-15,2080,2.79NAB,buy,2013-11-24,766,18.00SGP,buy,2014-02-11,4935,3.1WOW,sell,2014-04-13,68,45.27CCL,sell,2014-06-12,300,12.80CBA,buy,2014-11-05,45,62.39NAB,sell,2015-03-09,307,14.35NAB,sell,2015-07-03,209,14.98BHP,sell,2015-09-16,210,42.87CCL,sell,2016-03-06,170,9.12SGP,sell,2016-08-19,2614,3.46WOW,sell,2017-01-26,97,32.78XRO,buy,2017-05-31,99,80.14CBA,sell,2017-06-12,53,67.73TLS,sell,2017-07-19,1240,2.81BHP,sell,2018-01-05,116,37.14SGP,sell,2018-04-10,1547,3.74XRO,buy,2018-12-12,99,95.46APT,buy,2019-04-01,605,34.22CBA,sell,2019-08-14,80,64.64NAB,sell,2019-09-16,230,18.26APT,sell,2020-02-12,247,57.49CCL,Coca Cola Group,9.59WOW,Woolworths,37.32NAB,National Australia Bank,18.08SGP,Stockland Corporation,3.81XRO,Xero,101.37APT,Afterpay,81.78TLS,Telstra,2.83BHP,BHP Group,36.89CBA,Commonwealth Bank,65.022010,156002011,20002012,261102013,346552014,350002015,494202016,580062017,634702018,924772019,781242020,703652021,95500
Answered 3 days AfterJan 28, 2021ITC558Charles Sturt University

Answer To: WOW,buy, XXXXXXXXXX,500,24.3 CCL,buy, XXXXXXXXXX,625,8.15 CBA,buy, XXXXXXXXXX,812,60.25 WOW,sell,...

Swapnil answered on Jan 29 2021
73 Votes
75066/assignment-file-1onatvzp.docxFlock Stock Professionals (FSP) are pleased with your performance in previous projects and they have now hired you to write a basic stock portfolio management application.
Your program will read data from several files and then print out the stock portfolio in tabular format as well as draw it on a pie chart. Additionally, your program will also be able to generate a CGT report for any given financial year.
You have been provided with a zip archive containing three data files: trades.txt, live-prices.txt and income.txt. All three are plain text files containing comma
separated data values. Their data components are explained below.
· trades.txt file contains a list of stock trades (purchase or sale) over a period of roughly ten years. Each line contains data for a single trade. The fields in each line, in order, are stock code (3 letters), trade type (buy or sell), date, units traded, share price per unit. All trades have been sorted chronologically.
· live-prices.txt is supposed to contain cu
ent “live” price of all nine stocks involved in trades. Each record contains the stock code, company full name and live price.
· income.txt stores the historical record of annual gross income for a given FSP client. For example, the first line contains 2010,156000 which means the client earned $15,600 in the financial year that started on 1st July 2009 and ended on 30th June 2010.
Your program will ask the user for three filenames and then read and process these records for the following purposes
1. Create a tabular portfolio of client, that is, the list of stocks *cu
ently* held. Some stocks were purchased and completely sold in the past, hence they will not be part of portfolio. See the sample run below for an example of tabular output.
2. Display the portfolio in the form of a pie chart. Each slice in the chart would represent a single holding of the portfolio. Slices should be labelled with stock code. Plotting should be done via matplotlib li
ary. Refer to textbook section 7-8 for instructions and examples of charting.
3. Prompt the user for a year input and then generate a capital gains tax (CGT) report for the financial year ending in June of that year. Save the report is a new text file cgt-report.txt. For example, if user keys in a year value of 2018, your program will generate a CGT report for 2017-18 financial year. This will involve looking at each ‘sale’ trade from the period 1/July/2017 to 30/June/2018 and working out capital gains made during that sale. For simplicity purposes, make the following assumptions
· Each stock can be purchased only once, but can be sold partially in multiple iterations over the years.
· No CGT discount is applied. All of the raw capital gains are taxed.
Let us pick an example from give trades.txt dataset. One of the stocks sold during 2017-18 fiscal year is TLS. From the trade history we can see that 5560 units of TLS were bought in June 2013 at a price of $2.70 each. Out of these 5560 units, some were sold in October 2013. Now in 2018, the sale price is $2.81 per unit and capital gain is $0.11 per unit. 1240 units are being sold, thus overall gain is $136.40. From income.txt we can see that this client earned $92,477 in 2017-18 financial year, so their tax rate is 37% (see the table in assignment 2)***. Therefore the tax payable on this capital gain is $50.47. (We are not bothering with CGT discount). Similarly your program will work out the CGT for other stocks sold during the same fiscal year.
(*** The following is the information from assignment 2:
    Annual gross income
    Tax rate
    0 – $18,200
    $18,201 – $37,000
    $37,001 – $90,000
    $90,001 – $180,000
    $180,001 and ove
Capital gains is made when the sales value of stocks is more than purchase value.
To work with dates, you should use the datetime module from Python standard li
ary. It contains a function fromisoformat which takes in a string in YYYY-MM-DD format and returns a date object. These date objects can be easily compared with each other to see which one lies earlier. If the date is invalid, this function call will raise a ValueE
or. Following code demonstrates how this module can be used.
    from datetime import date
fy_start = date.fromisoformat('2017-07-01')
trade_date = date.fromisoformat('2017-07-19')
print(trade_date > fy_start) # outputs True
Your program should be able to handle following types of e
ors situations
· Invalid format of data in data files (e.g. more of less fields per record, 4 letter stock code, invalid dates, negative price or number of units etc.)
· Inco
ect filenames provided by use
· Invalid year value provided by use
In case of any of the above e
ors, display an e
or message and exit the program.
Constraint: You can only import these Python modules: sys, datetime, math and matplotli
You must use appropriate Python data structures (like lists, tuples and dictionaries) to store the data. Quality of your code will strongly depend on the choice of data structures.
A sample run of the program is given below to clearly demonstrate all the requirements.
    *** Flock Stock Professionals - Portfolio App ***
Please provide names of data files, or simply press Enter to accept default filenames.
Trade history file (trades.txt): [Enter]
Live price data file (live-prices.txt): [Enter]
Client's annual income records (income.txt): [Enter]
(1) Client's portfolio
Stock | Units Held | Value
CCL | 155 | $ 1,486.45
CBA | 724 | $47,074.48
TLS | 2240 | $ 6,339.20
BHP | 183 | $ 6,750.87
NAB | 20 | $ 361.60
SGP | 774 | $ 2,948.94
XRO | 198 | $20,071.26
APT | 358 | $29,277.24
Total Worth $114,310.04
(2) Pie chart of portfolio opens in new window
(3) CGT Report
Enter a year to generate CGT report: 2014
CGT report for the 2013-14 financial year successfully generated and saved in file cgt-report.txt
All tasks...

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here