def main():
    inputPositions = input('Please give a list of shares that you would like to buy. The input can be something like [1, 10, 100, 1000]. Type in \'quit\' to quit the program.\n')
    if inputPositions == 'quit':
        return
    # check 1st input string
    checkInput(inputPositions)
    # convert 1st input string to a list
    inputStrSplit = inputPositions[1:-1].strip().split(',')
    shares_list = []
    for share in inputStrSplit:
        shares_list.append(int(share))

    # check 2nd input string
    num_trails = input('Please give a number of trails that you would like to simulate. For example, 10000.Type in \'quit\' to quit the program.\n')
    if num_trails == 'quit':
        return

    # run Investment class
    print('Calculating...')
    inv = Investment(shares_list, int(num_trails))
    inv.calcPositionValue()
    inv.calcCumulativeReturn()
    inv.calcDailyReturn()
    inv.calcDailyReturnMean()
    inv.calcDailyReturnStd()
    inv.saveResults()
    print('Done. Results are saved.')
 def calcCumulativeReturn(self):
     inv = Investment('[1, 10, 100, 1000]', 100, 17)
     inv.setSeed()
     inv.calcPositionValue()
     inv.calcCumulativeReturn()
     inv.calcDailyReturn()
     inv.calcDailyReturnMean()
     self.assertEqual(np.round(inv.daily_mean, 4), np.array([0.1, 0.024, 0.0212, 0.0177]))
Exemple #3
0
 def calcCumulativeReturn(self):
     inv = Investment('[1, 10, 100, 1000]', 100, 17)
     inv.setSeed()
     inv.calcPositionValue()
     inv.calcCumulativeReturn()
     inv.calcDailyReturn()
     inv.calcDailyReturnMean()
     self.assertEqual(np.round(inv.daily_mean, 4),
                      np.array([0.1, 0.024, 0.0212, 0.0177]))
 def calcCumulativeReturn(self):
     inv = Investment('[1, 10, 100, 1000]', 100, 17)
     inv.setSeed()
     inv.calcPositionValue()
     inv.calcCumulativeReturn()
     inv.calcDailyReturn()
     inv.calcDailyReturnMean()
     inv.calcDailyReturnStd()
     self.assertEqual(inv.daily_std, np.array([0.995 , 0.3829, 0.1005, 0.0346]))
Exemple #5
0
 def calcCumulativeReturn(self):
     inv = Investment('[1, 10, 100, 1000]', 100, 17)
     inv.setSeed()
     inv.calcPositionValue()
     inv.calcCumulativeReturn()
     inv.calcDailyReturn()
     inv.calcDailyReturnMean()
     inv.calcDailyReturnStd()
     self.assertEqual(inv.daily_std,
                      np.array([0.995, 0.3829, 0.1005, 0.0346]))
Exemple #6
0
 def calcPositionValue(self):
     inv = Investment('[1, 10, 100, 1000]', 100, 17)
     inv.setSeed()
     inv.calcPositionValue()
     self.assertEqual(inv.position_value, np.array([1000, 100, 10, 1]))
 def calcPositionValue(self):
     inv = Investment('[1, 10, 100, 1000]', 100, 17)
     inv.setSeed()
     inv.calcPositionValue()
     self.assertEqual(inv.position_value, np.array([1000, 100, 10, 1]))