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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
from serenitas.analytics.dates import prev_business_day
from serenitas.utils.exchange import ExchangeMessage
import logging
import argparse
import datetime
from .sma import (
IsoselSMA,
BowdstSMA,
PositionReport,
BondPosition,
FuturePosition,
TranchePosition,
CDXPosition,
IRSwaptionPosition,
CDXSwaptionPosition,
)
from .cash import NTCashReport, UMBCashReport, BNYCashReport
from .admin import AccruedReport, AllReport
from .wires import BowdstWire, NTWire
from .custodians import upload_to_custodian
from serenitas.utils.remote import Client
logger = logging.getLogger(__name__)
parser = argparse.ArgumentParser()
parser.add_argument(
"-s",
"--sma_positions",
action="store_true",
help="upload sma positions to hedgemark",
)
parser.add_argument(
"-c", "--cash_reports", action="store_true", help="process cash reports to database"
)
parser.add_argument(
"-i",
"--isosel_reports",
action="store_true",
help="download isosel reports to database",
)
parser.add_argument(
"-w", "--wire_reports", action="store_true", help="download wires to db"
)
parser.add_argument(
"-sc",
"--send_to_custodians",
action="store_true",
help="upload trade files to notify custodians",
)
parser.add_argument(
"-n", "--no-upload", action="store_true", help="do not upload, just create files"
)
parser.add_argument(
"date",
nargs="?",
type=datetime.date.fromisoformat,
default=datetime.date.today(),
)
args = parser.parse_args()
cob = date = prev_business_day(args.date)
if args.sma_positions:
for sma_cls in (
IsoselSMA,
BowdstSMA,
):
sma = sma_cls(cob)
try:
sma.email_positions()
except ValueError as e:
logger.warning(e)
if args.cash_reports:
for report_cls in (
NTCashReport,
UMBCashReport,
BNYCashReport,
):
report = report_cls(args.date)
try:
report.to_db()
except ValueError as e:
logger.warning(e)
if args.isosel_reports:
for report_cls in (
AccruedReport,
AllReport,
):
try:
report_cls.to_db(cob)
except ValueError as e:
logger.info(e)
if args.wire_reports:
for wire_report in (BowdstWire, NTWire):
try:
wire_report.to_db(args.date)
except ValueError as e:
logger.info(e)
if args.send_to_custodians:
em = ExchangeMessage()
for account in (
"BBH",
"UMB",
):
try:
upload_to_custodian(account, args.date, not args.no_upload, em)
except ValueError as e:
logger.info(e)
|