finbourne-sdk-utils 0.0.24__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 (40) hide show
  1. finbourne-sdk-utils-0.0.24/LICENSE +21 -0
  2. finbourne-sdk-utils-0.0.24/MANIFEST.in +5 -0
  3. finbourne-sdk-utils-0.0.24/PKG-INFO +11 -0
  4. finbourne-sdk-utils-0.0.24/README.md +38 -0
  5. finbourne-sdk-utils-0.0.24/__version__.py +1 -0
  6. finbourne-sdk-utils-0.0.24/features/__init__.py +0 -0
  7. finbourne-sdk-utils-0.0.24/features/main.py +11 -0
  8. finbourne-sdk-utils-0.0.24/finbourne_sdk_utils/__init__.py +8 -0
  9. finbourne-sdk-utils-0.0.24/finbourne_sdk_utils/cocoon/__init__.py +34 -0
  10. finbourne-sdk-utils-0.0.24/finbourne_sdk_utils/cocoon/async_tools.py +94 -0
  11. finbourne-sdk-utils-0.0.24/finbourne_sdk_utils/cocoon/cocoon.py +1862 -0
  12. finbourne-sdk-utils-0.0.24/finbourne_sdk_utils/cocoon/cocoon_printer.py +455 -0
  13. finbourne-sdk-utils-0.0.24/finbourne_sdk_utils/cocoon/config/domain_settings.json +125 -0
  14. finbourne-sdk-utils-0.0.24/finbourne_sdk_utils/cocoon/config/seed_sample_data.json +36 -0
  15. finbourne-sdk-utils-0.0.24/finbourne_sdk_utils/cocoon/dateorcutlabel.py +198 -0
  16. finbourne-sdk-utils-0.0.24/finbourne_sdk_utils/cocoon/instruments.py +482 -0
  17. finbourne-sdk-utils-0.0.24/finbourne_sdk_utils/cocoon/properties.py +442 -0
  18. finbourne-sdk-utils-0.0.24/finbourne_sdk_utils/cocoon/seed_sample_data.py +137 -0
  19. finbourne-sdk-utils-0.0.24/finbourne_sdk_utils/cocoon/systemConfiguration.py +92 -0
  20. finbourne-sdk-utils-0.0.24/finbourne_sdk_utils/cocoon/transaction_type_upload.py +136 -0
  21. finbourne-sdk-utils-0.0.24/finbourne_sdk_utils/cocoon/utilities.py +1877 -0
  22. finbourne-sdk-utils-0.0.24/finbourne_sdk_utils/cocoon/validator.py +243 -0
  23. finbourne-sdk-utils-0.0.24/finbourne_sdk_utils/extract/__init__.py +1 -0
  24. finbourne-sdk-utils-0.0.24/finbourne_sdk_utils/extract/group_holdings.py +400 -0
  25. finbourne-sdk-utils-0.0.24/finbourne_sdk_utils/iam/__init__.py +1 -0
  26. finbourne-sdk-utils-0.0.24/finbourne_sdk_utils/iam/roles.py +74 -0
  27. finbourne-sdk-utils-0.0.24/finbourne_sdk_utils/jupyter_tools/__init__.py +2 -0
  28. finbourne-sdk-utils-0.0.24/finbourne_sdk_utils/jupyter_tools/hide_code_button.py +23 -0
  29. finbourne-sdk-utils-0.0.24/finbourne_sdk_utils/jupyter_tools/stop_execution.py +14 -0
  30. finbourne-sdk-utils-0.0.24/finbourne_sdk_utils/logger/LusidLogger.py +41 -0
  31. finbourne-sdk-utils-0.0.24/finbourne_sdk_utils/logger/__init__.py +1 -0
  32. finbourne-sdk-utils-0.0.24/finbourne_sdk_utils/pandas_utils/__init__.py +0 -0
  33. finbourne-sdk-utils-0.0.24/finbourne_sdk_utils/pandas_utils/lusid_pandas.py +128 -0
  34. finbourne-sdk-utils-0.0.24/finbourne_sdk_utils.egg-info/PKG-INFO +11 -0
  35. finbourne-sdk-utils-0.0.24/finbourne_sdk_utils.egg-info/SOURCES.txt +38 -0
  36. finbourne-sdk-utils-0.0.24/finbourne_sdk_utils.egg-info/dependency_links.txt +1 -0
  37. finbourne-sdk-utils-0.0.24/finbourne_sdk_utils.egg-info/requires.txt +13 -0
  38. finbourne-sdk-utils-0.0.24/finbourne_sdk_utils.egg-info/top_level.txt +2 -0
  39. finbourne-sdk-utils-0.0.24/setup.cfg +4 -0
  40. finbourne-sdk-utils-0.0.24/setup.py +34 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 FINBOURNE
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,5 @@
1
+ include finbourne_sdk_utils/cocoon/config/*.json
2
+ exclude finbourne_sdk_utils/commands/**
3
+ exclude finbourne_sdk_utils/data/*
4
+ exclude finbourne_sdk_utils/lpt/*
5
+ include __version__.py
@@ -0,0 +1,11 @@
1
+ Metadata-Version: 2.1
2
+ Name: finbourne-sdk-utils
3
+ Version: 0.0.24
4
+ Summary: Python utilitiesfor LUSID V2 SDK
5
+ Home-page: https://github.com/finbourne/finbourne-sdk-utils
6
+ Author: FINBOURNE Technology
7
+ Author-email: engineering@finbourne.com
8
+ License: MIT
9
+ Keywords: FINBOURNE,LUSID,LUSID SDK,python
10
+ Requires-Python: >=3.7
11
+ License-File: LICENSE
@@ -0,0 +1,38 @@
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
+ ```
@@ -0,0 +1 @@
1
+ __version__ = "0.0.24"
File without changes
@@ -0,0 +1,11 @@
1
+ import sys
2
+
3
+ from lusidfeature.reporter import extract_features_to_file
4
+
5
+
6
+ def main(argv):
7
+ extract_features_to_file(sys.argv)
8
+
9
+
10
+ if __name__ == "__main__":
11
+ main(sys.argv)
@@ -0,0 +1,8 @@
1
+ import finbourne_sdk_utils.cocoon.cocoon
2
+ import finbourne_sdk_utils.cocoon.instruments
3
+ import finbourne_sdk_utils.cocoon.properties
4
+ import finbourne_sdk_utils.cocoon.systemConfiguration
5
+ import finbourne_sdk_utils.cocoon.utilities
6
+ import finbourne_sdk_utils.cocoon.async_tools
7
+ import finbourne_sdk_utils.cocoon.validator
8
+ import finbourne_sdk_utils.cocoon.dateorcutlabel
@@ -0,0 +1,34 @@
1
+ import finbourne_sdk_utils.cocoon.cocoon
2
+ import finbourne_sdk_utils.cocoon.instruments
3
+ import finbourne_sdk_utils.cocoon.properties
4
+ import finbourne_sdk_utils.cocoon.systemConfiguration
5
+ import finbourne_sdk_utils.cocoon.utilities
6
+ from finbourne_sdk_utils.cocoon.instruments import resolve_instruments
7
+ from finbourne_sdk_utils.cocoon.properties import create_property_values
8
+ from finbourne_sdk_utils.cocoon.utilities import set_attributes_recursive
9
+ from finbourne_sdk_utils.cocoon.cocoon import load_from_data_frame
10
+ from finbourne_sdk_utils.cocoon.utilities import (
11
+ checkargs,
12
+ load_data_to_df_and_detect_delimiter,
13
+ check_mapping_fields_exist,
14
+ parse_args,
15
+ identify_cash_items,
16
+ validate_mapping_file_structure,
17
+ get_delimiter,
18
+ scale_quote_of_type,
19
+ strip_whitespace,
20
+ load_json_file,
21
+ default_fx_forward_model,
22
+ )
23
+ from finbourne_sdk_utils.cocoon.cocoon_printer import (
24
+ format_holdings_response,
25
+ format_instruments_response,
26
+ format_portfolios_response,
27
+ format_quotes_response,
28
+ format_transactions_response,
29
+ )
30
+
31
+ import finbourne_sdk_utils.cocoon.async_tools
32
+ import finbourne_sdk_utils.cocoon.validator
33
+ import finbourne_sdk_utils.cocoon.dateorcutlabel
34
+ from finbourne_sdk_utils.cocoon.seed_sample_data import seed_data
@@ -0,0 +1,94 @@
1
+ import asyncio
2
+ import functools
3
+ from threading import Thread, enumerate
4
+ import concurrent.futures
5
+
6
+
7
+ def start_event_loop_new_thread() -> asyncio.AbstractEventLoop:
8
+ """
9
+ Creates and starts a new event loop in a new thread
10
+
11
+ Returns
12
+ -------
13
+ loop : asyncio.AbstractEventLoop
14
+ The newly created loop
15
+
16
+ """
17
+
18
+ loop = asyncio.new_event_loop()
19
+ t = Thread(target=start_background_loop, args=(loop,), daemon=True)
20
+ t.start()
21
+ return loop
22
+
23
+
24
+ def stop_event_loop_new_thread(loop: asyncio.AbstractEventLoop) -> None:
25
+ """
26
+ Takes an event loop, stops it and once stopped closes it
27
+
28
+ Parameters
29
+ ----------
30
+ loop : asyncio.AbstractEventLoop
31
+ The loop to stop and close
32
+
33
+ """
34
+
35
+ thread_id = loop._thread_id
36
+ loop.call_soon_threadsafe(loop.stop)
37
+ threads = enumerate()
38
+ match = [thread for thread in threads if thread.ident == thread_id]
39
+ if len(match) == 1:
40
+ match[0].join(timeout=1)
41
+
42
+
43
+ def start_background_loop(loop: asyncio.AbstractEventLoop) -> None:
44
+ """
45
+ Sets and starts the event loop
46
+
47
+ Parameters
48
+ ----------
49
+ loop : asyncio.AbstractEventLoop
50
+ The event loop to use
51
+
52
+ """
53
+
54
+ asyncio.set_event_loop(loop)
55
+ loop.run_forever()
56
+
57
+
58
+ def run_in_executor(f):
59
+ """
60
+ Passes a synchronous & blocking function off to another thread so that it can be awaited
61
+
62
+ Parameters
63
+ ----------
64
+ f
65
+ The function to transform into an awaitable
66
+
67
+ Returns
68
+ -------
69
+ inner : callable
70
+ An awaitable version of the function with the execution delegated to another thread
71
+ """
72
+
73
+ @functools.wraps(f)
74
+ def inner(*args, **kwargs):
75
+ loop = asyncio.get_running_loop()
76
+
77
+ return loop.run_in_executor(
78
+ # If the function to be wrapped has been provided with a thread pool use that, otherwise create one
79
+ kwargs.get("thread_pool", ThreadPool(5).thread_pool),
80
+ lambda: f(*args, **kwargs),
81
+ )
82
+
83
+ return inner
84
+
85
+
86
+ class ThreadPool:
87
+ """
88
+ Creates a class which has a thread pool.
89
+ """
90
+
91
+ def __init__(self, max_workers):
92
+ self.thread_pool = concurrent.futures.ThreadPoolExecutor(
93
+ max_workers=max_workers
94
+ )