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.
- opencode_pyneruntime-6.6.4.dist-info/METADATA +281 -0
- opencode_pyneruntime-6.6.4.dist-info/RECORD +261 -0
- opencode_pyneruntime-6.6.4.dist-info/WHEEL +5 -0
- opencode_pyneruntime-6.6.4.dist-info/entry_points.txt +6 -0
- opencode_pyneruntime-6.6.4.dist-info/licenses/LICENSE +201 -0
- opencode_pyneruntime-6.6.4.dist-info/licenses/NOTICE +21 -0
- opencode_pyneruntime-6.6.4.dist-info/top_level.txt +1 -0
- pynecore/__init__.py +6 -0
- pynecore/cli/__init__.py +2 -0
- pynecore/cli/app.py +238 -0
- pynecore/cli/commands/__init__.py +343 -0
- pynecore/cli/commands/benchmark.py +186 -0
- pynecore/cli/commands/compile.py +198 -0
- pynecore/cli/commands/data.py +857 -0
- pynecore/cli/commands/debug.py +63 -0
- pynecore/cli/commands/optimize.py +956 -0
- pynecore/cli/commands/plugin.py +242 -0
- pynecore/cli/commands/run.py +2006 -0
- pynecore/cli/pluggable.py +132 -0
- pynecore/cli/utils/__init__.py +0 -0
- pynecore/cli/utils/api_error_handler.py +168 -0
- pynecore/cli/utils/broker_picker.py +330 -0
- pynecore/cli/utils/error_hook.py +28 -0
- pynecore/cli/utils/keyreader.py +178 -0
- pynecore/cli/utils/provider_picker.py +19 -0
- pynecore/cli/utils/symbol_browser.py +1149 -0
- pynecore/core/__init__.py +0 -0
- pynecore/core/aggregator.py +257 -0
- pynecore/core/bar_magnifier.py +168 -0
- pynecore/core/broker/__init__.py +64 -0
- pynecore/core/broker/defaults.py +113 -0
- pynecore/core/broker/disappearance.py +927 -0
- pynecore/core/broker/emulator.py +345 -0
- pynecore/core/broker/exceptions.py +346 -0
- pynecore/core/broker/idempotency.py +401 -0
- pynecore/core/broker/intent_builder.py +334 -0
- pynecore/core/broker/journal.py +1785 -0
- pynecore/core/broker/models.py +1600 -0
- pynecore/core/broker/native_failsafe_manager.py +1436 -0
- pynecore/core/broker/one_way_emulator.py +1128 -0
- pynecore/core/broker/position.py +787 -0
- pynecore/core/broker/run_identity.py +126 -0
- pynecore/core/broker/software_entry_stop_engine.py +351 -0
- pynecore/core/broker/software_partial_bracket_engine.py +1379 -0
- pynecore/core/broker/spot_inventory.py +1327 -0
- pynecore/core/broker/storage.py +2655 -0
- pynecore/core/broker/store_helpers.py +2161 -0
- pynecore/core/broker/sync_engine.py +16070 -0
- pynecore/core/broker/validation.py +382 -0
- pynecore/core/class_property.py +7 -0
- pynecore/core/config.py +392 -0
- pynecore/core/csv_file.py +547 -0
- pynecore/core/currency.py +262 -0
- pynecore/core/data_converter.py +1002 -0
- pynecore/core/datetime.py +296 -0
- pynecore/core/download_info.py +71 -0
- pynecore/core/download_runner.py +274 -0
- pynecore/core/htf_aggregator.py +181 -0
- pynecore/core/import_hook.py +358 -0
- pynecore/core/instance_state.py +494 -0
- pynecore/core/live_ltf_collector.py +442 -0
- pynecore/core/live_ltf_window.py +189 -0
- pynecore/core/live_runner.py +1347 -0
- pynecore/core/module_property.py +26 -0
- pynecore/core/ohlcv_file.py +1888 -0
- pynecore/core/overload.py +371 -0
- pynecore/core/pine_cast.py +113 -0
- pynecore/core/pine_export.py +95 -0
- pynecore/core/pine_method.py +244 -0
- pynecore/core/pine_range.py +86 -0
- pynecore/core/pine_udt.py +69 -0
- pynecore/core/plugin/__init__.py +394 -0
- pynecore/core/plugin/broker.py +781 -0
- pynecore/core/plugin/cli.py +96 -0
- pynecore/core/plugin/live_provider.py +208 -0
- pynecore/core/plugin/provider.py +331 -0
- pynecore/core/provider_string.py +148 -0
- pynecore/core/random.py +40 -0
- pynecore/core/resampler.py +686 -0
- pynecore/core/safe_convert.py +64 -0
- pynecore/core/script.py +1011 -0
- pynecore/core/script_runner.py +3202 -0
- pynecore/core/security.py +1749 -0
- pynecore/core/security_process.py +1253 -0
- pynecore/core/security_shm.py +456 -0
- pynecore/core/series.py +417 -0
- pynecore/core/strategy_stats.py +669 -0
- pynecore/core/symbol_map.py +134 -0
- pynecore/core/syminfo.py +505 -0
- pynecore/core/viz.py +591 -0
- pynecore/lib/__init__.py +1771 -0
- pynecore/lib/_fixnan.py +32 -0
- pynecore/lib/_math_stateful.py +202 -0
- pynecore/lib/_timeframe_change.py +101 -0
- pynecore/lib/adjustment.py +6 -0
- pynecore/lib/alert.py +39 -0
- pynecore/lib/alert.pyi +14 -0
- pynecore/lib/array.py +1051 -0
- pynecore/lib/barmerge.py +60 -0
- pynecore/lib/barstate.py +30 -0
- pynecore/lib/box.py +415 -0
- pynecore/lib/chart.py +128 -0
- pynecore/lib/color.py +152 -0
- pynecore/lib/color.pyi +50 -0
- pynecore/lib/currency.py +62 -0
- pynecore/lib/dayofweek.py +36 -0
- pynecore/lib/dayofweek.pyi +18 -0
- pynecore/lib/display.py +8 -0
- pynecore/lib/dividends.py +9 -0
- pynecore/lib/earnings.py +11 -0
- pynecore/lib/extend.py +6 -0
- pynecore/lib/font.py +5 -0
- pynecore/lib/footprint.py +79 -0
- pynecore/lib/format.py +11 -0
- pynecore/lib/hline.py +67 -0
- pynecore/lib/hline.pyi +24 -0
- pynecore/lib/label.py +409 -0
- pynecore/lib/line.py +433 -0
- pynecore/lib/linefill.py +93 -0
- pynecore/lib/location.py +11 -0
- pynecore/lib/log.py +362 -0
- pynecore/lib/map.py +150 -0
- pynecore/lib/math.py +385 -0
- pynecore/lib/matrix.py +708 -0
- pynecore/lib/order.py +8 -0
- pynecore/lib/pivotpointtype.py +8 -0
- pynecore/lib/plot.py +95 -0
- pynecore/lib/plot.pyi +33 -0
- pynecore/lib/polyline.py +91 -0
- pynecore/lib/position.py +15 -0
- pynecore/lib/request.py +281 -0
- pynecore/lib/runtime.py +5 -0
- pynecore/lib/scale.py +9 -0
- pynecore/lib/session.py +267 -0
- pynecore/lib/session.pyi +12 -0
- pynecore/lib/shape.py +18 -0
- pynecore/lib/size.py +12 -0
- pynecore/lib/splits.py +4 -0
- pynecore/lib/strategy/__init__.py +4778 -0
- pynecore/lib/strategy/closedtrades.py +347 -0
- pynecore/lib/strategy/closedtrades.pyi +53 -0
- pynecore/lib/strategy/commission.py +9 -0
- pynecore/lib/strategy/direction.py +9 -0
- pynecore/lib/strategy/oca.py +13 -0
- pynecore/lib/strategy/opentrades.py +281 -0
- pynecore/lib/strategy/opentrades.pyi +49 -0
- pynecore/lib/strategy/risk.py +109 -0
- pynecore/lib/string.py +649 -0
- pynecore/lib/syminfo.py +84 -0
- pynecore/lib/ta.py +2230 -0
- pynecore/lib/table.py +290 -0
- pynecore/lib/text.py +17 -0
- pynecore/lib/ticker.py +207 -0
- pynecore/lib/timeframe.py +293 -0
- pynecore/lib/volume_row.py +67 -0
- pynecore/lib/xloc.py +4 -0
- pynecore/lib/yloc.py +5 -0
- pynecore/providers/__init__.py +0 -0
- pynecore/providers/ccxt.py +664 -0
- pynecore/providers/replay.py +187 -0
- pynecore/pynesys/__init__.py +0 -0
- pynecore/pynesys/api.py +498 -0
- pynecore/pynesys/compiler.py +112 -0
- pynecore/standalone.py +99 -0
- pynecore/testing/__init__.py +1 -0
- pynecore/testing/broker_lab/__init__.py +41 -0
- pynecore/testing/broker_lab/__main__.py +5 -0
- pynecore/testing/broker_lab/cli.py +87 -0
- pynecore/testing/broker_lab/generate.py +47 -0
- pynecore/testing/broker_lab/model.py +84 -0
- pynecore/testing/broker_lab/reference.py +645 -0
- pynecore/testing/broker_lab/runner.py +372 -0
- pynecore/testing/broker_lab/scheduler.py +50 -0
- pynecore/testing/broker_lab/subprocess.py +73 -0
- pynecore/transformers/__init__.py +0 -0
- pynecore/transformers/builtin_shadow.py +136 -0
- pynecore/transformers/closure_arguments_transformer.py +428 -0
- pynecore/transformers/display_rewrite.py +140 -0
- pynecore/transformers/dynamic_default.py +147 -0
- pynecore/transformers/function_isolation.py +757 -0
- pynecore/transformers/import_lifter.py +61 -0
- pynecore/transformers/import_normalizer.py +328 -0
- pynecore/transformers/inline_series_hoist.py +178 -0
- pynecore/transformers/input_transformer.py +175 -0
- pynecore/transformers/lib_series.py +201 -0
- pynecore/transformers/locations.py +70 -0
- pynecore/transformers/module_properties.json +3387 -0
- pynecore/transformers/module_property.py +221 -0
- pynecore/transformers/ne_guard.py +70 -0
- pynecore/transformers/persistent.py +320 -0
- pynecore/transformers/persistent_series.py +76 -0
- pynecore/transformers/safe_convert_transformer.py +97 -0
- pynecore/transformers/safe_division_transformer.py +95 -0
- pynecore/transformers/script_requirements.py +308 -0
- pynecore/transformers/security.py +752 -0
- pynecore/transformers/security_instantiation.py +274 -0
- pynecore/transformers/series.py +275 -0
- pynecore/transformers/slot_layout.py +381 -0
- pynecore/transformers/type_checking_stripper.py +25 -0
- pynecore/transformers/unused_series_detector.py +267 -0
- pynecore/types/__init__.py +21 -0
- pynecore/types/alert.py +5 -0
- pynecore/types/barmerge.py +5 -0
- pynecore/types/base.py +39 -0
- pynecore/types/box.py +37 -0
- pynecore/types/chart.py +17 -0
- pynecore/types/color.py +107 -0
- pynecore/types/currency.py +5 -0
- pynecore/types/datetime.py +6 -0
- pynecore/types/display.py +5 -0
- pynecore/types/dividends.py +5 -0
- pynecore/types/earnings.py +5 -0
- pynecore/types/extend.py +5 -0
- pynecore/types/font.py +5 -0
- pynecore/types/footprint.py +41 -0
- pynecore/types/format.py +5 -0
- pynecore/types/hline.py +24 -0
- pynecore/types/ib_persistent.py +8 -0
- pynecore/types/ib_persistent.pyi +10 -0
- pynecore/types/label.py +35 -0
- pynecore/types/line.py +32 -0
- pynecore/types/linefill.py +13 -0
- pynecore/types/location.py +5 -0
- pynecore/types/matrix.py +999 -0
- pynecore/types/na.py +237 -0
- pynecore/types/na.pyi +83 -0
- pynecore/types/ohlcv.py +12 -0
- pynecore/types/order.py +5 -0
- pynecore/types/persistent.py +8 -0
- pynecore/types/persistent.pyi +13 -0
- pynecore/types/pine_types.py +11 -0
- pynecore/types/pine_types.pyi +15 -0
- pynecore/types/pivotpointtype.py +5 -0
- pynecore/types/plot.py +12 -0
- pynecore/types/plot_meta.py +60 -0
- pynecore/types/polyline.py +40 -0
- pynecore/types/position.py +5 -0
- pynecore/types/scale.py +5 -0
- pynecore/types/script_type.py +15 -0
- pynecore/types/series.py +23 -0
- pynecore/types/series.pyi +19 -0
- pynecore/types/session.py +35 -0
- pynecore/types/shape.py +5 -0
- pynecore/types/size.py +5 -0
- pynecore/types/source.py +33 -0
- pynecore/types/splits.py +5 -0
- pynecore/types/strategy.py +45 -0
- pynecore/types/table.py +87 -0
- pynecore/types/text.py +13 -0
- pynecore/types/type_checker.py +7 -0
- pynecore/types/type_checker.pyi +48 -0
- pynecore/types/volume_row.py +36 -0
- pynecore/types/weekdays.py +11 -0
- pynecore/types/xloc.py +5 -0
- pynecore/types/yloc.py +5 -0
- pynecore/utils/__init__.py +0 -0
- pynecore/utils/file_utils.py +50 -0
- pynecore/utils/rich/__init__.py +0 -0
- pynecore/utils/rich/date_column.py +25 -0
- pynecore/utils/sequence_view.py +92 -0
- 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")
|