-
Notifications
You must be signed in to change notification settings - Fork 0
/
statusInvest.py
51 lines (42 loc) · 1.47 KB
/
statusInvest.py
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
import json
from datetime import datetime
import pandas as pd
from collections import namedtuple
from FinanceTools import *
import numpy as np
import sys
class StatusInvest:
def __init__(self, inFile):
self.orders = pd.read_csv(inFile)
self.orders["Category"] = self.orders["Category"].apply(lambda x: "Ações" if x == "Stock" else "FII's")
self.orders["Type"] = self.orders["Type"].apply(lambda x: "C" if x == "Compra" else "V")
self.orders["Date"] = pd.to_datetime(self.orders["Date"]).dt.strftime("%d/%m/%Y")
self.orders["Corretora"] = "Clear"
self.orders["Corretagem"] = 0
self.orders["Impostos"] = 0
self.orders["IRRF"] = 0
self.orders = self.orders[
["Date", "Category", "Paper", "Type", "Qty", "Value", "Corretora", "Corretagem", "Fee", "Impostos", "IRRF"]
]
self.orders.columns = [
"Data operação",
"Categoria",
"Código Ativo",
"Operação C/V",
"Quantidade",
"Preço unitário",
"Corretora",
"Corretagem",
"Taxas",
"Impostos",
"IRRF",
]
def Dataframe(self):
return self.orders
def Convert(inFile="orders.csv", outFile="orders.csv"):
si = StatusInvest(inFile)
si.Dataframe().to_excel(outFile, index=False)
if __name__ == "__main__":
inFile = str(sys.argv[1])
outFile = str(sys.argv[2])
Convert(inFile, outFile)