Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

dont not use pandas Task 2: Simulating a Bond Auction 40 points; individual-only The US Treasury sells new bonds to investors by offering an auction.

image text in transcribed

image text in transcribed

image text in transcribed

dont not use pandas

Task 2: Simulating a Bond Auction 40 points; individual-only The US Treasury sells new bonds to investors by offering an auction. Interested investors must submit their bids in advance of a deadline, and the Treasury sells the bonds to investors at the highest possible prices (i.e., lowest yield to maturity) and thus the least interest cost. The auction announcement specifies the type of security to be sold (e.g., 5-year bonds with a 3% annual coupon rate), and the amount the Treasury is planning to sell (e.g., $500,000 of maturity value). The potential investors bids must specify the price they are willing to pay per $100 of maturity value (e.g., paying $99.50 per $100 bond in this example would give an annualized yield-to-maturity of about 3.1088%). In this task, you will write some functions to create a simple bond auction. To begin, you should download this sample.csv file containing a list of investor's bids. You will process this file to determine which bids will be accepted (i.e., those with the highest prices), and the minimum price that is successful in the auction. The design you should follow includes 3 functions, described below. You may write additional helper function if you find that useful, but they will not be graded. Do this entire task in a file called a4task2.py. 1. Write the function collect_bids (filename) to process the data file containing the bids. The data file will be in this format: bid_id, bid_amount, bid_price 1, 100000, 101.50 2, 100000, 101.25 3, 200000, 100.75 in which the first row contains the column headers, and each additional row contains three fields: the bid_id which identifies the bidder, the bid_amount (dollar value) of bonds the this investor would like to buy, and the bid_price that the investor is willing to pay. Your task in this function is to process the file and return a list containing the bids (i.e., a list of lists). For example: For example: >>> # call the function >>> bids = collect_bids('./bond_bids.csv') >>> print(bids) # show the data that was returned [[1, 100000, 101.5], [2, 100000, 101.25], [3, 200000, 100.75), # ...] 2. Write the function print_bids (bids) to process the a of bids, and produce a beautifully- formatted table of the bids. In your function, you will process a list containing bids one line at a time. For each bid (a list of 3 fields), you will separate the fields into separate variables and print with appropriate formatting, i.e., with dollar signs, clean spacing, nicely lined up, etc. For example: >>> bids = collect_bids ('./bond_bids.csv') >>> print_bids (bids) Bid ID Bid Amount Price 1 $ 100000 $ 101.500 2 S 100000 $ 101.250 3 S 200000 100.750 $ D E A 1 bid_id 2 3 3 4 5 6 7 8 9 10 11 B bid_amou bid_price 1 100000 101.5 2 100000 101.25 3 200000 100.75 4 400000 101.2 5 250000 100.9 6 300000 100.7 7 120000 101 8 150000 101.2 9 100000 101.75 10 350000 100.5 8 12 Task 2: Simulating a Bond Auction 40 points; individual-only The US Treasury sells new bonds to investors by offering an auction. Interested investors must submit their bids in advance of a deadline, and the Treasury sells the bonds to investors at the highest possible prices (i.e., lowest yield to maturity) and thus the least interest cost. The auction announcement specifies the type of security to be sold (e.g., 5-year bonds with a 3% annual coupon rate), and the amount the Treasury is planning to sell (e.g., $500,000 of maturity value). The potential investors bids must specify the price they are willing to pay per $100 of maturity value (e.g., paying $99.50 per $100 bond in this example would give an annualized yield-to-maturity of about 3.1088%). In this task, you will write some functions to create a simple bond auction. To begin, you should download this sample.csv file containing a list of investor's bids. You will process this file to determine which bids will be accepted (i.e., those with the highest prices), and the minimum price that is successful in the auction. The design you should follow includes 3 functions, described below. You may write additional helper function if you find that useful, but they will not be graded. Do this entire task in a file called a4task2.py. 1. Write the function collect_bids (filename) to process the data file containing the bids. The data file will be in this format: bid_id, bid_amount, bid_price 1, 100000, 101.50 2, 100000, 101.25 3, 200000, 100.75 in which the first row contains the column headers, and each additional row contains three fields: the bid_id which identifies the bidder, the bid_amount (dollar value) of bonds the this investor would like to buy, and the bid_price that the investor is willing to pay. Your task in this function is to process the file and return a list containing the bids (i.e., a list of lists). For example: For example: >>> # call the function >>> bids = collect_bids('./bond_bids.csv') >>> print(bids) # show the data that was returned [[1, 100000, 101.5], [2, 100000, 101.25], [3, 200000, 100.75), # ...] 2. Write the function print_bids (bids) to process the a of bids, and produce a beautifully- formatted table of the bids. In your function, you will process a list containing bids one line at a time. For each bid (a list of 3 fields), you will separate the fields into separate variables and print with appropriate formatting, i.e., with dollar signs, clean spacing, nicely lined up, etc. For example: >>> bids = collect_bids ('./bond_bids.csv') >>> print_bids (bids) Bid ID Bid Amount Price 1 $ 100000 $ 101.500 2 S 100000 $ 101.250 3 S 200000 100.750 $ D E A 1 bid_id 2 3 3 4 5 6 7 8 9 10 11 B bid_amou bid_price 1 100000 101.5 2 100000 101.25 3 200000 100.75 4 400000 101.2 5 250000 100.9 6 300000 100.7 7 120000 101 8 150000 101.2 9 100000 101.75 10 350000 100.5 8 12

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Accounting questions