-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest2.py
More file actions
85 lines (66 loc) · 2.32 KB
/
test2.py
File metadata and controls
85 lines (66 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import csv
import numpy
import random
def parseMicrosoft():
with open('microsoft-DataAnalysis.csv', 'r') as csvfile:
newArray = []
readCSV = csv.reader(csvfile)
header = next(readCSV)
for row in readCSV:
newArray.append(row[7])
return newArray
def parseMicrosoftAdjClose():
with open('microsoft-DataAnalysis.csv', 'r') as csvfile:
newArray = []
readCSV = csv.reader(csvfile)
header = next(readCSV)
for row in readCSV:
newArray.append(row[5])
return newArray
def parseAmazon():
with open('amazon-DataAnalysis.csv', 'r') as csvfile:
newArray = []
readCSV = csv.reader(csvfile)
header = next(readCSV)
for row in readCSV:
newArray.append(row[7])
return newArray
def parseAmazonAdjClose():
with open('amazon-DataAnalysis.csv', 'r') as csvfile:
newArray = []
readCSV = csv.reader(csvfile)
header = next(readCSV)
for row in readCSV:
newArray.append(row[5])
return newArray
def meanStdAdjFirstValCalculator(funcCompanies, adjClose, datapoints, investment):
if (funcCompanies == 'microsoft'):
a = parseMicrosoft()
if (funcCompanies == 'amazon'):
a = parseAmazon()
if (adjClose == 'microsoft'):
b = parseMicrosoftAdjClose()
if (adjClose == 'amazon'):
b = parseAmazonAdjClose()
unsortedRS = a
unsortedRS = unsortedRS[0:datapoints]
for i in range(1, datapoints, datapoints):
floatURS = [float(i) for i in unsortedRS]
sortRS = sorted(floatURS)
totalCount = len(sortRS)
totalSum = sum(sortRS)
mean = totalSum / totalCount
print(mean)
standardDeviation = numpy.std(sortRS)
print(standardDeviation)
adjCloseVal = b
for i in range(1, datapoints, datapoints):
adjCloseValFloat = [float(i) for i in adjCloseVal]
adjCloseFirstVal = adjCloseValFloat[0]
print(adjCloseFirstVal)
def calcMonte(funcCompanies, datapoints, investment):
if (funcCompanies == 'microsoft'):
mean, standardDeviation, adjCloseFirstVal = meanStdAdjFirstValCalculator()
print(mean, standardDeviation, adjCloseFirstVal)
calcMonte(parseMicrosoft(), 10, 1)
meanStdAdjFirstValCalculator(parseMicrosoft(), parseMicrosoftAdjClose(), 10, 1)