opencode-pyneruntime 6.6.4__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 (261) hide show
  1. opencode_pyneruntime-6.6.4.dist-info/METADATA +281 -0
  2. opencode_pyneruntime-6.6.4.dist-info/RECORD +261 -0
  3. opencode_pyneruntime-6.6.4.dist-info/WHEEL +5 -0
  4. opencode_pyneruntime-6.6.4.dist-info/entry_points.txt +6 -0
  5. opencode_pyneruntime-6.6.4.dist-info/licenses/LICENSE +201 -0
  6. opencode_pyneruntime-6.6.4.dist-info/licenses/NOTICE +21 -0
  7. opencode_pyneruntime-6.6.4.dist-info/top_level.txt +1 -0
  8. pynecore/__init__.py +6 -0
  9. pynecore/cli/__init__.py +2 -0
  10. pynecore/cli/app.py +238 -0
  11. pynecore/cli/commands/__init__.py +343 -0
  12. pynecore/cli/commands/benchmark.py +186 -0
  13. pynecore/cli/commands/compile.py +198 -0
  14. pynecore/cli/commands/data.py +857 -0
  15. pynecore/cli/commands/debug.py +63 -0
  16. pynecore/cli/commands/optimize.py +956 -0
  17. pynecore/cli/commands/plugin.py +242 -0
  18. pynecore/cli/commands/run.py +2006 -0
  19. pynecore/cli/pluggable.py +132 -0
  20. pynecore/cli/utils/__init__.py +0 -0
  21. pynecore/cli/utils/api_error_handler.py +168 -0
  22. pynecore/cli/utils/broker_picker.py +330 -0
  23. pynecore/cli/utils/error_hook.py +28 -0
  24. pynecore/cli/utils/keyreader.py +178 -0
  25. pynecore/cli/utils/provider_picker.py +19 -0
  26. pynecore/cli/utils/symbol_browser.py +1149 -0
  27. pynecore/core/__init__.py +0 -0
  28. pynecore/core/aggregator.py +257 -0
  29. pynecore/core/bar_magnifier.py +168 -0
  30. pynecore/core/broker/__init__.py +64 -0
  31. pynecore/core/broker/defaults.py +113 -0
  32. pynecore/core/broker/disappearance.py +927 -0
  33. pynecore/core/broker/emulator.py +345 -0
  34. pynecore/core/broker/exceptions.py +346 -0
  35. pynecore/core/broker/idempotency.py +401 -0
  36. pynecore/core/broker/intent_builder.py +334 -0
  37. pynecore/core/broker/journal.py +1785 -0
  38. pynecore/core/broker/models.py +1600 -0
  39. pynecore/core/broker/native_failsafe_manager.py +1436 -0
  40. pynecore/core/broker/one_way_emulator.py +1128 -0
  41. pynecore/core/broker/position.py +787 -0
  42. pynecore/core/broker/run_identity.py +126 -0
  43. pynecore/core/broker/software_entry_stop_engine.py +351 -0
  44. pynecore/core/broker/software_partial_bracket_engine.py +1379 -0
  45. pynecore/core/broker/spot_inventory.py +1327 -0
  46. pynecore/core/broker/storage.py +2655 -0
  47. pynecore/core/broker/store_helpers.py +2161 -0
  48. pynecore/core/broker/sync_engine.py +16070 -0
  49. pynecore/core/broker/validation.py +382 -0
  50. pynecore/core/class_property.py +7 -0
  51. pynecore/core/config.py +392 -0
  52. pynecore/core/csv_file.py +547 -0
  53. pynecore/core/currency.py +262 -0
  54. pynecore/core/data_converter.py +1002 -0
  55. pynecore/core/datetime.py +296 -0
  56. pynecore/core/download_info.py +71 -0
  57. pynecore/core/download_runner.py +274 -0
  58. pynecore/core/htf_aggregator.py +181 -0
  59. pynecore/core/import_hook.py +358 -0
  60. pynecore/core/instance_state.py +494 -0
  61. pynecore/core/live_ltf_collector.py +442 -0
  62. pynecore/core/live_ltf_window.py +189 -0
  63. pynecore/core/live_runner.py +1347 -0
  64. pynecore/core/module_property.py +26 -0
  65. pynecore/core/ohlcv_file.py +1888 -0
  66. pynecore/core/overload.py +371 -0
  67. pynecore/core/pine_cast.py +113 -0
  68. pynecore/core/pine_export.py +95 -0
  69. pynecore/core/pine_method.py +244 -0
  70. pynecore/core/pine_range.py +86 -0
  71. pynecore/core/pine_udt.py +69 -0
  72. pynecore/core/plugin/__init__.py +394 -0
  73. pynecore/core/plugin/broker.py +781 -0
  74. pynecore/core/plugin/cli.py +96 -0
  75. pynecore/core/plugin/live_provider.py +208 -0
  76. pynecore/core/plugin/provider.py +331 -0
  77. pynecore/core/provider_string.py +148 -0
  78. pynecore/core/random.py +40 -0
  79. pynecore/core/resampler.py +686 -0
  80. pynecore/core/safe_convert.py +64 -0
  81. pynecore/core/script.py +1011 -0
  82. pynecore/core/script_runner.py +3202 -0
  83. pynecore/core/security.py +1749 -0
  84. pynecore/core/security_process.py +1253 -0
  85. pynecore/core/security_shm.py +456 -0
  86. pynecore/core/series.py +417 -0
  87. pynecore/core/strategy_stats.py +669 -0
  88. pynecore/core/symbol_map.py +134 -0
  89. pynecore/core/syminfo.py +505 -0
  90. pynecore/core/viz.py +591 -0
  91. pynecore/lib/__init__.py +1771 -0
  92. pynecore/lib/_fixnan.py +32 -0
  93. pynecore/lib/_math_stateful.py +202 -0
  94. pynecore/lib/_timeframe_change.py +101 -0
  95. pynecore/lib/adjustment.py +6 -0
  96. pynecore/lib/alert.py +39 -0
  97. pynecore/lib/alert.pyi +14 -0
  98. pynecore/lib/array.py +1051 -0
  99. pynecore/lib/barmerge.py +60 -0
  100. pynecore/lib/barstate.py +30 -0
  101. pynecore/lib/box.py +415 -0
  102. pynecore/lib/chart.py +128 -0
  103. pynecore/lib/color.py +152 -0
  104. pynecore/lib/color.pyi +50 -0
  105. pynecore/lib/currency.py +62 -0
  106. pynecore/lib/dayofweek.py +36 -0
  107. pynecore/lib/dayofweek.pyi +18 -0
  108. pynecore/lib/display.py +8 -0
  109. pynecore/lib/dividends.py +9 -0
  110. pynecore/lib/earnings.py +11 -0
  111. pynecore/lib/extend.py +6 -0
  112. pynecore/lib/font.py +5 -0
  113. pynecore/lib/footprint.py +79 -0
  114. pynecore/lib/format.py +11 -0
  115. pynecore/lib/hline.py +67 -0
  116. pynecore/lib/hline.pyi +24 -0
  117. pynecore/lib/label.py +409 -0
  118. pynecore/lib/line.py +433 -0
  119. pynecore/lib/linefill.py +93 -0
  120. pynecore/lib/location.py +11 -0
  121. pynecore/lib/log.py +362 -0
  122. pynecore/lib/map.py +150 -0
  123. pynecore/lib/math.py +385 -0
  124. pynecore/lib/matrix.py +708 -0
  125. pynecore/lib/order.py +8 -0
  126. pynecore/lib/pivotpointtype.py +8 -0
  127. pynecore/lib/plot.py +95 -0
  128. pynecore/lib/plot.pyi +33 -0
  129. pynecore/lib/polyline.py +91 -0
  130. pynecore/lib/position.py +15 -0
  131. pynecore/lib/request.py +281 -0
  132. pynecore/lib/runtime.py +5 -0
  133. pynecore/lib/scale.py +9 -0
  134. pynecore/lib/session.py +267 -0
  135. pynecore/lib/session.pyi +12 -0
  136. pynecore/lib/shape.py +18 -0
  137. pynecore/lib/size.py +12 -0
  138. pynecore/lib/splits.py +4 -0
  139. pynecore/lib/strategy/__init__.py +4778 -0
  140. pynecore/lib/strategy/closedtrades.py +347 -0
  141. pynecore/lib/strategy/closedtrades.pyi +53 -0
  142. pynecore/lib/strategy/commission.py +9 -0
  143. pynecore/lib/strategy/direction.py +9 -0
  144. pynecore/lib/strategy/oca.py +13 -0
  145. pynecore/lib/strategy/opentrades.py +281 -0
  146. pynecore/lib/strategy/opentrades.pyi +49 -0
  147. pynecore/lib/strategy/risk.py +109 -0
  148. pynecore/lib/string.py +649 -0
  149. pynecore/lib/syminfo.py +84 -0
  150. pynecore/lib/ta.py +2230 -0
  151. pynecore/lib/table.py +290 -0
  152. pynecore/lib/text.py +17 -0
  153. pynecore/lib/ticker.py +207 -0
  154. pynecore/lib/timeframe.py +293 -0
  155. pynecore/lib/volume_row.py +67 -0
  156. pynecore/lib/xloc.py +4 -0
  157. pynecore/lib/yloc.py +5 -0
  158. pynecore/providers/__init__.py +0 -0
  159. pynecore/providers/ccxt.py +664 -0
  160. pynecore/providers/replay.py +187 -0
  161. pynecore/pynesys/__init__.py +0 -0
  162. pynecore/pynesys/api.py +498 -0
  163. pynecore/pynesys/compiler.py +112 -0
  164. pynecore/standalone.py +99 -0
  165. pynecore/testing/__init__.py +1 -0
  166. pynecore/testing/broker_lab/__init__.py +41 -0
  167. pynecore/testing/broker_lab/__main__.py +5 -0
  168. pynecore/testing/broker_lab/cli.py +87 -0
  169. pynecore/testing/broker_lab/generate.py +47 -0
  170. pynecore/testing/broker_lab/model.py +84 -0
  171. pynecore/testing/broker_lab/reference.py +645 -0
  172. pynecore/testing/broker_lab/runner.py +372 -0
  173. pynecore/testing/broker_lab/scheduler.py +50 -0
  174. pynecore/testing/broker_lab/subprocess.py +73 -0
  175. pynecore/transformers/__init__.py +0 -0
  176. pynecore/transformers/builtin_shadow.py +136 -0
  177. pynecore/transformers/closure_arguments_transformer.py +428 -0
  178. pynecore/transformers/display_rewrite.py +140 -0
  179. pynecore/transformers/dynamic_default.py +147 -0
  180. pynecore/transformers/function_isolation.py +757 -0
  181. pynecore/transformers/import_lifter.py +61 -0
  182. pynecore/transformers/import_normalizer.py +328 -0
  183. pynecore/transformers/inline_series_hoist.py +178 -0
  184. pynecore/transformers/input_transformer.py +175 -0
  185. pynecore/transformers/lib_series.py +201 -0
  186. pynecore/transformers/locations.py +70 -0
  187. pynecore/transformers/module_properties.json +3387 -0
  188. pynecore/transformers/module_property.py +221 -0
  189. pynecore/transformers/ne_guard.py +70 -0
  190. pynecore/transformers/persistent.py +320 -0
  191. pynecore/transformers/persistent_series.py +76 -0
  192. pynecore/transformers/safe_convert_transformer.py +97 -0
  193. pynecore/transformers/safe_division_transformer.py +95 -0
  194. pynecore/transformers/script_requirements.py +308 -0
  195. pynecore/transformers/security.py +752 -0
  196. pynecore/transformers/security_instantiation.py +274 -0
  197. pynecore/transformers/series.py +275 -0
  198. pynecore/transformers/slot_layout.py +381 -0
  199. pynecore/transformers/type_checking_stripper.py +25 -0
  200. pynecore/transformers/unused_series_detector.py +267 -0
  201. pynecore/types/__init__.py +21 -0
  202. pynecore/types/alert.py +5 -0
  203. pynecore/types/barmerge.py +5 -0
  204. pynecore/types/base.py +39 -0
  205. pynecore/types/box.py +37 -0
  206. pynecore/types/chart.py +17 -0
  207. pynecore/types/color.py +107 -0
  208. pynecore/types/currency.py +5 -0
  209. pynecore/types/datetime.py +6 -0
  210. pynecore/types/display.py +5 -0
  211. pynecore/types/dividends.py +5 -0
  212. pynecore/types/earnings.py +5 -0
  213. pynecore/types/extend.py +5 -0
  214. pynecore/types/font.py +5 -0
  215. pynecore/types/footprint.py +41 -0
  216. pynecore/types/format.py +5 -0
  217. pynecore/types/hline.py +24 -0
  218. pynecore/types/ib_persistent.py +8 -0
  219. pynecore/types/ib_persistent.pyi +10 -0
  220. pynecore/types/label.py +35 -0
  221. pynecore/types/line.py +32 -0
  222. pynecore/types/linefill.py +13 -0
  223. pynecore/types/location.py +5 -0
  224. pynecore/types/matrix.py +999 -0
  225. pynecore/types/na.py +237 -0
  226. pynecore/types/na.pyi +83 -0
  227. pynecore/types/ohlcv.py +12 -0
  228. pynecore/types/order.py +5 -0
  229. pynecore/types/persistent.py +8 -0
  230. pynecore/types/persistent.pyi +13 -0
  231. pynecore/types/pine_types.py +11 -0
  232. pynecore/types/pine_types.pyi +15 -0
  233. pynecore/types/pivotpointtype.py +5 -0
  234. pynecore/types/plot.py +12 -0
  235. pynecore/types/plot_meta.py +60 -0
  236. pynecore/types/polyline.py +40 -0
  237. pynecore/types/position.py +5 -0
  238. pynecore/types/scale.py +5 -0
  239. pynecore/types/script_type.py +15 -0
  240. pynecore/types/series.py +23 -0
  241. pynecore/types/series.pyi +19 -0
  242. pynecore/types/session.py +35 -0
  243. pynecore/types/shape.py +5 -0
  244. pynecore/types/size.py +5 -0
  245. pynecore/types/source.py +33 -0
  246. pynecore/types/splits.py +5 -0
  247. pynecore/types/strategy.py +45 -0
  248. pynecore/types/table.py +87 -0
  249. pynecore/types/text.py +13 -0
  250. pynecore/types/type_checker.py +7 -0
  251. pynecore/types/type_checker.pyi +48 -0
  252. pynecore/types/volume_row.py +36 -0
  253. pynecore/types/weekdays.py +11 -0
  254. pynecore/types/xloc.py +5 -0
  255. pynecore/types/yloc.py +5 -0
  256. pynecore/utils/__init__.py +0 -0
  257. pynecore/utils/file_utils.py +50 -0
  258. pynecore/utils/rich/__init__.py +0 -0
  259. pynecore/utils/rich/date_column.py +25 -0
  260. pynecore/utils/sequence_view.py +92 -0
  261. pynecore/utils/stdlib_checker.py +17 -0
pynecore/lib/table.py ADDED
@@ -0,0 +1,290 @@
1
+ from ..core.module_property import module_property
2
+ from ..types.base import next_vid
3
+ from ..types.table import Table
4
+ from ..types.na import NA
5
+ from ..lib import (color as _color, position as _position, size as _size, text as _text, font as _font)
6
+
7
+ _registry: list[Table] = []
8
+
9
+
10
+ def new(position: _position.Position, columns: int, rows: int, bgcolor: _color.Color = None,
11
+ frame_color: _color.Color = None, frame_width: int = 0, border_color: _color.Color = None,
12
+ border_width: int = 0, force_overlay: bool = False) -> Table:
13
+ """
14
+ Creates a new table object.
15
+
16
+ :param position: Position of the table. Possible values are: position.top_left, position.top_center,
17
+ position.top_right, position.middle_left, position.middle_center, position.middle_right,
18
+ position.bottom_left, position.bottom_center, position.bottom_right
19
+ :param columns: The number of columns in the table
20
+ :param rows: The number of rows in the table
21
+ :param bgcolor: The background color of the table. Optional. The default is no color
22
+ :param frame_color: The color of the outer frame of the table. Optional. The default is no color
23
+ :param frame_width: The width of the outer frame of the table. Optional. The default is 0
24
+ :param border_color: The color of the borders of the cells (excluding the outer frame). Optional.
25
+ The default is no color
26
+ :param border_width: The width of the borders of the cells (excluding the outer frame). Optional. The default is 0
27
+ :param force_overlay: If true, the drawing will display on the main chart pane, even when the
28
+ script occupies a separate pane. Optional. The default is false
29
+ :return: A table object
30
+ """
31
+ table = Table(
32
+ position=position,
33
+ columns=columns,
34
+ rows=rows,
35
+ bgcolor=bgcolor,
36
+ frame_color=frame_color,
37
+ frame_width=frame_width,
38
+ border_color=border_color,
39
+ border_width=border_width,
40
+ force_overlay=force_overlay
41
+ )
42
+ table.vid = next_vid()
43
+ _registry.append(table)
44
+ return table
45
+
46
+
47
+ # noinspection PyShadowingBuiltins
48
+ @module_property
49
+ def all() -> list[Table]:
50
+ """
51
+ Returns an array filled with all the current tables drawn by the script.
52
+
53
+ :return: Array of all table objects
54
+ """
55
+ return _registry
56
+
57
+
58
+ # noinspection PyShadowingBuiltins
59
+ def delete(table_id: Table) -> None:
60
+ """
61
+ Deletes a table object.
62
+
63
+ :param table_id: A table object
64
+ """
65
+ if isinstance(table_id, NA):
66
+ return
67
+ try:
68
+ _registry.remove(table_id)
69
+ except ValueError:
70
+ pass
71
+
72
+
73
+ def cell(table_id: Table, column: int, row: int, text: str = "", width: int | float = 0,
74
+ height: int | float = 0, text_color: _color.Color = _color.black,
75
+ text_halign: _text.AlignEnum = _text.align_center, text_valign: _text.AlignEnum = _text.align_center,
76
+ text_size: int | str = _size.normal, bgcolor: _color.Color = None, tooltip: str = "",
77
+ text_font_family: _font.FontFamilyEnum = _font.family_default,
78
+ text_formatting: _text.FormatEnum = _text.format_none) -> None:
79
+ """
80
+ Defines a cell in the table and sets its attributes.
81
+
82
+ :param table_id: A table object
83
+ :param column: The index of the cell's column. Numbering starts at 0
84
+ :param row: The index of the cell's row. Numbering starts at 0
85
+ :param text: The text to be displayed inside the cell. Optional. The default is empty string
86
+ :param width: The width of the cell as a % of the indicator's visual space. Optional. By default,
87
+ auto-adjusts the width based on the text inside the cell. Value 0 has the same effect
88
+ :param height: The height of the cell as a % of the indicator's visual space. Optional. By default,
89
+ auto-adjusts the height based on the text inside of the cell. Value 0 has the same effect
90
+ :param text_color: The color of the text. Optional. The default is color.black
91
+ :param text_halign: The horizontal alignment of the cell's text. Optional. The default value is text.align_center
92
+ :param text_valign: The vertical alignment of the cell's text. Optional. The default value is text.align_center
93
+ :param text_size: Size of the object. The size can be any positive integer, or one of the size.*
94
+ built-in constant strings. The default value is size.normal or 14
95
+ :param bgcolor: The background color of the text. Optional. The default is no color
96
+ :param tooltip: The tooltip to be displayed inside the cell. Optional
97
+ :param text_font_family: The font family of the text. Optional. The default value is font.family_default
98
+ :param text_formatting: The formatting of the displayed text. Optional. The default is text.format_none
99
+ """
100
+ if isinstance(table_id, NA):
101
+ return
102
+
103
+ # Create or get the cell
104
+ cell_obj = table_id.get_cell(column, row)
105
+
106
+ # Set all the cell properties
107
+ cell_obj.text = text
108
+ cell_obj.width = width
109
+ cell_obj.height = height
110
+ cell_obj.text_color = text_color
111
+ cell_obj.text_halign = text_halign
112
+ cell_obj.text_valign = text_valign
113
+ cell_obj.text_size = text_size
114
+ cell_obj.bgcolor = bgcolor
115
+ cell_obj.tooltip = tooltip
116
+ cell_obj.text_font_family = text_font_family
117
+ cell_obj.text_formatting = text_formatting
118
+
119
+
120
+ def clear(table_id: Table, start_column: int, start_row: int, end_column: int = None,
121
+ end_row: int = None) -> None:
122
+ """
123
+ Removes a cell or a sequence of cells from the table.
124
+
125
+ :param table_id: A table object
126
+ :param start_column: The index of the column of the first cell to delete. Numbering starts at 0
127
+ :param start_row: The index of the row of the first cell to delete. Numbering starts at 0
128
+ :param end_column: The index of the column of the last cell to delete. Optional. The default is
129
+ the argument used for start_column
130
+ :param end_row: The index of the row of the last cell to delete. Optional. The default is the
131
+ argument used for start_row
132
+ """
133
+ if isinstance(table_id, NA):
134
+ return
135
+ if end_column is None:
136
+ end_column = start_column
137
+ if end_row is None:
138
+ end_row = start_row
139
+
140
+ # Clear the specified range of cells
141
+ table_id.clear_cells(start_column, start_row, end_column, end_row)
142
+
143
+
144
+ def merge_cells(table_id: Table, start_column: int, start_row: int, end_column: int, end_row: int) -> None:
145
+ """
146
+ Merges a sequence of cells in the table into one cell.
147
+
148
+ :param table_id: A table object
149
+ :param start_column: The index of the column of the first cell to merge. Numbering starts at 0
150
+ :param start_row: The index of the row of the first cell to merge. Numbering starts at 0
151
+ :param end_column: The index of the column of the last cell to merge. Numbering starts at 0
152
+ :param end_row: The index of the row of the last cell to merge. Numbering starts at 0
153
+ """
154
+ if isinstance(table_id, NA):
155
+ return
156
+
157
+ # Merge the specified range of cells
158
+ table_id.merge_cells(start_column, start_row, end_column, end_row)
159
+
160
+
161
+ # Cell setter functions
162
+ def cell_set_bgcolor(table_id: Table, column: int, row: int, bgcolor: _color.Color) -> None:
163
+ """Sets the background color of the cell."""
164
+ if isinstance(table_id, NA):
165
+ return
166
+ cell_obj = table_id.get_cell(column, row)
167
+ cell_obj.bgcolor = bgcolor
168
+
169
+
170
+ def cell_set_height(table_id: Table, column: int, row: int, height: int | float) -> None:
171
+ """Sets the height of cell."""
172
+ if isinstance(table_id, NA):
173
+ return
174
+ cell_obj = table_id.get_cell(column, row)
175
+ cell_obj.height = height
176
+
177
+
178
+ def cell_set_text(table_id: Table, column: int, row: int, text: str) -> None:
179
+ """Sets the text in the specified cell."""
180
+ if isinstance(table_id, NA):
181
+ return
182
+ cell_obj = table_id.get_cell(column, row)
183
+ cell_obj.text = text
184
+
185
+
186
+ def cell_set_text_color(table_id: Table, column: int, row: int, text_color: _color.Color) -> None:
187
+ """Sets the color of the text inside the cell."""
188
+ if isinstance(table_id, NA):
189
+ return
190
+ cell_obj = table_id.get_cell(column, row)
191
+ cell_obj.text_color = text_color
192
+
193
+
194
+ def cell_set_text_font_family(table_id: Table, column: int, row: int, text_font_family: _font.FontFamilyEnum) -> None:
195
+ """Sets the font family of the text inside the cell."""
196
+ if isinstance(table_id, NA):
197
+ return
198
+ cell_obj = table_id.get_cell(column, row)
199
+ cell_obj.text_font_family = text_font_family
200
+
201
+
202
+ def cell_set_text_formatting(table_id: Table, column: int, row: int, text_formatting: _text.FormatEnum) -> None:
203
+ """Sets the formatting attributes the drawing applies to displayed text."""
204
+ if isinstance(table_id, NA):
205
+ return
206
+ cell_obj = table_id.get_cell(column, row)
207
+ cell_obj.text_formatting = text_formatting
208
+
209
+
210
+ def cell_set_text_halign(table_id: Table, column: int, row: int, text_halign: _text.AlignEnum) -> None:
211
+ """Sets the horizontal alignment of the cell's text."""
212
+ if isinstance(table_id, NA):
213
+ return
214
+ cell_obj = table_id.get_cell(column, row)
215
+ cell_obj.text_halign = text_halign
216
+
217
+
218
+ def cell_set_text_size(table_id: Table, column: int, row: int, text_size: int | str) -> None:
219
+ """Sets the size of the cell's text."""
220
+ if isinstance(table_id, NA):
221
+ return
222
+ cell_obj = table_id.get_cell(column, row)
223
+ cell_obj.text_size = text_size
224
+
225
+
226
+ def cell_set_text_valign(table_id: Table, column: int, row: int, text_valign: _text.AlignEnum) -> None:
227
+ """Sets the vertical alignment of a cell's text."""
228
+ if isinstance(table_id, NA):
229
+ return
230
+ cell_obj = table_id.get_cell(column, row)
231
+ cell_obj.text_valign = text_valign
232
+
233
+
234
+ def cell_set_tooltip(table_id: Table, column: int, row: int, tooltip: str) -> None:
235
+ """Sets the tooltip in the specified cell."""
236
+ if isinstance(table_id, NA):
237
+ return
238
+ cell_obj = table_id.get_cell(column, row)
239
+ cell_obj.tooltip = tooltip
240
+
241
+
242
+ def cell_set_width(table_id: Table, column: int, row: int, width: int | float) -> None:
243
+ """Sets the width of the cell."""
244
+ if isinstance(table_id, NA):
245
+ return
246
+ cell_obj = table_id.get_cell(column, row)
247
+ cell_obj.width = width
248
+
249
+
250
+ # Table setter functions
251
+ def set_bgcolor(table_id: Table, bgcolor: _color.Color) -> None:
252
+ """Sets the background color of a table."""
253
+ if isinstance(table_id, NA):
254
+ return
255
+ table_id.bgcolor = bgcolor
256
+
257
+
258
+ def set_border_color(table_id: Table, border_color: _color.Color) -> None:
259
+ """Sets the color of the borders (excluding the outer frame) of the table's cells."""
260
+ if isinstance(table_id, NA):
261
+ return
262
+ table_id.border_color = border_color
263
+
264
+
265
+ def set_border_width(table_id: Table, border_width: int) -> None:
266
+ """Sets the width of the borders (excluding the outer frame) of the table's cells."""
267
+ if isinstance(table_id, NA):
268
+ return
269
+ table_id.border_width = border_width
270
+
271
+
272
+ def set_frame_color(table_id: Table, frame_color: _color.Color) -> None:
273
+ """Sets the color of the outer frame of a table."""
274
+ if isinstance(table_id, NA):
275
+ return
276
+ table_id.frame_color = frame_color
277
+
278
+
279
+ def set_frame_width(table_id: Table, frame_width: int) -> None:
280
+ """Sets the width of the outer frame of a table."""
281
+ if isinstance(table_id, NA):
282
+ return
283
+ table_id.frame_width = frame_width
284
+
285
+
286
+ def set_position(table_id: Table, position: _position.Position) -> None:
287
+ """Sets the position of a table."""
288
+ if isinstance(table_id, NA):
289
+ return
290
+ table_id.position = position
pynecore/lib/text.py ADDED
@@ -0,0 +1,17 @@
1
+ from ..types.text import AlignEnum, FormatEnum, WrapEnum
2
+
3
+ # Text alignment constants
4
+ align_left = AlignEnum('left')
5
+ align_center = AlignEnum('center')
6
+ align_right = AlignEnum('right')
7
+ align_top = AlignEnum('top')
8
+ align_bottom = AlignEnum('bottom')
9
+
10
+ # Text format constants
11
+ format_bold = FormatEnum('bold')
12
+ format_italic = FormatEnum('italic')
13
+ format_none = FormatEnum('none')
14
+
15
+ # Text wrap constants
16
+ wrap_auto = WrapEnum('auto')
17
+ wrap_none = WrapEnum('none')
pynecore/lib/ticker.py ADDED
@@ -0,0 +1,207 @@
1
+ """
2
+ Pine Script ``ticker.*`` namespace - ticker identifier construction.
3
+ """
4
+ from . import syminfo
5
+
6
+ __all__ = [
7
+ 'heikinashi',
8
+ 'inherit',
9
+ 'kagi',
10
+ 'linebreak',
11
+ 'modify',
12
+ 'new',
13
+ 'pointfigure',
14
+ 'renko',
15
+ 'standard',
16
+ ]
17
+
18
+ # Internal separator embedded in a ticker identifier by the chart-type helpers
19
+ # (currently only ``heikinashi``). ``\x1f`` (ASCII Unit Separator) can never
20
+ # appear in a real ticker identifier, so a marked ticker never collides with a
21
+ # genuine symbol and never compares equal to the chart symbol — which keeps a
22
+ # Heikin Ashi request out of the same-context inline fast path and routes it to
23
+ # a subprocess that applies the chart-type transform per bar.
24
+ # ``_split_chart_type`` strips the marker back to the base symbol wherever the
25
+ # ticker is resolved to data.
26
+ _CHART_TYPE_SEP = '\x1f'
27
+
28
+
29
+ def _split_chart_type(tickerid: str) -> 'tuple[str, str | None]':
30
+ """
31
+ Split a chart-type-marked ticker identifier into its base symbol and type.
32
+
33
+ Internal helper (not a Pine builtin): the security machinery calls it to
34
+ strip the marker added by :func:`heikinashi` before resolving data.
35
+
36
+ :param tickerid: A ticker identifier, optionally carrying a chart-type marker
37
+ produced by :func:`heikinashi`
38
+ :return: ``(base_symbol, chart_type)``; ``chart_type`` is ``None`` for a plain
39
+ ticker identifier (no marker)
40
+ """
41
+ s = str(tickerid)
42
+ idx = s.find(_CHART_TYPE_SEP)
43
+ if idx < 0:
44
+ return s, None
45
+ return s[:idx], s[idx + len(_CHART_TYPE_SEP):]
46
+
47
+
48
+ # noinspection PyUnusedLocal
49
+ def new(prefix: str, ticker: str, session: str | None = None,
50
+ adjustment: str | None = None, backadjustment: str | None = None,
51
+ settlement_as_close: str | None = None) -> str:
52
+ """
53
+ Create a ticker identifier from an exchange prefix and a ticker name.
54
+
55
+ The ``session``, ``adjustment``, ``backadjustment`` and ``settlement_as_close``
56
+ parameters are accepted for Pine compatibility but do not alter the identifier:
57
+ PyneCore's data layer does not provide per-request session or adjustment variants
58
+ of a feed.
59
+
60
+ :param prefix: Exchange prefix (e.g. ``"BINANCE"``)
61
+ :param ticker: Ticker name (e.g. ``"BTCUSDT"``); a full identifier
62
+ (``"BINANCE:BTCUSDT"``) is used as-is
63
+ :param session: Session type, ignored (see above)
64
+ :param adjustment: Price adjustment type, ignored (see above)
65
+ :param backadjustment: Continuous contract back-adjustment, ignored (see above)
66
+ :param settlement_as_close: Settlement-as-close setting, ignored (see above)
67
+ :return: The ticker identifier (``"PREFIX:TICKER"``)
68
+ """
69
+ ticker = str(ticker)
70
+ if ':' in ticker:
71
+ return ticker
72
+ return f"{prefix}:{ticker}"
73
+
74
+
75
+ # noinspection PyUnusedLocal
76
+ def modify(tickerid: str, session: str | None = None, adjustment: str | None = None,
77
+ backadjustment: str | None = None, settlement_as_close: str | None = None) -> str:
78
+ """
79
+ Create a copy of a ticker identifier with modified session/adjustment settings.
80
+
81
+ The settings are accepted for Pine compatibility but do not alter the identifier:
82
+ PyneCore's data layer does not provide per-request session or adjustment variants
83
+ of a feed.
84
+
85
+ :param tickerid: The ticker identifier to modify
86
+ :param session: Session type, ignored (see above)
87
+ :param adjustment: Price adjustment type, ignored (see above)
88
+ :param backadjustment: Continuous contract back-adjustment, ignored (see above)
89
+ :param settlement_as_close: Settlement-as-close setting, ignored (see above)
90
+ :return: The ticker identifier
91
+ """
92
+ return str(tickerid)
93
+
94
+
95
+ def standard(symbol: str | None = None) -> str:
96
+ """
97
+ Return the ticker identifier of the standard chart type for a symbol.
98
+
99
+ PyneCore feeds carry no synthetic chart-type modifiers, so the standard form is
100
+ the identifier itself.
101
+
102
+ :param symbol: The ticker identifier; if None, the chart's symbol is used
103
+ :return: The standard-chart ticker identifier
104
+ """
105
+ if symbol is None:
106
+ return str(syminfo.tickerid)
107
+ return str(symbol)
108
+
109
+
110
+ def inherit(from_tickerid: str, symbol: str) -> str:
111
+ """
112
+ Create a ticker identifier for ``symbol`` inheriting the parameters of
113
+ ``from_tickerid``.
114
+
115
+ PyneCore feeds carry no chart-type or adjustment modifiers to inherit, so only the
116
+ exchange prefix is taken over when ``symbol`` has none.
117
+
118
+ :param from_tickerid: The ticker identifier to inherit parameters from
119
+ :param symbol: The symbol to build the new identifier for
120
+ :return: The ticker identifier
121
+ """
122
+ symbol = str(symbol)
123
+ if ':' in symbol:
124
+ return symbol
125
+ from_tickerid = str(from_tickerid)
126
+ if ':' in from_tickerid:
127
+ return f"{from_tickerid.split(':', 1)[0]}:{symbol}"
128
+ return symbol
129
+
130
+
131
+ def heikinashi(symbol: str) -> str:
132
+ """
133
+ Create a ticker identifier for requesting Heikin Ashi bar values.
134
+
135
+ The returned identifier carries an internal chart-type marker (see
136
+ :data:`_CHART_TYPE_SEP`). When passed to ``request.security()``, the security
137
+ child transforms each bar to Heikin Ashi before the script reads it; every
138
+ other consumer strips the marker back to the base symbol via
139
+ :func:`_split_chart_type`.
140
+
141
+ Works in both backtest and live mode. ``request.security_lower_tf()`` with a
142
+ chart type is not supported (it would need per-intrabar transformation).
143
+
144
+ :param symbol: The ticker identifier
145
+ :return: The base ticker identifier with the Heikin Ashi chart-type marker
146
+ """
147
+ return f"{symbol}{_CHART_TYPE_SEP}heikinashi"
148
+
149
+
150
+ # noinspection PyUnusedLocal
151
+ def renko(symbol: str, style: str | None = None, param: float | None = None,
152
+ request_wicks: bool = False, source: str | None = None) -> str:
153
+ """
154
+ Create a ticker identifier for requesting Renko bar values.
155
+
156
+ :param symbol: The ticker identifier
157
+ :param style: Renko box size style
158
+ :param param: Value of the selected style
159
+ :param request_wicks: Whether wick values are reflected
160
+ :param source: The price source
161
+ :raises NotImplementedError: PyneCore has no synthetic chart-type data feeds
162
+ """
163
+ raise NotImplementedError("ticker.renko() is not supported: "
164
+ "PyneCore has no synthetic chart-type data feeds")
165
+
166
+
167
+ # noinspection PyUnusedLocal
168
+ def pointfigure(symbol: str, source: str | None = None, style: str | None = None,
169
+ param: float | None = None, reversal: int | None = None) -> str:
170
+ """
171
+ Create a ticker identifier for requesting Point & Figure values.
172
+
173
+ :param symbol: The ticker identifier
174
+ :param source: The price source
175
+ :param style: Point & Figure box size style
176
+ :param param: Value of the selected style
177
+ :param reversal: The reversal amount
178
+ :raises NotImplementedError: PyneCore has no synthetic chart-type data feeds
179
+ """
180
+ raise NotImplementedError("ticker.pointfigure() is not supported: "
181
+ "PyneCore has no synthetic chart-type data feeds")
182
+
183
+
184
+ # noinspection PyUnusedLocal
185
+ def kagi(symbol: str, reversal: float) -> str:
186
+ """
187
+ Create a ticker identifier for requesting Kagi values.
188
+
189
+ :param symbol: The ticker identifier
190
+ :param reversal: The reversal amount
191
+ :raises NotImplementedError: PyneCore has no synthetic chart-type data feeds
192
+ """
193
+ raise NotImplementedError("ticker.kagi() is not supported: "
194
+ "PyneCore has no synthetic chart-type data feeds")
195
+
196
+
197
+ # noinspection PyUnusedLocal
198
+ def linebreak(symbol: str, number_of_lines: int) -> str:
199
+ """
200
+ Create a ticker identifier for requesting Line Break values.
201
+
202
+ :param symbol: The ticker identifier
203
+ :param number_of_lines: The number of lines
204
+ :raises NotImplementedError: PyneCore has no synthetic chart-type data feeds
205
+ """
206
+ raise NotImplementedError("ticker.linebreak() is not supported: "
207
+ "PyneCore has no synthetic chart-type data feeds")