コード例 #1
0
ファイル: create_brokers.py プロジェクト: MariaEgrv/trading
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
コード例 #2
0
ファイル: exemption_calc.py プロジェクト: MariaEgrv/trading
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}"
        )
コード例 #3
0
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()
コード例 #4
0
def check_brokers():
    brokers = get_brokers(session)
    return len(brokers) > 0