def get_investment_settings(self): """ Display a series of prompts to get how the user wants to invest their available cash. This fills out the investing dictionary. """ # Minimum cash print '---------' print 'The auto investor will automatically try to invest ALL available cash into a diversified portfolio' while(True): self.investing['min_cash'] = util.prompt_int('What\'s the MINIMUM amount of cash you want to invest each round?', self.investing['min_cash']) if self.investing['min_cash'] < 25: print '\nYou cannot invest less than $25. Please try again.' else: break # Min/max percent print '---------' while(True): print 'When auto investing, the LendingClub API will search for diversified investment portfolios available at that moment.' print 'To pick the appropriate one for you, it needs to know what the minimum and maximum AVERAGE interest rate value you will accept.' print 'The investment option closest to the maximum value will be chosen and all your available cash will be invested in it.\n' self.investing['min_percent'] = util.prompt_float('What\'s MININUM average interest rate portfolio that you will accept?', self.investing['min_percent']) # Max percent should default to being larger than the min percent if self.investing['max_percent'] is False or self.investing['max_percent'] < self.investing['min_percent']: self.investing['max_percent'] = self.investing['min_percent'] + 1 self.investing['max_percent'] = util.prompt_float('What\'s MAXIMUM average interest rate portfolio that you will accept?', self.investing['max_percent']) # Validation if self.investing['max_percent'] < self.investing['min_percent']: print 'The maximum value must be larger than, or equal to, the minimum value. Please try again.' elif self.investing['max_percent'] == self.investing['min_percent']: print 'It\'s very uncommon to find an available portfolio that will match an exact percent.' if not util.prompt_yn('Would you like to specify a broader range?'): break else: break # Max per note print '---------' while(True): self.investing['max_per_note'] = util.prompt_int('How much are you willing to invest per loan note (max per note)?', self.investing['max_per_note']) if self.investing['max_per_note'] < 25: print 'You have to invest AT LEAST $25 per note.' self.investing['max_per_note'] = 25 else: break # Portfolio print '---------' folioOption = False if self.investing['portfolio']: # if saved settings has a portfolio set, default the prompt to 'Y' to choose folioOption = 'y' if util.prompt_yn('Do you want to put your new investments into a named portfolio?', folioOption): self.investing['portfolio'] = self.portfolio_picker(self.investing['portfolio']) else: self.investing['portfolio'] = False print '\n---------' # Advanced filter settings if util.prompt_yn('Would you like to set advanced filter settings?', self.investing['filters'] is not False): self.get_filter_settings() # Review summary self.confirm_settings() return True
def test_prompt_int_prefill(self): # User enters empty string, select prefill util.get_input = lambda msg: "" self.assertEqual(util.prompt_int("msg", 15), 15)
def test_prompt_int_prefill(self): # User enters empty string, select prefill util.get_input = lambda msg: '' self.assertEqual(util.prompt_int('msg', 15), 15)
def get_investment_settings(self): """ Display a series of prompts to get how the user wants to invest their available cash. This fills out the investing dictionary. """ # Minimum cash print('---------') print('The auto investor will automatically try to invest ALL available cash into a diversified portfolio') while(True): self.investing['min_cash'] = util.prompt_int('What\'s the MINIMUM amount of cash you want to invest each round?', self.investing['min_cash']) if self.investing['min_cash'] < 25: print('\nYou cannot invest less than $25. Please try again.') else: break # Min/max percent print('---------') while(True): print('When auto investing, the LendingClub API will search for diversified investment portfolios available at that moment.') print('To pick the appropriate one for you, it needs to know what the minimum and maximum AVERAGE interest rate value you will accept.') print('The investment option closest to the maximum value will be chosen and all your available cash will be invested in it.\n') self.investing['min_percent'] = util.prompt_float('What\'s MININUM average interest rate portfolio that you will accept?', self.investing['min_percent']) # Max percent should default to being larger than the min percent if self.investing['max_percent'] is False or self.investing['max_percent'] < self.investing['min_percent']: self.investing['max_percent'] = self.investing['min_percent'] + 1 self.investing['max_percent'] = util.prompt_float('What\'s MAXIMUM average interest rate portfolio that you will accept?', self.investing['max_percent']) # Validation if self.investing['max_percent'] < self.investing['min_percent']: print('The maximum value must be larger than, or equal to, the minimum value. Please try again.') elif self.investing['max_percent'] == self.investing['min_percent']: print('It\'s very uncommon to find an available portfolio that will match an exact percent.') if not util.prompt_yn('Would you like to specify a broader range?'): break else: break # Max per note print('---------') while(True): self.investing['max_per_note'] = util.prompt_int('How much are you willing to invest per loan note (max per note)?', self.investing['max_per_note']) if self.investing['max_per_note'] < 25: print('You have to invest AT LEAST $25 per note.') self.investing['max_per_note'] = 25 else: break # Portfolio print('---------') folioOption = False if self.investing['portfolio']: # if saved settings has a portfolio set, default the prompt to 'Y' to choose folioOption = 'y' if util.prompt_yn('Do you want to put your new investments into a named portfolio?', folioOption): self.investing['portfolio'] = self.portfolio_picker(self.investing['portfolio']) else: self.investing['portfolio'] = False print('\n---------') # Advanced filter settings if util.prompt_yn('Would you like to set advanced filter settings?', self.investing['filters'] is not False): self.get_filter_settings() # Review summary self.confirm_settings() return True