def _check_if_broker_exists(name): brokers = get_brokers(session) existing_brokers = [] for broker in brokers: if broker.name.casefold().__eq__(name.casefold()): existing_brokers.append(broker.name) return existing_brokers
def calculate_running_exemption_per_broker(): brokers = get_brokers(session) for broker in brokers: total_exemption = 0 for exemption in broker.exemptions: total_exemption += exemption.exemption_amount total_profit = 0 for stock in broker.stocks: total_profit += stock.trade_profit print( f"Broker {broker.name} has remaining exemption {total_exemption - total_profit}" )
def new_stock_entry(): """add new stock record to the journal""" if (not check_brokers()): print("this command requries brokers to work please enter some with the new-broker-entry command") return brokers = get_brokers(session) new_stock = create_stock_from_cli(brokers) session.add(new_stock) session.commit() while click.confirm('do you want to continue?', abort=False): new_stock = create_stock_from_cli(brokers) session.add(new_stock) session.commit()
def check_brokers(): brokers = get_brokers(session) return len(brokers) > 0