Exemple #1
0
    def test_timer_decorator(self):
        log_file = base_log_file + '_decorator'
        my_logging.prepare_logger(log_file)
        sleep(0.5)
        my_logging.shutdown()

        content = read_file(log_file + '_data.log')

        d = json.loads(content)
        self.assertAlmostEqual(0.5, d['value'], 1)
Exemple #2
0
    def test_timer_context_manager(self):
        log_file = base_log_file + '_context_manager'
        my_logging.prepare_logger(log_file)
        my_logging.shutdown()

        with time_measure('mykey2'):
            time.sleep(0.5)

        content = read_file(log_file + '_data.log')
        d = json.loads(content)
        self.assertAlmostEqual(0.5, d['value'], 1)
Exemple #3
0
    def test_data(self):
        log_file = default_log_file + '_data_test'
        my_logging.prepare_logger(log_file)
        my_logging.data('key', 2)
        my_logging.info('ABCD')
        my_logging.shutdown()

        # check
        content = read_file(log_file + '_data.log')
        d = json.loads(content)
        self.assertEqual(d['key'], 'key')
        self.assertEqual(d['value'], 2)
        self.assertTrue('ABCD' not in content)
Exemple #4
0
    def test_logger(self):
        # ignore warnings
        warnings.simplefilter("ignore")

        # log something
        log_file = default_log_file + '_basic_test'
        my_logging.prepare_logger(log_file)
        my_logging.info("ABCD")
        my_logging.shutdown()

        # check logfile
        success = 'ABCD' in read_file(log_file + '_info.log')
        self.assertTrue(success)
Exemple #5
0
def main():

    # if datetime.date.today().day not in [1, 8, 15, 22, 29]:
    #     return 0

    # Stock Import
    log_file_path = \
        os.path.join('/Users/hmaupard/Documents/FinancialData/US/Equities/Logs/',
                     datetime.date.today().isoformat()+"-YahooImport.txt")
    my_logging.initialize_logging(log_file_path)

    start_date = datetime.date(2005, 1, 1)
    end_date = datetime.date.today()
    stock_universe = \
        my_tools.read_csv_all_lines('/Users/hmaupard/Documents/FinancialData/US/Equities/Universes/SPY.csv') + \
        my_tools.read_csv_all_lines('/Users/hmaupard/Documents/FinancialData/US/Equities/Universes/MDY.csv') + \
        my_tools.read_csv_all_lines('/Users/hmaupard/Documents/FinancialData/US/Equities/Universes/IWV.csv') + \
        my_tools.read_csv_all_lines('/Users/hmaupard/Documents/FinancialData/US/Equities/Universes/QQQ.csv')
    stock_universe = sorted(list(set(stock_universe)))

    import_directory = '/Users/hmaupard/Documents/FinancialData/US/Equities/Yahoo/'
    yahoo_div_and_split_import.retrieve_and_store_split_and_div(
        stock_universe, start_date, end_date, import_directory)

    my_logging.shutdown()

    # ETFs import
    log_file_path = \
        os.path.join('/Users/hmaupard/Documents/FinancialData/US/ETFs/Logs/',
                     datetime.date.today().isoformat()+"-YahooImport.txt")
    my_logging.initialize_logging(log_file_path)

    start_date = datetime.date(2005, 1, 1)
    end_date = datetime.date.today()
    etf_universe = sorted(
        list(
            set(
                my_tools.read_csv_all_lines(
                    '/Users/hmaupard/Documents/FinancialData/US/ETFs/Universes/ETFUniverse.csv'
                ))))

    import_directory = '/Users/hmaupard/Documents/FinancialData/US/ETFs/Yahoo/'
    yahoo_div_and_split_import.retrieve_and_store_split_and_div(
        etf_universe, start_date, end_date, import_directory)

    return 0