def make_trade(): stock = input("What stock do you want to trade? ").upper() quantity = int(input("How many shares are you trading? ")) direction = input("Are you [b]uying or [s]elling? (b/s) ") if direction not in ('b', 's'): return "Direction must be 'b' or 's'" else: direction = 'buy' if direction == 'b' else 'sell' traded_price = int(input("What is price per share in the trade in whole pennies? ")) record_trade(stock, quantity=quantity, direction=direction, traded_price=traded_price) return "Trade recorded"
def setUp(self): self.common_stock = stock_factory( stock_type='common', stock_symbol='Tea', last_dividend=7, par_value=100 ) self.preferred_stock = stock_factory( stock_type='preferred', stock_symbol='Gin', last_dividend=8, fixed_dividend=0.02, par_value=100 ) for count in range(15): for stock in [self.common_stock, self.preferred_stock]: record_trade( stock.stock_symbol, time=datetime.datetime.now() - datetime.timedelta(minutes=count), quantity=(count+1), direction='buy', traded_price=10 )