コード例 #1
0
def automate():
	number_of_zipped_files = len(get_all_files_in_directory(zipped_data_path))
	number_of_raw_files = len(get_all_files_in_directory(raw_data_path))
	number_of_filtered_files = len(get_all_files_in_directory(filtered_data_path))
	number_of_individual_files = len(get_all_files_in_directory(individual_data_path))

	if number_of_zipped_files == 0:
		logger.raise_exception('There are no .zip files to work with.', logger.LogicError)

	if number_of_raw_files == 0:
		extract_zip_files()

	if number_of_filtered_files == 0:
		filter_the_stock_files(raw_data_path, filtered_data_path)

	if number_of_individual_files == 0:
		combined_data_frame = load_all_stock_files()

		all_unique_names = combined_data_frame.symbol.values

		timer = Timer()

		for n in all_unique_names:
			timer.start_timer()
			local_data_frame = combined_data_frame[combined_data_frame.symbol == n]

			if len(local_data_frame) != 0:
				local_stock_path = str(str(individual_data_path) + n + '.csv')
				if not os.path.isfile(local_stock_path):
					local_data_frame.drop(local_data_frame.columns[0], axis=1, inplace=True)
					local_data_frame['date'] = pd.to_datetime(local_data_frame['date'])
					local_data_frame = local_data_frame.sort_values(by='date')
					create_csv_file(local_data_frame, local_stock_path)

			print('Length of local data frame: ' + str(len(local_data_frame)) + '\tLength of combined data: ' + str(len(combined_data_frame)))

			combined_data_frame = combined_data_frame[combined_data_frame.symbol != n]

			timer.end_timer()
			timer.print_time()
コード例 #2
0
def code_to_test_01():
    my_list = []
    my_set = set()

    for x in range(10000):
        my_list.append(x)
        my_set.add(x)

    timer = Timer()
    timer.start_timer()
    z = 0
    for y in range(10000):
        if my_list.__contains__(y):
            z += y
    timer.end_timer()
    timer.print_time()

    timer.start_timer()
    z = 0
    for y in range(10000):
        if my_set.__contains__(y):
            z += y
    timer.end_timer()
    timer.print_time()
コード例 #3
0
ファイル: carico.py プロジェクト: utarsuno/GenericProject
for un in list_of_all_unique_names:
    print(un)
logger.log('Finished seperating all the data_xv for individual stocks.')

exit(0)




'''

logger.log('There are: ' + str(len(list_of_all_unique_names)) + ' unique stocks.')

all_earnings = []

timer = Timer()
inner_timer = Timer()
logger.log('Starting the timer for the math code.')
timer.start_timer()
index = 0

bad_stocks = []


def perform_splits_on_stock(sl, data_frame):
	for s in sl:
		split_date = s.get_date()
		split_date = pd.to_datetime(split_date)
		data_frame.ix[data_frame.date <= split_date, 'open'] *= s.get_multiplier()
		data_frame.ix[data_frame.date <= split_date, 'high'] *= s.get_multiplier()
		data_frame.ix[data_frame.date <= split_date, 'low'] *= s.get_multiplier()