onetick-py 1.181.0__py3-none-any.whl → 1.182.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.181.0'
2
+ VERSION = '1.182.0'
@@ -285,6 +285,7 @@ def _update_field(self: 'Source', field, value):
285
285
  are_ints_not_time(field.dtype, value_dtype) and
286
286
  not issubclass(field.dtype, bool) and not issubclass(value_dtype, bool) and
287
287
  value_dtype is not field.dtype
288
+ and not isinstance(field, _StateColumn)
288
289
  ):
289
290
  # case for converting values between int based types, like long or byte
290
291
  convert_to_type = value_dtype
@@ -298,6 +299,9 @@ def _update_field(self: 'Source', field, value):
298
299
  field._dtype = value_dtype
299
300
  type_changes = True
300
301
 
302
+ if isinstance(field, _StateColumn) and (convert_to_type is not None or type_changes):
303
+ raise ValueError(f"The type of the state variable {field.name} can't be changed")
304
+
301
305
  # for aliases, TIMESTAMP ~ Time as an example
302
306
  key = str(field)
303
307
 
@@ -1000,3 +1000,65 @@ def character_present(
1000
1000
  ))
1001
1001
 
1002
1002
  return self
1003
+
1004
+
1005
+ def primary_exch(self: 'Source', discard_on_match: bool = False) -> Tuple['Source', 'Source']:
1006
+ """
1007
+ Propagates the tick if its exchange is the PRIMARY exchange of the security. The primary exchange information
1008
+ is supplied through the Reference Database. It expects the security level symbol (IBM, not IBM.N) and works
1009
+ by looking for a field called ``EXCHANGE`` and filtering out ticks where the field does not match
1010
+ the primary exchange for the security.
1011
+
1012
+ .. note::
1013
+ This EP may not work correctly with OneTick Cloud databases, due to differences
1014
+ in format of exchange names in RefDB and in tick data.
1015
+
1016
+ Parameters
1017
+ ----------
1018
+ discard_on_match: bool
1019
+ When set to ``True`` only ticks from non-primary exchange are propagated,
1020
+ otherwise ticks from primary exchange are propagated.
1021
+
1022
+ See also
1023
+ --------
1024
+ **PRIMARY_EXCH** OneTick event processor
1025
+
1026
+ Returns
1027
+ -------
1028
+ Two :class:`Source` for each of if-else branches
1029
+
1030
+ Examples
1031
+ --------
1032
+
1033
+ Get ticks from primary exchange:
1034
+
1035
+ >>> src = otp.DataSource('SOME_DB', tick_type='TRD', symbols='AAA', date=otp.date(2003, 12, 1)) # doctest: +SKIP
1036
+ >>> src, _ = src.primary_exch() # doctest: +SKIP
1037
+ >>> otp.run(src, symbol_date=otp.date(2003, 12, 1)) # doctest: +SKIP
1038
+ Time PRICE SIZE EXCHANGE
1039
+ 0 2003-12-01 00:00:00.001 26.5 150 B
1040
+ 1 2003-12-01 00:00:00.002 25.7 20 B
1041
+
1042
+ Get all ticks, but mark ticks from primary exchange in column ``T``:
1043
+
1044
+ >>> src = otp.DataSource('SOME_DB', tick_type='TRD', symbols='AAA', date=otp.date(2003, 12, 1)) # doctest: +SKIP
1045
+ >>> primary, other = src.primary_exch() # doctest: +SKIP
1046
+ >>> primary['T'] = 1 # doctest: +SKIP
1047
+ >>> other['T'] = 0 # doctest: +SKIP
1048
+ >>> data = otp.merge([primary, other]) # doctest: +SKIP
1049
+ >>> otp.run(src, symbol_date=otp.date(2003, 12, 1)) # doctest: +SKIP
1050
+ Time PRICE SIZE EXCHANGE T
1051
+ 0 2003-12-01 00:00:00.000 25.2 100 A 0
1052
+ 1 2003-12-01 00:00:00.001 26.5 150 B 1
1053
+ 2 2003-12-01 00:00:00.002 25.7 20 B 1
1054
+ 3 2003-12-01 00:00:00.003 24.8 40 A 0
1055
+ """
1056
+ source = self.copy(ep=otq.PrimaryExch(discard_on_match=discard_on_match))
1057
+
1058
+ if_source = source.copy()
1059
+ if_source.node().out_pin("IF")
1060
+
1061
+ else_source = source.copy()
1062
+ else_source.node().out_pin("ELSE")
1063
+
1064
+ return if_source, else_source
onetick/py/core/source.py CHANGED
@@ -1689,6 +1689,7 @@ class Source:
1689
1689
  time_filter,
1690
1690
  skip_bad_tick,
1691
1691
  character_present,
1692
+ primary_exch,
1692
1693
  )
1693
1694
  from ._source.source_methods.drops import ( # type: ignore[misc]
1694
1695
  drop,
@@ -163,6 +163,7 @@ class Node:
163
163
  params: dict = field(default_factory=dict)
164
164
  sinks: List[str] = field(default_factory=list)
165
165
  symbols: list = field(default_factory=list)
166
+ name: Optional[str] = field(default=None)
166
167
 
167
168
 
168
169
  @dataclass
@@ -776,6 +777,8 @@ def read_otq(path: str, parse_eval_from_params: bool = False) -> Optional[Graph]
776
777
  _save_dependency(security[0], current_query)
777
778
  elif node_param == "TICK_TYPE":
778
779
  current_query.nodes[node_id].tick_type = value
780
+ elif node_param == "NAME":
781
+ current_query.nodes[node_id].name = value
779
782
  else:
780
783
  _save_param(current_query.nodes[node_id].config, node_param, value)
781
784
 
@@ -944,6 +947,9 @@ def build_node(graphs: GraphStorage, node: Node, config: Config):
944
947
  if node.tick_type:
945
948
  table.cell([node.tick_type])
946
949
 
950
+ if node.name:
951
+ table.cell([f"<I>{node.name}</I>"])
952
+
947
953
  if config.render_debug_info:
948
954
  table.cell([node.id])
949
955
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: onetick-py
3
- Version: 1.181.0
3
+ Version: 1.182.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,7 +13,7 @@ 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=KPe2n8_FyAx3CQNqxYW8bByjpQ2hxgq0dEW2GSpxhPM,76
16
+ onetick/py/_version.py,sha256=6duBuEKq7UU6QULm1owR251o9fbS3vwJM7vn-lYoaoY,76
17
17
  onetick/py/backports.py,sha256=mR00mxe7E7UgBljf-Wa93Mo6lpi-C4Op561uhPUoEt8,815
18
18
  onetick/py/cache.py,sha256=BBZg8n0AGjZzZapg4752LkSZdX5C6DGf7vU9sAStv6A,12798
19
19
  onetick/py/compatibility.py,sha256=rBLoszCoSZrl9SnBYiPzWuoudZwhOP6d4exshy3BJTw,34530
@@ -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=HUQ7dBQqt3omg60ekZLxvPDEtm4e53PwTj8PY40kew4,65815
57
+ onetick/py/core/source.py,sha256=duFut5tYCzsTHPXwLGzQGwpRF_h4d83cqfWdWYIJlR0,65837
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
@@ -77,8 +77,8 @@ 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=bPCViMBCBHatoC3TUcGyyLT5em2ObUyNKTr4uE3XlmA,23165
81
- onetick/py/core/_source/source_methods/filters.py,sha256=WuSnK-tQsP3fL2bqVfMZpbpPgk_LG4L8lrYULSSGoKE,33930
80
+ onetick/py/core/_source/source_methods/fields.py,sha256=10_4HlRJOEMmuHsEOzM71MZ8wx8ppndQQNieLlNKf0E,23398
81
+ onetick/py/core/_source/source_methods/filters.py,sha256=l2nazixNNH_0zjmE4Il90ZX0scPn7pmIbjOKnjZkEfo,36400
82
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
@@ -141,15 +141,15 @@ onetick/py/utils/helpers.py,sha256=XY2PaMUSzFNIpiuiAY_gPQ0TnYTmfoPAGNAFh_6aB14,2
141
141
  onetick/py/utils/locator.py,sha256=YUOXU0yh0ZZZOJpJniAq9WNn0_u3X_M5q2tEwt1cp_4,2887
142
142
  onetick/py/utils/perf.py,sha256=g0r-9YUc2mx9Lj4PjG6Fk1keO3m9nC3t2cpHx3M-AeQ,19299
143
143
  onetick/py/utils/query.py,sha256=b60JmfJDx3mpP74rTQC3qnlCb6t4fYFEauVaH9ulwL8,1330
144
- onetick/py/utils/render.py,sha256=wTSUqkzrzrFeGQgeU5hEt1ckfW2i1hQjiEX1apUHAzs,44910
144
+ onetick/py/utils/render.py,sha256=WCWkbcPfUBr9AFT3Rg4A--Xd7fZjIZMQbTWX71d_znE,45124
145
145
  onetick/py/utils/render_cli.py,sha256=Np4omSvGwVhqnKSPII5Raz_t1chFF980oTDdyEJE0aQ,3006
146
146
  onetick/py/utils/script.py,sha256=Y8NujEo2_5QaP6KDnLKJiKQ7SmMjw8_dv8sYL9rHDCE,11184
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.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,,
150
+ onetick_py-1.182.0.dist-info/licenses/LICENSE,sha256=Yhu7lKNFS0fsaN-jSattEMRtCOPueP58Eu5BPH8ZGjM,1075
151
+ onetick_py-1.182.0.dist-info/METADATA,sha256=WDHkCg3Xu1RmZFMZygSdREaz8_ZGqRAhbg_OuV36cOI,7290
152
+ onetick_py-1.182.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
153
+ onetick_py-1.182.0.dist-info/entry_points.txt,sha256=bafJo_C7lPHz5pAdlIryLzxAlJ8F-We5cC7psdwcx4Q,131
154
+ onetick_py-1.182.0.dist-info/top_level.txt,sha256=Na1jSJmVMyYGOndaswt554QKIUwQjcYh6th2ATsmw0U,23
155
+ onetick_py-1.182.0.dist-info/RECORD,,