Example #1
0
		data_frame.ix[data_frame.date <= split_date, 'low'] *= s.get_multiplier()
		data_frame.ix[data_frame.date <= split_date, 'close'] *= s.get_multiplier()
	return data_frame

for un in list_of_all_unique_names:

    inner_timer.start_timer()
    print('Processing stock index: ' + str(index) + ' out of ' + str(len(list_of_all_unique_names)) + '\tLength of all data: ' + str(len(all_data)))
    index += 1

    single_data_frame = all_data[all_data.symbol == un]

    single_data_frame['date'] = pd.to_datetime(single_data_frame['date'])
    single_data_frame = single_data_frame.sort_values(by='date')

    split_list = splits.get_splits_for_stock(un.replace('&', '').replace('.csv', ''))

    if len(split_list) != 0:
    	single_data_frame = perform_splits_on_stock(split_list, single_data_frame)

    inner_earnings = simulation.run_simulation_for_single_stock(single_data_frame)
    if inner_earnings.made_trades():
        all_earnings.append(inner_earnings)
    else:
        bad_stocks.append(un)

    # We are finished using the information for that particular stock so we will remove it from the combined data_xv frame.
    all_data = all_data[all_data.symbol != un]

    inner_timer.end_timer()
    inner_timer.print_time()
Example #2
0
timer = Timer()

#gc.disable()

for single_stock in dm.get_all_files_in_directory(dm.individual_data_path):

	timer.start_timer()

	single_stock_path = dm.individual_data_path + single_stock
	print(single_stock_path)
	df = pd.read_csv(single_stock_path, header=None, usecols=[0, 1, 2, 3, 4])
	df.columns = ['date', 'open', 'high', 'low', 'close']

	df['date'] = pd.to_datetime(df['date'])

	split_list = splits.get_splits_for_stock(single_stock.replace('&', '').replace('.csv', ''))
	if len(split_list) != 0:
		df = perform_splits_on_stock(split_list, df)

	profits.append(sim.run_simple_simulation_for_single_stock(single_stock, df))

	timer.end_timer()
	timer.print_time()

#gc.enable()

profits.sort(key=lambda x: x.total_profit, reverse=False)

for p in profits:
	print(p)