src/stock.py
def buy(self, date, ticker, amount, unit_price, fee, currency):
        """check if there is enough free cash in the portfolio.
        If so, then return the transaction in dictionary form.
        e.g. return {'ticker': 'MSFT', 'date': '2022-02-02', 'quantity': 6, 'price': 120, 'fee': 2, 'currency': 'USD'} """
        try:
            StockPrice.check_ticker(ticker)
        except (KeyError, IndexError):
            print('This ticker is not in our database')
            return None
        tr = self.handle_transaction(date, ticker, amount, unit_price, fee, currency, type="Buy")
        return tr
check if there is enough free cash in the portfolio.
        If so, then return the transaction in dictionary form.
        e.g. return {'ticker': 'MSFT', 'date': '2022-02-02', 'quantity': 6, 'price': 120, 'fee': 2, 'currency': 'USD'} 
check if there is enough free cash in the portfolio.
If so, then return the transaction in dictionary form.
check if there is enough free cash in the portfolio . If so then return the transaction in dictionary form .
def buy(self, date, ticker, amount, unit_price, fee, currency):
        try:
            StockPrice.check_ticker(ticker)
        except (KeyError, IndexError):
            print('This ticker is not in our database')
            return None
        tr = self.handle_transaction(date, ticker, amount, unit_price, fee, currency, type="Buy")
        return tr
def buy ( self , date , ticker , amount , unit_price , fee , currency ) : try : StockPrice . check_ticker ( ticker ) except ( KeyError , IndexError ) : print ( 'This ticker is not in our database' ) return None tr = self . handle_transaction ( date , ticker , amount , unit_price , fee , currency , type = "Buy" ) return tr
check if there is enough free cash in the portfolio.
check if there is enough free cash in the portfolio .
"""check if there is enough free cash in the portfolio.
        If so, then return the transaction in dictionary form.
        e.g. return {'ticker': 'MSFT', 'date': '2022-02-02', 'quantity': 6, 'price': 120, 'fee': 2, 'currency': 'USD'} """
self
date
ticker
amount
unit_price
fee
currency