def semple_data(self):
        self.list_data.append(Stock('TEA', 'Common', 0, '', 100), )
        self.list_data.append(Stock('POP', 'Common', 8, '', 100), )
        self.list_data.append(Stock('ALE', 'Common', 23, '', 60), )

        self.list_data.append(Stock('GIN', 'Preferred', 8, '2%', 100), )
        self.list_data.append(Stock('JOE', 'Common', 13, '', 250), )
        return self.list_data
Beispiel #2
0
    def get_stock_details(self, id=None):
        self.id = id

        data_rows = None
        stock_dictionary = {}
        stock_list = []

        with DatabaseConnect() as cursor:
            if self.id is None:
                sql_select_query = """select stock_symbol, stock_name, last_price from stock_master"""
                cursor.execute(sql_select_query)
            else:
                sql_select_query = """select stock_symbol, stock_name, last_price from stock_master where stock_symbol = %s"""
                cursor.execute(sql_select_query, (self.id, ))

            data_rows = cursor.fetchall()
            print("Total number of rows: ", cursor.rowcount)

            for each_record in data_rows:
                stock_object = Stock()
                stock_object.stock_symbol = each_record[0]
                stock_object.stock_name = each_record[1]
                stock_object.last_price = SerializeObject.serialize_object(
                    each_record[2])

                stock_dictionary = ConvertToDictionary.convert_to_dictionary(
                    stock_object)
                stock_list.append(stock_dictionary)
            return stock_list
Beispiel #3
0
def get_all_stocks_from_config():
    """

    :return:
    """
    for key, value in STOCK_CONFIG.items():
        new_stock = Stock()
        new_stock.stock_symbol = key
        new_stock.last_dividend = value.get(LAST_DIVIDEND)
        new_stock.fixed_dividend = value.get(FIXED_DIVIDEND)
        new_stock.par_value = value.get(PAR_VALUE)
        new_stock.stock_type = value.get(STOCK_TYPE)
        stock_list.append(new_stock)
    return stock_list
Beispiel #4
0
def get_stock_by_symbol(stock_symbol):
    """

    :param stock_symbol:
    :return:
    """
    new_stock = None
    for key, value in STOCK_CONFIG.items():
        if stock_symbol == key:
            new_stock = Stock()
            new_stock.stock_symbol = key
            new_stock.last_dividend = value.get(LAST_DIVIDEND)
            new_stock.fixed_dividend = value.get(FIXED_DIVIDEND)
            new_stock.par_value = value.get(PAR_VALUE)
            new_stock.stock_type = value.get(STOCK_TYPE)
            break
    return new_stock
Beispiel #5
0
def getNYSEsymbols():
    try:
        with open('data/nysecompanylist.csv') as csvfile:
            csv_reader = csv.reader(csvfile, delimiter=',')
            line = 0
            for row in csv_reader:
                if line > 0:
                    Cache.stocks[row[0]]=Stock(symbol=row[0],
                        name=row[1],
                        lastsale=row[2],
                        marketcap=row[3],
                        ipoyear=row[4],
                        sector=row[5],
                        industry=row[6],
                        summary=row[7]
                          )

                line += 1
    except Exception as ex:
        logging.error(str(ex))
Beispiel #6
0
 def setUp(self):
     self.stock = Stock('TEA', 'Common', 3, '', 100)
     self.stock = Stock('GIN', 'Preferred', 8, '2%', 100)
Beispiel #7
0
 def test_stock(self):
     stock = Stock("Nokia")
     self.assertEqual("Nokia", stock.name)
 def search_stock(self, ticker_symbl):
     stock = Stock()
     stock.get_info(ticker_symbl)
     return stock
 def __get_current_price(self, ticker_symbl):
     stk = Stock()
     stk.get_info(ticker_symbl)
     return stk.current_price
Beispiel #10
0
 def __init__(self):
     self.stock = Stock(DEFAULT_TICKER)
     self.current_iteration = len(self.stock.price_history) + 1
     self.traders = []
     self.buy_orders = []
     self.sell_orders = []