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.
Files changed (152) hide show
  1. locator_parser/__init__.py +0 -0
  2. locator_parser/acl.py +73 -0
  3. locator_parser/actions.py +266 -0
  4. locator_parser/common.py +365 -0
  5. locator_parser/io.py +41 -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 +280 -0
  12. onetick/lib/__init__.py +4 -0
  13. onetick/lib/instance.py +138 -0
  14. onetick/py/__init__.py +290 -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 +645 -0
  19. onetick/py/aggregations/_docs.py +912 -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 +427 -0
  26. onetick/py/aggregations/other.py +1014 -0
  27. onetick/py/backports.py +26 -0
  28. onetick/py/cache.py +373 -0
  29. onetick/py/callback/__init__.py +5 -0
  30. onetick/py/callback/callback.py +275 -0
  31. onetick/py/callback/callbacks.py +131 -0
  32. onetick/py/compatibility.py +752 -0
  33. onetick/py/configuration.py +736 -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 +2307 -0
  45. onetick/py/core/_internal/_state_vars.py +87 -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 +810 -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 +270 -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 +1001 -0
  58. onetick/py/core/_source/source_methods/joins.py +1393 -0
  59. onetick/py/core/_source/source_methods/merges.py +566 -0
  60. onetick/py/core/_source/source_methods/misc.py +1325 -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 +702 -0
  68. onetick/py/core/_source/symbol.py +202 -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 +215 -0
  75. onetick/py/core/column_operations/_methods/methods.py +294 -0
  76. onetick/py/core/column_operations/_methods/op_types.py +150 -0
  77. onetick/py/core/column_operations/accessors/__init__.py +0 -0
  78. onetick/py/core/column_operations/accessors/_accessor.py +30 -0
  79. onetick/py/core/column_operations/accessors/decimal_accessor.py +92 -0
  80. onetick/py/core/column_operations/accessors/dt_accessor.py +464 -0
  81. onetick/py/core/column_operations/accessors/float_accessor.py +160 -0
  82. onetick/py/core/column_operations/accessors/str_accessor.py +1374 -0
  83. onetick/py/core/column_operations/base.py +1061 -0
  84. onetick/py/core/cut_builder.py +149 -0
  85. onetick/py/core/db_constants.py +20 -0
  86. onetick/py/core/eval_query.py +244 -0
  87. onetick/py/core/lambda_object.py +442 -0
  88. onetick/py/core/multi_output_source.py +193 -0
  89. onetick/py/core/per_tick_script.py +2253 -0
  90. onetick/py/core/query_inspector.py +465 -0
  91. onetick/py/core/source.py +1663 -0
  92. onetick/py/db/__init__.py +2 -0
  93. onetick/py/db/_inspection.py +1042 -0
  94. onetick/py/db/db.py +1423 -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 +2354 -0
  100. onetick/py/license.py +188 -0
  101. onetick/py/log.py +88 -0
  102. onetick/py/math.py +947 -0
  103. onetick/py/misc.py +437 -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 +211 -0
  108. onetick/py/pyomd_mock.py +47 -0
  109. onetick/py/run.py +841 -0
  110. onetick/py/servers.py +173 -0
  111. onetick/py/session.py +1342 -0
  112. onetick/py/sources/__init__.py +19 -0
  113. onetick/py/sources/cache.py +167 -0
  114. onetick/py/sources/common.py +126 -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 +1049 -0
  119. onetick/py/sources/empty.py +94 -0
  120. onetick/py/sources/odbc.py +337 -0
  121. onetick/py/sources/order_book.py +238 -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 +357 -0
  129. onetick/py/sources/ticks.py +825 -0
  130. onetick/py/sql.py +70 -0
  131. onetick/py/state.py +256 -0
  132. onetick/py/types.py +2056 -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 +499 -0
  141. onetick/py/utils/query.py +49 -0
  142. onetick/py/utils/render.py +1139 -0
  143. onetick/py/utils/script.py +244 -0
  144. onetick/py/utils/temp.py +471 -0
  145. onetick/py/utils/types.py +118 -0
  146. onetick/py/utils/tz.py +82 -0
  147. onetick_py-1.162.2.dist-info/METADATA +148 -0
  148. onetick_py-1.162.2.dist-info/RECORD +152 -0
  149. onetick_py-1.162.2.dist-info/WHEEL +5 -0
  150. onetick_py-1.162.2.dist-info/entry_points.txt +2 -0
  151. onetick_py-1.162.2.dist-info/licenses/LICENSE +21 -0
  152. onetick_py-1.162.2.dist-info/top_level.txt +2 -0
@@ -0,0 +1,160 @@
1
+ from onetick.py import types as ott
2
+ from onetick.py.core.column_operations.accessors._accessor import _Accessor
3
+
4
+
5
+ class _FloatAccessor(_Accessor):
6
+ """
7
+ Accessor for float (double in Onetick terminology) functions
8
+
9
+ >>> data = otp.Ticks(X=[1.1, 1.2])
10
+ >>> data["Y"] = data["X"].float.<function_name>() # doctest: +SKIP
11
+ """
12
+
13
+ def str(self, length=10, precision=6):
14
+ """
15
+ Converts float to str.
16
+
17
+ Converts number to string with given ``length`` and ``precision``.
18
+ The specified ``length`` should be greater than or equal
19
+ to the part of the number before the decimal point plus the number's sign (if any).
20
+
21
+ If ``length`` is specified as an int, the method will return strings with ``length`` characters,
22
+ if ``length`` is specified as a column, the method will return string default (64 characters) length.
23
+
24
+ Parameters
25
+ ----------
26
+ length: Operation or int
27
+ Length of the string.
28
+ precision: Operation or int
29
+ Number of symbols after dot.
30
+
31
+ Returns
32
+ -------
33
+ result: Operation
34
+ String representation of float value.
35
+
36
+ Examples
37
+ --------
38
+
39
+ >>> data = otp.Ticks(X=[1, 2.17, 10.31861, 3.141593])
40
+ >>> # OTdirective: snippet-name: float operations.to string.constant precision;
41
+ >>> data["X"] = data["X"].float.str(15, 3)
42
+ >>> data = otp.run(data)
43
+ >>> data["X"]
44
+ 0 1.000
45
+ 1 2.170
46
+ 2 10.319
47
+ 3 3.142
48
+ Name: X, dtype: object
49
+
50
+ >>> data = otp.Ticks(X=[1, 2.17, 10.31841, 3.141593],
51
+ ... LENGTH=[2, 3, 4, 5],
52
+ ... PRECISION=[5, 5, 3, 3])
53
+ >>> # OTdirective: snippet-name: float operations.to string.precision from fields;
54
+ >>> data["X"] = data["X"].float.str(data["LENGTH"], data["PRECISION"])
55
+ >>> data = otp.run(data)
56
+ >>> data["X"]
57
+ 0 1
58
+ 1 2.2
59
+ 2 10.3
60
+ 3 3.142
61
+ Name: X, dtype: object
62
+ """
63
+ dtype = ott.string[length] if isinstance(length, int) else str
64
+ length = ott.value2str(length)
65
+ precision = ott.value2str(precision)
66
+ return _FloatAccessor.Formatter(self._base_column,
67
+ dtype,
68
+ formatter=lambda x: f"str({x}, {length}, {precision})")
69
+
70
+ def cmp(self, other, eps):
71
+ """
72
+ Compare two double values between themselves according to ``eps`` relative difference.
73
+
74
+ This function returns 0 if column = other, 1 if column > other, and -1 if column < other.
75
+ Two numbers are considered to be equal if both of them are NaN or
76
+ ``abs(column - other) / (abs(column) + abs(other)) < eps``.
77
+ In other words, ``eps`` represents a relative difference (percentage) between the two numbers,
78
+ not an absolute difference.
79
+
80
+ Parameters
81
+ ----------
82
+ other: Operation or float
83
+ column or value to compare with
84
+ eps: Operation or float
85
+ column or value with relative difference
86
+
87
+ Returns
88
+ -------
89
+ result: Operation
90
+ 0 if column == other, 1 if column > other, and -1 if column < other.
91
+
92
+ See Also
93
+ --------
94
+ eq
95
+
96
+ Examples
97
+ --------
98
+
99
+ >>> data = otp.Ticks(X=[1, 2.17, 10.31841, 3.141593, 6],
100
+ ... OTHER=[1.01, 2.1, 10.32841, 3.14, 5],
101
+ ... EPS=[0, 1, 0.1, 0.001, 0.001])
102
+ >>> # OTdirective: snippet-name: float operations.approximate comparison.lt|eq|gt;
103
+ >>> data["X"] = data["X"].float.cmp(data["OTHER"], data["EPS"])
104
+ >>> data = otp.run(data)
105
+ >>> data["X"]
106
+ 0 -1.0
107
+ 1 0.0
108
+ 2 0.0
109
+ 3 0.0
110
+ 4 1.0
111
+ Name: X, dtype: float64
112
+ """
113
+ other = ott.value2str(other)
114
+ eps = ott.value2str(eps)
115
+ return _FloatAccessor.Formatter(self._base_column,
116
+ float,
117
+ formatter=lambda x: f"double_compare({x}, {other}, {eps})")
118
+
119
+ def eq(self, other, delta):
120
+ """
121
+ Compare two double values between themselves according to ``delta`` relative difference.
122
+ Calculated as ``abs(column - other) <= delta``.
123
+
124
+ Parameters
125
+ ----------
126
+ other: Operation, float
127
+ column or value to compare with
128
+ delta: Operation, float
129
+ column or value with relative difference
130
+
131
+ See Also
132
+ --------
133
+ cmp
134
+
135
+ Returns
136
+ -------
137
+ Operation
138
+
139
+ Examples
140
+ --------
141
+
142
+ >>> data = otp.Ticks(X=[1, 2.17, 10.31841, 3.141593, 6],
143
+ ... OTHER=[1.01, 2.1, 10.32841, 3.14, 5],
144
+ ... DELTA=[0, 1, 0.1, 0.01, 0.001])
145
+ >>> # OTdirective: snippet-name: float operations.approximate comparison.eq;
146
+ >>> data["X"] = (1 + data["X"] - 1).float.eq(data["OTHER"], data["DELTA"])
147
+ >>> data = otp.run(data)
148
+ >>> data["X"]
149
+ 0 0.0
150
+ 1 1.0
151
+ 2 1.0
152
+ 3 1.0
153
+ 4 0.0
154
+ Name: X, dtype: float64
155
+ """
156
+ other = ott.value2str(other)
157
+ delta = ott.value2str(delta)
158
+ return _FloatAccessor.Formatter(self._base_column,
159
+ bool,
160
+ formatter=lambda x: f"abs({x} - {other}) <= {delta}")