-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
101 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from operacao import Operacao | ||
from decimal import Decimal | ||
|
||
def toOperacao(tuple): | ||
return Operacao(tuple[0], tuple[1], tuple[2], tuple[3], tuple[4], tuple[5], tuple[6]) | ||
|
||
def toDateYMD(dataDMY): | ||
a = str(dataDMY).split('/') | ||
y = a[2] | ||
m = a[1] | ||
d = a[0] | ||
return y + '-' + m + '-' + d | ||
|
||
def toDecimal(str): | ||
if (',' in str and '.' in str): | ||
raise Exception("Número inválido: [" + str + "]. Use vírgula para decimais.") | ||
str = str.replace(',', '.') | ||
return Decimal(str) | ||
|
||
#print(toDateYMD("23/01/2021")) | ||
#print(toNumber("1.024,68")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from database import Database | ||
import converters | ||
|
||
class RN: | ||
|
||
db = None | ||
|
||
def __init__(self, operacoes): | ||
self.db = Database() | ||
for o in operacoes: | ||
self.db.add(o) | ||
|
||
def precoMedio(self, ticker, cv): | ||
db = self.db | ||
l = db.listarPorTicker(ticker) | ||
|
||
somatorio = 0 | ||
|
||
for o in l: | ||
if (o.isCompra() and cv.upper() == 'C'): | ||
somatorio += converters.toDecimal(o.preco) | ||
print(o) | ||
elif (o.isVenda() and cv.upper() == 'V'): | ||
somatorio += converters.toDecimal(o.preco) | ||
print(o) | ||
|
||
return round(somatorio / l.__len__(), 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
# um comentário | ||
|
||
01/02/2021 C 25 B3SA3 50,00 # Clear | ||
01/03/2021 C 25 B3SA3 51,00 # Clear | ||
17/03/2021 C 50 B3SA3 52,68 # Clear | ||
18/03/2021 V 100 LEVE3 19,24 # Mirae | ||
|
||
18/03/2021 V 100 LEVE3 19,24 # Mirae |