コード例 #1
0
 def test_init(self):
     '''
     test the initialization of investment class, ie. the assignment of position and num_trials
     '''
     self.assertEqual(
         Investment.investment([1, 10, 100, 1000], 100).positions,
         [1, 10, 100, 1000])
     self.assertEqual(
         Investment.investment([1, 10, 100, 1000], 100).num_trials, 100)
コード例 #2
0
ファイル: UnitTest.py プロジェクト: ds-ga-1007/assignment8
 def test_investment_return(self):
     '''
     test the investment return (daily) calculation function
     '''
     investment=Investment.investment(10,1000)
     daily_return=investment.investment_return(10)
     self.assertEqual(len(daily_return),1000)
     self.assertGreaterEqual(daily_return.all(), -1)
     self.assertLessEqual(daily_return.all(), 1)
コード例 #3
0
 def test_investment_return(self):
     '''
     test the investment return (daily) calculation function
     '''
     investment = Investment.investment(10, 1000)
     daily_return = investment.investment_return(10)
     self.assertEqual(len(daily_return), 1000)
     self.assertGreaterEqual(daily_return.all(), -1)
     self.assertLessEqual(daily_return.all(), 1)
コード例 #4
0
ファイル: UnitTest.py プロジェクト: ds-ga-1007/assignment8
 def test_init(self):
     '''
     test the initialization of investment class, ie. the assignment of position and num_trials
     '''
     self.assertEqual(Investment.investment([1,10,100,1000],100).positions,[1,10,100,1000])
     self.assertEqual(Investment.investment([1,10,100,1000],100).num_trials,100)
コード例 #5
0
ファイル: assignment8.py プロジェクト: ds-ga-1007/assignment8
                    'Invalid Input: all numbers of shares need to be positive')
            break
        except ValueError as msg:
            print(msg)
        except KeyboardInterrupt:
            print('Keyboard Interruption')
            sys.exit()
        except EOFError:
            print('EOFError')
            sys.exit()

    while True:
        try:
            inputstr2 = input(
                'Please enter the number of times you want to repeat the simulation'
            )
            if (inputstr2 == 'quit'):
                print("User Directed Quit.")
                sys.exit()
            num_trials = int(inputstr2)
            Investment.investment(positions, num_trials).simulation()
            break
        except ValueError as msg:
            print(msg)
        except KeyboardInterrupt:
            print('Keyboard Interruption')
            sys.exit()
        except EOFError:
            print('EOFError')
            sys.exit()