def insert_stock_transfer_record(data: dict, bank_account: object):
    """Inserts a transfer record between a bank account and a stock account.
    """
    from finance.models import Asset, deposit
    asset_krw = Asset.query.filter(Asset.name == 'KRW').first()
    subtotal = data['subtotal']
    date = data['date']
    if data['name'] == '증거금이체':
        return deposit(bank_account, asset_krw, -subtotal, date)
    elif data['name'] == '매매대금정산':
        return deposit(bank_account, asset_krw, subtotal, date)
    else:
        raise ValueError("Unrecognized transfer type '{}'".format(data['name'])
            )
