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/label.py
ADDED
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
from copy import copy as _copy
|
|
2
|
+
from typing import Any, overload
|
|
3
|
+
|
|
4
|
+
from ..core.module_property import module_property
|
|
5
|
+
from ..types.chart import ChartPoint
|
|
6
|
+
from ..types.base import next_vid
|
|
7
|
+
from ..types.label import LabelStyleEnum, Label
|
|
8
|
+
from ..types.na import NA, na_int, na_float
|
|
9
|
+
from ..types.pine_types import PyneFloat, PyneInt, PyneStr
|
|
10
|
+
from ..lib import xloc as _xloc, yloc as _yloc, color as _color, size as _size, text as _text, font as _font
|
|
11
|
+
from .. import lib
|
|
12
|
+
|
|
13
|
+
_registry: dict[Label, None] = {}
|
|
14
|
+
|
|
15
|
+
# Label style constants
|
|
16
|
+
style_none = LabelStyleEnum('n')
|
|
17
|
+
style_xcross = LabelStyleEnum('xcr')
|
|
18
|
+
style_cross = LabelStyleEnum('cr')
|
|
19
|
+
style_triangleup = LabelStyleEnum('tup')
|
|
20
|
+
style_triangledown = LabelStyleEnum('tdn')
|
|
21
|
+
style_flag = LabelStyleEnum('flg')
|
|
22
|
+
style_circle = LabelStyleEnum('cir')
|
|
23
|
+
style_arrowup = LabelStyleEnum('aup')
|
|
24
|
+
style_arrowdown = LabelStyleEnum('adn')
|
|
25
|
+
style_label_up = LabelStyleEnum('lup')
|
|
26
|
+
style_label_down = LabelStyleEnum('ldn')
|
|
27
|
+
style_label_left = LabelStyleEnum('llf')
|
|
28
|
+
style_label_right = LabelStyleEnum('lrg')
|
|
29
|
+
style_label_lower_left = LabelStyleEnum('llwlf')
|
|
30
|
+
style_label_lower_right = LabelStyleEnum('llwrg')
|
|
31
|
+
style_label_upper_left = LabelStyleEnum('luplf')
|
|
32
|
+
style_label_upper_right = LabelStyleEnum('luprg')
|
|
33
|
+
style_label_center = LabelStyleEnum('lcn')
|
|
34
|
+
style_square = LabelStyleEnum('sq')
|
|
35
|
+
style_diamond = LabelStyleEnum('dia')
|
|
36
|
+
style_text_outline = LabelStyleEnum('to')
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
@overload
|
|
40
|
+
def new(point: ChartPoint, text: str = "", xloc: _xloc.XLoc = _xloc.bar_index,
|
|
41
|
+
yloc: _yloc.YLoc = _yloc.price, color: _color.Color = _color.blue,
|
|
42
|
+
style: LabelStyleEnum = style_label_down, textcolor: _color.Color = _color.white,
|
|
43
|
+
size: _size.Size = _size.normal, textalign: _text.AlignEnum = _text.align_center,
|
|
44
|
+
tooltip: str = "", text_font_family: _font.FontFamilyEnum = _font.family_default,
|
|
45
|
+
force_overlay: bool = False, text_formatting: _text.FormatEnum = _text.format_none) -> Label: ...
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@overload
|
|
49
|
+
def new(x: int | float, y: int | float, text: str = "", xloc: _xloc.XLoc = _xloc.bar_index,
|
|
50
|
+
yloc: _yloc.YLoc = _yloc.price, color: _color.Color = _color.blue,
|
|
51
|
+
style: LabelStyleEnum = style_label_down, textcolor: _color.Color = _color.white,
|
|
52
|
+
size: _size.Size = _size.normal, textalign: _text.AlignEnum = _text.align_center,
|
|
53
|
+
tooltip: str = "", text_font_family: _font.FontFamilyEnum = _font.family_default,
|
|
54
|
+
force_overlay: bool = False, text_formatting: _text.FormatEnum = _text.format_none) -> Label: ...
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
# Positional parameter orders of the two Pine call shapes; ``new()`` maps ``*args``
|
|
58
|
+
# onto one of these depending on whether the first positional is a ``chart.point``.
|
|
59
|
+
_COMMON_PARAMS = ('xloc', 'yloc', 'color', 'style', 'textcolor', 'size', 'textalign',
|
|
60
|
+
'tooltip', 'text_font_family', 'force_overlay', 'text_formatting')
|
|
61
|
+
_POINT_PARAMS = ('point', 'text') + _COMMON_PARAMS
|
|
62
|
+
_COORD_PARAMS = ('x', 'y', 'text') + _COMMON_PARAMS
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
# noinspection PyProtectedMember
|
|
66
|
+
def new(*args: Any, **kwargs: Any) -> Label:
|
|
67
|
+
"""
|
|
68
|
+
Creates a new label object.
|
|
69
|
+
|
|
70
|
+
Two call shapes are accepted (Pine-compatible):
|
|
71
|
+
- ``label.new(point, text="", ...)`` where ``point`` is a ``chart.point`` object. In this
|
|
72
|
+
form the second positional argument is the label ``text``.
|
|
73
|
+
- ``label.new(x, y, text="", ...)`` where ``x`` is bar index (``xloc.bar_index``) or
|
|
74
|
+
bar UNIX time in milliseconds (``xloc.bar_time``), and ``y`` is the price.
|
|
75
|
+
A float ``x`` is truncated to int to mirror Pine's implicit float-to-int
|
|
76
|
+
conversion on ``series int`` parameters.
|
|
77
|
+
|
|
78
|
+
:param x: Bar index / bar time of the label position (coordinate form)
|
|
79
|
+
:param y: Price of the label position (coordinate form)
|
|
80
|
+
:param text: Label text
|
|
81
|
+
:param xloc: Possible values: ``xloc.bar_index`` and ``xloc.bar_time``
|
|
82
|
+
:param yloc: Possible values are ``yloc.price``, ``yloc.abovebar``, ``yloc.belowbar``
|
|
83
|
+
:param color: Color of the label border and arrow
|
|
84
|
+
:param style: Label style
|
|
85
|
+
:param textcolor: Text color
|
|
86
|
+
:param size: Size of the label
|
|
87
|
+
:param textalign: Label text alignment
|
|
88
|
+
:param tooltip: Hover to see tooltip label
|
|
89
|
+
:param text_font_family: The font family of the text
|
|
90
|
+
:param force_overlay: If true, the drawing will display on the main chart pane
|
|
91
|
+
:param text_formatting: The formatting of the displayed text
|
|
92
|
+
:param point: ``chart.point`` object (point form, keyword equivalent of the first positional)
|
|
93
|
+
:return: A label object
|
|
94
|
+
"""
|
|
95
|
+
if args:
|
|
96
|
+
names = _POINT_PARAMS if isinstance(args[0], ChartPoint) else _COORD_PARAMS
|
|
97
|
+
if len(args) > len(names):
|
|
98
|
+
raise TypeError(f"label.new() takes at most {len(names)} positional arguments")
|
|
99
|
+
for name, value in zip(names, args):
|
|
100
|
+
if name in kwargs:
|
|
101
|
+
raise TypeError(f"label.new() got multiple values for argument '{name}'")
|
|
102
|
+
kwargs[name] = value
|
|
103
|
+
point = kwargs.get('point')
|
|
104
|
+
text = kwargs.get('text', "")
|
|
105
|
+
xloc = kwargs.get('xloc', _xloc.bar_index)
|
|
106
|
+
yloc = kwargs.get('yloc', _yloc.price)
|
|
107
|
+
color = kwargs.get('color', _color.blue)
|
|
108
|
+
style = kwargs.get('style', style_label_down)
|
|
109
|
+
textcolor = kwargs.get('textcolor', _color.white)
|
|
110
|
+
size = kwargs.get('size', _size.normal)
|
|
111
|
+
textalign = kwargs.get('textalign', _text.align_center)
|
|
112
|
+
tooltip = kwargs.get('tooltip', "")
|
|
113
|
+
text_font_family = kwargs.get('text_font_family', _font.family_default)
|
|
114
|
+
force_overlay = kwargs.get('force_overlay', False)
|
|
115
|
+
text_formatting = kwargs.get('text_formatting', _text.format_none)
|
|
116
|
+
if isinstance(point, ChartPoint):
|
|
117
|
+
if xloc == _xloc.bar_time:
|
|
118
|
+
x_val, y_val = point.time, point.price
|
|
119
|
+
else:
|
|
120
|
+
x_val, y_val = point.index, point.price
|
|
121
|
+
else:
|
|
122
|
+
x = kwargs.get('x')
|
|
123
|
+
y = kwargs.get('y')
|
|
124
|
+
x_val = int(x) if isinstance(x, (int, float)) and x == x else na_int
|
|
125
|
+
y_val = y if isinstance(y, (int, float)) else na_float
|
|
126
|
+
|
|
127
|
+
label_obj = Label(
|
|
128
|
+
x=x_val,
|
|
129
|
+
y=y_val,
|
|
130
|
+
text=text,
|
|
131
|
+
xloc=xloc,
|
|
132
|
+
yloc=yloc or _yloc.price,
|
|
133
|
+
color=color,
|
|
134
|
+
style=style or style_label_down,
|
|
135
|
+
textcolor=textcolor,
|
|
136
|
+
size=size or _size.normal,
|
|
137
|
+
textalign=textalign or _text.align_center,
|
|
138
|
+
tooltip=tooltip,
|
|
139
|
+
text_font_family=text_font_family or _font.family_default,
|
|
140
|
+
force_overlay=force_overlay,
|
|
141
|
+
text_formatting=text_formatting or _text.format_none
|
|
142
|
+
)
|
|
143
|
+
label_obj.vid = next_vid()
|
|
144
|
+
_registry[label_obj] = None
|
|
145
|
+
# Enforce Pine's max_labels_count cap: drop the oldest label (FIFO) past the limit.
|
|
146
|
+
# A security child never sets ``lib._script``; fall back to TV's hard maximum
|
|
147
|
+
# (500) there, otherwise the registry grows without bound (the child re-runs
|
|
148
|
+
# main() for every bar of its own series, accumulating every drawing ever made).
|
|
149
|
+
if len(_registry) > (lib._script.max_labels_count if lib._script is not None else 500):
|
|
150
|
+
del _registry[next(iter(_registry))]
|
|
151
|
+
return label_obj
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
# noinspection PyShadowingBuiltins
|
|
155
|
+
@module_property
|
|
156
|
+
def all() -> list[Label]:
|
|
157
|
+
"""Returns all label objects"""
|
|
158
|
+
return list(_registry)
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
# noinspection PyShadowingBuiltins
|
|
162
|
+
def delete(id):
|
|
163
|
+
"""Delete label object"""
|
|
164
|
+
if isinstance(id, NA):
|
|
165
|
+
return
|
|
166
|
+
_registry.pop(id, None)
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
# noinspection PyShadowingBuiltins,PyProtectedMember
|
|
170
|
+
def copy(id):
|
|
171
|
+
"""Copy label object"""
|
|
172
|
+
if isinstance(id, NA):
|
|
173
|
+
return NA(Label)
|
|
174
|
+
clone = _copy(id)
|
|
175
|
+
clone.vid = next_vid()
|
|
176
|
+
_registry[clone] = None
|
|
177
|
+
if len(_registry) > (lib._script.max_labels_count if lib._script is not None else 500):
|
|
178
|
+
del _registry[next(iter(_registry))]
|
|
179
|
+
return clone
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
# noinspection PyShadowingBuiltins
|
|
183
|
+
def get_text(id: Label) -> PyneStr:
|
|
184
|
+
"""
|
|
185
|
+
Returns the text of the label.
|
|
186
|
+
|
|
187
|
+
:param id: Label object
|
|
188
|
+
:return: Label text
|
|
189
|
+
"""
|
|
190
|
+
if isinstance(id, NA):
|
|
191
|
+
return NA(str)
|
|
192
|
+
return id.text
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
# noinspection PyShadowingBuiltins
|
|
196
|
+
def set_text(id: Label, text: str) -> None:
|
|
197
|
+
"""
|
|
198
|
+
Sets the label text
|
|
199
|
+
|
|
200
|
+
:param id: Label object
|
|
201
|
+
:param text: New label text
|
|
202
|
+
"""
|
|
203
|
+
if isinstance(id, NA):
|
|
204
|
+
return
|
|
205
|
+
id.text = text
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
# noinspection PyShadowingBuiltins
|
|
209
|
+
def set_color(id: Label, color: _color.Color) -> None:
|
|
210
|
+
"""
|
|
211
|
+
Sets the label color
|
|
212
|
+
|
|
213
|
+
:param id: Label object
|
|
214
|
+
:param color: New label color
|
|
215
|
+
"""
|
|
216
|
+
if isinstance(id, NA):
|
|
217
|
+
return
|
|
218
|
+
id.color = color
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
# noinspection PyShadowingBuiltins
|
|
222
|
+
def set_style(id: Label, style: LabelStyleEnum) -> None:
|
|
223
|
+
"""
|
|
224
|
+
Sets the label style
|
|
225
|
+
|
|
226
|
+
:param id: Label object
|
|
227
|
+
:param style: New label style
|
|
228
|
+
"""
|
|
229
|
+
if isinstance(id, NA):
|
|
230
|
+
return
|
|
231
|
+
id.style = style
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
# noinspection PyShadowingBuiltins
|
|
235
|
+
def set_textcolor(id: Label, textcolor: _color.Color) -> None:
|
|
236
|
+
"""
|
|
237
|
+
Sets the label text color
|
|
238
|
+
|
|
239
|
+
:param id: Label object
|
|
240
|
+
:param textcolor: New text color
|
|
241
|
+
"""
|
|
242
|
+
if isinstance(id, NA):
|
|
243
|
+
return
|
|
244
|
+
id.textcolor = textcolor
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
# noinspection PyShadowingBuiltins
|
|
248
|
+
def set_size(id: Label, size: _size.Size) -> None:
|
|
249
|
+
"""
|
|
250
|
+
Sets the label size
|
|
251
|
+
|
|
252
|
+
:param id: Label object
|
|
253
|
+
:param size: New label size
|
|
254
|
+
"""
|
|
255
|
+
if isinstance(id, NA):
|
|
256
|
+
return
|
|
257
|
+
id.size = size
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
# noinspection PyShadowingBuiltins
|
|
261
|
+
def set_textalign(id: Label, textalign: _text.AlignEnum) -> None:
|
|
262
|
+
"""
|
|
263
|
+
Sets the label text alignment
|
|
264
|
+
|
|
265
|
+
:param id: Label object
|
|
266
|
+
:param textalign: New text alignment
|
|
267
|
+
"""
|
|
268
|
+
if isinstance(id, NA):
|
|
269
|
+
return
|
|
270
|
+
id.textalign = textalign
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
# noinspection PyShadowingBuiltins
|
|
274
|
+
def set_tooltip(id: Label, tooltip: str) -> None:
|
|
275
|
+
"""
|
|
276
|
+
Sets the label tooltip
|
|
277
|
+
|
|
278
|
+
:param id: Label object
|
|
279
|
+
:param tooltip: New tooltip text
|
|
280
|
+
"""
|
|
281
|
+
if isinstance(id, NA):
|
|
282
|
+
return
|
|
283
|
+
id.tooltip = tooltip
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
# noinspection PyShadowingBuiltins
|
|
287
|
+
def set_text_formatting(id: Label, text_formatting: _text.FormatEnum) -> None:
|
|
288
|
+
"""
|
|
289
|
+
Sets the formatting attributes the label applies to its displayed text.
|
|
290
|
+
|
|
291
|
+
:param id: Label object
|
|
292
|
+
:param text_formatting: New text formatting (e.g. text.format_bold, text.format_italic)
|
|
293
|
+
"""
|
|
294
|
+
if isinstance(id, NA):
|
|
295
|
+
return
|
|
296
|
+
id.text_formatting = text_formatting
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
# noinspection PyShadowingBuiltins
|
|
300
|
+
def set_x(id: Label, x: int) -> None:
|
|
301
|
+
"""
|
|
302
|
+
Sets bar index or bar time (depending on the xloc) of the label
|
|
303
|
+
|
|
304
|
+
:param id: Label object
|
|
305
|
+
:param x: Bar index or bar time
|
|
306
|
+
"""
|
|
307
|
+
if isinstance(id, NA):
|
|
308
|
+
return
|
|
309
|
+
id.x = x
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
# noinspection PyShadowingBuiltins
|
|
313
|
+
def set_y(id: Label, y: int | float) -> None:
|
|
314
|
+
"""
|
|
315
|
+
Sets price of the label
|
|
316
|
+
|
|
317
|
+
:param id: Label object
|
|
318
|
+
:param y: Price
|
|
319
|
+
"""
|
|
320
|
+
if isinstance(id, NA):
|
|
321
|
+
return
|
|
322
|
+
id.y = y
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
# noinspection PyShadowingBuiltins
|
|
326
|
+
def set_xy(id: Label, x: int, y: int | float) -> None:
|
|
327
|
+
"""
|
|
328
|
+
Sets bar index/time and price of the label
|
|
329
|
+
|
|
330
|
+
:param id: Label object
|
|
331
|
+
:param x: Bar index or bar time
|
|
332
|
+
:param y: Price
|
|
333
|
+
"""
|
|
334
|
+
if isinstance(id, NA):
|
|
335
|
+
return
|
|
336
|
+
id.x = x
|
|
337
|
+
id.y = y
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
# noinspection PyShadowingBuiltins
|
|
341
|
+
def set_point(id: Label, point: ChartPoint) -> None:
|
|
342
|
+
"""
|
|
343
|
+
Sets the location of the label's anchor to point, using the x-coordinate
|
|
344
|
+
field selected by the label's current xloc (bar index or bar time).
|
|
345
|
+
|
|
346
|
+
:param id: Label object
|
|
347
|
+
:param point: Chart point providing the new x (index/time) and y (price)
|
|
348
|
+
"""
|
|
349
|
+
if isinstance(id, NA):
|
|
350
|
+
return
|
|
351
|
+
if id.xloc == _xloc.bar_time:
|
|
352
|
+
id.x = point.time
|
|
353
|
+
else:
|
|
354
|
+
id.x = point.index
|
|
355
|
+
id.y = point.price
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
# noinspection PyShadowingBuiltins
|
|
359
|
+
def set_xloc(id: Label, x: int, xloc: _xloc.XLoc) -> None:
|
|
360
|
+
"""
|
|
361
|
+
Sets the x-location of the label, and the new bar index/time
|
|
362
|
+
|
|
363
|
+
:param id: Label object
|
|
364
|
+
:param x: Bar index or bar time, interpreted according to xloc
|
|
365
|
+
:param xloc: New x-location value
|
|
366
|
+
"""
|
|
367
|
+
if isinstance(id, NA):
|
|
368
|
+
return
|
|
369
|
+
id.x = x
|
|
370
|
+
id.xloc = xloc
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
# noinspection PyShadowingBuiltins
|
|
374
|
+
def set_yloc(id: Label, yloc: _yloc.YLoc) -> None:
|
|
375
|
+
"""
|
|
376
|
+
Sets the y-location of the label
|
|
377
|
+
|
|
378
|
+
:param id: Label object
|
|
379
|
+
:param yloc: New y-location value
|
|
380
|
+
"""
|
|
381
|
+
if isinstance(id, NA):
|
|
382
|
+
return
|
|
383
|
+
id.yloc = yloc
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
# noinspection PyShadowingBuiltins
|
|
387
|
+
def get_x(id: Label) -> PyneInt:
|
|
388
|
+
"""
|
|
389
|
+
Returns bar index or UNIX time (depending on the xloc value) of the label.
|
|
390
|
+
|
|
391
|
+
:param id: Label object
|
|
392
|
+
:return: Bar index or UNIX timestamp (in milliseconds)
|
|
393
|
+
"""
|
|
394
|
+
if isinstance(id, NA):
|
|
395
|
+
return NA(int)
|
|
396
|
+
return id.x
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
# noinspection PyShadowingBuiltins
|
|
400
|
+
def get_y(id: Label) -> PyneInt | PyneFloat:
|
|
401
|
+
"""
|
|
402
|
+
Returns price of the label.
|
|
403
|
+
|
|
404
|
+
:param id: Label object
|
|
405
|
+
:return: Price of the label
|
|
406
|
+
"""
|
|
407
|
+
if isinstance(id, NA):
|
|
408
|
+
return na_float
|
|
409
|
+
return id.y
|