everysk-lib 1.10.0__cp312-cp312-macosx_11_0_arm64.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.
- everysk/__init__.py +30 -0
- everysk/_version.py +683 -0
- everysk/api/__init__.py +61 -0
- everysk/api/api_requestor.py +167 -0
- everysk/api/api_resources/__init__.py +23 -0
- everysk/api/api_resources/api_resource.py +371 -0
- everysk/api/api_resources/calculation.py +779 -0
- everysk/api/api_resources/custom_index.py +42 -0
- everysk/api/api_resources/datastore.py +81 -0
- everysk/api/api_resources/file.py +42 -0
- everysk/api/api_resources/market_data.py +223 -0
- everysk/api/api_resources/parser.py +66 -0
- everysk/api/api_resources/portfolio.py +43 -0
- everysk/api/api_resources/private_security.py +42 -0
- everysk/api/api_resources/report.py +65 -0
- everysk/api/api_resources/report_template.py +39 -0
- everysk/api/api_resources/tests.py +115 -0
- everysk/api/api_resources/worker_execution.py +64 -0
- everysk/api/api_resources/workflow.py +65 -0
- everysk/api/api_resources/workflow_execution.py +93 -0
- everysk/api/api_resources/workspace.py +42 -0
- everysk/api/http_client.py +63 -0
- everysk/api/tests.py +32 -0
- everysk/api/utils.py +262 -0
- everysk/config.py +451 -0
- everysk/core/_tests/serialize/test_json.py +336 -0
- everysk/core/_tests/serialize/test_orjson.py +295 -0
- everysk/core/_tests/serialize/test_pickle.py +48 -0
- everysk/core/cloud_function/main.py +78 -0
- everysk/core/cloud_function/tests.py +86 -0
- everysk/core/compress.py +245 -0
- everysk/core/datetime/__init__.py +12 -0
- everysk/core/datetime/calendar.py +144 -0
- everysk/core/datetime/date.py +424 -0
- everysk/core/datetime/date_expression.py +299 -0
- everysk/core/datetime/date_mixin.py +1475 -0
- everysk/core/datetime/date_settings.py +30 -0
- everysk/core/datetime/datetime.py +713 -0
- everysk/core/exceptions.py +435 -0
- everysk/core/fields.py +1176 -0
- everysk/core/firestore.py +555 -0
- everysk/core/fixtures/_settings.py +29 -0
- everysk/core/fixtures/other/_settings.py +18 -0
- everysk/core/fixtures/user_agents.json +88 -0
- everysk/core/http.py +691 -0
- everysk/core/lists.py +92 -0
- everysk/core/log.py +709 -0
- everysk/core/number.py +37 -0
- everysk/core/object.py +1469 -0
- everysk/core/redis.py +1021 -0
- everysk/core/retry.py +51 -0
- everysk/core/serialize.py +674 -0
- everysk/core/sftp.py +414 -0
- everysk/core/signing.py +53 -0
- everysk/core/slack.py +127 -0
- everysk/core/string.py +199 -0
- everysk/core/tests.py +240 -0
- everysk/core/threads.py +199 -0
- everysk/core/undefined.py +74 -0
- everysk/core/unittests.py +73 -0
- everysk/core/workers.py +241 -0
- everysk/sdk/__init__.py +23 -0
- everysk/sdk/base.py +98 -0
- everysk/sdk/brutils/cnpj.py +373 -0
- everysk/sdk/brutils/cnpj_pd.py +42 -0
- everysk/sdk/engines/__init__.py +26 -0
- everysk/sdk/engines/cache.py +185 -0
- everysk/sdk/engines/compliance.py +37 -0
- everysk/sdk/engines/cryptography.py +69 -0
- everysk/sdk/engines/expression.cpython-312-darwin.so +0 -0
- everysk/sdk/engines/expression.pyi +53 -0
- everysk/sdk/engines/helpers.cpython-312-darwin.so +0 -0
- everysk/sdk/engines/helpers.pyi +26 -0
- everysk/sdk/engines/lock.py +120 -0
- everysk/sdk/engines/market_data.py +244 -0
- everysk/sdk/engines/settings.py +19 -0
- everysk/sdk/entities/__init__.py +23 -0
- everysk/sdk/entities/base.py +784 -0
- everysk/sdk/entities/base_list.py +131 -0
- everysk/sdk/entities/custom_index/base.py +209 -0
- everysk/sdk/entities/custom_index/settings.py +29 -0
- everysk/sdk/entities/datastore/base.py +160 -0
- everysk/sdk/entities/datastore/settings.py +17 -0
- everysk/sdk/entities/fields.py +375 -0
- everysk/sdk/entities/file/base.py +215 -0
- everysk/sdk/entities/file/settings.py +63 -0
- everysk/sdk/entities/portfolio/base.py +248 -0
- everysk/sdk/entities/portfolio/securities.py +241 -0
- everysk/sdk/entities/portfolio/security.py +580 -0
- everysk/sdk/entities/portfolio/settings.py +97 -0
- everysk/sdk/entities/private_security/base.py +226 -0
- everysk/sdk/entities/private_security/settings.py +17 -0
- everysk/sdk/entities/query.py +603 -0
- everysk/sdk/entities/report/base.py +214 -0
- everysk/sdk/entities/report/settings.py +23 -0
- everysk/sdk/entities/script.py +310 -0
- everysk/sdk/entities/secrets/base.py +128 -0
- everysk/sdk/entities/secrets/script.py +119 -0
- everysk/sdk/entities/secrets/settings.py +17 -0
- everysk/sdk/entities/settings.py +48 -0
- everysk/sdk/entities/tags.py +174 -0
- everysk/sdk/entities/worker_execution/base.py +307 -0
- everysk/sdk/entities/worker_execution/settings.py +62 -0
- everysk/sdk/entities/workflow_execution/base.py +113 -0
- everysk/sdk/entities/workflow_execution/settings.py +32 -0
- everysk/sdk/entities/workspace/base.py +99 -0
- everysk/sdk/entities/workspace/settings.py +27 -0
- everysk/sdk/settings.py +67 -0
- everysk/sdk/tests.py +105 -0
- everysk/sdk/worker_base.py +47 -0
- everysk/server/__init__.py +9 -0
- everysk/server/applications.py +63 -0
- everysk/server/endpoints.py +516 -0
- everysk/server/example_api.py +69 -0
- everysk/server/middlewares.py +80 -0
- everysk/server/requests.py +62 -0
- everysk/server/responses.py +119 -0
- everysk/server/routing.py +64 -0
- everysk/server/settings.py +36 -0
- everysk/server/tests.py +36 -0
- everysk/settings.py +98 -0
- everysk/sql/__init__.py +9 -0
- everysk/sql/connection.py +208 -0
- everysk/sql/model.py +376 -0
- everysk/sql/query.py +393 -0
- everysk/sql/row_factory.py +63 -0
- everysk/sql/settings.py +45 -0
- everysk/sql/utils.py +129 -0
- everysk/tests.py +23 -0
- everysk/utils.py +81 -0
- everysk/version.py +15 -0
- everysk_lib-1.10.0.dist-info/.gitignore +5 -0
- everysk_lib-1.10.0.dist-info/METADATA +326 -0
- everysk_lib-1.10.0.dist-info/RECORD +137 -0
- everysk_lib-1.10.0.dist-info/WHEEL +6 -0
- everysk_lib-1.10.0.dist-info/licenses/LICENSE.txt +9 -0
- everysk_lib-1.10.0.dist-info/top_level.txt +2 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
###############################################################################
|
|
2
|
+
#
|
|
3
|
+
# (C) Copyright 2023 EVERYSK TECHNOLOGIES
|
|
4
|
+
#
|
|
5
|
+
# This is an unpublished work containing confidential and proprietary
|
|
6
|
+
# information of EVERYSK TECHNOLOGIES. Disclosure, use, or reproduction
|
|
7
|
+
# without authorization of EVERYSK TECHNOLOGIES is prohibited.
|
|
8
|
+
#
|
|
9
|
+
###############################################################################
|
|
10
|
+
import string
|
|
11
|
+
import secrets
|
|
12
|
+
import uuid
|
|
13
|
+
|
|
14
|
+
from everysk.config import settings
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
ALPHANUMERIC = string.ascii_letters + string.digits
|
|
18
|
+
SYMBOL_ID_MAX_LEN = settings.SYMBOL_ID_MAX_LEN
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
###############################################################################
|
|
22
|
+
# Public Functions Implementation
|
|
23
|
+
###############################################################################
|
|
24
|
+
def generate_random_id(length: int, characters: str = ALPHANUMERIC) -> str:
|
|
25
|
+
"""
|
|
26
|
+
Generate a random ID based on the specified length and characters.
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
length (int): The desired length for the random ID.
|
|
30
|
+
characters (str, optional): The characters to use for generating the ID.
|
|
31
|
+
Default is alphanumeric characters.
|
|
32
|
+
|
|
33
|
+
Returns:
|
|
34
|
+
str: The generated random ID consisting of the specified characters.
|
|
35
|
+
|
|
36
|
+
Example:
|
|
37
|
+
>>> generate_random_id(18)
|
|
38
|
+
'xiXwQuig6cI11ny095'
|
|
39
|
+
|
|
40
|
+
>>> generate_random_id(5, 'abc')
|
|
41
|
+
'cbacb'
|
|
42
|
+
"""
|
|
43
|
+
return ''.join(secrets.choice(characters) for i in range(length))
|
|
44
|
+
|
|
45
|
+
def generate_unique_id():
|
|
46
|
+
"""
|
|
47
|
+
Generate a unique ID with fixed length (32 characters).
|
|
48
|
+
|
|
49
|
+
Returns:
|
|
50
|
+
str: The generated unique ID consisting of hexadecimal characters.
|
|
51
|
+
|
|
52
|
+
Example:
|
|
53
|
+
>>> generate_unique_id()
|
|
54
|
+
'dbdc803042ff48e19a344ad080a102dd'
|
|
55
|
+
"""
|
|
56
|
+
return uuid.uuid4().hex
|
|
57
|
+
|
|
58
|
+
def generate_short_random_id() -> str:
|
|
59
|
+
"""
|
|
60
|
+
Generate a random ID with a fixed length of 8 characters.
|
|
61
|
+
|
|
62
|
+
Returns:
|
|
63
|
+
str: The generated unique ID consisting of alphanumeric characters.
|
|
64
|
+
|
|
65
|
+
Example:
|
|
66
|
+
>>> generate_short_random_id()
|
|
67
|
+
'u0tmNqHP'
|
|
68
|
+
"""
|
|
69
|
+
return generate_random_id(length=settings.SIMPLE_UNIQUE_ID_LENGTH)
|
|
Binary file
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# This file was generated by Nuitka
|
|
2
|
+
|
|
3
|
+
# Stubs included by default
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
from everysk.sdk.engines.expression.base import ExpressionEngine
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
__name__ = ...
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
# Modules used internally, to allow implicit dependencies to be seen:
|
|
13
|
+
import os
|
|
14
|
+
import everysk
|
|
15
|
+
import everysk.sdk
|
|
16
|
+
import everysk.sdk.engines
|
|
17
|
+
import typing
|
|
18
|
+
import lark
|
|
19
|
+
import lark.tree
|
|
20
|
+
import everysk.config
|
|
21
|
+
import everysk.core
|
|
22
|
+
import everysk.core.log
|
|
23
|
+
import _frozen_importlib_external
|
|
24
|
+
import inspect
|
|
25
|
+
import importlib
|
|
26
|
+
import pkgutil
|
|
27
|
+
import functools
|
|
28
|
+
import numpy
|
|
29
|
+
import pandas
|
|
30
|
+
import everysk.core.datetime
|
|
31
|
+
import everysk.core.datetime.Date
|
|
32
|
+
import everysk.core.datetime.DateTime
|
|
33
|
+
import everysk.core.datetime.date_settings
|
|
34
|
+
import everysk.sdk.engines.helpers
|
|
35
|
+
import everysk.sdk.engines.helpers.transform
|
|
36
|
+
import datetime
|
|
37
|
+
import everysk.core.datetime.date_mixin
|
|
38
|
+
import collections
|
|
39
|
+
import collections.abc
|
|
40
|
+
import everysk.sdk.engines.helpers.algorithms
|
|
41
|
+
import everysk.sdk.engines.helpers.mathematical
|
|
42
|
+
import collections.OrderedDict
|
|
43
|
+
import everysk.sdk.engines.helpers.formater
|
|
44
|
+
import re
|
|
45
|
+
import unicodedata
|
|
46
|
+
import everysk.sdk.engines.cryptography
|
|
47
|
+
import unittest
|
|
48
|
+
import unittest.mock
|
|
49
|
+
import copy
|
|
50
|
+
import everysk.core.datetime.calendar
|
|
51
|
+
import lark.visitors
|
|
52
|
+
import decimal
|
|
53
|
+
import lark.exceptions
|
|
Binary file
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# This file was generated by Nuitka
|
|
2
|
+
|
|
3
|
+
# Stubs included by default
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
__name__ = ...
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
# Modules used internally, to allow implicit dependencies to be seen:
|
|
12
|
+
import os
|
|
13
|
+
import pandas
|
|
14
|
+
import numpy
|
|
15
|
+
import math
|
|
16
|
+
import decimal
|
|
17
|
+
import everysk
|
|
18
|
+
import everysk.core
|
|
19
|
+
import everysk.core.datetime
|
|
20
|
+
import everysk.core.datetime.DateTime
|
|
21
|
+
import everysk.sdk
|
|
22
|
+
import everysk.sdk.engines
|
|
23
|
+
import functools
|
|
24
|
+
import typing
|
|
25
|
+
import _frozen_importlib_external
|
|
26
|
+
import unittest
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
###############################################################################
|
|
2
|
+
#
|
|
3
|
+
# (C) Copyright 2025 EVERYSK TECHNOLOGIES
|
|
4
|
+
#
|
|
5
|
+
# This is an unpublished work containing confidential and proprietary
|
|
6
|
+
# information of EVERYSK TECHNOLOGIES. Disclosure, use, or reproduction
|
|
7
|
+
# without authorization of EVERYSK TECHNOLOGIES is prohibited.
|
|
8
|
+
#
|
|
9
|
+
###############################################################################
|
|
10
|
+
from uuid import uuid1
|
|
11
|
+
|
|
12
|
+
from everysk.config import settings
|
|
13
|
+
from everysk.core.fields import StrField, FloatField, BoolField
|
|
14
|
+
from everysk.core.exceptions import InvalidArgumentError
|
|
15
|
+
from everysk.sdk.base import BaseSDK
|
|
16
|
+
|
|
17
|
+
###############################################################################
|
|
18
|
+
# UserLock Class Implementation
|
|
19
|
+
###############################################################################
|
|
20
|
+
class UserLock(BaseSDK):
|
|
21
|
+
"""
|
|
22
|
+
UserLock class for acquiring and releasing locks.
|
|
23
|
+
This class provides methods to acquire a lock for a given token, release the lock,
|
|
24
|
+
and get information about the lock status.
|
|
25
|
+
It is used to manage locks in a distributed system to
|
|
26
|
+
prevent multiple processes from accessing the same resource simultaneously.
|
|
27
|
+
|
|
28
|
+
Attributes:
|
|
29
|
+
token (str): The unique identifier for the lock.
|
|
30
|
+
name (str): The name of the lock.
|
|
31
|
+
timeout (int): The expiration time for the lock in seconds.
|
|
32
|
+
|
|
33
|
+
Example:
|
|
34
|
+
>>> user_lock = UserLock(name='my_lock')
|
|
35
|
+
>>> user_lock.acquire()
|
|
36
|
+
UserLock(token='generated_token', name='my_lock', timeout=30)
|
|
37
|
+
>>> user_lock.get_lock_info()
|
|
38
|
+
{'locked': True, 'name': 'my_lock'}
|
|
39
|
+
>>> user_lock.release()
|
|
40
|
+
None
|
|
41
|
+
"""
|
|
42
|
+
token = StrField(default=None)
|
|
43
|
+
name = StrField(default=None, required=True)
|
|
44
|
+
timeout = FloatField(default=settings.USER_CACHE_LOCK_EXPIRATION_TIME, min_size=settings.USER_CACHE_LOCK_MIN_EXPIRATION_TIME, max_size=settings.USER_CACHE_LOCK_MAX_EXPIRATION_TIME)
|
|
45
|
+
blocking = BoolField(default=True) # If True, the lock will block until it can be acquired.
|
|
46
|
+
|
|
47
|
+
def acquire(self, token: str = None, blocking: bool = None, blocking_timeout: float = None) -> bool:
|
|
48
|
+
"""
|
|
49
|
+
Acquire a lock for a given token.
|
|
50
|
+
|
|
51
|
+
Args:
|
|
52
|
+
token (str | None): The token to use for the lock. If None, a new token will be generated.
|
|
53
|
+
blocking (bool | None): If True, wait until the lock is acquired. Defaults to None.
|
|
54
|
+
blocking_timeout (float | None): The maximum number of seconds to wait for the lock. Defaults to None.
|
|
55
|
+
|
|
56
|
+
Returns:
|
|
57
|
+
bool: True if the lock was acquired successfully, False otherwise.
|
|
58
|
+
|
|
59
|
+
Example:
|
|
60
|
+
>>> user_lock = UserLock(name='my_lock')
|
|
61
|
+
>>> user_lock.acquire()
|
|
62
|
+
True
|
|
63
|
+
"""
|
|
64
|
+
if not token and not self.token:
|
|
65
|
+
self.token = uuid1().hex
|
|
66
|
+
elif token:
|
|
67
|
+
self.token = token
|
|
68
|
+
|
|
69
|
+
return self.get_response(self_obj=self, params={'token': token, 'blocking': blocking, 'blocking_timeout': blocking_timeout})
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def release(self, force: bool = False) -> None:
|
|
73
|
+
"""
|
|
74
|
+
Release the lock for a given identifier.
|
|
75
|
+
|
|
76
|
+
Args:
|
|
77
|
+
force (bool): If True, force the release of the lock even if it is not owned.
|
|
78
|
+
This will delete the key from Redis. Defaults to False.
|
|
79
|
+
|
|
80
|
+
Example:
|
|
81
|
+
>>> UserLock.release('my_lock')
|
|
82
|
+
None
|
|
83
|
+
"""
|
|
84
|
+
if not self.token:
|
|
85
|
+
raise InvalidArgumentError("Cannot release an unlocked lock")
|
|
86
|
+
|
|
87
|
+
return self.get_response(self_obj=self, params={'force': force})
|
|
88
|
+
|
|
89
|
+
def do_release(self, expected_token: str) -> None:
|
|
90
|
+
"""
|
|
91
|
+
Release the lock for a given token.
|
|
92
|
+
This method is used to release a lock that was previously acquired.
|
|
93
|
+
|
|
94
|
+
Args:
|
|
95
|
+
expected_token (str): The unique token for the lock to release.
|
|
96
|
+
|
|
97
|
+
Example:
|
|
98
|
+
>>> user_lock = UserLock(name='my_lock')
|
|
99
|
+
>>> user_lock.do_release(token='token')
|
|
100
|
+
None
|
|
101
|
+
"""
|
|
102
|
+
if not expected_token:
|
|
103
|
+
raise InvalidArgumentError("Cannot release an unlocked lock")
|
|
104
|
+
|
|
105
|
+
return self.get_response(self_obj=self, params={'expected_token': expected_token})
|
|
106
|
+
|
|
107
|
+
def get_lock_info(self) -> dict:
|
|
108
|
+
"""
|
|
109
|
+
Get information about the lock status.
|
|
110
|
+
This method returns a dictionary containing information about the lock status.
|
|
111
|
+
|
|
112
|
+
Returns:
|
|
113
|
+
dict: A dictionary containing the lock status and other information.
|
|
114
|
+
|
|
115
|
+
Example:
|
|
116
|
+
>>> user_lock = UserLock(name='my_lock')
|
|
117
|
+
>>> user_lock.get_lock_info()
|
|
118
|
+
{'locked': True, 'name': 'my_lock'}
|
|
119
|
+
"""
|
|
120
|
+
return self.get_response(self_obj=self)
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
###############################################################################
|
|
2
|
+
#
|
|
3
|
+
# (C) Copyright 2025 EVERYSK TECHNOLOGIES
|
|
4
|
+
#
|
|
5
|
+
# This is an unpublished work containing confidential and proprietary
|
|
6
|
+
# information of EVERYSK TECHNOLOGIES. Disclosure, use, or reproduction
|
|
7
|
+
# without authorization of EVERYSK TECHNOLOGIES is prohibited.
|
|
8
|
+
#
|
|
9
|
+
###############################################################################
|
|
10
|
+
from functools import lru_cache
|
|
11
|
+
from typing import Any
|
|
12
|
+
|
|
13
|
+
from everysk.config import settings
|
|
14
|
+
from everysk.core.fields import DateField, ListField, StrField, BoolField, ChoiceField
|
|
15
|
+
from everysk.core.datetime import Date
|
|
16
|
+
from everysk.core.http import HttpGETConnection
|
|
17
|
+
from everysk.sdk.base import BaseSDK
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
###############################################################################
|
|
21
|
+
# MarketData Class Implementation
|
|
22
|
+
###############################################################################
|
|
23
|
+
class MarketData(BaseSDK):
|
|
24
|
+
|
|
25
|
+
date = DateField(default=Undefined)
|
|
26
|
+
start_date = DateField(default=None)
|
|
27
|
+
end_date = DateField(default=None)
|
|
28
|
+
ticker_list = ListField(default=None)
|
|
29
|
+
ticker_type = ChoiceField(default=None, choices=settings.ENGINES_MARKET_DATA_TICKER_TYPES)
|
|
30
|
+
projection = StrField(default=None)
|
|
31
|
+
nearest = BoolField(default=False)
|
|
32
|
+
real_time = BoolField(default=False)
|
|
33
|
+
|
|
34
|
+
def get_security(
|
|
35
|
+
self,
|
|
36
|
+
date: Date = Undefined,
|
|
37
|
+
ticker_list: list[str] = Undefined,
|
|
38
|
+
ticker_type: list[str] = Undefined,
|
|
39
|
+
projection: str = Undefined,
|
|
40
|
+
nearest: bool = Undefined
|
|
41
|
+
) -> dict:
|
|
42
|
+
"""
|
|
43
|
+
Get security data.
|
|
44
|
+
|
|
45
|
+
Args:
|
|
46
|
+
date (Date): The date.
|
|
47
|
+
ticker_list (list[str]): The ticker list.
|
|
48
|
+
ticker_type (list[str]): The ticker type.
|
|
49
|
+
projection (str): The projection.
|
|
50
|
+
nearest (bool): The nearest flag.
|
|
51
|
+
|
|
52
|
+
Returns:
|
|
53
|
+
dict: The security data.
|
|
54
|
+
"""
|
|
55
|
+
return self.get_response(self_obj=self, params={'date': date, 'ticker_list': ticker_list, 'ticker_type': ticker_type, 'projection': projection, 'nearest': nearest})
|
|
56
|
+
|
|
57
|
+
def get_historical(
|
|
58
|
+
self,
|
|
59
|
+
date: Date = Undefined,
|
|
60
|
+
start_date: Date = Undefined,
|
|
61
|
+
end_date: Date = Undefined,
|
|
62
|
+
ticker_list: list[str] = Undefined,
|
|
63
|
+
ticker_type: str = Undefined,
|
|
64
|
+
projection: str = Undefined,
|
|
65
|
+
nearest: bool = Undefined,
|
|
66
|
+
real_time: bool = Undefined
|
|
67
|
+
) -> dict:
|
|
68
|
+
"""
|
|
69
|
+
Get historical data.
|
|
70
|
+
|
|
71
|
+
Args:
|
|
72
|
+
date (Date): The date.
|
|
73
|
+
start_date (Date): The start date.
|
|
74
|
+
end_date (Date): The end date.
|
|
75
|
+
ticker_list (list[str]): The ticker list.
|
|
76
|
+
ticker_type (str): The ticker type.
|
|
77
|
+
projection (str): The projection.
|
|
78
|
+
|
|
79
|
+
Returns:
|
|
80
|
+
dict: The historical data.
|
|
81
|
+
"""
|
|
82
|
+
return self.get_response(self_obj=self, params={'date': date, 'start_date': start_date, 'end_date': end_date, 'ticker_list': ticker_list, 'ticker_type': ticker_type, 'projection': projection, 'nearest': nearest, 'real_time': real_time})
|
|
83
|
+
|
|
84
|
+
def search(
|
|
85
|
+
self,
|
|
86
|
+
conditions: list[list[str, str, Any]],
|
|
87
|
+
fields: list[str] | None = None,
|
|
88
|
+
order_by: str | None = None,
|
|
89
|
+
limit: int | None = Undefined,
|
|
90
|
+
date: str | Date = Undefined,
|
|
91
|
+
path: str = ''
|
|
92
|
+
) -> list[dict]:
|
|
93
|
+
"""
|
|
94
|
+
Search assets via Market Data Beta with dynamic filters.
|
|
95
|
+
|
|
96
|
+
Args:
|
|
97
|
+
*conditions: Each condition is a list or tuple with (field, operator, value). Example: ('cnpj_fundo', '=', '56903183000100')
|
|
98
|
+
fields (list[str]): List of fields to include in the response.
|
|
99
|
+
order_by (str): Field to order the results by. Prefix with '-' for descending order (e.g., '-columnA').
|
|
100
|
+
limit (int): Limit the number of results.
|
|
101
|
+
date (str | Date): The date to search for.
|
|
102
|
+
path (str): The path to search for.
|
|
103
|
+
|
|
104
|
+
Returns:
|
|
105
|
+
list[dict]: The search results.
|
|
106
|
+
|
|
107
|
+
"""
|
|
108
|
+
return self.get_response(self_obj=self, params={'conditions': conditions, 'fields': fields, 'order_by': order_by, 'limit': limit, 'date': date, 'path': path})
|
|
109
|
+
|
|
110
|
+
def get_currencies(self) -> dict:
|
|
111
|
+
"""
|
|
112
|
+
Get the currencies information from the Market Data engine.
|
|
113
|
+
|
|
114
|
+
Returns:
|
|
115
|
+
dict: A dictionary with the currencies information.
|
|
116
|
+
|
|
117
|
+
Example:
|
|
118
|
+
>>> from everysk.sdk.engines import MarketData
|
|
119
|
+
|
|
120
|
+
>>> market_data = MarketData()
|
|
121
|
+
>>> currencies = market_data.currencies()
|
|
122
|
+
>>> currencies
|
|
123
|
+
{
|
|
124
|
+
'base_currencies': [
|
|
125
|
+
["AED", "Uae Dirham/Us Dollar Fx Spot Rate"],
|
|
126
|
+
["USD", "Us Dollar/Us Dollar Fx Spot Rate"],
|
|
127
|
+
...
|
|
128
|
+
],
|
|
129
|
+
'crypto_currencies': [
|
|
130
|
+
["BTC", "Bitcoin"],
|
|
131
|
+
["ETH", "Ethereum"],
|
|
132
|
+
...
|
|
133
|
+
],
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
"""
|
|
137
|
+
return self.get_response(self_obj=self)
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
class MarketDataPublic:
|
|
141
|
+
## Public attributes
|
|
142
|
+
cache_timeout: int = 60 * 60 * 24 # Timeout for cache 24 hours
|
|
143
|
+
http_timeout: int = 30 # Timeout for HTTP requests 30 seconds
|
|
144
|
+
|
|
145
|
+
## Private methods
|
|
146
|
+
def _get_server_url(self) -> str:
|
|
147
|
+
""" Get the public URL for the Market Data engine. """
|
|
148
|
+
return settings.MARKET_DATA_PUBLIC_URL
|
|
149
|
+
|
|
150
|
+
def _get_response(self, url: str, params: dict) -> dict:
|
|
151
|
+
"""
|
|
152
|
+
Get the response from the Market Data engine.
|
|
153
|
+
|
|
154
|
+
Args:
|
|
155
|
+
url (str): The URL to send the request to.
|
|
156
|
+
params (dict): The parameters to include in the request.
|
|
157
|
+
"""
|
|
158
|
+
with HttpGETConnection(url=url, timeout=self.http_timeout, params=params) as conn:
|
|
159
|
+
response = conn.get_response()
|
|
160
|
+
|
|
161
|
+
return response.json()
|
|
162
|
+
|
|
163
|
+
# To use lru_cache, don't use unhashable types like dict or list as params.
|
|
164
|
+
@lru_cache(maxsize=128)
|
|
165
|
+
def _get_response_cache(self, endpoint: str, **params: dict) -> list[dict[str, str]]:
|
|
166
|
+
"""
|
|
167
|
+
Get the cached response from the Market Data engine or fetch a new one.
|
|
168
|
+
|
|
169
|
+
Args:
|
|
170
|
+
endpoint (str): The API endpoint to call.
|
|
171
|
+
params (dict): The parameters to include in the request.
|
|
172
|
+
"""
|
|
173
|
+
if 'limit' not in params:
|
|
174
|
+
params['limit'] = '*'
|
|
175
|
+
|
|
176
|
+
url = f'{self._get_server_url()}/{endpoint}'
|
|
177
|
+
return self._get_response(url=url, params=params)
|
|
178
|
+
|
|
179
|
+
## Public methods
|
|
180
|
+
def get_countries(self, **params) -> list[dict[str, str]]:
|
|
181
|
+
"""
|
|
182
|
+
Get all countries information from the Market Data.
|
|
183
|
+
Fields: code, created_at, currency, name, region, updated_at
|
|
184
|
+
|
|
185
|
+
Args:
|
|
186
|
+
fields (list[str]): The fields to include in the response.
|
|
187
|
+
order_by (str): The field to order the results by.
|
|
188
|
+
limit (int): The maximum number of results to return.
|
|
189
|
+
"""
|
|
190
|
+
params['order_by'] = params.get('order_by', 'code__asc')
|
|
191
|
+
return self._get_response_cache(endpoint='countries', **params)
|
|
192
|
+
|
|
193
|
+
def get_cryptos(self, **params) -> list[dict[str, str]]:
|
|
194
|
+
"""
|
|
195
|
+
Get all crypto information from the Market Data.
|
|
196
|
+
Fields: code, created_at, mkt_cap, name, status, updated_at, vendor_symbol, volume
|
|
197
|
+
|
|
198
|
+
Args:
|
|
199
|
+
fields (list[str]): The fields to include in the response.
|
|
200
|
+
order_by (str): The field to order the results by.
|
|
201
|
+
limit (int): The maximum number of results to return.
|
|
202
|
+
"""
|
|
203
|
+
params['order_by'] = params.get('order_by', 'code__asc')
|
|
204
|
+
return self._get_response_cache(endpoint='cryptos', **params)
|
|
205
|
+
|
|
206
|
+
def get_currencies(self, **params) -> list[dict[str, str]]:
|
|
207
|
+
"""
|
|
208
|
+
Get all currency information from the Market Data.
|
|
209
|
+
Fields: code, created_at, name, status, updated_at
|
|
210
|
+
|
|
211
|
+
Args:
|
|
212
|
+
fields (list[str]): The fields to include in the response.
|
|
213
|
+
order_by (str): The field to order the results by.
|
|
214
|
+
limit (int): The maximum number of results to return.
|
|
215
|
+
"""
|
|
216
|
+
params['order_by'] = params.get('order_by', 'code__asc')
|
|
217
|
+
return self._get_response_cache(endpoint='currencies', **params)
|
|
218
|
+
|
|
219
|
+
def get_exchanges(self, **params) -> list[dict[str, str]]:
|
|
220
|
+
"""
|
|
221
|
+
Get all exchange information from the Market Data.
|
|
222
|
+
Fields: country, created_at, description, exchange_type, mic, updated_at
|
|
223
|
+
|
|
224
|
+
Args:
|
|
225
|
+
fields (list[str]): The fields to include in the response.
|
|
226
|
+
order_by (str): The field to order the results by.
|
|
227
|
+
limit (int): The maximum number of results to return.
|
|
228
|
+
"""
|
|
229
|
+
params['order_by'] = params.get('order_by', 'mic__asc')
|
|
230
|
+
return self._get_response_cache(endpoint='exchanges', **params)
|
|
231
|
+
|
|
232
|
+
def get_holidays(self, **params) -> list[dict[str, str]]:
|
|
233
|
+
"""
|
|
234
|
+
Get all holiday information from the Market Data.
|
|
235
|
+
Fields: calendar, created_at, date, description, updated_at, year
|
|
236
|
+
If some range is needed you can use year__gt=2024, year__lt=2026.
|
|
237
|
+
|
|
238
|
+
Args:
|
|
239
|
+
fields (list[str]): The fields to include in the response.
|
|
240
|
+
order_by (str): The field to order the results by.
|
|
241
|
+
limit (int): The maximum number of results to return.
|
|
242
|
+
"""
|
|
243
|
+
params['order_by'] = params.get('order_by', 'date__asc')
|
|
244
|
+
return self._get_response_cache(endpoint='holidays', **params)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
###############################################################################
|
|
2
|
+
#
|
|
3
|
+
# (C) Copyright 2023 EVERYSK TECHNOLOGIES
|
|
4
|
+
#
|
|
5
|
+
# This is an unpublished work containing confidential and proprietary
|
|
6
|
+
# information of EVERYSK TECHNOLOGIES. Disclosure, use, or reproduction
|
|
7
|
+
# without authorization of EVERYSK TECHNOLOGIES is prohibited.
|
|
8
|
+
#
|
|
9
|
+
###############################################################################
|
|
10
|
+
from everysk.core.fields import FloatField, IntField, ListField, StrField, TupleField
|
|
11
|
+
|
|
12
|
+
ENGINES_EXPRESSION_DEFAULT_DATA_TYPES = TupleField(default=('cpp_var', 'str_var'), readonly=True)
|
|
13
|
+
ENGINES_CACHE_EXECUTION_EXPIRATION_TIME = IntField(default=14400, readonly=True)
|
|
14
|
+
ENGINES_MARKET_DATA_TICKER_TYPES = ListField(default=('everysk_symbol', 'everysk_id', None), readonly=True)
|
|
15
|
+
|
|
16
|
+
MARKET_DATA_PUBLIC_URL = StrField(default='https://public-market-data-1088321674060.us-central1.run.app', readonly=True)
|
|
17
|
+
USER_CACHE_LOCK_EXPIRATION_TIME = FloatField(default=10.0, readonly=True)
|
|
18
|
+
USER_CACHE_LOCK_MIN_EXPIRATION_TIME = FloatField(default=0.01, readonly=True)
|
|
19
|
+
USER_CACHE_LOCK_MAX_EXPIRATION_TIME = FloatField(default=60.0, readonly=True)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
###############################################################################
|
|
2
|
+
#
|
|
3
|
+
# (C) Copyright 2025 EVERYSK TECHNOLOGIES
|
|
4
|
+
#
|
|
5
|
+
# This is an unpublished work containing confidential and proprietary
|
|
6
|
+
# information of EVERYSK TECHNOLOGIES. Disclosure, use, or reproduction
|
|
7
|
+
# without authorization of EVERYSK TECHNOLOGIES is prohibited.
|
|
8
|
+
#
|
|
9
|
+
###############################################################################
|
|
10
|
+
from everysk.core.string import import_from_string
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
###############################################################################
|
|
14
|
+
# Private Functions Implementation
|
|
15
|
+
###############################################################################
|
|
16
|
+
def __getattr__(_name: str):
|
|
17
|
+
from everysk.config import settings # pylint: disable=import-outside-toplevel
|
|
18
|
+
modules = settings.EVERYSK_SDK_ENTITIES_MODULES_PATH
|
|
19
|
+
|
|
20
|
+
if _name in modules:
|
|
21
|
+
return import_from_string(modules[_name])
|
|
22
|
+
|
|
23
|
+
raise AttributeError(f"cannot import name '{_name}' from everysk.sdk")
|