def test_stock_transaction_sanity(self):
        stock_db_connection = get_default_db_connection()
        reset_table(stock_db_connection)
        stock_transaction_table = StockTransactionTable(stock_db_connection)
        stock_transaction = StockTransaction()
        stock_transaction.set_symbol("601398")
        stock_transaction.set_buy_or_sell("buy")
        stock_transaction.set_quantity(100)
        stock_transaction.set_price(4.51)
        stock_transaction.set_date(date(2015, 11, 10))
        stock_transaction_table.add_stock_transaction(stock_transaction)

        stock_transaction = StockTransaction()
        stock_transaction.set_symbol("601857")
        stock_transaction.set_buy_or_sell("buy")
        stock_transaction.set_quantity(100)
        stock_transaction.set_price(4.51)
        stock_transaction.set_date(date(2015, 11, 10))
        stock_transaction_table.add_stock_transaction(stock_transaction)

        stock_transaction = \
            stock_transaction_table.get_stock_transaction_by_trans_id(1)
        stock_transaction.set_quantity("500")
        stock_transaction_table.update_stock_transaction(stock_transaction)

        stock_transaction = \
            stock_transaction_table.get_stock_transaction_by_trans_id(1)
        stock_transaction_table.delete_stock_transaction(stock_transaction)

        return
Beispiel #2
0
    def update_stock_transaction(self):
        trans_id = int(self.entryTransId.get())

        stock_transaction_table = StockTransactionTable()
        stock_transaction = \
            stock_transaction_table.get_stock_transaction_by_trans_id(trans_id)

        symbol = self.entrySymbol.get()
        buy_or_sell = self.entryBuyOrSell.get()
        quantity = int(self.entryQuantity.get())
        price = float(self.entryPrice.get())
        date = self.entryDate.get()

        stock_transaction.set_symbol(symbol)
        stock_transaction.set_buy_or_sell(buy_or_sell)
        stock_transaction.set_quantity(quantity)
        stock_transaction.set_price(price)

        stock_transaction_table.update_stock_transaction(stock_transaction)

        self.refresh_list_box()

        return