onetick-py 1.162.2__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.
- locator_parser/__init__.py +0 -0
- locator_parser/acl.py +73 -0
- locator_parser/actions.py +266 -0
- locator_parser/common.py +365 -0
- locator_parser/io.py +41 -0
- locator_parser/locator.py +150 -0
- onetick/__init__.py +101 -0
- onetick/doc_utilities/__init__.py +3 -0
- onetick/doc_utilities/napoleon.py +40 -0
- onetick/doc_utilities/ot_doctest.py +140 -0
- onetick/doc_utilities/snippets.py +280 -0
- onetick/lib/__init__.py +4 -0
- onetick/lib/instance.py +138 -0
- onetick/py/__init__.py +290 -0
- onetick/py/_stack_info.py +89 -0
- onetick/py/_version.py +2 -0
- onetick/py/aggregations/__init__.py +11 -0
- onetick/py/aggregations/_base.py +645 -0
- onetick/py/aggregations/_docs.py +912 -0
- onetick/py/aggregations/compute.py +286 -0
- onetick/py/aggregations/functions.py +2216 -0
- onetick/py/aggregations/generic.py +104 -0
- onetick/py/aggregations/high_low.py +80 -0
- onetick/py/aggregations/num_distinct.py +83 -0
- onetick/py/aggregations/order_book.py +427 -0
- onetick/py/aggregations/other.py +1014 -0
- onetick/py/backports.py +26 -0
- onetick/py/cache.py +373 -0
- onetick/py/callback/__init__.py +5 -0
- onetick/py/callback/callback.py +275 -0
- onetick/py/callback/callbacks.py +131 -0
- onetick/py/compatibility.py +752 -0
- onetick/py/configuration.py +736 -0
- onetick/py/core/__init__.py +0 -0
- onetick/py/core/_csv_inspector.py +93 -0
- onetick/py/core/_internal/__init__.py +0 -0
- onetick/py/core/_internal/_manually_bound_value.py +6 -0
- onetick/py/core/_internal/_nodes_history.py +250 -0
- onetick/py/core/_internal/_op_utils/__init__.py +0 -0
- onetick/py/core/_internal/_op_utils/every_operand.py +9 -0
- onetick/py/core/_internal/_op_utils/is_const.py +10 -0
- onetick/py/core/_internal/_per_tick_scripts/tick_list_sort_template.script +121 -0
- onetick/py/core/_internal/_proxy_node.py +140 -0
- onetick/py/core/_internal/_state_objects.py +2307 -0
- onetick/py/core/_internal/_state_vars.py +87 -0
- onetick/py/core/_source/__init__.py +0 -0
- onetick/py/core/_source/_symbol_param.py +95 -0
- onetick/py/core/_source/schema.py +97 -0
- onetick/py/core/_source/source_methods/__init__.py +0 -0
- onetick/py/core/_source/source_methods/aggregations.py +810 -0
- onetick/py/core/_source/source_methods/applyers.py +296 -0
- onetick/py/core/_source/source_methods/columns.py +141 -0
- onetick/py/core/_source/source_methods/data_quality.py +301 -0
- onetick/py/core/_source/source_methods/debugs.py +270 -0
- onetick/py/core/_source/source_methods/drops.py +120 -0
- onetick/py/core/_source/source_methods/fields.py +619 -0
- onetick/py/core/_source/source_methods/filters.py +1001 -0
- onetick/py/core/_source/source_methods/joins.py +1393 -0
- onetick/py/core/_source/source_methods/merges.py +566 -0
- onetick/py/core/_source/source_methods/misc.py +1325 -0
- onetick/py/core/_source/source_methods/pandases.py +155 -0
- onetick/py/core/_source/source_methods/renames.py +356 -0
- onetick/py/core/_source/source_methods/sorts.py +183 -0
- onetick/py/core/_source/source_methods/switches.py +142 -0
- onetick/py/core/_source/source_methods/symbols.py +117 -0
- onetick/py/core/_source/source_methods/times.py +627 -0
- onetick/py/core/_source/source_methods/writes.py +702 -0
- onetick/py/core/_source/symbol.py +202 -0
- onetick/py/core/_source/tmp_otq.py +222 -0
- onetick/py/core/column.py +209 -0
- onetick/py/core/column_operations/__init__.py +0 -0
- onetick/py/core/column_operations/_methods/__init__.py +4 -0
- onetick/py/core/column_operations/_methods/_internal.py +28 -0
- onetick/py/core/column_operations/_methods/conversions.py +215 -0
- onetick/py/core/column_operations/_methods/methods.py +294 -0
- onetick/py/core/column_operations/_methods/op_types.py +150 -0
- onetick/py/core/column_operations/accessors/__init__.py +0 -0
- onetick/py/core/column_operations/accessors/_accessor.py +30 -0
- onetick/py/core/column_operations/accessors/decimal_accessor.py +92 -0
- onetick/py/core/column_operations/accessors/dt_accessor.py +464 -0
- onetick/py/core/column_operations/accessors/float_accessor.py +160 -0
- onetick/py/core/column_operations/accessors/str_accessor.py +1374 -0
- onetick/py/core/column_operations/base.py +1061 -0
- onetick/py/core/cut_builder.py +149 -0
- onetick/py/core/db_constants.py +20 -0
- onetick/py/core/eval_query.py +244 -0
- onetick/py/core/lambda_object.py +442 -0
- onetick/py/core/multi_output_source.py +193 -0
- onetick/py/core/per_tick_script.py +2253 -0
- onetick/py/core/query_inspector.py +465 -0
- onetick/py/core/source.py +1663 -0
- onetick/py/db/__init__.py +2 -0
- onetick/py/db/_inspection.py +1042 -0
- onetick/py/db/db.py +1423 -0
- onetick/py/db/utils.py +64 -0
- onetick/py/docs/__init__.py +0 -0
- onetick/py/docs/docstring_parser.py +112 -0
- onetick/py/docs/utils.py +81 -0
- onetick/py/functions.py +2354 -0
- onetick/py/license.py +188 -0
- onetick/py/log.py +88 -0
- onetick/py/math.py +947 -0
- onetick/py/misc.py +437 -0
- onetick/py/oqd/__init__.py +22 -0
- onetick/py/oqd/eps.py +1195 -0
- onetick/py/oqd/sources.py +325 -0
- onetick/py/otq.py +211 -0
- onetick/py/pyomd_mock.py +47 -0
- onetick/py/run.py +841 -0
- onetick/py/servers.py +173 -0
- onetick/py/session.py +1342 -0
- onetick/py/sources/__init__.py +19 -0
- onetick/py/sources/cache.py +167 -0
- onetick/py/sources/common.py +126 -0
- onetick/py/sources/csv.py +642 -0
- onetick/py/sources/custom.py +85 -0
- onetick/py/sources/data_file.py +305 -0
- onetick/py/sources/data_source.py +1049 -0
- onetick/py/sources/empty.py +94 -0
- onetick/py/sources/odbc.py +337 -0
- onetick/py/sources/order_book.py +238 -0
- onetick/py/sources/parquet.py +168 -0
- onetick/py/sources/pit.py +191 -0
- onetick/py/sources/query.py +495 -0
- onetick/py/sources/snapshots.py +419 -0
- onetick/py/sources/split_query_output_by_symbol.py +198 -0
- onetick/py/sources/symbology_mapping.py +123 -0
- onetick/py/sources/symbols.py +357 -0
- onetick/py/sources/ticks.py +825 -0
- onetick/py/sql.py +70 -0
- onetick/py/state.py +256 -0
- onetick/py/types.py +2056 -0
- onetick/py/utils/__init__.py +70 -0
- onetick/py/utils/acl.py +93 -0
- onetick/py/utils/config.py +186 -0
- onetick/py/utils/default.py +49 -0
- onetick/py/utils/file.py +38 -0
- onetick/py/utils/helpers.py +76 -0
- onetick/py/utils/locator.py +94 -0
- onetick/py/utils/perf.py +499 -0
- onetick/py/utils/query.py +49 -0
- onetick/py/utils/render.py +1139 -0
- onetick/py/utils/script.py +244 -0
- onetick/py/utils/temp.py +471 -0
- onetick/py/utils/types.py +118 -0
- onetick/py/utils/tz.py +82 -0
- onetick_py-1.162.2.dist-info/METADATA +148 -0
- onetick_py-1.162.2.dist-info/RECORD +152 -0
- onetick_py-1.162.2.dist-info/WHEEL +5 -0
- onetick_py-1.162.2.dist-info/entry_points.txt +2 -0
- onetick_py-1.162.2.dist-info/licenses/LICENSE +21 -0
- onetick_py-1.162.2.dist-info/top_level.txt +2 -0
onetick/py/math.py
ADDED
|
@@ -0,0 +1,947 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
from onetick.py.core.column_operations.base import _Operation
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class _MaxOperator(_Operation):
|
|
6
|
+
|
|
7
|
+
def __init__(self, objs):
|
|
8
|
+
from onetick.py.types import get_type_by_objects
|
|
9
|
+
|
|
10
|
+
super().__init__(dtype=get_type_by_objects(objs))
|
|
11
|
+
|
|
12
|
+
def _str_max(l_val, r_val):
|
|
13
|
+
if type(r_val) is list:
|
|
14
|
+
if len(r_val) > 1:
|
|
15
|
+
r_val = _str_max(r_val[0], r_val[1:])
|
|
16
|
+
else:
|
|
17
|
+
r_val = r_val[0]
|
|
18
|
+
# CASE should be uppercased because it can be used in per-tick script
|
|
19
|
+
return 'CASE({0} > {1}, 1, {0}, {1})'.format(str(l_val), str(r_val))
|
|
20
|
+
|
|
21
|
+
self._repr = _str_max(objs[0], objs[1:])
|
|
22
|
+
|
|
23
|
+
def __str__(self):
|
|
24
|
+
return self._repr
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def max(*objs):
|
|
28
|
+
"""
|
|
29
|
+
Returns maximum value from list of ``objs``.
|
|
30
|
+
|
|
31
|
+
Parameters
|
|
32
|
+
----------
|
|
33
|
+
objs: int, float, :py:class:`~onetick.py.Operation`, :py:class:`~onetick.py.Column`
|
|
34
|
+
|
|
35
|
+
Returns
|
|
36
|
+
-------
|
|
37
|
+
:py:class:`~onetick.py.Operation`
|
|
38
|
+
|
|
39
|
+
Examples
|
|
40
|
+
--------
|
|
41
|
+
>>> data = otp.Tick(A=1)
|
|
42
|
+
>>> data['MAX'] = otp.math.max(5, data['A'])
|
|
43
|
+
>>> otp.run(data)
|
|
44
|
+
Time A MAX
|
|
45
|
+
0 2003-12-01 1 5
|
|
46
|
+
"""
|
|
47
|
+
return _MaxOperator(list(objs))
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class _MinOperator(_Operation):
|
|
51
|
+
|
|
52
|
+
def __init__(self, objs):
|
|
53
|
+
from onetick.py.types import get_type_by_objects
|
|
54
|
+
|
|
55
|
+
super().__init__(dtype=get_type_by_objects(objs))
|
|
56
|
+
|
|
57
|
+
def _str_min(l_val, r_val):
|
|
58
|
+
if type(r_val) is list:
|
|
59
|
+
if len(r_val) > 1:
|
|
60
|
+
r_val = _str_min(r_val[0], r_val[1:])
|
|
61
|
+
else:
|
|
62
|
+
r_val = r_val[0]
|
|
63
|
+
# CASE should be uppercased because it can be used in per-tick script
|
|
64
|
+
return 'CASE({0} < {1}, 1, {0}, {1})'.format(str(l_val), str(r_val))
|
|
65
|
+
|
|
66
|
+
self._repr = _str_min(objs[0], objs[1:])
|
|
67
|
+
|
|
68
|
+
def __str__(self):
|
|
69
|
+
return self._repr
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def min(*objs):
|
|
73
|
+
"""
|
|
74
|
+
Returns minimum value from list of ``objs``.
|
|
75
|
+
|
|
76
|
+
Parameters
|
|
77
|
+
----------
|
|
78
|
+
objs: int, float, :py:class:`~onetick.py.Operation`, :py:class:`~onetick.py.Column`
|
|
79
|
+
|
|
80
|
+
Returns
|
|
81
|
+
-------
|
|
82
|
+
:py:class:`~onetick.py.Operation`
|
|
83
|
+
|
|
84
|
+
Examples
|
|
85
|
+
--------
|
|
86
|
+
>>> data = otp.Tick(A=1)
|
|
87
|
+
>>> data['MIN'] = otp.math.min(-5, data['A'])
|
|
88
|
+
>>> otp.run(data)
|
|
89
|
+
Time A MIN
|
|
90
|
+
0 2003-12-01 1 -5
|
|
91
|
+
"""
|
|
92
|
+
return _MinOperator(list(objs))
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
class _RandomFunc(_Operation):
|
|
96
|
+
"""
|
|
97
|
+
It implements the `rand` built-in function.
|
|
98
|
+
"""
|
|
99
|
+
|
|
100
|
+
def __init__(self, min_value: int, max_value: int, seed: Optional[int] = None):
|
|
101
|
+
super().__init__(dtype=int)
|
|
102
|
+
|
|
103
|
+
def _repr(min_value, max_value, seed):
|
|
104
|
+
result = f'rand({str(min_value)}, {str(max_value)}'
|
|
105
|
+
if seed is not None:
|
|
106
|
+
result += f',{str(seed)})'
|
|
107
|
+
else:
|
|
108
|
+
result += ')'
|
|
109
|
+
return result
|
|
110
|
+
|
|
111
|
+
self._repr = _repr(min_value, max_value, seed)
|
|
112
|
+
|
|
113
|
+
def __str__(self):
|
|
114
|
+
return self._repr
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def rand(min_value: int, max_value: int, seed: Optional[int] = None):
|
|
118
|
+
"""
|
|
119
|
+
Returns a pseudo-random value in the range between ``min_value`` and ``max_value`` (both inclusive).
|
|
120
|
+
If ``seed`` is not specified, the function produces different values each time a query is invoked.
|
|
121
|
+
If ``seed`` is specified, for this seed the function produces the same sequence of values
|
|
122
|
+
each time a query is invoked.
|
|
123
|
+
|
|
124
|
+
Parameters
|
|
125
|
+
----------
|
|
126
|
+
min_value: int, :py:class:`~onetick.py.Operation`, :py:class:`~onetick.py.Column`
|
|
127
|
+
max_value: int, :py:class:`~onetick.py.Operation`, :py:class:`~onetick.py.Column`
|
|
128
|
+
seed: int, :py:class:`~onetick.py.Operation`, :py:class:`~onetick.py.Column`
|
|
129
|
+
|
|
130
|
+
Returns
|
|
131
|
+
-------
|
|
132
|
+
:py:class:`~onetick.py.Operation`
|
|
133
|
+
|
|
134
|
+
Examples
|
|
135
|
+
--------
|
|
136
|
+
>>> data = otp.Tick(A=1)
|
|
137
|
+
>>> data['RAND'] = otp.math.rand(1, 1000)
|
|
138
|
+
"""
|
|
139
|
+
|
|
140
|
+
if isinstance(min_value, int) and min_value < 0:
|
|
141
|
+
raise ValueError("It is not possible to use negative values for the `min_value`")
|
|
142
|
+
if isinstance(min_value, int) and isinstance(max_value, int) and min_value >= max_value:
|
|
143
|
+
raise ValueError("The `max_value` parameter should be more than `min_value`")
|
|
144
|
+
|
|
145
|
+
return _RandomFunc(min_value, max_value, seed)
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
class _Now(_Operation):
|
|
149
|
+
|
|
150
|
+
def __init__(self):
|
|
151
|
+
from onetick.py.types import nsectime
|
|
152
|
+
|
|
153
|
+
super().__init__(dtype=nsectime)
|
|
154
|
+
|
|
155
|
+
def _repr():
|
|
156
|
+
return 'now()'
|
|
157
|
+
|
|
158
|
+
self._repr = _repr()
|
|
159
|
+
|
|
160
|
+
def __str__(self):
|
|
161
|
+
return self._repr
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
# TODO: this is not math, let's move it somewhere else
|
|
165
|
+
def now():
|
|
166
|
+
"""
|
|
167
|
+
Returns the current time expressed as the number of milliseconds since the UNIX epoch.
|
|
168
|
+
|
|
169
|
+
Returns
|
|
170
|
+
-------
|
|
171
|
+
:py:class:`~onetick.py.Operation`
|
|
172
|
+
|
|
173
|
+
Examples
|
|
174
|
+
--------
|
|
175
|
+
>>> data = otp.Tick(A=1)
|
|
176
|
+
>>> data['NOW'] = otp.now()
|
|
177
|
+
"""
|
|
178
|
+
return _Now()
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
class _Ln(_Operation):
|
|
182
|
+
"""
|
|
183
|
+
Compute the natural logarithm.
|
|
184
|
+
"""
|
|
185
|
+
|
|
186
|
+
def __init__(self, value):
|
|
187
|
+
super().__init__(dtype=float)
|
|
188
|
+
|
|
189
|
+
def _repr(value):
|
|
190
|
+
return f'LOG({str(value)})'
|
|
191
|
+
|
|
192
|
+
self._repr = _repr(value)
|
|
193
|
+
|
|
194
|
+
def __str__(self):
|
|
195
|
+
return self._repr
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
def ln(value):
|
|
199
|
+
"""
|
|
200
|
+
Compute the natural logarithm of the ``value``.
|
|
201
|
+
|
|
202
|
+
Parameters
|
|
203
|
+
----------
|
|
204
|
+
value: int, float, :py:class:`~onetick.py.Operation`, :py:class:`~onetick.py.Column`
|
|
205
|
+
|
|
206
|
+
Returns
|
|
207
|
+
-------
|
|
208
|
+
:py:class:`~onetick.py.Operation`
|
|
209
|
+
|
|
210
|
+
Examples
|
|
211
|
+
--------
|
|
212
|
+
>>> data = otp.Tick(A=1)
|
|
213
|
+
>>> data['LN'] = otp.math.ln(2.718282)
|
|
214
|
+
>>> otp.run(data)
|
|
215
|
+
Time A LN
|
|
216
|
+
0 2003-12-01 1 1.0
|
|
217
|
+
|
|
218
|
+
See Also
|
|
219
|
+
--------
|
|
220
|
+
onetick.py.math.exp
|
|
221
|
+
"""
|
|
222
|
+
return _Ln(value)
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
class _Log10(_Operation):
|
|
226
|
+
"""
|
|
227
|
+
Compute the base-10 logarithm.
|
|
228
|
+
"""
|
|
229
|
+
|
|
230
|
+
def __init__(self, value):
|
|
231
|
+
super().__init__(dtype=float)
|
|
232
|
+
|
|
233
|
+
def _repr(value):
|
|
234
|
+
return f'LOG10({str(value)})'
|
|
235
|
+
|
|
236
|
+
self._repr = _repr(value)
|
|
237
|
+
|
|
238
|
+
def __str__(self):
|
|
239
|
+
return self._repr
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
def log10(value):
|
|
243
|
+
"""
|
|
244
|
+
Compute the base-10 logarithm of the ``value``.
|
|
245
|
+
|
|
246
|
+
Parameters
|
|
247
|
+
----------
|
|
248
|
+
value: int, float, :py:class:`~onetick.py.Operation`, :py:class:`~onetick.py.Column`
|
|
249
|
+
|
|
250
|
+
Returns
|
|
251
|
+
-------
|
|
252
|
+
:py:class:`~onetick.py.Operation`
|
|
253
|
+
|
|
254
|
+
Examples
|
|
255
|
+
--------
|
|
256
|
+
>>> data = otp.Tick(A=1)
|
|
257
|
+
>>> data['LOG10'] = otp.math.log10(100)
|
|
258
|
+
>>> otp.run(data)
|
|
259
|
+
Time A LOG10
|
|
260
|
+
0 2003-12-01 1 2.0
|
|
261
|
+
"""
|
|
262
|
+
return _Log10(value)
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
class _Exp(_Operation):
|
|
266
|
+
"""
|
|
267
|
+
Compute the natural exponent.
|
|
268
|
+
"""
|
|
269
|
+
|
|
270
|
+
def __init__(self, value):
|
|
271
|
+
super().__init__(dtype=float)
|
|
272
|
+
|
|
273
|
+
def _repr(value):
|
|
274
|
+
return f'EXP({str(value)})'
|
|
275
|
+
|
|
276
|
+
self._repr = _repr(value)
|
|
277
|
+
|
|
278
|
+
def __str__(self):
|
|
279
|
+
return self._repr
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
def exp(value):
|
|
283
|
+
"""
|
|
284
|
+
Compute the natural exponent of the ``value``.
|
|
285
|
+
|
|
286
|
+
Parameters
|
|
287
|
+
----------
|
|
288
|
+
value: int, float, :py:class:`~onetick.py.Operation`, :py:class:`~onetick.py.Column`
|
|
289
|
+
|
|
290
|
+
Returns
|
|
291
|
+
-------
|
|
292
|
+
:py:class:`~onetick.py.Operation`
|
|
293
|
+
|
|
294
|
+
Examples
|
|
295
|
+
--------
|
|
296
|
+
>>> data = otp.Tick(A=1)
|
|
297
|
+
>>> data['E'] = otp.math.exp(1)
|
|
298
|
+
>>> otp.run(data)
|
|
299
|
+
Time A E
|
|
300
|
+
0 2003-12-01 1 2.718282
|
|
301
|
+
|
|
302
|
+
See Also
|
|
303
|
+
--------
|
|
304
|
+
onetick.py.math.ln
|
|
305
|
+
"""
|
|
306
|
+
return _Exp(value)
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
class _Sqrt(_Operation):
|
|
310
|
+
"""
|
|
311
|
+
Compute the square root.
|
|
312
|
+
"""
|
|
313
|
+
|
|
314
|
+
def __init__(self, value):
|
|
315
|
+
super().__init__(dtype=float)
|
|
316
|
+
|
|
317
|
+
def _repr(value):
|
|
318
|
+
return f'SQRT({str(value)})'
|
|
319
|
+
|
|
320
|
+
self._repr = _repr(value)
|
|
321
|
+
|
|
322
|
+
def __str__(self):
|
|
323
|
+
return self._repr
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
def sqrt(value):
|
|
327
|
+
"""
|
|
328
|
+
Compute the square root of the ``value``.
|
|
329
|
+
|
|
330
|
+
Parameters
|
|
331
|
+
----------
|
|
332
|
+
value: int, float, :py:class:`~onetick.py.Operation`, :py:class:`~onetick.py.Column`
|
|
333
|
+
|
|
334
|
+
Returns
|
|
335
|
+
-------
|
|
336
|
+
:py:class:`~onetick.py.Operation`
|
|
337
|
+
|
|
338
|
+
Examples
|
|
339
|
+
--------
|
|
340
|
+
>>> data = otp.Tick(A=1)
|
|
341
|
+
>>> data['SQRT'] = otp.math.sqrt(4)
|
|
342
|
+
>>> otp.run(data)
|
|
343
|
+
Time A SQRT
|
|
344
|
+
0 2003-12-01 1 2.0
|
|
345
|
+
"""
|
|
346
|
+
return _Sqrt(value)
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
class _Sign(_Operation):
|
|
350
|
+
"""
|
|
351
|
+
Get the sign of value.
|
|
352
|
+
"""
|
|
353
|
+
|
|
354
|
+
def __init__(self, value):
|
|
355
|
+
super().__init__(dtype=int)
|
|
356
|
+
|
|
357
|
+
def _repr(value):
|
|
358
|
+
return f'SIGN({str(value)})'
|
|
359
|
+
|
|
360
|
+
self._repr = _repr(value)
|
|
361
|
+
|
|
362
|
+
def __str__(self):
|
|
363
|
+
return self._repr
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
def sign(value):
|
|
367
|
+
"""
|
|
368
|
+
Compute the sign of the ``value``.
|
|
369
|
+
|
|
370
|
+
Parameters
|
|
371
|
+
----------
|
|
372
|
+
value: int, float, :py:class:`~onetick.py.Operation`, :py:class:`~onetick.py.Column`
|
|
373
|
+
|
|
374
|
+
Returns
|
|
375
|
+
-------
|
|
376
|
+
:py:class:`~onetick.py.Operation`
|
|
377
|
+
|
|
378
|
+
Examples
|
|
379
|
+
--------
|
|
380
|
+
>>> data = otp.Tick(A=1)
|
|
381
|
+
>>> data['SIGN_POS'] = otp.math.sign(123)
|
|
382
|
+
>>> data['SIGN_ZERO'] = otp.math.sign(0)
|
|
383
|
+
>>> data['SIGN_NEG'] = otp.math.sign(-123)
|
|
384
|
+
>>> otp.run(data)
|
|
385
|
+
Time A SIGN_POS SIGN_ZERO SIGN_NEG
|
|
386
|
+
0 2003-12-01 1 1 0 -1
|
|
387
|
+
"""
|
|
388
|
+
return _Sign(value)
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
class _Power(_Operation):
|
|
392
|
+
"""
|
|
393
|
+
Compute the ``base`` to the power of the ``exponent``.
|
|
394
|
+
"""
|
|
395
|
+
|
|
396
|
+
def __init__(self, base, exponent):
|
|
397
|
+
super().__init__(dtype=float)
|
|
398
|
+
|
|
399
|
+
def _repr(base, exponent):
|
|
400
|
+
return f'POWER({str(base)}, {str(exponent)})'
|
|
401
|
+
|
|
402
|
+
self._repr = _repr(base, exponent)
|
|
403
|
+
|
|
404
|
+
def __str__(self):
|
|
405
|
+
return self._repr
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
def pow(base, exponent):
|
|
409
|
+
"""
|
|
410
|
+
Compute the ``base`` to the power of the ``exponent``.
|
|
411
|
+
|
|
412
|
+
Parameters
|
|
413
|
+
----------
|
|
414
|
+
base: int, float, :py:class:`~onetick.py.Operation`, :py:class:`~onetick.py.Column`
|
|
415
|
+
exponent: int, float, :py:class:`~onetick.py.Operation`, :py:class:`~onetick.py.Column`
|
|
416
|
+
|
|
417
|
+
Returns
|
|
418
|
+
-------
|
|
419
|
+
:py:class:`~onetick.py.Operation`
|
|
420
|
+
|
|
421
|
+
Examples
|
|
422
|
+
--------
|
|
423
|
+
>>> data = otp.Tick(A=2)
|
|
424
|
+
>>> data['RES'] = otp.math.pow(data['A'], 10)
|
|
425
|
+
>>> otp.run(data)
|
|
426
|
+
Time A RES
|
|
427
|
+
0 2003-12-01 2 1024.0
|
|
428
|
+
"""
|
|
429
|
+
return _Power(base, exponent)
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
class _Pi(_Operation):
|
|
433
|
+
|
|
434
|
+
def __init__(self):
|
|
435
|
+
super().__init__(dtype=float)
|
|
436
|
+
|
|
437
|
+
def _repr():
|
|
438
|
+
return 'PI()'
|
|
439
|
+
|
|
440
|
+
self._repr = _repr()
|
|
441
|
+
|
|
442
|
+
def __str__(self):
|
|
443
|
+
return self._repr
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
def pi():
|
|
447
|
+
"""
|
|
448
|
+
Returns the value of Pi number.
|
|
449
|
+
|
|
450
|
+
Returns
|
|
451
|
+
-------
|
|
452
|
+
:py:class:`~onetick.py.Operation`
|
|
453
|
+
|
|
454
|
+
Examples
|
|
455
|
+
--------
|
|
456
|
+
>>> data = otp.Tick(A=1)
|
|
457
|
+
>>> data['PI'] = otp.math.pi()
|
|
458
|
+
>>> otp.run(data)
|
|
459
|
+
Time A PI
|
|
460
|
+
0 2003-12-01 1 3.141593
|
|
461
|
+
"""
|
|
462
|
+
return _Pi()
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
class _Sin(_Operation):
|
|
466
|
+
"""
|
|
467
|
+
Returns the value of trigonometric function `sin` for the given angle number expressed in radians.
|
|
468
|
+
"""
|
|
469
|
+
|
|
470
|
+
def __init__(self, value):
|
|
471
|
+
super().__init__(dtype=float)
|
|
472
|
+
|
|
473
|
+
def _repr(value):
|
|
474
|
+
return f'SIN({str(value)})'
|
|
475
|
+
|
|
476
|
+
self._repr = _repr(value)
|
|
477
|
+
|
|
478
|
+
def __str__(self):
|
|
479
|
+
return self._repr
|
|
480
|
+
|
|
481
|
+
|
|
482
|
+
def sin(value):
|
|
483
|
+
"""
|
|
484
|
+
Returns the value of trigonometric function `sin` for the given ``value`` number expressed in radians.
|
|
485
|
+
|
|
486
|
+
Parameters
|
|
487
|
+
----------
|
|
488
|
+
value: int, float, :py:class:`~onetick.py.Operation`, :py:class:`~onetick.py.Column`
|
|
489
|
+
|
|
490
|
+
Returns
|
|
491
|
+
-------
|
|
492
|
+
:py:class:`~onetick.py.Operation`
|
|
493
|
+
|
|
494
|
+
Examples
|
|
495
|
+
--------
|
|
496
|
+
>>> data = otp.Tick(A=1)
|
|
497
|
+
>>> data['SIN'] = otp.math.sin(otp.math.pi() / 6)
|
|
498
|
+
>>> otp.run(data)
|
|
499
|
+
Time A SIN
|
|
500
|
+
0 2003-12-01 1 0.5
|
|
501
|
+
|
|
502
|
+
See Also
|
|
503
|
+
--------
|
|
504
|
+
:py:data:`onetick.py.math.pi`
|
|
505
|
+
:py:func:`onetick.py.math.asin`
|
|
506
|
+
"""
|
|
507
|
+
return _Sin(value)
|
|
508
|
+
|
|
509
|
+
|
|
510
|
+
class _Cos(_Operation):
|
|
511
|
+
"""
|
|
512
|
+
Returns the value of trigonometric function `cos` for the given angle number expressed in radians.
|
|
513
|
+
"""
|
|
514
|
+
|
|
515
|
+
def __init__(self, value):
|
|
516
|
+
super().__init__(dtype=float)
|
|
517
|
+
|
|
518
|
+
def _repr(value):
|
|
519
|
+
return f'COS({str(value)})'
|
|
520
|
+
|
|
521
|
+
self._repr = _repr(value)
|
|
522
|
+
|
|
523
|
+
def __str__(self):
|
|
524
|
+
return self._repr
|
|
525
|
+
|
|
526
|
+
|
|
527
|
+
def cos(value):
|
|
528
|
+
"""
|
|
529
|
+
Returns the value of trigonometric function `cos` for the given ``value`` number expressed in radians.
|
|
530
|
+
|
|
531
|
+
Parameters
|
|
532
|
+
----------
|
|
533
|
+
value: int, float, :py:class:`~onetick.py.Operation`, :py:class:`~onetick.py.Column`
|
|
534
|
+
|
|
535
|
+
Returns
|
|
536
|
+
-------
|
|
537
|
+
:py:class:`~onetick.py.Operation`
|
|
538
|
+
|
|
539
|
+
Examples
|
|
540
|
+
--------
|
|
541
|
+
>>> data = otp.Tick(A=1)
|
|
542
|
+
>>> data['COS'] = otp.math.cos(otp.math.pi() / 3)
|
|
543
|
+
>>> otp.run(data)
|
|
544
|
+
Time A COS
|
|
545
|
+
0 2003-12-01 1 0.5
|
|
546
|
+
|
|
547
|
+
See Also
|
|
548
|
+
--------
|
|
549
|
+
:py:data:`onetick.py.math.pi`
|
|
550
|
+
:py:func:`onetick.py.math.acos`
|
|
551
|
+
"""
|
|
552
|
+
return _Cos(value)
|
|
553
|
+
|
|
554
|
+
|
|
555
|
+
class _Tan(_Operation):
|
|
556
|
+
"""
|
|
557
|
+
Returns the value of trigonometric function `tan` for the given angle number expressed in radians.
|
|
558
|
+
"""
|
|
559
|
+
|
|
560
|
+
def __init__(self, value):
|
|
561
|
+
super().__init__(dtype=float)
|
|
562
|
+
|
|
563
|
+
def _repr(value):
|
|
564
|
+
return f'TAN({str(value)})'
|
|
565
|
+
|
|
566
|
+
self._repr = _repr(value)
|
|
567
|
+
|
|
568
|
+
def __str__(self):
|
|
569
|
+
return self._repr
|
|
570
|
+
|
|
571
|
+
|
|
572
|
+
def tan(value):
|
|
573
|
+
"""
|
|
574
|
+
Returns the value of trigonometric function `tan` for the given ``value`` number expressed in radians.
|
|
575
|
+
|
|
576
|
+
Parameters
|
|
577
|
+
----------
|
|
578
|
+
value: int, float, :py:class:`~onetick.py.Operation`, :py:class:`~onetick.py.Column`
|
|
579
|
+
|
|
580
|
+
Returns
|
|
581
|
+
-------
|
|
582
|
+
:py:class:`~onetick.py.Operation`
|
|
583
|
+
|
|
584
|
+
Examples
|
|
585
|
+
--------
|
|
586
|
+
>>> data = otp.Tick(A=1)
|
|
587
|
+
>>> data['TAN'] = otp.math.tan(otp.math.pi() / 4)
|
|
588
|
+
>>> otp.run(data)
|
|
589
|
+
Time A TAN
|
|
590
|
+
0 2003-12-01 1 1.0
|
|
591
|
+
|
|
592
|
+
See Also
|
|
593
|
+
--------
|
|
594
|
+
:py:data:`onetick.py.math.pi`
|
|
595
|
+
:py:func:`onetick.py.math.atan`
|
|
596
|
+
"""
|
|
597
|
+
return _Tan(value)
|
|
598
|
+
|
|
599
|
+
|
|
600
|
+
class _Cot(_Operation):
|
|
601
|
+
"""
|
|
602
|
+
Returns the value of trigonometric function `cot` for the given angle number expressed in radians.
|
|
603
|
+
"""
|
|
604
|
+
|
|
605
|
+
def __init__(self, value):
|
|
606
|
+
super().__init__(dtype=float)
|
|
607
|
+
|
|
608
|
+
def _repr(value):
|
|
609
|
+
return f'COT({str(value)})'
|
|
610
|
+
|
|
611
|
+
self._repr = _repr(value)
|
|
612
|
+
|
|
613
|
+
def __str__(self):
|
|
614
|
+
return self._repr
|
|
615
|
+
|
|
616
|
+
|
|
617
|
+
def cot(value):
|
|
618
|
+
"""
|
|
619
|
+
Returns the value of trigonometric function `cot` for the given ``value`` number expressed in radians.
|
|
620
|
+
|
|
621
|
+
Parameters
|
|
622
|
+
----------
|
|
623
|
+
value: int, float, :py:class:`~onetick.py.Operation`, :py:class:`~onetick.py.Column`
|
|
624
|
+
|
|
625
|
+
Returns
|
|
626
|
+
-------
|
|
627
|
+
:py:class:`~onetick.py.Operation`
|
|
628
|
+
|
|
629
|
+
Examples
|
|
630
|
+
--------
|
|
631
|
+
>>> data = otp.Tick(A=1)
|
|
632
|
+
>>> data['COT'] = otp.math.cot(otp.math.pi() / 4)
|
|
633
|
+
>>> otp.run(data)
|
|
634
|
+
Time A COT
|
|
635
|
+
0 2003-12-01 1 1.0
|
|
636
|
+
|
|
637
|
+
See Also
|
|
638
|
+
--------
|
|
639
|
+
:py:data:`onetick.py.math.pi`
|
|
640
|
+
:py:func:`onetick.py.math.acot`
|
|
641
|
+
"""
|
|
642
|
+
return _Cot(value)
|
|
643
|
+
|
|
644
|
+
|
|
645
|
+
class _Asin(_Operation):
|
|
646
|
+
"""
|
|
647
|
+
Returns the value of inverse trigonometric function `arcsin`.
|
|
648
|
+
"""
|
|
649
|
+
|
|
650
|
+
def __init__(self, value):
|
|
651
|
+
super().__init__(dtype=float)
|
|
652
|
+
|
|
653
|
+
def _repr(value):
|
|
654
|
+
return f'ASIN({str(value)})'
|
|
655
|
+
|
|
656
|
+
self._repr = _repr(value)
|
|
657
|
+
|
|
658
|
+
def __str__(self):
|
|
659
|
+
return self._repr
|
|
660
|
+
|
|
661
|
+
|
|
662
|
+
def asin(value):
|
|
663
|
+
"""
|
|
664
|
+
Returns the value of inverse trigonometric function `arcsin`.
|
|
665
|
+
|
|
666
|
+
Parameters
|
|
667
|
+
----------
|
|
668
|
+
value: int, float, :py:class:`~onetick.py.Operation`, :py:class:`~onetick.py.Column`
|
|
669
|
+
|
|
670
|
+
Returns
|
|
671
|
+
-------
|
|
672
|
+
:py:class:`~onetick.py.Operation`
|
|
673
|
+
|
|
674
|
+
Examples
|
|
675
|
+
--------
|
|
676
|
+
>>> data = otp.Tick(A=1)
|
|
677
|
+
>>> data['ASIN'] = otp.math.asin(1).round(4) # should return pi/2 ~ 1.5708
|
|
678
|
+
>>> otp.run(data)
|
|
679
|
+
Time A ASIN
|
|
680
|
+
0 2003-12-01 1 1.5708
|
|
681
|
+
|
|
682
|
+
`otp.math.arcsin()` is the alias for `otp.math.asin()`:
|
|
683
|
+
|
|
684
|
+
>>> data = otp.Tick(A=1)
|
|
685
|
+
>>> data['ASIN'] = otp.math.arcsin(1).round(4)
|
|
686
|
+
>>> otp.run(data)
|
|
687
|
+
Time A ASIN
|
|
688
|
+
0 2003-12-01 1 1.5708
|
|
689
|
+
|
|
690
|
+
See Also
|
|
691
|
+
--------
|
|
692
|
+
:py:data:`onetick.py.math.pi`
|
|
693
|
+
:py:func:`onetick.py.math.sin`
|
|
694
|
+
"""
|
|
695
|
+
return _Asin(value)
|
|
696
|
+
|
|
697
|
+
|
|
698
|
+
arcsin = asin
|
|
699
|
+
|
|
700
|
+
|
|
701
|
+
class _Acos(_Operation):
|
|
702
|
+
"""
|
|
703
|
+
Returns the value of inverse trigonometric function `arccos`.
|
|
704
|
+
"""
|
|
705
|
+
|
|
706
|
+
def __init__(self, value):
|
|
707
|
+
super().__init__(dtype=float)
|
|
708
|
+
|
|
709
|
+
def _repr(value):
|
|
710
|
+
return f'ACOS({str(value)})'
|
|
711
|
+
|
|
712
|
+
self._repr = _repr(value)
|
|
713
|
+
|
|
714
|
+
def __str__(self):
|
|
715
|
+
return self._repr
|
|
716
|
+
|
|
717
|
+
|
|
718
|
+
def acos(value):
|
|
719
|
+
"""
|
|
720
|
+
Returns the value of inverse trigonometric function `arccos`.
|
|
721
|
+
|
|
722
|
+
Parameters
|
|
723
|
+
----------
|
|
724
|
+
value: int, float, :py:class:`~onetick.py.Operation`, :py:class:`~onetick.py.Column`
|
|
725
|
+
|
|
726
|
+
Returns
|
|
727
|
+
-------
|
|
728
|
+
:py:class:`~onetick.py.Operation`
|
|
729
|
+
|
|
730
|
+
Examples
|
|
731
|
+
--------
|
|
732
|
+
>>> data = otp.Tick(A=1)
|
|
733
|
+
>>> data['ACOS'] = otp.math.acos(-1).round(4) # should return pi ~ 3.1416
|
|
734
|
+
>>> otp.run(data)
|
|
735
|
+
Time A ACOS
|
|
736
|
+
0 2003-12-01 1 3.1416
|
|
737
|
+
|
|
738
|
+
`otp.math.arccos()` is the alias for `otp.math.acos()`:
|
|
739
|
+
|
|
740
|
+
>>> data = otp.Tick(A=1)
|
|
741
|
+
>>> data['ACOS'] = otp.math.arccos(-1).round(4)
|
|
742
|
+
>>> otp.run(data)
|
|
743
|
+
Time A ACOS
|
|
744
|
+
0 2003-12-01 1 3.1416
|
|
745
|
+
|
|
746
|
+
See Also
|
|
747
|
+
--------
|
|
748
|
+
:py:data:`onetick.py.math.pi`
|
|
749
|
+
:py:func:`onetick.py.math.cos`
|
|
750
|
+
"""
|
|
751
|
+
return _Acos(value)
|
|
752
|
+
|
|
753
|
+
|
|
754
|
+
arccos = acos
|
|
755
|
+
|
|
756
|
+
|
|
757
|
+
class _Atan(_Operation):
|
|
758
|
+
"""
|
|
759
|
+
Returns the value of inverse trigonometric function `arctan`.
|
|
760
|
+
"""
|
|
761
|
+
|
|
762
|
+
def __init__(self, value):
|
|
763
|
+
super().__init__(dtype=float)
|
|
764
|
+
|
|
765
|
+
def _repr(value):
|
|
766
|
+
return f'ATAN({str(value)})'
|
|
767
|
+
|
|
768
|
+
self._repr = _repr(value)
|
|
769
|
+
|
|
770
|
+
def __str__(self):
|
|
771
|
+
return self._repr
|
|
772
|
+
|
|
773
|
+
|
|
774
|
+
def atan(value):
|
|
775
|
+
"""
|
|
776
|
+
Returns the value of inverse trigonometric function `arctan`.
|
|
777
|
+
|
|
778
|
+
Parameters
|
|
779
|
+
----------
|
|
780
|
+
value: int, float, :py:class:`~onetick.py.Operation`, :py:class:`~onetick.py.Column`
|
|
781
|
+
|
|
782
|
+
Returns
|
|
783
|
+
-------
|
|
784
|
+
:py:class:`~onetick.py.Operation`
|
|
785
|
+
|
|
786
|
+
Examples
|
|
787
|
+
--------
|
|
788
|
+
>>> data = otp.Tick(A=1)
|
|
789
|
+
>>> data['ATAN'] = otp.math.atan(1).round(4) # should return pi/4 ~ 0.7854
|
|
790
|
+
>>> otp.run(data)
|
|
791
|
+
Time A ATAN
|
|
792
|
+
0 2003-12-01 1 0.7854
|
|
793
|
+
|
|
794
|
+
`otp.math.arctan()` is the alias for `otp.math.atan()`:
|
|
795
|
+
|
|
796
|
+
>>> data = otp.Tick(A=1)
|
|
797
|
+
>>> data['ATAN'] = otp.math.arctan(1).round(4)
|
|
798
|
+
>>> otp.run(data)
|
|
799
|
+
Time A ATAN
|
|
800
|
+
0 2003-12-01 1 0.7854
|
|
801
|
+
|
|
802
|
+
See Also
|
|
803
|
+
--------
|
|
804
|
+
:py:data:`onetick.py.math.pi`
|
|
805
|
+
:py:func:`onetick.py.math.tan`
|
|
806
|
+
"""
|
|
807
|
+
return _Atan(value)
|
|
808
|
+
|
|
809
|
+
|
|
810
|
+
arctan = atan
|
|
811
|
+
|
|
812
|
+
|
|
813
|
+
class _Acot(_Operation):
|
|
814
|
+
"""
|
|
815
|
+
Returns the value of inverse trigonometric function `arccot`.
|
|
816
|
+
"""
|
|
817
|
+
|
|
818
|
+
def __init__(self, value):
|
|
819
|
+
super().__init__(dtype=float)
|
|
820
|
+
|
|
821
|
+
def _repr(value):
|
|
822
|
+
return f'ACOT({str(value)})'
|
|
823
|
+
|
|
824
|
+
self._repr = _repr(value)
|
|
825
|
+
|
|
826
|
+
def __str__(self):
|
|
827
|
+
return self._repr
|
|
828
|
+
|
|
829
|
+
|
|
830
|
+
def acot(value):
|
|
831
|
+
"""
|
|
832
|
+
Returns the value of inverse trigonometric function `arccot`.
|
|
833
|
+
|
|
834
|
+
Parameters
|
|
835
|
+
----------
|
|
836
|
+
value: int, float, :py:class:`~onetick.py.Operation`, :py:class:`~onetick.py.Column`
|
|
837
|
+
|
|
838
|
+
Returns
|
|
839
|
+
-------
|
|
840
|
+
:py:class:`~onetick.py.Operation`
|
|
841
|
+
|
|
842
|
+
Examples
|
|
843
|
+
--------
|
|
844
|
+
>>> data = otp.Tick(A=1)
|
|
845
|
+
>>> data['ACOT'] = otp.math.acot(1).round(4) # should return pi/4 ~ 0.7854
|
|
846
|
+
>>> otp.run(data)
|
|
847
|
+
Time A ACOT
|
|
848
|
+
0 2003-12-01 1 0.7854
|
|
849
|
+
|
|
850
|
+
`otp.math.arccot()` is the alias for `otp.math.acot()`:
|
|
851
|
+
|
|
852
|
+
>>> data = otp.Tick(A=1)
|
|
853
|
+
>>> data['ACOT'] = otp.math.arccot(1).round(4)
|
|
854
|
+
>>> otp.run(data)
|
|
855
|
+
Time A ACOT
|
|
856
|
+
0 2003-12-01 1 0.7854
|
|
857
|
+
|
|
858
|
+
See Also
|
|
859
|
+
--------
|
|
860
|
+
:py:data:`onetick.py.math.pi`
|
|
861
|
+
:py:func:`onetick.py.math.cot`
|
|
862
|
+
"""
|
|
863
|
+
return _Acot(value)
|
|
864
|
+
|
|
865
|
+
|
|
866
|
+
arccot = acot
|
|
867
|
+
|
|
868
|
+
|
|
869
|
+
class _Mod(_Operation):
|
|
870
|
+
"""
|
|
871
|
+
Implements the remainder from dividing ``value1`` by ``value2``
|
|
872
|
+
"""
|
|
873
|
+
|
|
874
|
+
def __init__(self, value1, value2):
|
|
875
|
+
super().__init__(dtype=int)
|
|
876
|
+
|
|
877
|
+
def _repr(value1, value2):
|
|
878
|
+
return f'MOD({str(value1)}, {str(value2)})'
|
|
879
|
+
|
|
880
|
+
self._repr = _repr(value1, value2)
|
|
881
|
+
|
|
882
|
+
def __str__(self):
|
|
883
|
+
return self._repr
|
|
884
|
+
|
|
885
|
+
|
|
886
|
+
def mod(value1, value2):
|
|
887
|
+
"""
|
|
888
|
+
Computes the remainder from dividing ``value1`` by ``value2``
|
|
889
|
+
|
|
890
|
+
Parameters
|
|
891
|
+
----------
|
|
892
|
+
value1: int, float, :py:class:`~onetick.py.Operation`, :py:class:`~onetick.py.Column`
|
|
893
|
+
value2: int, float, :py:class:`~onetick.py.Operation`, :py:class:`~onetick.py.Column`
|
|
894
|
+
|
|
895
|
+
Returns
|
|
896
|
+
-------
|
|
897
|
+
:py:class:`~onetick.py.Operation`
|
|
898
|
+
|
|
899
|
+
Examples
|
|
900
|
+
--------
|
|
901
|
+
>>> data = otp.Tick(A=100)
|
|
902
|
+
>>> data['MOD'] = otp.math.mod(data['A'], 72)
|
|
903
|
+
>>> otp.run(data)
|
|
904
|
+
Time A MOD
|
|
905
|
+
0 2003-12-01 100 28
|
|
906
|
+
"""
|
|
907
|
+
return _Mod(value1, value2)
|
|
908
|
+
|
|
909
|
+
|
|
910
|
+
class _Floor(_Operation):
|
|
911
|
+
"""
|
|
912
|
+
Returns a long integer value representing the largest integer that is less than or equal to the `value`.
|
|
913
|
+
"""
|
|
914
|
+
|
|
915
|
+
def __init__(self, value):
|
|
916
|
+
super().__init__(dtype=int)
|
|
917
|
+
|
|
918
|
+
def _repr(val):
|
|
919
|
+
return f'FLOOR({str(val)})'
|
|
920
|
+
|
|
921
|
+
self._repr = _repr(value)
|
|
922
|
+
|
|
923
|
+
def __str__(self):
|
|
924
|
+
return self._repr
|
|
925
|
+
|
|
926
|
+
|
|
927
|
+
def floor(value):
|
|
928
|
+
"""
|
|
929
|
+
Returns a long integer value representing the largest integer that is less than or equal to the `value`.
|
|
930
|
+
|
|
931
|
+
Parameters
|
|
932
|
+
----------
|
|
933
|
+
value: int, float, :py:class:`~onetick.py.Operation`, :py:class:`~onetick.py.Column`
|
|
934
|
+
|
|
935
|
+
Returns
|
|
936
|
+
-------
|
|
937
|
+
:py:class:`~onetick.py.Operation`
|
|
938
|
+
|
|
939
|
+
Examples
|
|
940
|
+
--------
|
|
941
|
+
>>> data = otp.Tick(A=1.2)
|
|
942
|
+
>>> data['FLOOR'] = otp.math.floor(data['A'])
|
|
943
|
+
>>> otp.run(data)
|
|
944
|
+
Time A FLOOR
|
|
945
|
+
0 2003-12-01 1.2 1
|
|
946
|
+
"""
|
|
947
|
+
return _Floor(value)
|