def ontrial(self, model, simulation, trial, value, engine, args):
        '''
            want to test some strategies for betting
            set wager for each bet
            if previous bet

            value : float
                sample from model
            
        '''
                     
	   
        # if we lost last time then double up		
		
        if self.previous_value == -1:
		if args.has_key('args'):
                	self.wager = (self.wager*float(args['args']['wager_multiplier'][0]))
		else:
			self.wager = (self.wager*0.1)      
        
        # keep track of coin toss paths
        self.r[simulation,trial] = self.r[simulation,trial-1] + value
        if args.has_key('args'):
            self.r0 = float(args['args']['wager_multiplier'][0])
        else:
			self.r0 =0.1
        # if we won, add the wager
        # else subtract the wager
        
        if self.pnl[simulation,trial-1] > 0:        
            if value == 1 :
                self.pnl[simulation,trial] = self.pnl[simulation,trial-1] + self.wager
            else:
                self.pnl[simulation,trial] = self.pnl[simulation,trial-1] - self.wager
        else:
            # no bet to be made here
            self.pnl[simulation,trial] = self.pnl[simulation,trial-1]
             
        # always reset wager    
        self.reset_wager()
        
        # keep track of the previous value for next time around
        self.previous_value = value
        
	def add_prefix(self, filename):
		from hashlib import md5
		from time import localtime
		return "%s_%s"%(md5(str(localtime())).hexdigest(), filename)

            want to test some strategies for betting
            set wager for each bet
            if previous bet

            value : float
                sample from model
            
        
recipes/Python/578869_Monte_Carlo_Engine__How_find_optimised_wager/recipe-578869.py