import sys
class Indicator:
name = None
gain = []
loss = []
avrgGain = 1
avrgLoss = 1
def __init__(self, name):
self.name = name;
def Std(self):
for i in range(14):
inp=(int(input("Input "+`i+1`+"th price: ")))
if (inp>=0):
self.gain.append(inp)
else:
self.loss.append(inp)
self.avrgGain = sum(self.gain)/len(self.gain) #TODO : it should be /14
self.avrgLoss = sum(self.loss)/len(self.loss) #TODO : it should be /14
def StdOut(self):
print "Gains:"
for i in range(len(self.gain)):
print self.gain[i]
print "Losses:"
for i in range(len(self.loss)):
print self.loss[i]
class RSI(Indicator):
RSI = 1
RS = 1
def __init__ (self, name):
Indicator.__init__(self, name)
def Evaluate(self):
self.RS = Indicator.avrgGain / Indicator.avrgLoss
self.RSI = 100 - (100/(1+self.RS))
# MAIN PART
test = RSI("NAME") #create
test.Std() #input
test.Evaluate() #evaluate
print "PRINT GAINS AND LOSES"
test.StdOut()
print "AVERAGE GAIN"
print test.avrgGain
print "AVERAGE LOSS"
print test.avrgLoss
print "PRINT RSI :"
print RSI.RSI
# WHAT WERE INPUTS (example is for 4, instead of 14). the code is for 14 now.
# Input 1th price: -10
# Input 2th price: -20
# Input 3th price: 60
# Input 4th price: 80
#WHAT WAS OUTPUTS
# PRINT GAINS AND LOSES
# Gains:
# 60
# 80
# Losses:
# -10
# -20
# AVERAGE GAIN
# 70
# AVERAGE LOSS
# -15
# PRINT RSI :
# 1