onetick-py 1.179.0__py3-none-any.whl → 1.181.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/py/_version.py CHANGED
@@ -1,2 +1,2 @@
1
1
  # This file was generated automatically. DO NOT CHANGE.
2
- VERSION = '1.179.0'
2
+ VERSION = '1.181.0'
@@ -859,3 +859,9 @@ def is_not_fixed_bds_484():
859
859
  # BDS-484: seems like timezone is ignored in otq.run in some cases
860
860
  return _is_min_build_or_version(None, None,
861
861
  20251010120000, min_update_number=2)
862
+
863
+
864
+ def is_webapi_access_token_scope_supported():
865
+ # 20251030: Fixed OTDEV-37063: onetick.query_webapi.get_access_token method must take scope as a parameter
866
+ return _is_min_build_or_version(None, None,
867
+ 20251010120000, min_update_number=2)
@@ -644,6 +644,13 @@ class Config:
644
644
  env_var_name='OTP_ACCESS_TOKEN_URL',
645
645
  )
646
646
 
647
+ access_token_scope = OtpProperty(
648
+ description='Scope for obtaining SSO access token.',
649
+ base_default=None,
650
+ allowed_types=str,
651
+ env_var_name='OTP_ACCESS_TOKEN_SCOPE',
652
+ )
653
+
647
654
  trusted_certificates_file = OtpProperty(
648
655
  description='Either a boolean, in which case it controls whether we verify the server TLS certificate '
649
656
  'or a string with the path to the file with list of '
@@ -8,6 +8,7 @@ from onetick.py.compatibility import is_existing_fields_handling_supported
8
8
  from onetick.py.core._internal._state_objects import _StateColumn
9
9
  from onetick.py.core.column import _Column, _ColumnAggregation, _LagOperator
10
10
  from onetick.py.core.column_operations._methods.methods import is_arithmetical, is_compare
11
+ from onetick.py.core.column_operations._methods.op_types import are_ints_not_time
11
12
  from onetick.py.core.column_operations.base import _Operation
12
13
  from onetick.py.core.cut_builder import _BaseCutBuilder
13
14
  from onetick.py.core.lambda_object import _LambdaIfElse
@@ -280,6 +281,13 @@ def _update_field(self: 'Source', field, value):
280
281
  elif issubclass(field.dtype, str) and base_type is int:
281
282
  type_changes = True
282
283
  convert_to_type = int
284
+ elif (
285
+ are_ints_not_time(field.dtype, value_dtype) and
286
+ not issubclass(field.dtype, bool) and not issubclass(value_dtype, bool) and
287
+ value_dtype is not field.dtype
288
+ ):
289
+ # case for converting values between int based types, like long or byte
290
+ convert_to_type = value_dtype
283
291
  else:
284
292
  if issubclass(value_dtype, bool):
285
293
  value_dtype = float
@@ -544,6 +544,8 @@ def join_with_query(
544
544
  default_fields_for_outer_join=None,
545
545
  symbol_time=None,
546
546
  concurrency=None,
547
+ batch_size=None,
548
+ shared_thread_count=None,
547
549
  process_query_async: bool = True,
548
550
  **kwargs,
549
551
  ) -> 'Source':
@@ -621,7 +623,12 @@ def join_with_query(
621
623
  symbol_time : :py:class:`otp.datetime <onetick.py.datetime>`, :py:class:`otp.Operation <onetick.py.Operation>`
622
624
  Time that will be used by Onetick to map the symbol with which ``query`` is executed to the reference data.
623
625
  This parameter is only necessary if the query is expected to perform symbology conversions.
624
- concurrency : int
626
+ concurrency: int
627
+ Specifies concurrency for the joined ``query`` execution.
628
+ Default is 1 (no concurrency).
629
+ batch_size: int
630
+ Specifies batch size for the joined ``query`` execution. Default is 0.
631
+ shared_thread_count: int
625
632
  Specifies number of threads for asynchronous processing of ``query`` per unbound symbol list.
626
633
  By default, the number of threads is 1.
627
634
  process_query_async: bool
@@ -904,11 +911,23 @@ def join_with_query(
904
911
  columns.update(self._get_columns_with_prefix(sub_source, prefix))
905
912
  columns.update(self.columns(skip_meta_fields=True))
906
913
 
914
+ otq_properties = {}
915
+ if concurrency is not None:
916
+ if not isinstance(concurrency, int) or concurrency <= 0:
917
+ raise ValueError(f"Parameter 'concurrency' should be a positive integer, got {concurrency}")
918
+ otq_properties['concurrency'] = concurrency
919
+
920
+ if batch_size is not None:
921
+ if not isinstance(batch_size, int) or batch_size < 0:
922
+ raise ValueError(f"Parameter 'batch_size' should be a non-negative integer, got {batch_size}")
923
+ otq_properties['batch_size'] = batch_size
924
+
907
925
  res = self.copy(columns=columns)
908
926
 
909
927
  res._merge_tmp_otq(sub_source)
910
928
  query_name = sub_source._store_in_tmp_otq(
911
- res._tmp_otq, symbols='_NON_EXISTING_SYMBOL_', operation_suffix="join_with_query"
929
+ res._tmp_otq, symbols='_NON_EXISTING_SYMBOL_', operation_suffix="join_with_query",
930
+ **otq_properties,
912
931
  ) # TODO: combine with _convert_symbol_to_string
913
932
  # ------------------------------------ #
914
933
 
@@ -928,10 +947,10 @@ def join_with_query(
928
947
  default_fields_for_outer_join=default_fields_for_outer_join_str,
929
948
  process_query_asynchronously=process_query_async,
930
949
  )
931
- if concurrency is not None:
932
- if not isinstance(concurrency, int) or concurrency <= 0:
933
- raise ValueError('Wrong value of concurrency parameter passed! concurrency should be a positive integer')
934
- join_params['shared_thread_count'] = concurrency
950
+ if shared_thread_count is not None:
951
+ if not isinstance(shared_thread_count, int) or shared_thread_count <= 0:
952
+ raise ValueError("Parameter 'shared_thread_count' should be a positive integer")
953
+ join_params['shared_thread_count'] = shared_thread_count
935
954
 
936
955
  start_time = kwargs.get('start_time', start)
937
956
  end_time = kwargs.get('end_time', end)
@@ -259,16 +259,27 @@ def write(
259
259
  raise ValueError('LOAD out_of_range_tick_action cannot be used with start_date+end_date, use date instead')
260
260
  elif out_of_range_tick_action.upper() == 'EXCEPTION':
261
261
  if start_date and end_date:
262
+ end = end_date + otp.Day(1) # end_date is inclusive
263
+
262
264
  # WRITE_TO_ONETICK_DB use DAY_BOUNDARY_TZ and DAY_BOUNDARY_OFFSET
263
265
  # to check tick timestamp is out of range or not
264
266
  # so we mimic it here with THROW event processor
265
- src = otp.Source(otq.DbShowConfig(str(db), 'DB_TIME_INTERVALS'))
267
+ src = otp.Source(otq.DbShowConfig(str(db), 'DB_TIME_INTERVALS'), schema={
268
+ 'DAY_BOUNDARY_TZ': int, 'DAY_BOUNDARY_OFFSET': int, 'START_DATE': int, 'END_DATE': int,
269
+ })
270
+
271
+ # Filter not relevant locator time intervals
272
+ src, _ = src[
273
+ (src['START_DATE'].astype(otp.msectime) <= otp.dt(start_date).to_operation()) &
274
+ (src['END_DATE'].astype(otp.msectime) > otp.dt(end).to_operation())
275
+ ]
266
276
  src.table(inplace=True, DAY_BOUNDARY_TZ=str, DAY_BOUNDARY_OFFSET=int)
267
277
  # DAY_BOUNDARY_OFFSET offset are in seconds
268
278
  src['DAY_BOUNDARY_OFFSET'] = src['DAY_BOUNDARY_OFFSET'] * 1000
269
279
  src.rename(
270
280
  {'DAY_BOUNDARY_TZ': '__DAY_BOUNDARY_TZ', 'DAY_BOUNDARY_OFFSET': '__DAY_BOUNDARY_OFFSET'}, inplace=True
271
281
  )
282
+
272
283
  self = self.join_with_query(src, symbol=f"{str(db)}::DUMMY", caching='per_symbol')
273
284
  timezone = self['__DAY_BOUNDARY_TZ']
274
285
  offset = self['__DAY_BOUNDARY_OFFSET']
@@ -288,7 +299,6 @@ def write(
288
299
  inplace=True,
289
300
  )
290
301
 
291
- end = end_date + otp.Day(1) # end_date is inclusive
292
302
  end_formatted = end.strftime('%Y-%m-%d')
293
303
  end_op = otp.dt(end).to_operation(timezone=timezone) + offset
294
304
  self.throw(
@@ -63,6 +63,14 @@ class TmpOtq:
63
63
  def __init__(self):
64
64
  self.queries = {}
65
65
 
66
+ def __check_params(self, params):
67
+ supported_query_parameters = ('running_query_flag', 'symbol_date', 'concurrency', 'batch_size')
68
+ for param in params:
69
+ if param not in supported_query_parameters:
70
+ raise ValueError(
71
+ f"Query parameter '{param}' is not one of the supported parameters: {supported_query_parameters}"
72
+ )
73
+
66
74
  def add_query(self, query, suffix="", name=None, params=None):
67
75
  """
68
76
  Adds query with a unique generated name to the storage.
@@ -89,6 +97,7 @@ class TmpOtq:
89
97
  raise ValueError(f"There is already a query with name '{name}' in {self.__class__.__name__} storage")
90
98
  if params is None:
91
99
  params = {}
100
+ self.__check_params(params)
92
101
  self.queries[name] = (query, params)
93
102
  return name
94
103
 
@@ -119,7 +128,9 @@ class TmpOtq:
119
128
  def save_to_file(self, query=None, query_name="main_query", file_path=None, file_suffix="",
120
129
  start=None, end=None, start_time_expression=None, end_time_expression=None, timezone=None,
121
130
  running_query_flag=None,
122
- symbol_date=None):
131
+ symbol_date=None,
132
+ concurrency=None,
133
+ batch_size=None):
123
134
  """
124
135
  Saves all queries from the query dict and one more query (if passed);
125
136
  returns absolute path to passed query in file (if passed) or path of resulted file
@@ -146,9 +157,17 @@ class TmpOtq:
146
157
  end time expression for the resulting .otq file
147
158
  timezone: str
148
159
  timezone for the resulting .otq file
160
+ running_query_flag:
161
+ Will be applied only to the query specified in the ``query`` parameter.
149
162
  symbol_date: :py:class:`otp.datetime <onetick.py.datetime>` or :py:class:`datetime.datetime` or int
150
163
  Symbol date for the query or integer in the YYYYMMDD format.
151
164
  Will be applied only to the query specified in the ``query`` parameter.
165
+ concurrency: int
166
+ Concurrency set for the query.
167
+ Will be applied only to the query specified in the ``query`` parameter.
168
+ batch_size: int
169
+ Batch size set for the query.
170
+ Will be applied only to the query specified in the ``query`` parameter.
152
171
 
153
172
  Returns
154
173
  -------
@@ -178,6 +197,10 @@ class TmpOtq:
178
197
  query_params['running_query_flag'] = running_query_flag
179
198
  if symbol_date is not None:
180
199
  query_params['symbol_date'] = symbol_date
200
+ if concurrency is not None:
201
+ query_params['concurrency'] = concurrency
202
+ if batch_size is not None:
203
+ query_params['batch_size'] = batch_size
181
204
  queries_dict[query_name] = (query, query_params)
182
205
 
183
206
  # defining file-wise start/end times and time expressions
@@ -217,6 +240,11 @@ class TmpOtq:
217
240
  if stored_symbol_date is not None:
218
241
  stored_symbol_date = int(utils.symbol_date_to_str(stored_symbol_date))
219
242
  stored_query.set_symbol_date(stored_symbol_date)
243
+ if stored_query_params.get('concurrency') is not None:
244
+ stored_query.set_max_concurrency(stored_query_params['concurrency'])
245
+ if stored_query_params.get('batch_size') is not None:
246
+ stored_query.set_batch_size(stored_query_params['batch_size'])
247
+
220
248
  query_list.append(stored_query)
221
249
 
222
250
  _ = otli.OneTickLib()
onetick/py/core/source.py CHANGED
@@ -526,7 +526,8 @@ class Source:
526
526
  symbol_date=symbol_date)
527
527
 
528
528
  def _store_in_tmp_otq(self, tmp_otq, operation_suffix="tmp_query", symbols=None, start=None, end=None,
529
- raw=None, add_passthrough=True, name=None, timezone=None, symbol_date=None):
529
+ raw=None, add_passthrough=True, name=None, timezone=None, symbol_date=None,
530
+ concurrency=None, batch_size=None):
530
531
  """
531
532
  Adds this source to the tmp_otq storage
532
533
 
@@ -573,7 +574,13 @@ class Source:
573
574
  else:
574
575
  graph.time_interval_properties().set_timezone(timezone)
575
576
 
576
- params = {'symbol_date': symbol_date} if symbol_date is not None else {}
577
+ params = {}
578
+ if symbol_date is not None:
579
+ params['symbol_date'] = symbol_date
580
+ if concurrency is not None:
581
+ params['concurrency'] = concurrency
582
+ if batch_size is not None:
583
+ params['batch_size'] = batch_size
577
584
  suffix = self._name_suffix(suffix=operation_suffix, separator='__', remove_invalid_symbols=True)
578
585
  return tmp_otq.add_query(graph, suffix=suffix, name=name, params=params)
579
586
 
onetick/py/otq.py CHANGED
@@ -58,7 +58,10 @@ elif otp.__webapi__:
58
58
 
59
59
  def run(*args, **kwargs):
60
60
  from onetick.py import config # noqa
61
- from onetick.py.compatibility import is_max_concurrency_with_webapi_supported
61
+ from onetick.py.compatibility import (
62
+ is_max_concurrency_with_webapi_supported,
63
+ is_webapi_access_token_scope_supported
64
+ )
62
65
 
63
66
  if not config.http_address and 'http_address' not in kwargs:
64
67
  raise ValueError('otp.run() http_address keyword param, '
@@ -149,7 +152,20 @@ elif otp.__webapi__:
149
152
  if not param_value:
150
153
  raise ValueError(f'`access_token_url` parameter set, however `{param_name}` parameter missing.')
151
154
 
152
- kwargs['access_token'] = otq.get_access_token(access_token_url, client_id, client_secret)
155
+ token_kwargs = {}
156
+
157
+ if 'scope' in kwargs:
158
+ scope = kwargs.pop('scope')
159
+ else:
160
+ scope = config.access_token_scope
161
+
162
+ if scope:
163
+ if not is_webapi_access_token_scope_supported():
164
+ raise RuntimeError('Parameter `scope` is not supported on used version of OneTick')
165
+
166
+ token_kwargs['scope'] = scope
167
+
168
+ kwargs['access_token'] = otq.get_access_token(access_token_url, client_id, client_secret, **token_kwargs)
153
169
 
154
170
  if 'access_token_url' in kwargs:
155
171
  del kwargs['access_token_url']
@@ -17,9 +17,9 @@ from .common import update_node_tick_type
17
17
 
18
18
  class Symbols(Source):
19
19
  """
20
- Construct a source that returns ticks with information about symbols in a database.
21
- The SYMBOL_NAME field is populated with symbol names. The TICK_TYPE field contains
22
- corresponding tick type (enabled by the ``show_tick_type`` parameter).
20
+ Construct a source that returns symbol names from the database.
21
+
22
+ The **SYMBOL_NAME** field will contain symbol names.
23
23
 
24
24
  Parameters
25
25
  ----------
@@ -42,7 +42,7 @@ class Symbols(Source):
42
42
  If you want symbol name to contain literal ``%`` character, you should write ``NQ\\%``.
43
43
  ``\\`` is a special character too, so it need to be escaped too
44
44
  if you want symbol name to contain literal backslash, e.g. ``NQ\\\\M23``.
45
- Default is ``%``.
45
+ Default is ``%`` (any symbol name).
46
46
 
47
47
  for_tick_type: str
48
48
  Fetch only symbols belong to this tick type, if specified.
@@ -54,10 +54,14 @@ class Symbols(Source):
54
54
  Translation is performed, if destination symbology is not empty
55
55
  and is different from that of the queried database.
56
56
  show_original_symbols: bool
57
- Switches original symbol name propagation as a tick field ORIGINAL_SYMBOL_NAME
58
- if symbol name translation is performed (if `symbology` is set).
59
- Note that if this parameter is set to True,
60
- database symbols with missing translations are also propagated.
57
+ Switches original symbol name propagation as a tick field **ORIGINAL_SYMBOL_NAME**
58
+ if symbol name translation is performed (if parameter ``symbology`` is set).
59
+
60
+ .. note::
61
+
62
+ If this parameter is set to True, database symbols with missing translations are also propagated.
63
+ In this case **ORIGINAL_SYMBOL_NAME** will be presented, but **SYMBOL_NAME** field will be empty.
64
+
61
65
  discard_on_match: bool
62
66
  If True, then parameter ``pattern`` filters out symbols to return from the database.
63
67
  cep_method: str
@@ -115,95 +119,152 @@ class Symbols(Source):
115
119
 
116
120
  This class can be used to get a list of all symbols in the database:
117
121
 
118
- >>> symbols = otp.Symbols('US_COMP', date=otp.dt(2022, 3, 1))
119
- >>> otp.run(symbols)
120
- Time SYMBOL_NAME
121
- 0 2022-03-01 AAP
122
- 1 2022-03-01 AAPL
122
+ >>> data = otp.Symbols('US_COMP_SAMPLE', date=otp.dt(2024, 2, 1)) # doctest: +SKIP
123
+ >>> otp.run(data) # doctest: +SKIP
124
+ Time SYMBOL_NAME
125
+ 0 2024-02-01 A
126
+ 1 2024-02-01 AAL
127
+ 2 2024-02-01 AAPL
128
+ 3 2024-02-01 ABBV
129
+ 4 2024-02-01 ABNB
130
+ .. ... ...
131
+ 496 2024-02-01 XYL
132
+ 497 2024-02-01 YUM
133
+ 498 2024-02-01 ZBH
134
+ 499 2024-02-01 ZBRA
135
+ 500 2024-02-01 ZTS
123
136
 
124
137
  By default database name and time interval will be inherited from :py:func:`otp.run <onetick.py.run>`:
125
138
 
126
- >>> data = otp.Symbols()
127
- >>> otp.run(data, symbols='US_COMP::', date=otp.dt(2022, 3, 1))
128
- Time SYMBOL_NAME
129
- 0 2022-03-01 AAP
130
- 1 2022-03-01 AAPL
139
+ >>> data = otp.Symbols() # doctest: +SKIP
140
+ >>> otp.run(data, symbols='US_COMP_SAMPLE::', date=otp.dt(2024, 2, 1)) # doctest: +SKIP
141
+ Time SYMBOL_NAME
142
+ 0 2024-02-01 A
143
+ 1 2024-02-01 AAL
144
+ 2 2024-02-01 AAPL
145
+ .. ... ...
131
146
 
132
- Parameter ``keep_db`` can be used to show database name in a SYMBOL_NAME field.
147
+ Parameter ``keep_db`` can be used to show database name in the output.
133
148
  It is useful when querying symbols for many databases:
134
149
 
135
- >>> data = otp.Symbols(keep_db=True)
136
- >>> data = otp.merge([data], symbols=['SOME_DB::', 'SOME_DB_2::'])
137
- >>> otp.run(data, date=otp.config.default_start_time) # doctest: +ELLIPSIS
138
- Time SYMBOL_NAME
139
- 0 2003-12-01 SOME_DB::S1
140
- 1 2003-12-01 SOME_DB::S2
141
- 2 2003-12-01 SOME_DB_2::S1
142
- 3 2003-12-01 SOME_DB_2::S2
150
+ >>> data = otp.Symbols(keep_db=True) # doctest: +SKIP
151
+ >>> data = data.first(2) # doctest: +SKIP
152
+ >>> data = otp.merge([data], symbols=['US_COMP_SAMPLE::', 'CME_SAMPLE::']) # doctest: +SKIP
153
+ >>> otp.run(data, date=otp.dt(2024, 2, 1)) # doctest: +SKIP
154
+ Time SYMBOL_NAME
155
+ 0 2024-02-01 US_COMP_SAMPLE::A
156
+ 1 2024-02-01 US_COMP_SAMPLE::AAL
157
+ 2 2024-02-01 CME_SAMPLE::CL\\F25
158
+ 3 2024-02-01 CME_SAMPLE::CL\\F26
159
+ .. ... ...
143
160
 
144
161
  By default symbols for all tick types are returned.
145
162
  You can set parameter ``show_tick_type`` to print the tick type for each symbol:
146
163
 
147
- >>> symbols = otp.Symbols('US_COMP', show_tick_type=True)
148
- >>> otp.run(symbols, date=otp.dt(2022, 3, 1))
149
- Time SYMBOL_NAME TICK_TYPE
150
- 0 2022-03-01 AAP TRD
151
- 1 2022-03-01 AAPL QTE
152
- 2 2022-03-01 AAPL TRD
164
+ >>> data = otp.Symbols('US_COMP_SAMPLE', show_tick_type=True) # doctest: +SKIP
165
+ >>> otp.run(data, date=otp.dt(2024, 2, 1)) # doctest: +SKIP
166
+ Time SYMBOL_NAME TICK_TYPE
167
+ 0 2024-02-01 A DAY
168
+ 1 2024-02-01 A LULD
169
+ 2 2024-02-01 A NBBO
170
+ 3 2024-02-01 A QTE
171
+ 4 2024-02-01 A STAT
172
+ .. ... ... ...
153
173
 
154
174
  Parameter ``for_tick_type`` can be used to specify a single tick type for which to return symbols:
155
175
 
156
- >>> symbols = otp.Symbols('US_COMP', show_tick_type=True, for_tick_type='TRD')
157
- >>> otp.run(symbols, date=otp.dt(2022, 3, 1))
158
- Time SYMBOL_NAME TICK_TYPE
159
- 0 2022-03-01 AAP TRD
160
- 1 2022-03-01 AAPL TRD
176
+ >>> data = otp.Symbols('US_COMP_SAMPLE', show_tick_type=True, for_tick_type='TRD') # doctest: +SKIP
177
+ >>> otp.run(data, date=otp.dt(2024, 2, 1)) # doctest: +SKIP
178
+ Time SYMBOL_NAME TICK_TYPE
179
+ 0 2024-02-01 A TRD
180
+ 1 2024-02-01 AAL TRD
181
+ 2 2024-02-01 AAPL TRD
182
+ 3 2024-02-01 ABBV TRD
183
+ 4 2024-02-01 ABNB TRD
184
+ .. ... ... ...
161
185
 
162
186
  Parameter ``pattern`` can be used to specify the pattern to filter symbol names:
163
187
 
164
- >>> symbols = otp.Symbols('US_COMP', show_tick_type=True, for_tick_type='TRD', pattern='AAP_')
165
- >>> otp.run(symbols, date=otp.dt(2022, 3, 1))
188
+ >>> data = otp.Symbols('US_COMP_SAMPLE', show_tick_type=True, for_tick_type='TRD',
189
+ ... pattern='AAP_') # doctest: +SKIP
190
+ >>> otp.run(data, date=otp.dt(2024, 2, 1)) # doctest: +SKIP
166
191
  Time SYMBOL_NAME TICK_TYPE
167
- 0 2022-03-01 AAPL TRD
192
+ 0 2024-02-01 AAPL TRD
168
193
 
169
194
  Parameter ``discard_on_match`` can be used to use ``pattern`` to filter out symbols instead:
170
195
 
171
- >>> symbols = otp.Symbols('US_COMP', show_tick_type=True, for_tick_type='TRD',
172
- ... pattern='AAP_', discard_on_match=True)
173
- >>> otp.run(symbols, date=otp.dt(2022, 3, 1))
174
- Time SYMBOL_NAME TICK_TYPE
175
- 0 2022-03-01 AAP TRD
196
+ >>> data = otp.Symbols('US_COMP_SAMPLE', show_tick_type=True, for_tick_type='TRD',
197
+ ... pattern='AAP_', discard_on_match=True) # doctest: +SKIP
198
+ >>> otp.run(data, date=otp.dt(2024, 2, 1)) # doctest: +SKIP
199
+ Time SYMBOL_NAME TICK_TYPE
200
+ 0 2024-02-01 A TRD
201
+ 1 2024-02-01 AAL TRD
202
+ 2 2024-02-01 ABBV TRD
203
+ 3 2024-02-01 ABNB TRD
204
+ 4 2024-02-01 ABT TRD
205
+ .. ... ... ...
176
206
 
177
207
  ``otp.Symbols`` object can be used to specify symbols for the main query:
178
208
 
179
- >>> symbols = otp.Symbols('US_COMP')
180
- >>> data = otp.DataSource('US_COMP', tick_type='TRD')
181
- >>> result = otp.run(data, symbols=symbols, date=otp.dt(2022, 3, 1))
182
- >>> result['AAPL']
183
- Time PRICE SIZE
184
- 0 2022-03-01 00:00:00.000 1.3 100
185
- 1 2022-03-01 00:00:00.001 1.4 10
186
- 2 2022-03-01 00:00:00.002 1.4 50
187
- >>> result['AAP']
188
- Time PRICE
189
- 0 2022-03-01 00:00:00.000 45.37
190
- 1 2022-03-01 00:00:00.001 45.41
209
+ >>> symbols = otp.Symbols('US_COMP_SAMPLE') # doctest: +SKIP
210
+ >>> symbols = symbols.first(3) # doctest: +SKIP
211
+ >>> data = otp.DataSource('US_COMP_SAMPLE', tick_type='TRD') # doctest: +SKIP
212
+ >>> result = otp.run(data, symbols=symbols, date=otp.dt(2024, 2, 1)) # doctest: +SKIP
213
+ >>> result['AAPL'][['Time', 'PRICE', 'SIZE']] # doctest: +SKIP
214
+ Time PRICE SIZE
215
+ 0 2024-02-01 04:00:00.008283417 186.50 6
216
+ 1 2024-02-01 04:00:00.008290927 185.59 1
217
+ 2 2024-02-01 04:00:00.008291153 185.49 107
218
+ 3 2024-02-01 04:00:00.010381671 185.49 1
219
+ 4 2024-02-01 04:00:00.011224206 185.50 2
220
+ .. ... ... ...
221
+
222
+ >>> result['AAL'][['Time', 'PRICE', 'SIZE']] # doctest: +SKIP
223
+ Time PRICE SIZE
224
+ 0 2024-02-01 04:00:00.097381367 14.33 1
225
+ 1 2024-02-01 04:00:00.138908789 14.37 1
226
+ 2 2024-02-01 04:00:00.726613365 14.36 10
227
+ 3 2024-02-01 04:00:02.195702506 14.36 73
228
+ 4 2024-02-01 04:01:55.268302813 14.39 1
229
+ .. ... ... ...
191
230
 
192
231
  Additional fields of the ``otp.Symbols`` can be used in the main query as symbol parameters:
193
232
 
194
- >>> symbols = otp.Symbols('SOME_DB', show_tick_type=True, keep_db=True)
195
- >>> symbols['PARAM'] = symbols['SYMBOL_NAME'] + '__' + symbols['TICK_TYPE']
196
- >>> data = otp.DataSource('SOME_DB')
197
- >>> data['S_PARAM'] = data.Symbol['PARAM', str]
198
- >>> data = otp.merge([data], symbols=symbols)
199
- >>> otp.run(data)
200
- Time X S_PARAM
201
- 0 2003-12-01 00:00:00.000 1 SOME_DB::S1__TT
202
- 1 2003-12-01 00:00:00.000 -3 SOME_DB::S2__TT
203
- 2 2003-12-01 00:00:00.001 2 SOME_DB::S1__TT
204
- 3 2003-12-01 00:00:00.001 -2 SOME_DB::S2__TT
205
- 4 2003-12-01 00:00:00.002 3 SOME_DB::S1__TT
206
- 5 2003-12-01 00:00:00.002 -1 SOME_DB::S2__TT
233
+ >>> symbols = otp.Symbols('US_COMP_SAMPLE', show_tick_type=True, for_tick_type='TRD') # doctest: +SKIP
234
+ >>> symbols['PARAM'] = symbols['SYMBOL_NAME'] + '__' + symbols['TICK_TYPE'] # doctest: +SKIP
235
+ >>> data = otp.DataSource('US_COMP_SAMPLE', tick_type='TRD') # doctest: +SKIP
236
+ >>> data = data.first(1) # doctest: +SKIP
237
+ >>> data['S_PARAM'] = data.Symbol['PARAM', str] # doctest: +SKIP
238
+ >>> data = otp.merge([data], symbols=symbols) # doctest: +SKIP
239
+ >>> data = data[['PRICE', 'SIZE', 'S_PARAM']] # doctest: +SKIP
240
+ >>> otp.run(data, date=otp.dt(2024, 2, 1)) # doctest: +SKIP
241
+ Time PRICE SIZE S_PARAM
242
+ 0 2024-02-01 04:00:00.001974784 193.800 4 HSY__TRD
243
+ 1 2024-02-01 04:00:00.003547904 57.810 18 OXY__TRD
244
+ 2 2024-02-01 04:00:00.006354688 42.810 30 DVN__TRD
245
+ 3 2024-02-01 04:00:00.007310080 165.890 9 WMT__TRD
246
+ 4 2024-02-01 04:00:00.007833957 43.170 22 INTC__TRD
247
+ .. ... ... ... ...
248
+
249
+ Use parameter ``symbology`` to specify different symbology to translate to.
250
+ You can also use parameter ``show_original_symbols`` to print original symbols.
251
+ Note that some symbols may not have a translation in target symbology, so their names will be empty:
252
+
253
+ >>> data = otp.Symbols('US_COMP', for_tick_type='TRD',
254
+ ... symbology='FGV', show_original_symbols=True) # doctest: +SKIP
255
+ >>> otp.run(data, start=otp.dt(2023, 5, 15, 9, 30), end=otp.dt(2023, 5, 15, 9, 30, 1)) # doctest: +SKIP
256
+ Time SYMBOL_NAME ORIGINAL_SYMBOL_NAME
257
+ 0 2023-05-15 09:30:00 BBG000C2V3D6 US_COMP::A
258
+ 1 2023-05-15 09:30:00 BBG00B3T3HD3 US_COMP::AA
259
+ 2 2023-05-15 09:30:00 BBG01B0JRCS6 US_COMP::AAA
260
+ 3 2023-05-15 09:30:00 BBG00LPXX872 US_COMP::AAAU
261
+ 4 2023-05-15 09:30:00 BBG00YZC2Z91 US_COMP::AAC
262
+ ... ... ... ...
263
+ 10946 2023-05-15 09:30:00 US_COMP::ZXIET
264
+ 10947 2023-05-15 09:30:00 US_COMP::ZXZZT
265
+ 10948 2023-05-15 09:30:00 BBG019XSYC89 US_COMP::ZYME
266
+ 10949 2023-05-15 09:30:00 BBG007BBS8B7 US_COMP::ZYNE
267
+ 10950 2023-05-15 09:30:00 BBG000BJBXZ2 US_COMP::ZYXI
207
268
 
208
269
  **Escaping special characters in the pattern**
209
270
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: onetick-py
3
- Version: 1.179.0
3
+ Version: 1.181.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
@@ -13,17 +13,17 @@ onetick/lib/__init__.py,sha256=Rp7CIDoA4E6LIm1f2mNvl_5b_n-0U3suA3FmBXbmKoU,114
13
13
  onetick/lib/instance.py,sha256=3FJB8PWs2ap-EGb6DzsnLRL2meTMUViTdy343m6tHvM,4825
14
14
  onetick/py/__init__.py,sha256=JVXbKakzScRnwpJVEkerJkX-UAX7Surdp4PCImvvieA,11183
15
15
  onetick/py/_stack_info.py,sha256=PHZOkW_fK7Fbl4YEj5CaYK9L6vh4j-bUU7_cSYOWZ30,2546
16
- onetick/py/_version.py,sha256=NIQ4soDVt1sFWTMrIBFgdv_DSfBeoHRI7JLquEtfnD4,76
16
+ onetick/py/_version.py,sha256=KPe2n8_FyAx3CQNqxYW8bByjpQ2hxgq0dEW2GSpxhPM,76
17
17
  onetick/py/backports.py,sha256=mR00mxe7E7UgBljf-Wa93Mo6lpi-C4Op561uhPUoEt8,815
18
18
  onetick/py/cache.py,sha256=BBZg8n0AGjZzZapg4752LkSZdX5C6DGf7vU9sAStv6A,12798
19
- onetick/py/compatibility.py,sha256=FuFLY1XAaYU9E8g0nj9hbBAv7euY4IaZd9W5BWDC9FU,34250
20
- onetick/py/configuration.py,sha256=KCX44v_nEOZDvo-rItIrNVKKvqyM73QUwIivez2VHvY,28448
19
+ onetick/py/compatibility.py,sha256=rBLoszCoSZrl9SnBYiPzWuoudZwhOP6d4exshy3BJTw,34530
20
+ onetick/py/configuration.py,sha256=wOmGBaaT89uz6Eny3Pp_tFpATto-qZXcqNRyy4rzmQw,28655
21
21
  onetick/py/functions.py,sha256=Kqromia64o1K4fgbLbijw64o5pFGBZRog52824wOxlA,98004
22
22
  onetick/py/license.py,sha256=50dsFrE-NKsPOdkAoyxHr44bH8DzFCr_6TabX0JH6tQ,6140
23
23
  onetick/py/log.py,sha256=Els2drZcVjJrD6kvbwgFGEpg6jAacoUEtyN6rCaauuk,2723
24
24
  onetick/py/math.py,sha256=MZvlyUjxOWGJvmxK8pfMkCr4THM52AE6NyGEidgDMyE,26311
25
25
  onetick/py/misc.py,sha256=mD-EJslLGjQ0ROEez76HvOY0tsX8_1bC1QOkyHY9FZ8,13934
26
- onetick/py/otq.py,sha256=VSdCrp3zTzNQHv9gM_xE4Al4ujBsio7uWk3SqU4eC4Y,8271
26
+ onetick/py/otq.py,sha256=TAOFw8e_p0mfTEV92qb_AzHplbv_H71hMwnT3qNmksg,8780
27
27
  onetick/py/pyomd_mock.py,sha256=A7IIUraN9yCsPhvnHXQUZrmwFjlh7vofSnYm4G7bdsc,2006
28
28
  onetick/py/run.py,sha256=Ql-hN0R9GZvxf0ukRUgVpqxk69Dez6T0CA1Cn2Fq1dY,40805
29
29
  onetick/py/servers.py,sha256=h6l0X55kcnpI25bZcYaBpPAAGBZjqk9mt1SQe4xZrh0,6840
@@ -54,7 +54,7 @@ onetick/py/core/lambda_object.py,sha256=ayob_2c2XYSG7vFsqp-2b9FSPD-3TFReLbx3de3t
54
54
  onetick/py/core/multi_output_source.py,sha256=f3dXr9kwmED77oWDFVr9cn44aYiJxC81loq2pX4u50Q,8766
55
55
  onetick/py/core/per_tick_script.py,sha256=I3pfidriS1TrFPc3DAABt91GKMgby9P_8KBatiFQx6U,83322
56
56
  onetick/py/core/query_inspector.py,sha256=Jwnw7qUVvjvaT63mQ5PkUSy8x36knoxWrNll3aXuLZw,16440
57
- onetick/py/core/source.py,sha256=PFFoAvhGd80MEUuTOCCOwDxyk0pqyUn85rUOHWIQ_1o,65566
57
+ onetick/py/core/source.py,sha256=HUQ7dBQqt3omg60ekZLxvPDEtm4e53PwTj8PY40kew4,65815
58
58
  onetick/py/core/_internal/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
59
59
  onetick/py/core/_internal/_manually_bound_value.py,sha256=a4JF63g9MtXsIwpDqm_PCLBH51_SaG1-T6jWV5-IJ1k,191
60
60
  onetick/py/core/_internal/_nodes_history.py,sha256=fCpJ4FWFDzM-bmi-YyCHmNYuFM-CL_lE2bXySOi-TPY,7194
@@ -69,7 +69,7 @@ onetick/py/core/_source/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG
69
69
  onetick/py/core/_source/_symbol_param.py,sha256=odFDK85lIa_mqQW-yA4ozz9DFPqWA0qWMjY0UDkniDQ,3233
70
70
  onetick/py/core/_source/schema.py,sha256=WWaa2HtSNNp1G4Z4Hx85fnUJpTvpBnX7xmDq3Jct9XM,2619
71
71
  onetick/py/core/_source/symbol.py,sha256=H274Xd-f_0IqF6jMKmxIvQj1lGD-3F54E27y8A-lSYA,8269
72
- onetick/py/core/_source/tmp_otq.py,sha256=OQRl6cFUJTrv2wiR0mp4IM4oFcroRVrK8cKzJ89iA2U,9363
72
+ onetick/py/core/_source/tmp_otq.py,sha256=6HRbUZK_INF7BB29Ej2q_tulkR2SXlOua1--0pnsW4I,10779
73
73
  onetick/py/core/_source/source_methods/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
74
74
  onetick/py/core/_source/source_methods/aggregations.py,sha256=EBdHV8IFwdptPDxQncHjtXkNr6lOCvp06OmjBzFs4AU,27526
75
75
  onetick/py/core/_source/source_methods/applyers.py,sha256=UlVJznASMfuEzUSWEQj7tcR-fhztU0iFOTe0JHf4u4c,10104
@@ -77,9 +77,9 @@ onetick/py/core/_source/source_methods/columns.py,sha256=JJNr0Wqf8B9igLVoCNtFeNE
77
77
  onetick/py/core/_source/source_methods/data_quality.py,sha256=iz8e-60se-rNH72k5fRxX3cm3ahfbBZ7R7E46Be5zhs,9343
78
78
  onetick/py/core/_source/source_methods/debugs.py,sha256=Hq08HYjF2sEZQAcBlwNMVKpu0muCWNIYEhmPqbKkSZw,10176
79
79
  onetick/py/core/_source/source_methods/drops.py,sha256=3ZXfQWXsl0-ZLHdp6D-wTu2saqCYHZ-Gn777aMRSRp0,4403
80
- onetick/py/core/_source/source_methods/fields.py,sha256=6GozvRornClXfEu6oY9-JpN3gOceewB6OJweRR7x2Zw,22740
80
+ onetick/py/core/_source/source_methods/fields.py,sha256=bPCViMBCBHatoC3TUcGyyLT5em2ObUyNKTr4uE3XlmA,23165
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=Qq50NfHH46jAfotXEf-lccN47erYBukJgtnP9NhOaok,61637
82
+ onetick/py/core/_source/source_methods/joins.py,sha256=gHUjCXjfHHn64R2fC4Aceq2W74yncE0GEhgtZX7LfMo,62484
83
83
  onetick/py/core/_source/source_methods/merges.py,sha256=vhU640pAUklzJh1J_yFZ7O-vFjbmSWg7jHPo0o0NXj8,24486
84
84
  onetick/py/core/_source/source_methods/misc.py,sha256=qK4Z0guEJaLr2CCvpRA2zvilUEsRd7dEjtVp9hI6jc8,61547
85
85
  onetick/py/core/_source/source_methods/pandases.py,sha256=BbvIlw6ipqC2dOiKSyyZ5jhAtE4ZtdL30OZXV_e_FuE,3670
@@ -88,7 +88,7 @@ onetick/py/core/_source/source_methods/sorts.py,sha256=tDFt3rObNHP-S_HOtDd6SLpgk
88
88
  onetick/py/core/_source/source_methods/switches.py,sha256=pcnfT45QWn87qq1pWkvZbqeEoM7lrq8qNPxM8g9raxs,3846
89
89
  onetick/py/core/_source/source_methods/symbols.py,sha256=MG0dgVVVJ6fD_-GJkkXEgTeAsfS79ymJWmuKSL-0QSs,3968
90
90
  onetick/py/core/_source/source_methods/times.py,sha256=2kbLHG-3RQM6uWmw8pBGDiAz4R83KK46Tp1smTY6SR8,27665
91
- onetick/py/core/_source/source_methods/writes.py,sha256=fPUbiqlm30Kb4QzXZLtWCsQiTFBDxK5oOWuVyfVXbYM,42717
91
+ onetick/py/core/_source/source_methods/writes.py,sha256=Ar57d3Gn9ZOezyd6Gl4QgMEyZRky2NwXh32h1--XQfA,43125
92
92
  onetick/py/core/column_operations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
93
93
  onetick/py/core/column_operations/base.py,sha256=gn-4rz4FMAR2pp-7e9DulKc6L05YAMkGkIiEwzHmYmo,36102
94
94
  onetick/py/core/column_operations/_methods/__init__.py,sha256=_C5hpQG51MingtWW2N8vYzSVFpR314xIrtukBfEfPMk,207
@@ -129,7 +129,7 @@ onetick/py/sources/query.py,sha256=ENwkdAVs2CeNnzWpLlProuNG6eT7I_88BlgcHFSFEYY,1
129
129
  onetick/py/sources/snapshots.py,sha256=-CAHisUNUFexgFoeKcAVv6gK47TGWxh6bAbsHiHDrvc,17130
130
130
  onetick/py/sources/split_query_output_by_symbol.py,sha256=5fKIZfF8FAgLjx_TiHpts8J4JtxoetF-5bEj6nsxbdI,8157
131
131
  onetick/py/sources/symbology_mapping.py,sha256=01mwI4w9yxeg2VcxJRaR72MDafjyUBZvMopJC1hhjh0,4809
132
- onetick/py/sources/symbols.py,sha256=ZN0TuKJSNx6QursoLrEIiL-Zi0KgwBwTNzgolKmbdos,15604
132
+ onetick/py/sources/symbols.py,sha256=n8-o6Et0gvMYiWjTIbp23Q6ZIwX9Nx7bhXcfJN3cSOU,20017
133
133
  onetick/py/sources/ticks.py,sha256=JPniCDY5Ldd7CH3PfjcaBGL-vyNsteI9tiLkZ5lm1Ys,32764
134
134
  onetick/py/utils/__init__.py,sha256=iiPsbVUs0UEn-clA877DbOoiiLGT2ab9UqmN9RMCahA,1354
135
135
  onetick/py/utils/acl.py,sha256=da4_rrV3pA7_9OcjvRxtZ0ofzwNxslGVbWqFUJK2rSw,2692
@@ -147,9 +147,9 @@ onetick/py/utils/script.py,sha256=Y8NujEo2_5QaP6KDnLKJiKQ7SmMjw8_dv8sYL9rHDCE,11
147
147
  onetick/py/utils/temp.py,sha256=j-BC155dE46k0zfKTTs26KTF0CK6WA1hO2GD54iunyM,17380
148
148
  onetick/py/utils/types.py,sha256=7u9s9uN1jlkgud8_TSLy6iFzQFBtKJ0v3yamgOVitrs,3747
149
149
  onetick/py/utils/tz.py,sha256=sYUKigaORonp7Xa6x806xVYJ69lYJHd6NrLxQHB5AZo,2878
150
- onetick_py-1.179.0.dist-info/licenses/LICENSE,sha256=Yhu7lKNFS0fsaN-jSattEMRtCOPueP58Eu5BPH8ZGjM,1075
151
- onetick_py-1.179.0.dist-info/METADATA,sha256=BArsneiokQHldh-5zgW4LhXjMI4lCb9ZzCDyYg6ud1s,7290
152
- onetick_py-1.179.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
153
- onetick_py-1.179.0.dist-info/entry_points.txt,sha256=bafJo_C7lPHz5pAdlIryLzxAlJ8F-We5cC7psdwcx4Q,131
154
- onetick_py-1.179.0.dist-info/top_level.txt,sha256=Na1jSJmVMyYGOndaswt554QKIUwQjcYh6th2ATsmw0U,23
155
- onetick_py-1.179.0.dist-info/RECORD,,
150
+ onetick_py-1.181.0.dist-info/licenses/LICENSE,sha256=Yhu7lKNFS0fsaN-jSattEMRtCOPueP58Eu5BPH8ZGjM,1075
151
+ onetick_py-1.181.0.dist-info/METADATA,sha256=tSv9emqWMVLCrzjysnWd9H5yyZYCZXmbepOMwwpmbGc,7290
152
+ onetick_py-1.181.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
153
+ onetick_py-1.181.0.dist-info/entry_points.txt,sha256=bafJo_C7lPHz5pAdlIryLzxAlJ8F-We5cC7psdwcx4Q,131
154
+ onetick_py-1.181.0.dist-info/top_level.txt,sha256=Na1jSJmVMyYGOndaswt554QKIUwQjcYh6th2ATsmw0U,23
155
+ onetick_py-1.181.0.dist-info/RECORD,,