예제 #1
0
def load_all_stock_files():

	logger.log('Loading all the stock files.')
	all_data_frames = []

	for file_name in get_all_files_in_directory(filtered_data_path):
		if file_name[0] == 's' or file_name[0] == 'S':

			logger.log(file_name)

			current_data_frame = pd.read_csv(filtered_data_path + file_name, header=None, usecols=[0, 1, 2, 3, 4, 5])
			current_data_frame.columns = ['symbol', 'date', 'open', 'high', 'low', 'close']

			'''The bottom 2 are now done through the filters.

			# Remove all rows that have a volume of zero.
			current_data_frame = current_data_frame[current_data_frame.volume != 0]

			# Drop the volume column. It is only needed for the filter.
			current_data_frame = current_data_frame.drop('volume', axis=1)

			# Remove all rows that have an open that is less than 10.0.
			current_data_frame = current_data_frame[current_data_frame.open > 10.0]

			'''

			all_data_frames.append(current_data_frame)

	logger.log('Finished loading all the stock files.')

	logger.log('Combining all the stock data.')
	combined_data_frame = pd.concat(all_data_frames, axis=0, ignore_index=True)
	logger.log('Finished combining all the stock data.')
	print(len(combined_data_frame))
	return combined_data_frame
예제 #2
0
list_of_all_unique_names = combined_data_frame.symbol.unique()

#for stock_name in list_of_all_unique_stock_names:
#    local_data_frame = combined_data_frame[combined_data_frame.symbol == stock_name]
#    print(str(len(local_data_frame)) + stock_name)

single_data_frame['date'] = pd.to_datetime(single_data_frame['date'])
single_data_frame.sort('date')
print(single_data_frame)
'''

logger.enable_logging()
logger.enable_time_stamp()

all_data = data_manager.load_all_stock_files()
logger.log('All data_xv is merged and ready to use.')

logger.log('Seperating the data_xv for individual stocks.')
list_of_all_unique_names = all_data.symbol.unique()

'''
DataFrameDict = {elem : pd.DataFrame for elem in list_of_all_unique_names}

for key in DataFrameDict.keys():
    DataFrameDict[key] = all_data[:][all_data.symbol == key]

for un in list_of_all_unique_names:
    print(un)
logger.log('Finished seperating all the data_xv for individual stocks.')

exit(0)