Ejemplo n.º 1
0
def main_program(positions_input, number_of_simulations):
    """This is the main program that takes the clean inputs and calls the investment_instrument class.
    The program iterates through each investment position and outputs a histogram and mean/std stats. 
    """
    print("Please WAIT! The program is calculating daily returns for your inputted scenarios. This may take a while.")
    
    # this is the file where the stats results will be saved
    file = open("results.txt", "w")
    file.close()
    for i in positions_input:
        # for each position, define daily_return using the class to "fix" simulated results so that
        # the histogram and stats are produced using the same daily return values
        daily_ret = investment_instrument(i,number_of_simulations).generate_daily_returns()
        investment_instrument(i,number_of_simulations).histogram(daily_ret)
        investment_instrument(i,number_of_simulations).summary_stats(daily_ret)        
Ejemplo n.º 2
0
def main_program(positions_input, number_of_simulations):
    """This is the main program that takes the clean inputs and calls the investment_instrument class.
    The program iterates through each investment position and outputs a histogram and mean/std stats. 
    """
    print(
        "Please WAIT! The program is calculating daily returns for your inputted scenarios. This may take a while."
    )

    # this is the file where the stats results will be saved
    file = open("results.txt", "w")
    file.close()
    for i in positions_input:
        # for each position, define daily_return using the class to "fix" simulated results so that
        # the histogram and stats are produced using the same daily return values
        daily_ret = investment_instrument(
            i, number_of_simulations).generate_daily_returns()
        investment_instrument(i, number_of_simulations).histogram(daily_ret)
        investment_instrument(i,
                              number_of_simulations).summary_stats(daily_ret)
Ejemplo n.º 3
0
			valid_positions = ['1','10','100','1000']
			if positions in valid_positions:
				positions = int(positions)
				positions_check = 1
			else:
				print "Sorry, I didn't understand.  Please type 1, 10, 100, or 1000 as you input."

		num_trials_check = 0
		while num_trials_check == 0:
        		num_trials = raw_input("How many times would you like to repeat the test?")
        		valid_num_trials = range(10001)
			del valid_num_trials[0]
			valid_num_trials = map(str,valid_num_trials)
        		if num_trials in valid_num_trials:
                		num_trials = int(num_trials)
                		num_trials_check = 1
        		else:
                		print "Sorry, I didn't understand.  Please type a number between 1 and 10,000 as you input."

		invest = investment_instrument(positions,num_trials)
		invest.mean_n_std()
		invest.plot_hist()

	except KeyboardInterrupt:
		print "\nProgram ended by user."
		sys.exit(1)

	except ValueError:
		print "\nError with input format."