onetick-py 1.171.0__py3-none-any.whl → 1.173.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.171.0'
2
+ VERSION = '1.173.0'
@@ -3,6 +3,7 @@ import warnings
3
3
  from dataclasses import dataclass, astuple
4
4
  from datetime import datetime
5
5
  from typing import Optional
6
+
6
7
  from packaging.version import parse as parse_version
7
8
 
8
9
  import onetick.py as otp
@@ -416,14 +417,15 @@ def is_odbc_query_supported():
416
417
 
417
418
 
418
419
  def is_event_processor_repr_upper():
419
- return _is_min_build_or_version(None, None,
420
- 20240205120000, min_update_number=0) or otq.webapi
420
+ if otq.webapi:
421
+ return True
422
+ return _is_min_build_or_version(1.25, None,
423
+ 20240205120000, min_update_number=0)
421
424
 
422
425
 
423
426
  def is_date_trunc_fixed():
424
- # tests/core/accessors/test_dt.py::TestDateTrunc::test_dst_year
425
- # this test will show, when release fixes the issue
426
- return _is_min_build_or_version(None, None,
427
+ # Fixed 0032253: DATE_TRUNC function returns wrong answer in case of daylight saving time
428
+ return _is_min_build_or_version(1.25, None,
427
429
  20240205120000, min_update_number=0)
428
430
 
429
431
 
@@ -511,7 +513,8 @@ def is_duplicating_quotes_not_supported():
511
513
  # 20240329: Fixed 0032754:
512
514
  # Logical expressions should trigger error when duplicate single(or double) quote
513
515
  # is directly followed or preceded by some name
514
- return _is_min_build_or_version(None, None, 20240330120000)
516
+ return _is_min_build_or_version(1.25, None,
517
+ 20240330120000)
515
518
 
516
519
 
517
520
  def are_quotes_in_query_params_supported():
@@ -681,9 +684,9 @@ def is_ob_virtual_prl_and_show_full_detail_supported():
681
684
 
682
685
 
683
686
  def is_per_tick_script_boolean_problem():
684
- # strange problem, couldn't reproduce it anywhere except a single onetick build
687
+ # strange problem, couldn't reproduce it anywhere except a single onetick release
685
688
  version = get_onetick_version()
686
- return version.release_version == '1.22' and version.build_number in (20220815034358, 20220128183755)
689
+ return version.release_version == '1.22'
687
690
 
688
691
 
689
692
  def is_symbol_time_override_fixed():
@@ -709,8 +712,10 @@ def is_native_plus_zstd_supported():
709
712
 
710
713
  def is_save_snapshot_database_parameter_supported():
711
714
  # 20220929: Implemented 0028559: Update SAVE_SNAPSHOT to specify output database
712
- return _is_min_build_or_version(1.23, 20230605193357,
713
- 20221111120000)
715
+ client_support = 'database' in otq.SaveSnapshot.Parameters.list_parameters()
716
+ server_support = _is_min_build_or_version(1.23, 20230605193357,
717
+ 20221111120000)
718
+ return client_support and server_support
714
719
 
715
720
 
716
721
  def is_join_with_snapshot_snapshot_fields_parameter_supported():
@@ -656,8 +656,9 @@ class Config:
656
656
  )
657
657
 
658
658
  max_expected_ticks_per_symbol = OtpProperty(
659
- description='Expected maximum number of ticks per symbol (used for performance optimizations).',
660
- base_default=2000,
659
+ description='Expected maximum number of ticks per symbol (used for performance optimizations). '
660
+ 'Default is 2000.',
661
+ base_default=None,
661
662
  allowed_types=int,
662
663
  env_var_name='OTP_MAX_EXPECTED_TICKS_PER_SYMBOL',
663
664
  )
@@ -23,8 +23,8 @@ def write(
23
23
  symbol: Union[str, 'otp.Column', None] = None,
24
24
  tick_type: Union[str, 'otp.Column', None] = None,
25
25
  date: Union[datetime.date, Type[adaptive], None] = adaptive,
26
- start: Optional[datetime.date] = None,
27
- end: Optional[datetime.date] = None,
26
+ start_date: Optional[datetime.date] = None,
27
+ end_date: Optional[datetime.date] = None,
28
28
  append: bool = False,
29
29
  keep_symbol_and_tick_type: Union[bool, Type[adaptive]] = adaptive,
30
30
  propagate: bool = True,
@@ -72,22 +72,21 @@ def write(
72
72
  date where to save data.
73
73
  Should be set to `None` if writing to accelerator or memory database.
74
74
  By default, it is set to `otp.config.default_date`.
75
- start: :py:class:`otp.datetime <onetick.py.datetime>` or None
75
+ start_date: :py:class:`otp.datetime <onetick.py.datetime>` or None
76
76
  Start date for data to save. It is inclusive.
77
77
  Cannot be used with ``date`` parameter.
78
78
  Also cannot be used with ``inplace`` set to ``True``.
79
79
  Should be set to `None` if writing to accelerator or memory database.
80
80
  By default, None.
81
- end: :py:class:`otp.datetime <onetick.py.datetime>` or None
82
- End date for data to save. It is exclusive, so be sure to set
83
- it to the next day after the last day in data.
81
+ end_date: :py:class:`otp.datetime <onetick.py.datetime>` or None
82
+ End date for data to save. It is inclusive.
84
83
  Cannot be used with ``date`` parameter.
85
84
  Also cannot be used with ``inplace`` set to ``True``.
86
85
  Should be set to `None` if writing to accelerator or memory database.
87
86
  By default, None.
88
87
  append: bool
89
88
  If False - data will be rewritten for this ``date``
90
- or range of dates (from ``start`` to ``end``),
89
+ or range of dates (from ``start_date`` to ``end_date``),
91
90
  otherwise data will be appended: new symbols are added,
92
91
  existing symbols can be modified (append new ticks, modify existing ticks).
93
92
  This option is not valid for accelerator databases.
@@ -100,12 +99,12 @@ def write(
100
99
  propagate: bool
101
100
  Propagate ticks after that event processor or not.
102
101
  out_of_range_tick_action: str
103
- Action to be executed if tick's timestamp's date is not ``date`` or between ``start`` or ``end``:
102
+ Action to be executed if tick's timestamp's date is not ``date`` or between ``start_date`` or ``end_date``:
104
103
 
105
104
  * `exception`: runtime exception will be raised
106
105
  * `ignore`: tick will not be written to the database
107
106
  * `load`: writes tick to the database anyway.
108
- Can be used only with ``date``, not with ``start``+``end``.
107
+ Can be used only with ``date``, not with ``start_date``+``end_date``.
109
108
 
110
109
  Default: `exception`
111
110
  timestamp: Column
@@ -134,7 +133,7 @@ def write(
134
133
  A flag controls whether operation should be applied inplace.
135
134
  If ``inplace=True``, then it returns nothing.
136
135
  Otherwise, method returns a new modified object.
137
- Cannot be ``True`` if ``start`` and ``end`` are set.
136
+ Cannot be ``True`` if ``start_date`` and ``end_date`` are set.
138
137
  kwargs:
139
138
  .. deprecated:: 1.21.0
140
139
 
@@ -176,6 +175,15 @@ def write(
176
175
  warnings.warn("Parameter 'keep_timestamp_field' is deprecated, use 'keep_timestamp'", FutureWarning)
177
176
  keep_timestamp = kwargs.pop('keep_timestamp_field')
178
177
 
178
+ if 'start' in kwargs:
179
+ warnings.warn("Parameter 'start' is deprecated, use 'start_date'", FutureWarning)
180
+ start_date = kwargs.pop('start')
181
+
182
+ if 'end' in kwargs:
183
+ warnings.warn("Parameter 'end' is deprecated, use 'end_date'", FutureWarning)
184
+ # Parameter 'end' was exclusive. Parameter 'end_date' is inclusive.
185
+ end_date = kwargs.pop('end') - otp.Day(1)
186
+
179
187
  if kwargs:
180
188
  raise TypeError(f'write() got unexpected arguments: {list(kwargs)}')
181
189
 
@@ -194,15 +202,18 @@ def write(
194
202
  f'Field "{field_name}" contains lowercase characters and cannot be saved to a Onetick database'
195
203
  )
196
204
 
197
- if date is not adaptive and (start or end):
198
- raise ValueError('date cannot be used with start+end')
205
+ if date is not adaptive and (start_date or end_date):
206
+ raise ValueError('date cannot be used with start_date+end_date')
199
207
 
200
- if date is adaptive and (start and end) and inplace:
208
+ if date is adaptive and (start_date and end_date) and inplace:
201
209
  # join_with_query and merge are used for multiple dates, so inplace is not supported
202
- raise ValueError('cannot run on multiple dates if inplace is True, use one value for date instead of start+end')
210
+ raise ValueError(
211
+ 'cannot run on multiple dates if inplace is True,'
212
+ ' use one value for date instead of start_date+end_date'
213
+ )
203
214
 
204
- if (start and not end) or (not start and end):
205
- raise ValueError('start and end should be both specified or both None')
215
+ if (start_date and not end_date) or (not start_date and end_date):
216
+ raise ValueError('start_date and end_date should be both specified or both None')
206
217
 
207
218
  if date is adaptive:
208
219
  date = configuration.config.default_date
@@ -244,10 +255,10 @@ def write(
244
255
  # let's ignore
245
256
  pass
246
257
  elif out_of_range_tick_action.upper() == 'LOAD':
247
- if start and end:
248
- raise ValueError('LOAD out_of_range_tick_action cannot be used with start+end, use date instead')
258
+ if start_date and end_date:
259
+ raise ValueError('LOAD out_of_range_tick_action cannot be used with start_date+end_date, use date instead')
249
260
  elif out_of_range_tick_action.upper() == 'EXCEPTION':
250
- if start and end:
261
+ if start_date and end_date:
251
262
  # WRITE_TO_ONETICK_DB use DAY_BOUNDARY_TZ and DAY_BOUNDARY_OFFSET
252
263
  # to check tick timestamp is out of range or not
253
264
  # so we mimic it here with THROW event processor
@@ -259,10 +270,12 @@ def write(
259
270
  {'DAY_BOUNDARY_TZ': '__DAY_BOUNDARY_TZ', 'DAY_BOUNDARY_OFFSET': '__DAY_BOUNDARY_OFFSET'}, inplace=True
260
271
  )
261
272
  self = self.join_with_query(src, symbol=f"{str(db)}::DUMMY", caching='per_symbol')
262
- start_formatted = start.strftime('%Y-%m-%d')
263
- end_formatted = end.strftime('%Y-%m-%d')
264
- convert_timestamp = self['TIMESTAMP'].dt.strftime('%Y%m%d%H%M%S.%J', timezone=self['__DAY_BOUNDARY_TZ'])
265
- start_op = otp.dt(start).to_operation(timezone=self['__DAY_BOUNDARY_TZ']) + self['__DAY_BOUNDARY_OFFSET']
273
+ timezone = self['__DAY_BOUNDARY_TZ']
274
+ offset = self['__DAY_BOUNDARY_OFFSET']
275
+ convert_timestamp = self['TIMESTAMP'].dt.strftime('%Y%m%d%H%M%S.%J', timezone=timezone)
276
+
277
+ start_formatted = start_date.strftime('%Y-%m-%d')
278
+ start_op = otp.dt(start_date).to_operation(timezone=timezone) + offset
266
279
  self.throw(
267
280
  where=(self['TIMESTAMP'] < start_op),
268
281
  message=(
@@ -270,11 +283,14 @@ def write(
270
283
  + convert_timestamp
271
284
  + ' of a tick, visible or hidden, '
272
285
  + f'earlier than {start_formatted} in timezone '
273
- + self['__DAY_BOUNDARY_TZ']
286
+ + timezone
274
287
  ),
275
288
  inplace=True,
276
289
  )
277
- end_op = otp.dt(end).to_operation(timezone=self['__DAY_BOUNDARY_TZ']) + self['__DAY_BOUNDARY_OFFSET']
290
+
291
+ end = end_date + otp.Day(1) # end_date is inclusive
292
+ end_formatted = end.strftime('%Y-%m-%d')
293
+ end_op = otp.dt(end).to_operation(timezone=timezone) + offset
278
294
  self.throw(
279
295
  where=(self['TIMESTAMP'] >= end_op),
280
296
  message=(
@@ -282,10 +298,11 @@ def write(
282
298
  + convert_timestamp
283
299
  + ' of a tick, visible or hidden, '
284
300
  + f'later than {end_formatted} in timezone '
285
- + self['__DAY_BOUNDARY_TZ']
301
+ + timezone
286
302
  ),
287
303
  inplace=True,
288
304
  )
305
+ self.drop(['__DAY_BOUNDARY_TZ', '__DAY_BOUNDARY_OFFSET'], inplace=True)
289
306
  else:
290
307
  raise ValueError(
291
308
  f'Unknown out_of_range_tick_action: {out_of_range_tick_action}.'
@@ -303,18 +320,16 @@ def write(
303
320
  use_context_of_query=use_context_of_query,
304
321
  )
305
322
 
306
- if start and end:
307
- days = (end - start).days
323
+ if start_date and end_date:
324
+ days = (end_date - start_date).days
308
325
  if days < 0:
309
- raise ValueError("Parameter 'start' must be less than parameter 'end'")
310
- if days == 0:
311
- raise ValueError("Parameters 'start' and 'end' must specify different dates")
326
+ raise ValueError("Parameter 'start_date' must be less than or equal to parameter 'end_date'")
312
327
  branches = []
313
- for i in range(days):
328
+ for i in range(days + 1):
314
329
  branch = self.copy()
315
330
  branch.sink(
316
331
  otq.WriteToOnetickDb(
317
- date=(start + otp.Day(i)).strftime('%Y%m%d'),
332
+ date=(start_date + otp.Day(i)).strftime('%Y%m%d'),
318
333
  propagate_ticks=propagate,
319
334
  out_of_range_tick_action='IGNORE',
320
335
  **kwargs,
@@ -35,7 +35,7 @@ class SymbolType:
35
35
  | :ref:`api/misc/symbol_param:Symbol Parameters Objects`
36
36
  """
37
37
 
38
- self._name = _SymbolParamColumn("_SYMBOL_NAME", str)
38
+ self.__name = _SymbolParamColumn("_SYMBOL_NAME", str)
39
39
 
40
40
  @property
41
41
  def name(self):
@@ -61,7 +61,7 @@ class SymbolType:
61
61
  4 2003-12-01 00:00:00.002 3 S1
62
62
  5 2003-12-01 00:00:00.002 -1 S2
63
63
  """
64
- return self._name
64
+ return self.__name
65
65
 
66
66
  def get(self, name, dtype, default=None):
67
67
  """
@@ -131,6 +131,9 @@ class SymbolType:
131
131
  -------
132
132
  _SymbolParamColumn
133
133
  """
134
+ if item == '__objclass__':
135
+ # fix for PY-1399 (some inspect functions try to access this special attribute)
136
+ raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{item}'")
134
137
  if not item.startswith('_') and item != 'pytest_mock_example_attribute_that_shouldnt_exist':
135
138
  warnings.warn("`__getattr__` method is deprecated. Please, use `__getitem__` method instead.",
136
139
  FutureWarning, stacklevel=2)
@@ -14,10 +14,7 @@ class DatetimeSubtractionWarning(FutureWarning):
14
14
 
15
15
 
16
16
  def round(prev_op, precision):
17
- if precision is not None:
18
- return MethodResult(f'round_double({str(prev_op)},{str(precision)})', float)
19
- else:
20
- return MethodResult(f'round({str(prev_op)})', int)
17
+ return MethodResult(f'round_double({str(prev_op)},{str(precision)})', float)
21
18
 
22
19
 
23
20
  def isin(prev_op, items):
@@ -11,13 +11,11 @@ class _Accessor:
11
11
  self._base_column = base_column
12
12
 
13
13
  class Formatter(_Operation):
14
+ def __init__(self, dtype, formatter, op_params):
15
+ def op_func(*args, **kwargs):
16
+ return formatter(*args, **kwargs), dtype
14
17
 
15
- def __init__(self, base_column, dtype, formatter):
16
- super().__init__(dtype=dtype, op_params=[base_column])
17
- self._formatter = formatter
18
-
19
- def __str__(self):
20
- return self._formatter(str(self._op_params[0]))
18
+ super().__init__(op_func=op_func, op_params=op_params, dtype=dtype)
21
19
 
22
20
  def _preprocess_tz_and_format(self,
23
21
  timezone: typing.Union[Operation, str, None],
@@ -1,5 +1,6 @@
1
1
  from onetick.py import types as ott
2
2
  from onetick.py.core.column_operations.accessors._accessor import _Accessor
3
+ from onetick.py.core.column_operations.base import _Operation
3
4
 
4
5
 
5
6
  class _DecimalAccessor(_Accessor):
@@ -37,10 +38,16 @@ class _DecimalAccessor(_Accessor):
37
38
  3 3.142
38
39
  Name: X, dtype: object
39
40
  """
41
+ def formatter(column, _precision):
42
+ column = ott.value2str(column)
43
+ _precision = ott.value2str(_precision)
44
+
45
+ return f'decimal_to_string({column}, {_precision})'
46
+
40
47
  return _DecimalAccessor.Formatter(
41
- self._base_column,
42
- str,
43
- formatter=lambda x: f'decimal_to_string({x}, {precision})'
48
+ op_params=[self._base_column, precision],
49
+ dtype=str,
50
+ formatter=formatter,
44
51
  )
45
52
 
46
53
  def cmp(self, other, eps):
@@ -83,10 +90,15 @@ class _DecimalAccessor(_Accessor):
83
90
  4 1.0
84
91
  Name: X, dtype: float64
85
92
  """
86
- other = ott.value2str(other)
87
- eps = ott.value2str(eps)
93
+
94
+ def formatter(column, _other, _eps):
95
+ column = ott.value2str(column)
96
+ _other = ott.value2str(_other)
97
+ _eps = ott.value2str(_eps)
98
+ return f'decimal_compare({column}, {_other}, {_eps})'
99
+
88
100
  return _DecimalAccessor.Formatter(
89
- self._base_column,
90
- ott.decimal,
91
- formatter=lambda x: f'decimal_compare({x}, {other}, {eps})'
101
+ op_params=[self._base_column, other, eps],
102
+ dtype=ott.decimal,
103
+ formatter=formatter,
92
104
  )