finbourne-sdk-utils 0.0.25__tar.gz → 0.0.26__tar.gz

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.
Files changed (42) hide show
  1. {finbourne-sdk-utils-0.0.25/finbourne_sdk_utils.egg-info → finbourne-sdk-utils-0.0.26}/PKG-INFO +1 -1
  2. finbourne-sdk-utils-0.0.26/README.md +223 -0
  3. finbourne-sdk-utils-0.0.26/__version__.py +1 -0
  4. {finbourne-sdk-utils-0.0.25 → finbourne-sdk-utils-0.0.26/finbourne_sdk_utils.egg-info}/PKG-INFO +1 -1
  5. finbourne-sdk-utils-0.0.25/README.md +0 -38
  6. finbourne-sdk-utils-0.0.25/__version__.py +0 -1
  7. {finbourne-sdk-utils-0.0.25 → finbourne-sdk-utils-0.0.26}/LICENSE +0 -0
  8. {finbourne-sdk-utils-0.0.25 → finbourne-sdk-utils-0.0.26}/MANIFEST.in +0 -0
  9. {finbourne-sdk-utils-0.0.25 → finbourne-sdk-utils-0.0.26}/features/__init__.py +0 -0
  10. {finbourne-sdk-utils-0.0.25 → finbourne-sdk-utils-0.0.26}/features/main.py +0 -0
  11. {finbourne-sdk-utils-0.0.25 → finbourne-sdk-utils-0.0.26}/finbourne_sdk_utils/__init__.py +0 -0
  12. {finbourne-sdk-utils-0.0.25 → finbourne-sdk-utils-0.0.26}/finbourne_sdk_utils/cocoon/__init__.py +0 -0
  13. {finbourne-sdk-utils-0.0.25 → finbourne-sdk-utils-0.0.26}/finbourne_sdk_utils/cocoon/async_tools.py +0 -0
  14. {finbourne-sdk-utils-0.0.25 → finbourne-sdk-utils-0.0.26}/finbourne_sdk_utils/cocoon/cocoon.py +0 -0
  15. {finbourne-sdk-utils-0.0.25 → finbourne-sdk-utils-0.0.26}/finbourne_sdk_utils/cocoon/cocoon_printer.py +0 -0
  16. {finbourne-sdk-utils-0.0.25 → finbourne-sdk-utils-0.0.26}/finbourne_sdk_utils/cocoon/config/domain_settings.json +0 -0
  17. {finbourne-sdk-utils-0.0.25 → finbourne-sdk-utils-0.0.26}/finbourne_sdk_utils/cocoon/config/seed_sample_data.json +0 -0
  18. {finbourne-sdk-utils-0.0.25 → finbourne-sdk-utils-0.0.26}/finbourne_sdk_utils/cocoon/dateorcutlabel.py +0 -0
  19. {finbourne-sdk-utils-0.0.25 → finbourne-sdk-utils-0.0.26}/finbourne_sdk_utils/cocoon/instruments.py +0 -0
  20. {finbourne-sdk-utils-0.0.25 → finbourne-sdk-utils-0.0.26}/finbourne_sdk_utils/cocoon/properties.py +0 -0
  21. {finbourne-sdk-utils-0.0.25 → finbourne-sdk-utils-0.0.26}/finbourne_sdk_utils/cocoon/seed_sample_data.py +0 -0
  22. {finbourne-sdk-utils-0.0.25 → finbourne-sdk-utils-0.0.26}/finbourne_sdk_utils/cocoon/systemConfiguration.py +0 -0
  23. {finbourne-sdk-utils-0.0.25 → finbourne-sdk-utils-0.0.26}/finbourne_sdk_utils/cocoon/transaction_type_upload.py +0 -0
  24. {finbourne-sdk-utils-0.0.25 → finbourne-sdk-utils-0.0.26}/finbourne_sdk_utils/cocoon/utilities.py +0 -0
  25. {finbourne-sdk-utils-0.0.25 → finbourne-sdk-utils-0.0.26}/finbourne_sdk_utils/cocoon/validator.py +0 -0
  26. {finbourne-sdk-utils-0.0.25 → finbourne-sdk-utils-0.0.26}/finbourne_sdk_utils/extract/__init__.py +0 -0
  27. {finbourne-sdk-utils-0.0.25 → finbourne-sdk-utils-0.0.26}/finbourne_sdk_utils/extract/group_holdings.py +0 -0
  28. {finbourne-sdk-utils-0.0.25 → finbourne-sdk-utils-0.0.26}/finbourne_sdk_utils/iam/__init__.py +0 -0
  29. {finbourne-sdk-utils-0.0.25 → finbourne-sdk-utils-0.0.26}/finbourne_sdk_utils/iam/roles.py +0 -0
  30. {finbourne-sdk-utils-0.0.25 → finbourne-sdk-utils-0.0.26}/finbourne_sdk_utils/jupyter_tools/__init__.py +0 -0
  31. {finbourne-sdk-utils-0.0.25 → finbourne-sdk-utils-0.0.26}/finbourne_sdk_utils/jupyter_tools/hide_code_button.py +0 -0
  32. {finbourne-sdk-utils-0.0.25 → finbourne-sdk-utils-0.0.26}/finbourne_sdk_utils/jupyter_tools/stop_execution.py +0 -0
  33. {finbourne-sdk-utils-0.0.25 → finbourne-sdk-utils-0.0.26}/finbourne_sdk_utils/logger/LusidLogger.py +0 -0
  34. {finbourne-sdk-utils-0.0.25 → finbourne-sdk-utils-0.0.26}/finbourne_sdk_utils/logger/__init__.py +0 -0
  35. {finbourne-sdk-utils-0.0.25 → finbourne-sdk-utils-0.0.26}/finbourne_sdk_utils/pandas_utils/__init__.py +0 -0
  36. {finbourne-sdk-utils-0.0.25 → finbourne-sdk-utils-0.0.26}/finbourne_sdk_utils/pandas_utils/lusid_pandas.py +0 -0
  37. {finbourne-sdk-utils-0.0.25 → finbourne-sdk-utils-0.0.26}/finbourne_sdk_utils.egg-info/SOURCES.txt +0 -0
  38. {finbourne-sdk-utils-0.0.25 → finbourne-sdk-utils-0.0.26}/finbourne_sdk_utils.egg-info/dependency_links.txt +0 -0
  39. {finbourne-sdk-utils-0.0.25 → finbourne-sdk-utils-0.0.26}/finbourne_sdk_utils.egg-info/requires.txt +0 -0
  40. {finbourne-sdk-utils-0.0.25 → finbourne-sdk-utils-0.0.26}/finbourne_sdk_utils.egg-info/top_level.txt +0 -0
  41. {finbourne-sdk-utils-0.0.25 → finbourne-sdk-utils-0.0.26}/setup.cfg +0 -0
  42. {finbourne-sdk-utils-0.0.25 → finbourne-sdk-utils-0.0.26}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: finbourne-sdk-utils
3
- Version: 0.0.25
3
+ Version: 0.0.26
4
4
  Summary: Python utilities for LUSID V2 SDK
5
5
  Home-page: https://github.com/finbourne/finbourne-sdk-utils
6
6
  Author: FINBOURNE Technology
@@ -0,0 +1,223 @@
1
+ ![LUSID_by_Finbourne](./resources/Finbourne_Logo_Teal.svg)
2
+
3
+ # Python tools for LUSID
4
+
5
+ This SDK package contains a set of utility functions for interacting with [LUSID by FINBOURNE](https://support.lusid.com/). To use it you'll need a LUSID account. [Sign up for free at lusid.com](https://www.lusid.com/app/signup)
6
+
7
+
8
+ ![PyPI](https://img.shields.io/pypi/v/finbourne_sdk_utils?color=blue)
9
+
10
+
11
+ ## Installation
12
+
13
+ The PyPi package for lusid-python-tools can installed globally on your machine using the following command:
14
+
15
+ ```sh
16
+ $ pip install finbourne-sdk-utils
17
+ ```
18
+
19
+ or if you are running as a non privileged user you may prefer to install specifically for your user account:
20
+
21
+ ```sh
22
+ $ pip install --user finbourne-sdk-utils
23
+ ```
24
+
25
+ ## Upgrading
26
+
27
+ To upgrade finbourne_sdk_utils run one of the commands below
28
+
29
+ ```sh
30
+ $ pip install finbourne-sdk-utils -U
31
+ ```
32
+
33
+ or
34
+
35
+ ```sh
36
+ $ pip install finbourne-sdk-utils -U --user
37
+ ```
38
+ ## Source Code
39
+
40
+ The source code for this package is available on github ( https://github.com/finbourne/finbourne-sdk-utils). Please refer to this repository for more examples and implementation details.
41
+
42
+
43
+ ## Examples of Use
44
+ Create a python environment and install the package
45
+ ```sh
46
+ $ pip install finbourne-sdk-utils
47
+ ```
48
+
49
+ ### Generate a time backed unique id
50
+
51
+ main.py
52
+ ```python
53
+ from finbourne_sdk_utils.cocoon.utilities import generate_time_based_unique_id
54
+
55
+
56
+ def main():
57
+
58
+ # Using a finbourne-sdk-utils utility function to create a random portfolio code
59
+ # Generates a unique ID based on the current time since epoch
60
+ portfolio_code = generate_time_based_unique_id(None)
61
+
62
+ print(f"Portfolio Code: {portfolio_code} ")
63
+
64
+
65
+ if __name__ == "__main__":
66
+ main()
67
+
68
+ ```
69
+
70
+ ### Upsert Instruments from a csv file
71
+
72
+ global-fund-combined-instrument-master.csv
73
+ ```
74
+ instrument_name,client_internal,currency,isin,figi,couprate,s&p rating,moodys_rating
75
+ BP_LondonStockEx_BP,imd_43535553,GBP,GB0007980591,BBG000C05BD1,nan,nan,nan
76
+ BurfordCapital_LondonStockEx_BUR,imd_43534356,GBP,GG00B4L84979,BBG000PN88Q7,nan,nan,nan
77
+ EKFDiagnostics_LondonStockEx_EKF,imd_34535355,GBP,GB0031509804,BBG000BVNBN3,nan,nan,nan
78
+ ```
79
+
80
+
81
+ main.py
82
+
83
+ ```python
84
+ from pathlib import Path
85
+ import pandas as pd
86
+ from finbourne_sdk_utils import cocoon as cocoon
87
+ import lusid
88
+
89
+ def load_from_csv():
90
+
91
+ api_factory = lusid.SyncApiClientFactory()
92
+
93
+ data_frame = pd.read_csv(Path(__file__).parent.joinpath("global-fund-combined-instrument-master.csv"))
94
+
95
+ responses = cocoon.load_from_data_frame(
96
+ api_factory=api_factory,
97
+ scope="TestScope1",
98
+ data_frame=data_frame,
99
+ mapping_required={"name": "instrument_name"},
100
+ mapping_optional={},
101
+ file_type="instruments",
102
+ identifier_mapping={"Figi": "figi", "Isin": "isin", "ClientInternal": "client_internal"},
103
+ property_columns=["s&p rating", "moodys_rating", "currency"],
104
+ properties_scope="TestPropertiesScope1",
105
+ instrument_scope= "TestScope1",
106
+ )
107
+
108
+ rows_loaded =sum(
109
+ [
110
+ len(response.values)
111
+ for response in responses["instruments"]["success"]
112
+ ]
113
+ )
114
+ error_count = sum(
115
+ [
116
+ len(response.values)
117
+ for response in responses["instruments"]["errors"]
118
+ ]
119
+ )
120
+
121
+ print(f"Rows loaded = {rows_loaded} rows expected = {len(data_frame)}")
122
+ print(f"Encounted {error_count} errors")
123
+
124
+
125
+ if __name__ == "__main__":
126
+ load_from_csv()
127
+ ```
128
+
129
+
130
+ ## Tips for using V2 of the Lusid Python Tools
131
+
132
+ Existing code that uses the original LusidTools (lusid-python-tools) library is not compatible with V2 of the SDKs. You can use the following information to help port notebooks or your own code to use finbourne_sdk_utils (finbourne-sdk-utils), which is compatible with V2 SDKs.
133
+
134
+ ## Why upgrade
135
+
136
+ This package is now based on V2 of the Python SDKs. The latest V2 brings many enhancements and language improvements. V1 of the SDKs is now deprecated, and hence any new work should use the latest V2 packages.
137
+
138
+ ## Differences between this version and the previous SDK
139
+
140
+ The V2 SDKs bring a few improvements which may break existing code. Reading this section may help port existing Python code that used the lusidtools package.
141
+
142
+ **secrets.json file replaced by environment variables**
143
+
144
+ We have improved security by removing the need for a local secrets.json file. Instead, the environment variables need to be set.
145
+
146
+ See https://support.lusid.com/docs/how-do-i-use-an-api-access-token-with-the-lusid-sdk.
147
+
148
+ **Signature changes to iam.create_role()**
149
+
150
+ Is now:
151
+ ```python
152
+ def create_role(
153
+ access_api_factory: finbourne_access.extensions.SyncApiClientFactory,
154
+ identity_api_factory: finbourne_identity.extensions.SyncApiClientFactory,
155
+ access_role_creation_request: access_models.RoleCreationRequest,
156
+ ) -> None:
157
+ ```
158
+ Was
159
+ ```python
160
+ def create_role(
161
+ api_factory: lusid.SyncApiClientFactory,
162
+ access_role_creation_request: access_models.RoleCreationRequest,
163
+ ):
164
+ ```
165
+ Reason, rework of the ApiClientFactory means the configuration isn't available, thus we now explictity pass in the factory methods for access and identity
166
+
167
+ **Lusid.Models, finbourne_access and fibnoure_identity DTOs are now inherited from BaseModel**
168
+
169
+ Previously all V1 API DTO ( models classes ) were herited from Object, but now V2 API DTOs use pydantic's BaseModel.
170
+ 1. This allows easier type checking and enumeration using pydantic. This change enforces better type checking at run time. Notable is the type checking on each property such as min max length of a string. Floats and integers can not be string representations in V2, i.e. code can not rely on implicit type conversions
171
+ 2. The DTO do not have the properties openapi_types , attribute_map and required_map. attribute_map has a equivalent __properties. These are not available and are now discovered at runtime. See the get_attributes_and_types() within finbourne_sdk_utils.cocoon namespace.
172
+ 3. Each DTO has a Config property, a pydantic configuration technique
173
+ 4. Default constructor now expects **kwargs or named parameters. see https://docs.pydantic.dev/1.10/#__tabbed_1_3.
174
+
175
+
176
+ **ApiClient is now async, not synchronous**
177
+
178
+ Not strictly a finbourne-sdk-utils change as ApiClient is defined in the lusid python SDK. The synchronous class is now call SyncApiClient. The utility functions have been tested synchronously and examples show Synchronous usage.
179
+
180
+ **response object from API calls**
181
+
182
+ SDK APIs now return am ApiResponse object with properties status_code, data and headers, rather than repsonse[0], response[1] etc.
183
+
184
+ Strictly not a finbourne-sdk-utils tools change, but some utility functions will return the native API response object
185
+
186
+ **response error handling change**
187
+
188
+ Serverside errors may now be thrown using ApiException
189
+
190
+ **Better value checking client side before invoking API**
191
+
192
+ The client-side code may generate ApiValue exceptions, assignments are now validated to ensure data types are used correctly. Examples include DateTime properties, previously the time part would have defaulted to midnight if only the date was provided, but now client-side checking will ensure it's a correctly formatted ISO 8601 string representation. Likewise, DateTime field will also expect the regional information or Zulu specified.
193
+
194
+ **Model Objects to_dict() now returns the alias of the object parameters**
195
+
196
+ V2 of the python SDK uses the BaseModel as the base class for all Model objects used by the APIs. The implementation of the to_dict() now returns the alias version of the property values. The alias is the original name of the parameter as specified in the API swagger definition. Typically, the APIs use camelCase notation, the python SDK will convert these to snake_case. For example, UpsertInstruments response returns 'lusidInstrumentId', but the model object uses lusid_instrument_id, with the alias lusidInstrumentId, i.e.
197
+
198
+ ```python
199
+ class Instrument(BaseModel):
200
+ ...
201
+ lusid_instrument_id: constr(strict=True, min_length=1) = Field(..., alias="lusidInstrumentId", description="The unique LUSID Instrument Identifier (LUID) of the instrument.")
202
+ ...
203
+
204
+ ```
205
+
206
+ likewise, when the SDK serialises the Model instances to send to the server, the reverse occurs, i.e. the alias equivalents are used to construct the request body.
207
+
208
+ As a consequence, the utility functions will also use the alias equivalents, ie.
209
+
210
+ V2 becomes
211
+ ```python
212
+ # Transform API response to a dataframe and show internally-generated unique LUID for each mastered instrument
213
+ upsert_instruments_response_df = lusid_response_to_data_frame(list(upsert_instruments_response.values.values()))
214
+
215
+ display(upsert_instruments_response_df[["name", "lusidInstrumentId"]])
216
+ ```
217
+ From previous V1
218
+ ```python
219
+ # Transform API response to a dataframe and show internally-generated unique LUID for each mastered instrument
220
+ upsert_instruments_response_df = lusid_response_to_data_frame(list(upsert_instruments_response.values.values()))
221
+
222
+ display(upsert_instruments_response_df[["name", "lusid_instrument_id"]])
223
+ ```
@@ -0,0 +1 @@
1
+ __version__ = "0.0.26"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: finbourne-sdk-utils
3
- Version: 0.0.25
3
+ Version: 0.0.26
4
4
  Summary: Python utilities for LUSID V2 SDK
5
5
  Home-page: https://github.com/finbourne/finbourne-sdk-utils
6
6
  Author: FINBOURNE Technology
@@ -1,38 +0,0 @@
1
- ![LUSID_by_Finbourne](./resources/Finbourne_Logo_Teal.svg)
2
-
3
- # Python tools for LUSID
4
-
5
- This package contains a set of utility functions for interacting with [LUSID by FINBOURNE](https://www.finbourne.com/lusid-technology). To use it you'll need a LUSID account. [Sign up for free at lusid.com](https://www.lusid.com/app/signup)
6
-
7
-
8
- ![PyPI](https://img.shields.io/pypi/v/finbourne_sdk_utils?color=blue)
9
-
10
- For more details see the lusid-python-tools [wiki](https://github.com/finbourne/lusid-python-tools/wiki).
11
-
12
- ## Installation
13
-
14
- The PyPi package for lusid-python-tools can installed globally on your machine using the following command:
15
-
16
- ```sh
17
- $ pip install finbourne-sdk-utils
18
- ```
19
-
20
- or if you are running as a non privileged user you may prefer to install specifically for your user account:
21
-
22
- ```sh
23
- $ pip install --user finbourne-sdk-utils
24
- ```
25
-
26
- ## Upgrading
27
-
28
- To upgrade finbourne_sdk_utils run one of the commands below
29
-
30
- ```sh
31
- $ pip install finbourne-sdk-utils -U
32
- ```
33
-
34
- or
35
-
36
- ```sh
37
- $ pip install finbourne-sdk-utils -U --user
38
- ```
@@ -1 +0,0 @@
1
- __version__ = "0.0.25"