forked from guilhermecgs/ir
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ir.py
78 lines (54 loc) · 2.02 KB
/
ir.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
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
import argparse
import os
import sys
import pandas as pd
from src.calculo_ir import CalculoIr
from src.dropbox_files import upload_dropbox_file, OPERATIONS_FILEPATH
from src.envia_relatorio_por_email import envia_relatorio_html_por_email
from src.relatorio import relatorio_txt, relatorio_html, assunto
from src.stuff import get_operations, \
merge_operacoes, \
df_to_csv
def main(raw_args):
parser = argparse.ArgumentParser()
parser.add_argument('--do', required=False)
args = parser.parse_args(raw_args)
pd.set_option('display.max_columns', None)
pd.set_option('display.width', 200)
if args.do == 'busca_trades_e_faz_merge_operacoes':
do_busca_trades_e_faz_merge_operacoes()
return
if args.do == 'check_environment_variables':
do_check_environment_variables()
return
if args.do == 'calculo_ir':
do_calculo_ir()
return
do_busca_trades_e_faz_merge_operacoes()
do_calculo_ir()
def do_busca_trades_e_faz_merge_operacoes():
from src.crawler_cei import CrawlerCei
crawler_cei = CrawlerCei(headless=True)
df_cei = crawler_cei.busca_trades()
from src.dropbox_files import download_dropbox_file
download_dropbox_file()
df = get_operations()
df = merge_operacoes(df, df_cei)
df_to_csv(df, OPERATIONS_FILEPATH)
upload_dropbox_file(OPERATIONS_FILEPATH, os.environ['DROPBOX_FILE_LOCATION'])
def do_check_environment_variables():
from tests.test_environment_variables import TestEnvironmentVariables
TestEnvironmentVariables().test_environment_variables()
def do_calculo_ir():
from src.dropbox_files import download_dropbox_file
download_dropbox_file()
df = get_operations()
from src.stuff import calcula_custodia
calcula_custodia(df)
calculo_ir = CalculoIr(df=df)
calculo_ir.calcula()
print(relatorio_txt(calculo_ir))
envia_relatorio_html_por_email(assunto(calculo_ir),
relatorio_html(calculo_ir))
if __name__ == "__main__":
main(sys.argv[1:])