# (a)
# (i)
stocks = {}
def initStocks():
stockList = [
['3AB','Telecom','12/12/2018',1.55,3000],
['S12','S&P','12/08/2018',3.25,2000],
['AE1','A ENG','04/03/2018',1.45,4000]
]
for sublist in stockList:
stocks[sublist[0]] = sublist[1:]
print(stocks)
# (ii)
# in dictionary we can directly look for stock short code and get the
# information for stock but in list we need to iterate
# we can create dictionary for sold stocks and store the information
# (b)
stockHeld = {}
stockHeld = stocks
# Code : 'Name', 'Last Sold', 'Volume'
stockSold = {}
def holdingStocks():
print("Held Stock Details:")
# Iterating over values
for shortCode, stockDetails in stockHeld.items():
print("Code: "+ shortCode)
print("Name: "+ stockDetails[0])
print("Last Purchase Date: "+ stockDetails[1])
print('Average Price $: ',stockDetails[2])
print('Volume: ',stockDetails[3])
print('Investment cost ($):', float(stockDetails[3])*float(stockDetails[2]))
print("..........................")
def soldStocks():
print("Sold Stock Details:")
# Iterating over values
if len(stockSold) > 0:
for shortCode, stockDetails in soldStocks.items():
print("Code: "+ shortCode)
print("Name: "+ stockDetails[0])
print("Last Sold Date: "+ stockDetails[1])
print('Volume: ',stockDetails[3])
buyPrice =float(stockHeld[shortCode][2])
soldPrice = float(stockDetails[2])
print('Profit/Loss ($):', float(stockDetails[3])*(soldPrice - buyPrice))
print("..........................")
def buyStock():
shortCode = input("Enter Stock code:")
if stocks.get(shortCode) != None:
print("You are buying existing stock - " + stocks.get(shortCode)[0] )
pricePerUnit = input("Enter current Price per unit:")
stockNo = input("Enter Number of Stock:")
purDate = input("Enter Date of purchase (dd/mm/yyyy):")
stockUpdate = {}
stockUpdate[shortCode] = [stocks.get(shortCode)[0],purDate, pricePerUnit, stockNo]
stockHeld.update(stockUpdate)
stockHeld[shortCode] = stocks[shortCode]
else:
print("You are buying new stock")
name = input("Enter name:")
pricePerUnit = input("Enter current Price per unit:")
stockNo = input("Enter Number of Stock:")
purDate = input("Enter Date of purchase (dd/mm/yyyy):")
print( shortCode + "Stock not in the stock list.")
stockHeld[shortCode] = [name,purDate,pricePerUnit, stockNo]
def sellStock(shortCode):
stockSold[shortCode] = stocks[shortCode]
def OperationOnStocks():
ans=True
while ans:
print ("""
Menu
1. List Holding and sold details for a stock
2. Buy Stock
3. Sell Stocks
4. list Holdings
5. list Sold Stock
0. Exit
""")
ans=input("What would you like to do? ")
if ans=="1":
holdingStocks()
soldStocks()
elif ans=="2":
buyStock()
elif ans=="3":
sellStock()
elif ans=="4":
holdingStocks()
elif ans=="5":
soldStocks()
elif ans=="0":
break
elif ans !="":
print("\n Not Valid Choice Try again")
holdingStocks()
soldStocks()
if __name__ == "__main__":
initStocks()
OperationOnStocks()
//output:
Requires Python to answer A client wishes to keep track of his investment in shares. Write...
(PYTHON) Stock Transaction Program Last month Joe purchased some stock from StockTrade. 1. Write a function(s) to allow the user to input the followings: ·The name of the stock ·Number of shares Joe bought · Stock purchase price · Stock selling price ·Broker commission 2. Write function(s) to calculate: and: · The amount of money Joe paid for the stock (number of shares bought * purchase price) · The amount of commission Joe paid his broker when he bought the...
Problem Statement Last month Tian purchased some stock in Acme Software, Inc. Here are the details of the purchase: The number of shares that Tian purchased was 1,000 When Tian purchased the stock, he paid $33.92 per share Tian paid his stockbroker a commission that amounted to 2% of the amount he paid for the stock. One week later, Tian sold the stock. Here are the details of the sale: The number of shares sold was 1,000...
Allen exercised a nonstatutory stock option and purchased shares of his company's stock on October 31, 2016. He purchaed the shares for less than fair market value. That year, he included $3,000 in compensation income from exercising his option. On December 5, 2018, Allen sold the stock for a profit. When he received a 2018 form 1099-B from his broker reporting details of the sale, he noticed that his cost basis did not include the $3,000 compensation element from 2016....
You write one MBI July 120 put contract (equaling 100 shares) for a premium of $5. The option is held until the expiration date, when MBI stock sells for $123 per share. You will realize a ______ on the investment. Multiple Choice $300 loss $300 profit $500 profit $800 profit
You write one MBI July 120 put contract (equaling 100 shares) for a premium of $5. The option is held until the expiration date, when MBI stock sells for $123 per share. You will realize a ______ on the investment. Multiple Choice A) $500 profit B) $300 profit C) $800 profit D) $300 loss
I
need a program that solves this
34. Write a program to process stock data. The stock data should be read from a text file containing the following data: stock code, stock name, amount invested r.xx), shares held, and current price. Use the Internet or your local paper to gather data on at least 20 stocks. (You may use mutual funds in place of stocks.) As each stock is read, insert it into a doubly linked multilinked list The first...
Antonio received 40 ISOs (each option gives him the right to purchase 20 shares of Zorro stock for $3 per share) at the time he started working for Zorro Corporation six years ago. Zorro’s stock price was $3 per share at the time. Now that Zorro’s stock price is $50 per share, Antonio intends to exercise all of his options and immediately sell all the shares he receives from the options exercise. (Enter all amounts as positive values. Leave no...
10. Stock Transaction Program 18pts Last month Joe purchased some stock in Acme Software, Inc. Here are the details of the purchase: • The number of shares that Joe purchased was 1,000. • When Joe purchased the stock, he paid $32.87 per share. • Joe paid his stockbroker a commission that amounted to 2 percent of the amount he paid for the stock. Two weeks later Joe sold the stock. Here are the details of the sale: • The number...
Please use C++ only
CSIT163 Project 1 - Taking Stock Recently, Joe Btfsplk purchased some stock in Acme Software, Inc. The details of the purchase are as follows: • 1,000 shares at $32.87 per share. • The stockbroker received $5 dollars plus a commission of 2% of the total purchase. Should he decide to sell, the stockbroker receives $5 dollars plus a commission of 2% of the total sale. Feeling jittery, Joe is considering selling the stock. The only thing...
Use the option quote information shown here to answer the
questions that follow. The stock is currently selling for $114, and
the size of each contract is 100 shares.
a. Suppose you buy 10 contracts of the
February 110 call option. How much will you pay, ignoring
commissions?
b-1. Suppose you buy 10 contracts of
the February 110 call option and also suppose that Macrosoft stock
is selling for $140 per share on the expiration date. How much is
your...