Fixed function using the wrong dictionary on iteration

This commit is contained in:
TiagoRG 2022-11-14 10:09:40 +00:00
parent 2eed0e4776
commit 331f62f9bd
Signed by untrusted user who does not match committer: TiagoRG
GPG Key ID: DFCD48E3F420DB42
1 changed files with 5 additions and 6 deletions

View File

@ -1,6 +1,5 @@
import re
# Constantes para indexar os tuplos:
NAME, DATE, OPEN, MAX, MIN, CLOSE, VOLUME = 0, 1, 2, 3, 4, 5, 6
@ -33,7 +32,7 @@ def loadStockFile(filename):
name = parts[NAME]
date = parts[DATE]
tup = (name, date, float(parts[OPEN]), float(parts[MAX]),
float(parts[MIN]), float(parts[CLOSE]), int(parts[VOLUME]))
float(parts[MIN]), float(parts[CLOSE]), int(parts[VOLUME]))
lst.append(tup)
return lst
@ -41,7 +40,7 @@ def loadStockFile(filename):
def totalVolume(lst):
totVol = {}
# Complete ...
for tup in totVol:
for tup in lst:
if tup[NAME] not in totVol:
totVol[tup[NAME]] = tup[VOLUME]
else:
@ -62,7 +61,7 @@ def maxValorization(lst):
if re.match(pat, dia):
dia = dia[1]
if data == int(dia):
maxcomp = tup[OPEN]/tup[CLOSE] * 100
maxcomp = tup[OPEN] / tup[CLOSE] * 100
if maxcomp > maxDiario:
maxDiario = maxcomp
maxDiarioComp = tup[NAME]