onetick-py 1.166.0__py3-none-any.whl → 1.168.0__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.
onetick/lib/instance.py CHANGED
@@ -5,7 +5,7 @@ import gc
5
5
  import inspect
6
6
  from enum import Enum
7
7
 
8
- if os.getenv("OTP_WEBAPI"):
8
+ if os.getenv('OTP_WEBAPI', default='').lower() not in ('0', 'false', 'no', ''):
9
9
  import onetick.query_webapi as otq
10
10
 
11
11
  class OneTickLibMock:
onetick/py/__init__.py CHANGED
@@ -2,7 +2,7 @@
2
2
  import os
3
3
  from . import _version
4
4
  __version__ = _version.VERSION
5
- __webapi__: bool = bool(os.getenv("OTP_WEBAPI"))
5
+ __webapi__: bool = os.getenv('OTP_WEBAPI', default='').lower() not in ('0', 'false', 'no', '')
6
6
 
7
7
 
8
8
  def __validate_onetick_query_integration(): # noqa
@@ -77,7 +77,8 @@ def __validate_onetick_query_integration(): # noqa
77
77
  if _otq_import_ex is None:
78
78
  return
79
79
 
80
- # webapi is installed to pip and OTP_WEBAPI=1, we don't need to raise any exception
80
+ # PY-1033: if we can't import onetick.query, but can import onetick.query_webapi
81
+ # then we can just use it and don't need to raise any exception (even if OTP_WEBAPI is not set)
81
82
  try:
82
83
  import onetick.query_webapi
83
84
  __webapi__ = True
onetick/py/_version.py CHANGED
@@ -1,2 +1,2 @@
1
1
  # This file was generated automatically. DO NOT CHANGE.
2
- VERSION = '1.166.0'
2
+ VERSION = '1.168.0'
@@ -758,3 +758,12 @@ def is_include_market_order_ticks_supported(**kwargs):
758
758
  return _is_min_build_or_version(1.25, 20241229055942,
759
759
  20240812120000, min_update_number=2,
760
760
  **kwargs)
761
+
762
+
763
+ def is_join_with_query_symbol_time_otq_supported():
764
+ # 20241209: Fixed 0034770: hours/minutes/seconds part of otq parameter _SYMBOL_TIME, expressed in
765
+ # milliseconds since 1970/01/01 00:00:00 GMT, is ignored
766
+ # 20250219: Implemented 0035092: passing otq param _SYMBOL_TIME should be just like setting symbol_date
767
+ # to the equivalent value, except in YYYYMMDDhhmmss format
768
+ return _is_min_build_or_version(None, None,
769
+ 20250227120000)
@@ -14,6 +14,7 @@ from onetick.py.core.eval_query import prepare_params
14
14
  from onetick.py.otq import otq
15
15
  from onetick.py.compatibility import (
16
16
  is_supported_point_in_time,
17
+ is_join_with_query_symbol_time_otq_supported,
17
18
  is_join_with_snapshot_snapshot_fields_parameter_supported,
18
19
  )
19
20
 
@@ -72,6 +73,19 @@ def _columns_to_params_for_joins(columns, query_params=False):
72
73
  else:
73
74
  raise ValueError('Parameter symbol_time has to be a datetime value!')
74
75
 
76
+ elif key == '_SYMBOL_TIME' and query_params:
77
+ # hack to support passing _SYMBOL_TIME to called query as a parameter
78
+ if dtype is otp.nsectime:
79
+ convert_rule += get_msecs_expression(ott.value2str(value))
80
+ elif dtype is str:
81
+ ns = f'PARSE_NSECTIME("%Y%m%d%H%M%S", {ott.value2str(value)}, _TIMEZONE)'
82
+ convert_rule += get_msecs_expression(ns)
83
+ elif dtype is otp.msectime:
84
+ # for backward compatibility
85
+ convert_rule += get_msecs_expression(value)
86
+ else:
87
+ raise ValueError('Parameter symbol_time has to be a datetime value!')
88
+
75
89
  elif dtype is str:
76
90
  if are_strings(getattr(value, "dtype", None)):
77
91
  convert_rule += str(value)
@@ -80,17 +94,7 @@ def _columns_to_params_for_joins(columns, query_params=False):
80
94
  elif dtype is otp.msectime:
81
95
  convert_rule += get_msecs_expression(value)
82
96
  elif dtype is otp.nsectime:
83
- if key == '_SYMBOL_TIME' and query_params:
84
- # hack to support passing _SYMBOL_TIME to called query as a parameter
85
- warnings.warn(
86
- 'Query parameter _SYMBOL_TIME passed to join_with_query! '
87
- 'This is deprecated. Please use a dedicated `symbol_time` parameter of the '
88
- 'join_with_query function',
89
- FutureWarning,
90
- stacklevel=3,
91
- )
92
- convert_rule += get_msecs_expression(value)
93
- elif query_params:
97
+ if query_params:
94
98
  # this can be used for query params but cannot be used for symbol params
95
99
  # overall it's better
96
100
  convert_rule += "'NSECTIME('+tostring(NSECTIME_TO_LONG(" + str(value) + "))+')'"
@@ -672,10 +676,10 @@ def join_with_query(
672
676
  Function object as query is also supported (Note it will be executed only once in python's code):
673
677
 
674
678
  >>> def func(symbol):
675
- ... d = otp.Ticks(TYPE=["six"])
676
- ... d = d.update(dict(TYPE="three"), where=(symbol.name == "3")) # symbol is always converted to string
677
- ... d["TYPE"] = symbol['PREF'] + d["TYPE"] + symbol['POST']
678
- ... return d
679
+ ... d = otp.Ticks(TYPE=["six"])
680
+ ... d = d.update(dict(TYPE="three"), where=(symbol.name == "3")) # symbol is always converted to string
681
+ ... d["TYPE"] = symbol['PREF'] + d["TYPE"] + symbol['POST']
682
+ ... return d
679
683
  >>> # OTdirective: snippet-name: Special functions.join with query.with a function
680
684
  >>> data = otp.Ticks(A=[1, 2], B=[2, 4])
681
685
  >>> res = data.join_with_query(func, how='inner', symbol=(data['A'] + data['B'], dict(PREF="_", POST="$")))
@@ -689,9 +693,9 @@ def join_with_query(
689
693
  accessible through the "symbol" object:
690
694
 
691
695
  >>> def func(symbol):
692
- ... d = otp.Ticks(TYPE=["six"])
693
- ... d["TYPE"] = symbol['PREF'] + d["TYPE"] + symbol['POST']
694
- ... return d
696
+ ... d = otp.Ticks(TYPE=["six"])
697
+ ... d["TYPE"] = symbol['PREF'] + d["TYPE"] + symbol['POST']
698
+ ... return d
695
699
  >>> # OTdirective: snippet-name: 'Source' operations.join with query.source as symbol;
696
700
  >>> data = otp.Ticks(A=[1, 2], B=[2, 4], PREF=["_", "$"], POST=["$", "_"])
697
701
  >>> res = data.join_with_query(func, how='inner', symbol=data)
@@ -834,22 +838,20 @@ def join_with_query(
834
838
  'object (dict or Source), or a tuple containing both'
835
839
  )
836
840
 
837
- # adding symbol time
838
841
  if '_PARAM_SYMBOL_TIME' in converted_symbol_param_columns.keys():
839
842
  warnings.warn(
840
843
  '"_PARAM_SYMBOL_TIME" explicitly passed among join_with_query symbol parameters! '
841
- 'This is deprecated - please use symbol_time parameter instead. '
842
- 'If you specify symbol_time parameter, it will override the explicitly passed value',
844
+ 'This is deprecated - please use symbol_time parameter instead.',
845
+ FutureWarning,
846
+ stacklevel=2,
847
+ )
848
+ if '_SYMBOL_TIME' in params.keys():
849
+ warnings.warn(
850
+ 'Query parameter "_SYMBOL_TIME" passed to join_with_query! '
851
+ 'This is deprecated. Please use a dedicated `symbol_time` parameter.',
843
852
  FutureWarning,
844
853
  stacklevel=2,
845
854
  )
846
- if symbol_time is not None:
847
- if ott.get_object_type(symbol_time) is not otp.nsectime and ott.get_object_type(symbol_time) is not str:
848
- raise ValueError(
849
- f'Parameter of type {ott.get_object_type(symbol_time)} passed as symbol_time! '
850
- 'This parameter only supports datetime values or strings'
851
- )
852
- converted_symbol_param_columns['_PARAM_SYMBOL_TIME'] = symbol_time
853
855
 
854
856
  # prepare temporary file
855
857
  # ------------------------------------ #
@@ -875,6 +877,19 @@ def join_with_query(
875
877
  if not sub_source._is_unbound_required():
876
878
  sub_source += otp.Empty()
877
879
 
880
+ # adding symbol time
881
+ if symbol_time is not None:
882
+ if ott.get_object_type(symbol_time) is not otp.nsectime and ott.get_object_type(symbol_time) is not str:
883
+ raise ValueError(
884
+ f'Parameter of type {ott.get_object_type(symbol_time)} passed as symbol_time! '
885
+ 'This parameter only supports datetime values or strings'
886
+ )
887
+ if is_join_with_query_symbol_time_otq_supported():
888
+ params = params.copy()
889
+ params['_SYMBOL_TIME'] = symbol_time
890
+ else:
891
+ converted_symbol_param_columns['_PARAM_SYMBOL_TIME'] = symbol_time
892
+
878
893
  params_str = _columns_to_params_for_joins(params, query_params=True)
879
894
  symbol_params_str = _columns_to_params_for_joins(converted_symbol_param_columns)
880
895
 
@@ -1,11 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: onetick-py
3
- Version: 1.166.0
3
+ Version: 1.168.0
4
4
  Summary: Python package that allows you to work with OneTick
5
5
  Author-email: solutions <solutions@onetick.com>
6
6
  License-Expression: MIT
7
7
  Project-URL: Documentation, https://docs.pip.distribution.sol.onetick.com
8
- Project-URL: OneTick, https://onetick.com/
8
+ Project-URL: OneTick, https://onetick.com
9
+ Project-URL: GitHub, https://github.com/onemarketdata/onetick-py
9
10
  Classifier: Topic :: Database :: Front-Ends
10
11
  Classifier: Topic :: Scientific/Engineering
11
12
  Classifier: Programming Language :: Python :: 3.9
@@ -10,13 +10,13 @@ onetick/doc_utilities/napoleon.py,sha256=CE2r7xJ2Oz_MHDbMQx5hOE6JxkRPXQE55QE4bq3
10
10
  onetick/doc_utilities/ot_doctest.py,sha256=AWF-rXyF3BqYSYcxIuImUC1ezbkqxrmaG6DsHexW1e4,4101
11
11
  onetick/doc_utilities/snippets.py,sha256=q1mergoBMGxiVOnuWuKIKTMOOJ7O_EWp4SKIesK8piM,8930
12
12
  onetick/lib/__init__.py,sha256=Rp7CIDoA4E6LIm1f2mNvl_5b_n-0U3suA3FmBXbmKoU,114
13
- onetick/lib/instance.py,sha256=Fn3yoowjBtImAhR6n-f-Ti5J1q-RdDI-EGLpZvNwTi4,4773
14
- onetick/py/__init__.py,sha256=j2WBnhu01i8VdOYkn9BGc-7JeAqXQoCFjVfXFZCSz-4,10950
13
+ onetick/lib/instance.py,sha256=3FJB8PWs2ap-EGb6DzsnLRL2meTMUViTdy343m6tHvM,4825
14
+ onetick/py/__init__.py,sha256=Kxqcimy3N2m0j7fKtLcJkUEzK8aVc1KadJBb4BMB7qI,11093
15
15
  onetick/py/_stack_info.py,sha256=PHZOkW_fK7Fbl4YEj5CaYK9L6vh4j-bUU7_cSYOWZ30,2546
16
- onetick/py/_version.py,sha256=T7ZvgZ7oLmgBxuEhhoUnyBO9HmAIkrC8X-53r0gdo00,76
16
+ onetick/py/_version.py,sha256=ez2JjayGNBgEc5sdZ8WODcct19IhBk97v6qaJmd1SIA,76
17
17
  onetick/py/backports.py,sha256=mR00mxe7E7UgBljf-Wa93Mo6lpi-C4Op561uhPUoEt8,815
18
18
  onetick/py/cache.py,sha256=f9WwFFCTqCP3eaA4V57tNPjCBHNPzU8ZvH81IuUsBE8,12756
19
- onetick/py/compatibility.py,sha256=99UHDi58IZSLl9XcWjJTZerAsHGp_zV6zqfwRl2yDTY,30068
19
+ onetick/py/compatibility.py,sha256=G6L1HYvSrn0K5fFN0w3DQqaXoUJjmTTfDny2m7MXxdo,30556
20
20
  onetick/py/configuration.py,sha256=Cb_tH3F2vKMF27mFtd5TwXxhUA5Axmxp2TR3OKFfmQ0,27497
21
21
  onetick/py/functions.py,sha256=LyLQ7NTNFzKfkR3A5RazS3tOtVqORe1BPrg6B4AAuLM,97689
22
22
  onetick/py/license.py,sha256=50dsFrE-NKsPOdkAoyxHr44bH8DzFCr_6TabX0JH6tQ,6140
@@ -79,7 +79,7 @@ onetick/py/core/_source/source_methods/debugs.py,sha256=Hq08HYjF2sEZQAcBlwNMVKpu
79
79
  onetick/py/core/_source/source_methods/drops.py,sha256=3ZXfQWXsl0-ZLHdp6D-wTu2saqCYHZ-Gn777aMRSRp0,4403
80
80
  onetick/py/core/_source/source_methods/fields.py,sha256=6GozvRornClXfEu6oY9-JpN3gOceewB6OJweRR7x2Zw,22740
81
81
  onetick/py/core/_source/source_methods/filters.py,sha256=WuSnK-tQsP3fL2bqVfMZpbpPgk_LG4L8lrYULSSGoKE,33930
82
- onetick/py/core/_source/source_methods/joins.py,sha256=Tozh9PxFpnnYfZNQ-dggzAV-PrbTeEZ2G-afSac8KJ0,60638
82
+ onetick/py/core/_source/source_methods/joins.py,sha256=B7Nw3oSJIdTNvTDDHHTOMrmea5p0llQNXBEg9eoaMx0,61172
83
83
  onetick/py/core/_source/source_methods/merges.py,sha256=efk-R4WOjB2pcAIGWPsZsDzYuitADztH5xtRWTBfutk,23115
84
84
  onetick/py/core/_source/source_methods/misc.py,sha256=Y6H-fJEVlTYNjiDVO9phVI-A9IaGzBSV-11GuoX4ZU4,57012
85
85
  onetick/py/core/_source/source_methods/pandases.py,sha256=BbvIlw6ipqC2dOiKSyyZ5jhAtE4ZtdL30OZXV_e_FuE,3670
@@ -144,9 +144,9 @@ onetick/py/utils/script.py,sha256=Y8NujEo2_5QaP6KDnLKJiKQ7SmMjw8_dv8sYL9rHDCE,11
144
144
  onetick/py/utils/temp.py,sha256=j-BC155dE46k0zfKTTs26KTF0CK6WA1hO2GD54iunyM,17380
145
145
  onetick/py/utils/types.py,sha256=_tYf66r9JVgjtiCJfxIxrg_BQEjHkjlnck_i86dBYEY,3606
146
146
  onetick/py/utils/tz.py,sha256=QXclESLGU8YXysUT9DXkcBqLWWO47Bb_tanFUzYpPZI,2800
147
- onetick_py-1.166.0.dist-info/licenses/LICENSE,sha256=Yhu7lKNFS0fsaN-jSattEMRtCOPueP58Eu5BPH8ZGjM,1075
148
- onetick_py-1.166.0.dist-info/METADATA,sha256=9XNNTuV5nIuI__DkAo55-tf9ffox-brTrXioDP7_DIA,7960
149
- onetick_py-1.166.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
150
- onetick_py-1.166.0.dist-info/entry_points.txt,sha256=QmK_tFswIN-SQRmtnTSBEi8GvT0TVq-66IzXXZIsV3U,81
151
- onetick_py-1.166.0.dist-info/top_level.txt,sha256=Na1jSJmVMyYGOndaswt554QKIUwQjcYh6th2ATsmw0U,23
152
- onetick_py-1.166.0.dist-info/RECORD,,
147
+ onetick_py-1.168.0.dist-info/licenses/LICENSE,sha256=Yhu7lKNFS0fsaN-jSattEMRtCOPueP58Eu5BPH8ZGjM,1075
148
+ onetick_py-1.168.0.dist-info/METADATA,sha256=H4m68NHPxufzDpqpF57CLSwzWSOOxtnWgdJTH0MC1yg,8024
149
+ onetick_py-1.168.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
150
+ onetick_py-1.168.0.dist-info/entry_points.txt,sha256=QmK_tFswIN-SQRmtnTSBEi8GvT0TVq-66IzXXZIsV3U,81
151
+ onetick_py-1.168.0.dist-info/top_level.txt,sha256=Na1jSJmVMyYGOndaswt554QKIUwQjcYh6th2ATsmw0U,23
152
+ onetick_py-1.168.0.dist-info/RECORD,,