Help with python stock portfolio tracker first meeting with objects on my own

At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get our expert's

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this and thousands of other questions.

A community for students.

Help with python stock portfolio tracker first meeting with objects on my own

Computer Science
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this and thousands of other questions

Hi I'm trying to make a python stock portfolio tracker, so far I have made two attempts, and got stuck at both of them, any tips? #1 # Stock portfolio tracker import datetime def welcome(): print "Welcome to the stock portfolio tracker" print "Let's hope it works this time" class Stock(object): # Creates and saves a portfolio of stocks def __init__(self, date, price, number_of_shares): # Initialises the portfolio and takes three arguments self.date = date self.price = price self.number_of_shares = number_of_shares def __str__(self): # Creates a string representation of the portfolio # and prints requested values return "date purchased :%s, Price: %s, Number_of_shares %s" %( self.date, self.price, self.number_of_shares) def getPurchaseValue(self): # Computes the purchase value as price per share x number of shares return (self.price * self.number_of_shares) def getSaleValue(self, salePrice): # Computes the sale value as price per share * shares return (self.salePrice * number_of_shares) class Portfolio(Stock): # Creates a portfolio of collected stocks def __init__(self, stockName): self.stockName = stockName portfolio = [] def addStock(self): newStock = raw_input('What is the company ticker?') name = raw_input('Enter the ticker of the stock to add') price = raw_input('Enter the price of the stock') shares = raw_input('How many shares to add?') newstock[name, price, shares] def main(): welcome() MSFT = Stock(10,10,10) print MSFT
#2 # New attempt at creating a portfolio of stocks class DataBook(object): def __init__(self, price, shares, date): self.price = price self.shares = shares self.date = date self.get_info() def get_info(self): sf = \ """ price = %s shares = %s date = %s """ return sf %(self.price, self.shares, self.date) def main(): name_dic = {} ticker = raw_input("What is the company's ticker?") price = int(raw_input('What was the price?')) shares = raw_input('how many shares did you buy?') date = raw_input(' When did you buy it?') name_dic[ticker] = DataBook(price, shares, date) main()
Any feedback will be greatly appreciated=)

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

In Stock.getSaleValue() where does self.salePrice come from? In Portfolio.addStock, what is newstock[name, price, shares]? Square brackets are for lists, parentheses are for functions. DataBook.get_info has a formatted string, but no variables substituted in. main() looks like it would be setting up a dictionary, but name_dic is a list. Advice: Develop you classes independently. It helps to develop/debug them one at a time, and if you're hoping to reuse them it forces you to make them separate.

Not the answer you are looking for?

Search for more explanations.

Ask your own question