def import_stock_records(filename): """Parses exported data from the Shinhan HTS.""" account_bank = Account.query.filter(Account.name == "신한 입출금").first() account_stock = Account.query.filter(Account.name == "신한 주식").first() with open(filename) as fin: for parsed in parse_stock_records(fin): insert_stock_record(parsed, account_stock, account_bank)
def import_stock_records(filename): """Parses exported data from the Shinhan HTS.""" app = create_app(__name__) with app.app_context(): account_bank = Account.query \ .filter(Account.name == '신한 입출금').first() account_stock = Account.query \ .filter(Account.name == '신한 주식').first() with open(filename) as fin: for parsed in parse_stock_records(fin): insert_stock_record(parsed, account_stock, account_bank)
def test_insert_stock_record(db, account_stock, account_checking): data = { "date": parse_date("2016-06-30"), "sequence": 1, "category1": "장내매수", "category2": "매수", "code": "005380", "name": "현대차", "unit_price": 136000, "quantity": 10, "subtotal": 1360000, "interest": 0, "fees": 200, "late_fees": 0, "channel": "", "final_amount": 1670200, } asset = Asset.create(type="stock", code="005380.KS", description="현대차") record = insert_stock_record(data, account_stock, account_checking) # TODO: Automate this process db.session.delete(record) db.session.delete(asset) db.session.commit()
def test_insert_stock_record(db, account_stock, account_checking): data = { 'date': parse_date('2016-06-30'), 'sequence': 1, 'category1': '장내매수', 'category2': '매수', 'code': '005380', 'name': '현대차', 'unit_price': 136000, 'quantity': 10, 'subtotal': 1360000, 'interest': 0, 'fees': 200, 'late_fees': 0, 'channel': '', 'final_amount': 1670200, } asset = Asset.create(type='stock', code='005380.KS', description='현대차') record = insert_stock_record(data, account_stock, account_checking) # TODO: Automate this process db.session.delete(record) db.session.delete(asset) db.session.commit()