-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaster_long.py
More file actions
87 lines (75 loc) · 2.38 KB
/
aster_long.py
File metadata and controls
87 lines (75 loc) · 2.38 KB
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
"""Captor Aster Global Credit attribution analysis module."""
from openseries import (
OpenFrame,
OpenTimeSeries,
get_previous_business_day_before_today,
report_html,
)
from attribution import (
attribution_area,
attribution_waterfall,
compute_grouped_attribution_with_cumulative,
get_party_name,
get_performance,
get_timeserie,
)
from graphql_client import GraphqlClient
if __name__ == "__main__":
gql_client = GraphqlClient()
fund_id = "605b2e5cc34cf5001154c90d"
fund_name = get_party_name(graphql=gql_client, party_id=fund_id)
start = None
end = get_previous_business_day_before_today()
perfdata = get_performance(
graphql=gql_client, client_id=fund_id, start_dt=start, end_dt=end
)
_, cumperf, totserie, baseccy = compute_grouped_attribution_with_cumulative(
data=perfdata,
group_by="modelType",
group_values=["CdsIndex"],
method="simple",
)
navserie = OpenTimeSeries.from_arrays(
name=fund_name,
dates=[item["date"] for item in totserie],
values=[item["value"] for item in totserie],
baseccy=baseccy,
)
frame = OpenFrame(
constituents=[
OpenTimeSeries.from_arrays(
name=key,
dates=[item["date"] for item in value],
values=[item["value"] for item in value],
baseccy=baseccy,
)
for key, value in cumperf.items()
]
)
frame.tsdf = frame.tsdf.add(1.0)
_, _ = attribution_area(
data=frame,
series=navserie,
title=fund_name,
tick_fmt=".3%",
filename=f"{fund_name.replace(' ', '').replace('-', '')}_area",
)
_, _ = attribution_waterfall(
data=frame,
title=fund_name,
filename=f"{fund_name.replace(' ', '').replace('-', '')}_waterfall",
)
compare_id = "6391a977e6a359fc24e82ba4"
compare_name = "1.4 x Bloomberg Global Agg Corp hedged SEK"
compareserie = get_timeserie(
graphql=gql_client, timeseries_id=compare_id, name=compare_name
)
compare = OpenFrame(constituents=[navserie, compareserie])
compare.trunc_frame()
report_html(
data=compare,
bar_freq="BQE",
title="Captor Aster Global Credit",
filename=f"{fund_name.replace(' ', '').replace('-', '')}_report.html",
auto_open=True,
)