コード例 #1
0
def __evaluate_simulation_results(parameters, logdata_folder, graph_folder, generation_number, plot_name = None):
	assert logdata_folder, "Please specify where the logdata is located"
	data = empty_data_matrix(1)

	#ob_round_based = np.genfromtxt(logdata_folder + 'columnLog_roundBased_orderbook(0,0).csv', names=True, dtype=int, delimiter=',', usecols=(1,2))
	#stock_round_based = np.genfromtxt(logdata_folder + 'columnLog_roundBased_stock0.csv', names=True, dtype=int, delimiter=',', usecols=(0,1))
	trades = IO.load_trade_log_data(logdata_folder)

	

	
	fas = get_fundamental_after_shock()
	within_margin = get_number_of_rounds_within_stability_margin(trades['price'], trades['round'], fas)
	#data['n_simulation_rounds_within_stability_margin'] = within_margin['total_number_of_rounds']
	#data['n_seperate_intervals_within_stability_margin'] = within_margin['n_intervals']
	if 'longest_interval_within_margin' in data_for_failed_simulation.keys():
		data['longest_interval_within_margin'] = within_margin['longest_interval']
	if 'stdev' in data_for_failed_simulation.keys():
		data['stdev'] = get_tp_std_after_entering_margin(trades['price'], trades['round'])
	if 'overshoot' in data_for_failed_simulation.keys():
		data['overshoot'] = calculate_overshoot(fas, trades['price'], trades['round'])
	if 'time_to_reach_new_fundamental' in data_for_failed_simulation.keys():
		data['time_to_reach_new_fundamental'] = get_first_round_to_reach_new_fundamental(trades['price'], trades['round'])
	if 'round_stable' in data_for_failed_simulation.keys():
		data['round_stable'] = calculate_round_stable(trades['price'], trades['round'], fas)

	if np.random.random() <= PLOT_SAVE_PROB:
		data_id = 'gen%s_%s_%s'%(generation_number, get_epoch_time(), str(abs(hash(np.random.random()))))
		print graph_folder + data_id + '.npz'
		
		IO.save_tradeprice_data(trades['round'], trades['price'], data, parameters, graph_folder + data_id + '.npz')
		plotting.make_pretty_tradeprice_plot(trades['round'], trades['price'], graph_folder + data_id + '.png')
		#plotting.make_tradeprice_plot(trades['round'], trades['price'], data, parameters, graph_folder + data_id + '.png')
	else:
		data_id = None
		
	if not KEEP_SIMULATION_DATA: IO.delete_simulation_data(logdata_folder)
	return data, data_id