def simulation(self): """This function will perform the simulation process with several trials.""" for pos in self.positions: p = Position(pos) cumu_ret = np.zeros(self.num_trials) daily_ret = np.zeros(self.num_trials) for trial in range(self.num_trials): #Get a daily return value cumu_ret[trial] = p.invest() #convert return value to return ratio daily_ret[trial] = (cumu_ret[trial] / 1000.0) - 1 self.trials.append(daily_ret)
def test_invest(self): p = Position(10) self.assertTrue(p.invest() <= 2000) self.assertTrue(p.invest() >= 0)