finbourne-sdk-utils 0.0.24__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- features/__init__.py +0 -0
- features/main.py +11 -0
- finbourne_sdk_utils/__init__.py +8 -0
- finbourne_sdk_utils/cocoon/__init__.py +34 -0
- finbourne_sdk_utils/cocoon/async_tools.py +94 -0
- finbourne_sdk_utils/cocoon/cocoon.py +1862 -0
- finbourne_sdk_utils/cocoon/cocoon_printer.py +455 -0
- finbourne_sdk_utils/cocoon/config/domain_settings.json +125 -0
- finbourne_sdk_utils/cocoon/config/seed_sample_data.json +36 -0
- finbourne_sdk_utils/cocoon/dateorcutlabel.py +198 -0
- finbourne_sdk_utils/cocoon/instruments.py +482 -0
- finbourne_sdk_utils/cocoon/properties.py +442 -0
- finbourne_sdk_utils/cocoon/seed_sample_data.py +137 -0
- finbourne_sdk_utils/cocoon/systemConfiguration.py +92 -0
- finbourne_sdk_utils/cocoon/transaction_type_upload.py +136 -0
- finbourne_sdk_utils/cocoon/utilities.py +1877 -0
- finbourne_sdk_utils/cocoon/validator.py +243 -0
- finbourne_sdk_utils/extract/__init__.py +1 -0
- finbourne_sdk_utils/extract/group_holdings.py +400 -0
- finbourne_sdk_utils/iam/__init__.py +1 -0
- finbourne_sdk_utils/iam/roles.py +74 -0
- finbourne_sdk_utils/jupyter_tools/__init__.py +2 -0
- finbourne_sdk_utils/jupyter_tools/hide_code_button.py +23 -0
- finbourne_sdk_utils/jupyter_tools/stop_execution.py +14 -0
- finbourne_sdk_utils/logger/LusidLogger.py +41 -0
- finbourne_sdk_utils/logger/__init__.py +1 -0
- finbourne_sdk_utils/lpt/__init__.py +0 -0
- finbourne_sdk_utils/lpt/back_compat.py +20 -0
- finbourne_sdk_utils/lpt/cash_ladder.py +191 -0
- finbourne_sdk_utils/lpt/connect_lusid.py +64 -0
- finbourne_sdk_utils/lpt/connect_none.py +5 -0
- finbourne_sdk_utils/lpt/connect_token.py +9 -0
- finbourne_sdk_utils/lpt/dfq.py +321 -0
- finbourne_sdk_utils/lpt/either.py +65 -0
- finbourne_sdk_utils/lpt/get_instruments.py +101 -0
- finbourne_sdk_utils/lpt/lpt.py +374 -0
- finbourne_sdk_utils/lpt/lse.py +188 -0
- finbourne_sdk_utils/lpt/map_instruments.py +164 -0
- finbourne_sdk_utils/lpt/pager.py +32 -0
- finbourne_sdk_utils/lpt/record.py +13 -0
- finbourne_sdk_utils/lpt/refreshing_token.py +43 -0
- finbourne_sdk_utils/lpt/search_instruments.py +48 -0
- finbourne_sdk_utils/lpt/stdargs.py +154 -0
- finbourne_sdk_utils/lpt/txn_config.py +128 -0
- finbourne_sdk_utils/lpt/txn_config_yaml.py +493 -0
- finbourne_sdk_utils/pandas_utils/__init__.py +0 -0
- finbourne_sdk_utils/pandas_utils/lusid_pandas.py +128 -0
- finbourne_sdk_utils-0.0.24.dist-info/LICENSE +21 -0
- finbourne_sdk_utils-0.0.24.dist-info/METADATA +25 -0
- finbourne_sdk_utils-0.0.24.dist-info/RECORD +52 -0
- finbourne_sdk_utils-0.0.24.dist-info/WHEEL +5 -0
- finbourne_sdk_utils-0.0.24.dist-info/top_level.txt +2 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import lusid
|
|
2
|
+
import lusid.models as models
|
|
3
|
+
import logging
|
|
4
|
+
|
|
5
|
+
logger = logging.getLogger()
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def create_transaction_type_configuration(api_factory, alias, movements):
|
|
9
|
+
"""
|
|
10
|
+
This function creates a transaction type configuration if it doesn't already exist.
|
|
11
|
+
|
|
12
|
+
Parameters
|
|
13
|
+
----------
|
|
14
|
+
api_factory : The LUSID api factory to use
|
|
15
|
+
alias : lusid.models.TransactionConfigurationTypeAlias
|
|
16
|
+
An aliases with type and group
|
|
17
|
+
movements : list[lusid.models.TransactionConfigurationMovementDataRequest]
|
|
18
|
+
The movements to use for
|
|
19
|
+
transaction type
|
|
20
|
+
|
|
21
|
+
Returns
|
|
22
|
+
-------
|
|
23
|
+
response : (lusid.models.createtransactiontyperesponse)
|
|
24
|
+
The response from creating the transaction type
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
# Call LUSID to get your transaction type configuration
|
|
28
|
+
response = api_factory.build(
|
|
29
|
+
lusid.api.SystemConfigurationApi
|
|
30
|
+
).list_configuration_transaction_types()
|
|
31
|
+
|
|
32
|
+
aliases_current = [
|
|
33
|
+
(alias.type, alias.transaction_group)
|
|
34
|
+
for transaction_grouping in response.transaction_configs
|
|
35
|
+
for alias in transaction_grouping.aliases
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
logger.info(
|
|
39
|
+
f"The LUSID enviornment currently has {len(aliases_current)} transaction aliases"
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
if (alias.type, alias.transaction_group) in aliases_current:
|
|
43
|
+
logging.warning(
|
|
44
|
+
"The following alias already exists: "
|
|
45
|
+
+ f"Type of {alias.type} with source {alias.transaction_group}"
|
|
46
|
+
)
|
|
47
|
+
return response
|
|
48
|
+
|
|
49
|
+
logger.info(f"Creating a new transaction aliases called: {alias.type}")
|
|
50
|
+
|
|
51
|
+
response = api_factory.build(
|
|
52
|
+
lusid.api.SystemConfigurationApi
|
|
53
|
+
).create_configuration_transaction_type(
|
|
54
|
+
transaction_configuration_data_request=models.TransactionConfigurationDataRequest(
|
|
55
|
+
aliases=[alias], movements=movements
|
|
56
|
+
)
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
return response
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def upsert_transaction_type_alias(api_factory, new_transaction_config):
|
|
63
|
+
"""
|
|
64
|
+
This function overrides the current transaction types alias with a new configuration.
|
|
65
|
+
The alias will be created if it does not already exist.
|
|
66
|
+
|
|
67
|
+
Parameters
|
|
68
|
+
----------
|
|
69
|
+
api_factory: factory
|
|
70
|
+
The LUSID api factory to use.
|
|
71
|
+
new_transaction_config: list[lusid.models.TransactionConfigurationDataRequest]
|
|
72
|
+
A list of new transaction type configurations
|
|
73
|
+
|
|
74
|
+
Returns
|
|
75
|
+
-------
|
|
76
|
+
response : (lusid.models.TransactionSetConfigurationData)
|
|
77
|
+
The response from setting the transaction type
|
|
78
|
+
"""
|
|
79
|
+
|
|
80
|
+
# Call LUSID to get a list of the current transaction types
|
|
81
|
+
|
|
82
|
+
current_transaction_types = api_factory.build(
|
|
83
|
+
lusid.api.SystemConfigurationApi
|
|
84
|
+
).list_configuration_transaction_types()
|
|
85
|
+
|
|
86
|
+
transaction_configs_list = current_transaction_types.transaction_configs
|
|
87
|
+
|
|
88
|
+
# Define function to delete current alias if it already exists
|
|
89
|
+
|
|
90
|
+
def delete_current_alias(updated_alias):
|
|
91
|
+
|
|
92
|
+
for txn_index, trans_type in enumerate(transaction_configs_list):
|
|
93
|
+
|
|
94
|
+
for alias_index, alias in enumerate(trans_type.aliases):
|
|
95
|
+
|
|
96
|
+
if (
|
|
97
|
+
alias.type == updated_alias.type
|
|
98
|
+
and alias.transaction_group == updated_alias.transaction_group
|
|
99
|
+
):
|
|
100
|
+
del trans_type.aliases[alias_index]
|
|
101
|
+
|
|
102
|
+
break
|
|
103
|
+
|
|
104
|
+
else:
|
|
105
|
+
continue
|
|
106
|
+
|
|
107
|
+
# If there are no aliases assigned against the old movement, delete the transaction type configuration from LUSID
|
|
108
|
+
# We don't want to leave unassigned movements in LUSID
|
|
109
|
+
|
|
110
|
+
if len(trans_type.aliases) == 0:
|
|
111
|
+
del transaction_configs_list[txn_index]
|
|
112
|
+
|
|
113
|
+
break
|
|
114
|
+
|
|
115
|
+
# Loop over list of new aliases and delete them if they already exist
|
|
116
|
+
|
|
117
|
+
new_aliases_nested = [item.aliases for item in new_transaction_config]
|
|
118
|
+
new_aliases = [item for sublist in new_aliases_nested for item in sublist]
|
|
119
|
+
|
|
120
|
+
for item in new_aliases:
|
|
121
|
+
delete_current_alias(item)
|
|
122
|
+
|
|
123
|
+
# Then set the new aliases with new config
|
|
124
|
+
|
|
125
|
+
transaction_configs_list = transaction_configs_list + new_transaction_config
|
|
126
|
+
|
|
127
|
+
set_response = api_factory.build(
|
|
128
|
+
lusid.api.SystemConfigurationApi
|
|
129
|
+
).set_configuration_transaction_types(
|
|
130
|
+
transaction_set_configuration_data_request=models.TransactionSetConfigurationDataRequest(
|
|
131
|
+
transaction_config_requests=transaction_configs_list,
|
|
132
|
+
side_config_requests=current_transaction_types.side_definitions,
|
|
133
|
+
)
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
return set_response
|