onetick-py 1.177.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.
Files changed (152) hide show
  1. locator_parser/__init__.py +0 -0
  2. locator_parser/acl.py +73 -0
  3. locator_parser/actions.py +262 -0
  4. locator_parser/common.py +368 -0
  5. locator_parser/io.py +43 -0
  6. locator_parser/locator.py +150 -0
  7. onetick/__init__.py +101 -0
  8. onetick/doc_utilities/__init__.py +3 -0
  9. onetick/doc_utilities/napoleon.py +40 -0
  10. onetick/doc_utilities/ot_doctest.py +140 -0
  11. onetick/doc_utilities/snippets.py +279 -0
  12. onetick/lib/__init__.py +4 -0
  13. onetick/lib/instance.py +141 -0
  14. onetick/py/__init__.py +293 -0
  15. onetick/py/_stack_info.py +89 -0
  16. onetick/py/_version.py +2 -0
  17. onetick/py/aggregations/__init__.py +11 -0
  18. onetick/py/aggregations/_base.py +648 -0
  19. onetick/py/aggregations/_docs.py +948 -0
  20. onetick/py/aggregations/compute.py +286 -0
  21. onetick/py/aggregations/functions.py +2216 -0
  22. onetick/py/aggregations/generic.py +104 -0
  23. onetick/py/aggregations/high_low.py +80 -0
  24. onetick/py/aggregations/num_distinct.py +83 -0
  25. onetick/py/aggregations/order_book.py +501 -0
  26. onetick/py/aggregations/other.py +1014 -0
  27. onetick/py/backports.py +26 -0
  28. onetick/py/cache.py +374 -0
  29. onetick/py/callback/__init__.py +5 -0
  30. onetick/py/callback/callback.py +276 -0
  31. onetick/py/callback/callbacks.py +131 -0
  32. onetick/py/compatibility.py +798 -0
  33. onetick/py/configuration.py +771 -0
  34. onetick/py/core/__init__.py +0 -0
  35. onetick/py/core/_csv_inspector.py +93 -0
  36. onetick/py/core/_internal/__init__.py +0 -0
  37. onetick/py/core/_internal/_manually_bound_value.py +6 -0
  38. onetick/py/core/_internal/_nodes_history.py +250 -0
  39. onetick/py/core/_internal/_op_utils/__init__.py +0 -0
  40. onetick/py/core/_internal/_op_utils/every_operand.py +9 -0
  41. onetick/py/core/_internal/_op_utils/is_const.py +10 -0
  42. onetick/py/core/_internal/_per_tick_scripts/tick_list_sort_template.script +121 -0
  43. onetick/py/core/_internal/_proxy_node.py +140 -0
  44. onetick/py/core/_internal/_state_objects.py +2312 -0
  45. onetick/py/core/_internal/_state_vars.py +93 -0
  46. onetick/py/core/_source/__init__.py +0 -0
  47. onetick/py/core/_source/_symbol_param.py +95 -0
  48. onetick/py/core/_source/schema.py +97 -0
  49. onetick/py/core/_source/source_methods/__init__.py +0 -0
  50. onetick/py/core/_source/source_methods/aggregations.py +809 -0
  51. onetick/py/core/_source/source_methods/applyers.py +296 -0
  52. onetick/py/core/_source/source_methods/columns.py +141 -0
  53. onetick/py/core/_source/source_methods/data_quality.py +301 -0
  54. onetick/py/core/_source/source_methods/debugs.py +272 -0
  55. onetick/py/core/_source/source_methods/drops.py +120 -0
  56. onetick/py/core/_source/source_methods/fields.py +619 -0
  57. onetick/py/core/_source/source_methods/filters.py +1002 -0
  58. onetick/py/core/_source/source_methods/joins.py +1413 -0
  59. onetick/py/core/_source/source_methods/merges.py +605 -0
  60. onetick/py/core/_source/source_methods/misc.py +1455 -0
  61. onetick/py/core/_source/source_methods/pandases.py +155 -0
  62. onetick/py/core/_source/source_methods/renames.py +356 -0
  63. onetick/py/core/_source/source_methods/sorts.py +183 -0
  64. onetick/py/core/_source/source_methods/switches.py +142 -0
  65. onetick/py/core/_source/source_methods/symbols.py +117 -0
  66. onetick/py/core/_source/source_methods/times.py +627 -0
  67. onetick/py/core/_source/source_methods/writes.py +986 -0
  68. onetick/py/core/_source/symbol.py +205 -0
  69. onetick/py/core/_source/tmp_otq.py +222 -0
  70. onetick/py/core/column.py +209 -0
  71. onetick/py/core/column_operations/__init__.py +0 -0
  72. onetick/py/core/column_operations/_methods/__init__.py +4 -0
  73. onetick/py/core/column_operations/_methods/_internal.py +28 -0
  74. onetick/py/core/column_operations/_methods/conversions.py +216 -0
  75. onetick/py/core/column_operations/_methods/methods.py +292 -0
  76. onetick/py/core/column_operations/_methods/op_types.py +160 -0
  77. onetick/py/core/column_operations/accessors/__init__.py +0 -0
  78. onetick/py/core/column_operations/accessors/_accessor.py +28 -0
  79. onetick/py/core/column_operations/accessors/decimal_accessor.py +104 -0
  80. onetick/py/core/column_operations/accessors/dt_accessor.py +537 -0
  81. onetick/py/core/column_operations/accessors/float_accessor.py +184 -0
  82. onetick/py/core/column_operations/accessors/str_accessor.py +1367 -0
  83. onetick/py/core/column_operations/base.py +1121 -0
  84. onetick/py/core/cut_builder.py +150 -0
  85. onetick/py/core/db_constants.py +20 -0
  86. onetick/py/core/eval_query.py +245 -0
  87. onetick/py/core/lambda_object.py +441 -0
  88. onetick/py/core/multi_output_source.py +232 -0
  89. onetick/py/core/per_tick_script.py +2256 -0
  90. onetick/py/core/query_inspector.py +464 -0
  91. onetick/py/core/source.py +1744 -0
  92. onetick/py/db/__init__.py +2 -0
  93. onetick/py/db/_inspection.py +1128 -0
  94. onetick/py/db/db.py +1327 -0
  95. onetick/py/db/utils.py +64 -0
  96. onetick/py/docs/__init__.py +0 -0
  97. onetick/py/docs/docstring_parser.py +112 -0
  98. onetick/py/docs/utils.py +81 -0
  99. onetick/py/functions.py +2398 -0
  100. onetick/py/license.py +190 -0
  101. onetick/py/log.py +88 -0
  102. onetick/py/math.py +935 -0
  103. onetick/py/misc.py +470 -0
  104. onetick/py/oqd/__init__.py +22 -0
  105. onetick/py/oqd/eps.py +1195 -0
  106. onetick/py/oqd/sources.py +325 -0
  107. onetick/py/otq.py +216 -0
  108. onetick/py/pyomd_mock.py +47 -0
  109. onetick/py/run.py +916 -0
  110. onetick/py/servers.py +173 -0
  111. onetick/py/session.py +1347 -0
  112. onetick/py/sources/__init__.py +19 -0
  113. onetick/py/sources/cache.py +167 -0
  114. onetick/py/sources/common.py +128 -0
  115. onetick/py/sources/csv.py +642 -0
  116. onetick/py/sources/custom.py +85 -0
  117. onetick/py/sources/data_file.py +305 -0
  118. onetick/py/sources/data_source.py +1045 -0
  119. onetick/py/sources/empty.py +94 -0
  120. onetick/py/sources/odbc.py +337 -0
  121. onetick/py/sources/order_book.py +271 -0
  122. onetick/py/sources/parquet.py +168 -0
  123. onetick/py/sources/pit.py +191 -0
  124. onetick/py/sources/query.py +495 -0
  125. onetick/py/sources/snapshots.py +419 -0
  126. onetick/py/sources/split_query_output_by_symbol.py +198 -0
  127. onetick/py/sources/symbology_mapping.py +123 -0
  128. onetick/py/sources/symbols.py +374 -0
  129. onetick/py/sources/ticks.py +825 -0
  130. onetick/py/sql.py +70 -0
  131. onetick/py/state.py +251 -0
  132. onetick/py/types.py +2131 -0
  133. onetick/py/utils/__init__.py +70 -0
  134. onetick/py/utils/acl.py +93 -0
  135. onetick/py/utils/config.py +186 -0
  136. onetick/py/utils/default.py +49 -0
  137. onetick/py/utils/file.py +38 -0
  138. onetick/py/utils/helpers.py +76 -0
  139. onetick/py/utils/locator.py +94 -0
  140. onetick/py/utils/perf.py +498 -0
  141. onetick/py/utils/query.py +49 -0
  142. onetick/py/utils/render.py +1374 -0
  143. onetick/py/utils/script.py +244 -0
  144. onetick/py/utils/temp.py +471 -0
  145. onetick/py/utils/types.py +120 -0
  146. onetick/py/utils/tz.py +84 -0
  147. onetick_py-1.177.0.dist-info/METADATA +137 -0
  148. onetick_py-1.177.0.dist-info/RECORD +152 -0
  149. onetick_py-1.177.0.dist-info/WHEEL +5 -0
  150. onetick_py-1.177.0.dist-info/entry_points.txt +2 -0
  151. onetick_py-1.177.0.dist-info/licenses/LICENSE +21 -0
  152. onetick_py-1.177.0.dist-info/top_level.txt +2 -0
@@ -0,0 +1,184 @@
1
+ from onetick.py import types as ott
2
+ from onetick.py.core.column_operations.accessors._accessor import _Accessor
3
+ from onetick.py.core.column_operations.base import _Operation
4
+
5
+
6
+ class _FloatAccessor(_Accessor):
7
+ """
8
+ Accessor for float (double in Onetick terminology) functions
9
+
10
+ >>> data = otp.Ticks(X=[1.1, 1.2])
11
+ >>> data["Y"] = data["X"].float.<function_name>() # doctest: +SKIP
12
+ """
13
+
14
+ def str(self, length=10, precision=6):
15
+ """
16
+ Converts float to str.
17
+
18
+ Converts number to string with given ``length`` and ``precision``.
19
+ The specified ``length`` should be greater than or equal
20
+ to the part of the number before the decimal point plus the number's sign (if any).
21
+
22
+ If ``length`` is specified as an int, the method will return strings with ``length`` characters,
23
+ if ``length`` is specified as a column, the method will return string default (64 characters) length.
24
+
25
+ Parameters
26
+ ----------
27
+ length: Operation or int
28
+ Length of the string.
29
+ precision: Operation or int
30
+ Number of symbols after dot.
31
+
32
+ Returns
33
+ -------
34
+ result: Operation
35
+ String representation of float value.
36
+
37
+ Examples
38
+ --------
39
+
40
+ >>> data = otp.Ticks(X=[1, 2.17, 10.31861, 3.141593, otp.nan, otp.inf, -otp.inf])
41
+ >>> # OTdirective: snippet-name: float operations.to string.constant precision;
42
+ >>> data["Y"] = data["X"].float.str(15, 3)
43
+ >>> otp.run(data)
44
+ Time X Y
45
+ 0 2003-12-01 00:00:00.000 1.000000 1.000
46
+ 1 2003-12-01 00:00:00.001 2.170000 2.170
47
+ 2 2003-12-01 00:00:00.002 10.318610 10.319
48
+ 3 2003-12-01 00:00:00.003 3.141593 3.142
49
+ 4 2003-12-01 00:00:00.004 NaN nan
50
+ 5 2003-12-01 00:00:00.005 inf inf
51
+ 6 2003-12-01 00:00:00.006 -inf -inf
52
+
53
+ Parameters ``length`` and ``precision`` can also be taken from the columns:
54
+
55
+ >>> data = otp.Ticks(X=[1, 2.17, 10.31841, 3.141593],
56
+ ... LENGTH=[2, 3, 4, 5],
57
+ ... PRECISION=[5, 5, 3, 3])
58
+ >>> # OTdirective: snippet-name: float operations.to string.precision from fields;
59
+ >>> data["Y"] = data["X"].float.str(data["LENGTH"], data["PRECISION"])
60
+ >>> otp.run(data)
61
+ Time X LENGTH PRECISION Y
62
+ 0 2003-12-01 00:00:00.000 1.000000 2 5 1
63
+ 1 2003-12-01 00:00:00.001 2.170000 3 5 2.2
64
+ 2 2003-12-01 00:00:00.002 10.318410 4 3 10.3
65
+ 3 2003-12-01 00:00:00.003 3.141593 5 3 3.142
66
+ """
67
+ dtype = ott.string[length] if isinstance(length, int) else str
68
+
69
+ def formatter(column, _length, _precision):
70
+ column = ott.value2str(column)
71
+ _length = ott.value2str(_length)
72
+ _precision = ott.value2str(_precision)
73
+ str_expr = f"str({column}, {_length}, {_precision})"
74
+ # BDS-478: str() function raises exception for nan and inf values, so converting them manually
75
+ str_expr = f'CASE({column}, NAN(), "nan", INFINITY(), "inf", -INFINITY(), "-inf", {str_expr})'
76
+ return str_expr
77
+
78
+ return _FloatAccessor.Formatter(
79
+ op_params=[self._base_column, length, precision],
80
+ dtype=dtype,
81
+ formatter=formatter,
82
+ )
83
+
84
+ def cmp(self, other, eps):
85
+ """
86
+ Compare two double values between themselves according to ``eps`` relative difference.
87
+
88
+ This function returns 0 if column = other, 1 if column > other, and -1 if column < other.
89
+ Two numbers are considered to be equal if both of them are NaN or
90
+ ``abs(column - other) / (abs(column) + abs(other)) < eps``.
91
+ In other words, ``eps`` represents a relative difference (percentage) between the two numbers,
92
+ not an absolute difference.
93
+
94
+ Parameters
95
+ ----------
96
+ other: Operation or float
97
+ column or value to compare with
98
+ eps: Operation or float
99
+ column or value with relative difference
100
+
101
+ Returns
102
+ -------
103
+ result: Operation
104
+ 0 if column == other, 1 if column > other, and -1 if column < other.
105
+
106
+ See Also
107
+ --------
108
+ eq
109
+
110
+ Examples
111
+ --------
112
+
113
+ >>> data = otp.Ticks(X=[1, 2.17, 10.31841, 3.141593, 6],
114
+ ... OTHER=[1.01, 2.1, 10.32841, 3.14, 5],
115
+ ... EPS=[0, 1, 0.1, 0.001, 0.001])
116
+ >>> # OTdirective: snippet-name: float operations.approximate comparison.lt|eq|gt;
117
+ >>> data["Y"] = data["X"].float.cmp(data["OTHER"], data["EPS"])
118
+ >>> otp.run(data)
119
+ Time X OTHER EPS Y
120
+ 0 2003-12-01 00:00:00.000 1.000000 1.01000 0.000 -1.0
121
+ 1 2003-12-01 00:00:00.001 2.170000 2.10000 1.000 0.0
122
+ 2 2003-12-01 00:00:00.002 10.318410 10.32841 0.100 0.0
123
+ 3 2003-12-01 00:00:00.003 3.141593 3.14000 0.001 0.0
124
+ 4 2003-12-01 00:00:00.004 6.000000 5.00000 0.001 1.0
125
+ """
126
+ def formatter(column, _other, _eps):
127
+ column = ott.value2str(column)
128
+ _other = ott.value2str(_other)
129
+ _eps = ott.value2str(_eps)
130
+ return f"double_compare({column}, {_other}, {_eps})"
131
+
132
+ return _FloatAccessor.Formatter(
133
+ op_params=[self._base_column, other, eps],
134
+ dtype=float,
135
+ formatter=formatter,
136
+ )
137
+
138
+ def eq(self, other, delta):
139
+ """
140
+ Compare two double values between themselves according to ``delta`` relative difference.
141
+ Calculated as ``abs(column - other) <= delta``.
142
+
143
+ Parameters
144
+ ----------
145
+ other: Operation, float
146
+ column or value to compare with
147
+ delta: Operation, float
148
+ column or value with relative difference
149
+
150
+ See Also
151
+ --------
152
+ cmp
153
+
154
+ Returns
155
+ -------
156
+ Operation
157
+
158
+ Examples
159
+ --------
160
+
161
+ >>> data = otp.Ticks(X=[1, 2.17, 10.31841, 3.141593, 6],
162
+ ... OTHER=[1.01, 2.1, 10.32841, 3.14, 5],
163
+ ... DELTA=[0, 1, 0.1, 0.01, 0.001])
164
+ >>> # OTdirective: snippet-name: float operations.approximate comparison.eq;
165
+ >>> data["Y"] = (1 + data["X"] - 1).float.eq(data["OTHER"], data["DELTA"])
166
+ >>> otp.run(data)
167
+ Time X OTHER DELTA Y
168
+ 0 2003-12-01 00:00:00.000 1.000000 1.01000 0.000 0.0
169
+ 1 2003-12-01 00:00:00.001 2.170000 2.10000 1.000 1.0
170
+ 2 2003-12-01 00:00:00.002 10.318410 10.32841 0.100 1.0
171
+ 3 2003-12-01 00:00:00.003 3.141593 3.14000 0.010 1.0
172
+ 4 2003-12-01 00:00:00.004 6.000000 5.00000 0.001 0.0
173
+ """
174
+ def formatter(column, _other, _delta):
175
+ column = ott.value2str(column)
176
+ _other = ott.value2str(_other)
177
+ _delta = ott.value2str(_delta)
178
+ return f"abs({column} - {_other}) <= {_delta}"
179
+
180
+ return _FloatAccessor.Formatter(
181
+ op_params=[self._base_column, other, delta],
182
+ dtype=bool,
183
+ formatter=formatter,
184
+ )