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
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
from typing import TYPE_CHECKING
|
|
2
|
+
|
|
3
|
+
if TYPE_CHECKING:
|
|
4
|
+
from pynecore.types.type_checker import *
|
|
5
|
+
|
|
6
|
+
from functools import lru_cache
|
|
7
|
+
from datetime import datetime, timedelta
|
|
8
|
+
|
|
9
|
+
from ..core.module_property import module_property
|
|
10
|
+
|
|
11
|
+
from .. import lib
|
|
12
|
+
from . import syminfo as _syminfo
|
|
13
|
+
|
|
14
|
+
from ._timeframe_change import change
|
|
15
|
+
|
|
16
|
+
__all__ = [
|
|
17
|
+
'change',
|
|
18
|
+
'from_seconds',
|
|
19
|
+
'in_seconds',
|
|
20
|
+
'isdaily',
|
|
21
|
+
'isdwm',
|
|
22
|
+
'isintraday',
|
|
23
|
+
'isminutes',
|
|
24
|
+
'ismonthly',
|
|
25
|
+
'isseconds',
|
|
26
|
+
'isticks',
|
|
27
|
+
'isweekly',
|
|
28
|
+
'main_period',
|
|
29
|
+
'multiplier',
|
|
30
|
+
'period'
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
@lru_cache(maxsize=128)
|
|
34
|
+
def _process_tf(timeframe: str) -> tuple[str, int]:
|
|
35
|
+
"""
|
|
36
|
+
Process the timeframe string and return the modi fier and multiplier
|
|
37
|
+
|
|
38
|
+
:param timeframe: The timeframe string in TradingView format
|
|
39
|
+
:return: A tuple with the modifier and multiplier
|
|
40
|
+
:raises AssertionError: If the timeframe is invalid
|
|
41
|
+
"""
|
|
42
|
+
assert len(timeframe) > 0, "Invalid timeframe: empty string!"
|
|
43
|
+
|
|
44
|
+
# Simple minutes
|
|
45
|
+
if timeframe.isdigit():
|
|
46
|
+
_modifier = ''
|
|
47
|
+
_multiplier = int(timeframe)
|
|
48
|
+
|
|
49
|
+
# Multiplier and modifier
|
|
50
|
+
elif len(timeframe) > 1:
|
|
51
|
+
if not timeframe[-1].isdigit():
|
|
52
|
+
_modifier = timeframe[-1]
|
|
53
|
+
_multiplier = int(timeframe[:-1])
|
|
54
|
+
else:
|
|
55
|
+
raise AssertionError("Invalid timeframe format!")
|
|
56
|
+
|
|
57
|
+
# Just a single character
|
|
58
|
+
else:
|
|
59
|
+
_modifier = timeframe
|
|
60
|
+
_multiplier = 1
|
|
61
|
+
|
|
62
|
+
assert _modifier in ('', 'T', 'S', 'D', 'W', 'M'), "Invalid timeframe: wrong modifier!"
|
|
63
|
+
assert _multiplier > 0, "Invalid timeframe: wrong multiplier!"
|
|
64
|
+
return _modifier, _multiplier
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
# noinspection PyProtectedMember
|
|
68
|
+
def _is_new_session(current_dt: datetime, prev_dt: datetime | None = None, tf_sec: int | None = None) -> bool:
|
|
69
|
+
"""
|
|
70
|
+
Check if current bar starts a new session.
|
|
71
|
+
|
|
72
|
+
:param current_dt: Current candle datetime (in local exchange timezone)
|
|
73
|
+
:param prev_dt: Previous candle datetime (in local exchange timezone)
|
|
74
|
+
:param tf_sec: Timeframe width in seconds
|
|
75
|
+
:return: True if this is the first candle of a new session
|
|
76
|
+
"""
|
|
77
|
+
if tf_sec is None:
|
|
78
|
+
tf_sec: int = in_seconds(_syminfo.period)
|
|
79
|
+
if prev_dt is None:
|
|
80
|
+
prev_dt: datetime = current_dt - timedelta(seconds=tf_sec)
|
|
81
|
+
|
|
82
|
+
current_weekday = current_dt.weekday()
|
|
83
|
+
prev_weekday = prev_dt.weekday()
|
|
84
|
+
|
|
85
|
+
# Get all possible session starts:
|
|
86
|
+
# 1. Current day sessions
|
|
87
|
+
# 2. If previous day different, then previous day's overnight sessions
|
|
88
|
+
session_starts = [
|
|
89
|
+
ss for day, ss in _syminfo._session_starts
|
|
90
|
+
if day == current_weekday
|
|
91
|
+
]
|
|
92
|
+
|
|
93
|
+
if prev_weekday != current_weekday:
|
|
94
|
+
prev_day_starts = [
|
|
95
|
+
(ss, se) for day, ss, se in _syminfo._opening_hours
|
|
96
|
+
if day == prev_weekday and se < ss # Only overnight sessions
|
|
97
|
+
]
|
|
98
|
+
# Add overnight session starts to check
|
|
99
|
+
for ss, se in prev_day_starts:
|
|
100
|
+
session_starts.append(ss)
|
|
101
|
+
|
|
102
|
+
# For each session start
|
|
103
|
+
for start_time in session_starts:
|
|
104
|
+
session_start = current_dt.replace(
|
|
105
|
+
hour=start_time.hour,
|
|
106
|
+
minute=start_time.minute,
|
|
107
|
+
second=start_time.second,
|
|
108
|
+
microsecond=0
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
# If it crosses the day boundary, we set it to the previous day
|
|
112
|
+
if prev_weekday != current_weekday and start_time > current_dt.time():
|
|
113
|
+
session_start = session_start - timedelta(days=1)
|
|
114
|
+
|
|
115
|
+
# If session starts in this bar
|
|
116
|
+
if (current_dt <= session_start < current_dt + timedelta(seconds=tf_sec) and
|
|
117
|
+
session_start > prev_dt):
|
|
118
|
+
return True
|
|
119
|
+
|
|
120
|
+
return False
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
@lru_cache(maxsize=128)
|
|
124
|
+
def from_seconds(seconds: int) -> str:
|
|
125
|
+
"""
|
|
126
|
+
Convert seconds to a timeframe
|
|
127
|
+
|
|
128
|
+
:param seconds: The seconds to convert
|
|
129
|
+
:return: The timeframe in TradingView format
|
|
130
|
+
"""
|
|
131
|
+
if seconds % (60 * 60 * 24 * 7 * 4) == 0:
|
|
132
|
+
return f"{seconds // (60 * 60 * 24 * 7 * 4)}M"
|
|
133
|
+
if seconds % (60 * 60 * 24 * 7) == 0:
|
|
134
|
+
return f"{seconds // (60 * 60 * 24 * 7)}W"
|
|
135
|
+
if seconds % (60 * 60 * 24) == 0:
|
|
136
|
+
return f"{seconds // (60 * 60 * 24)}D"
|
|
137
|
+
if seconds % 60 == 0:
|
|
138
|
+
return f"{seconds // 60}"
|
|
139
|
+
return f"{seconds}S"
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def in_seconds(timeframe: str | None = None) -> int:
|
|
143
|
+
"""
|
|
144
|
+
Convert the timeframe to seconds
|
|
145
|
+
|
|
146
|
+
:param timeframe: The timeframe to convert. If not provided or an empty string,
|
|
147
|
+
uses the current chart timeframe (Pine treats ``""`` as the chart timeframe).
|
|
148
|
+
:return: The timeframe in seconds
|
|
149
|
+
:raises ValueError: If the timeframe is invalid
|
|
150
|
+
"""
|
|
151
|
+
if not timeframe:
|
|
152
|
+
timeframe: str = str(_syminfo.period)
|
|
153
|
+
_modifier, _multiplier = _process_tf(timeframe)
|
|
154
|
+
if _modifier == 'S':
|
|
155
|
+
return _multiplier
|
|
156
|
+
elif _modifier == 'D':
|
|
157
|
+
return _multiplier * 60 * 60 * 24
|
|
158
|
+
elif _modifier == 'W':
|
|
159
|
+
return _multiplier * 60 * 60 * 24 * 7
|
|
160
|
+
elif _modifier == 'M':
|
|
161
|
+
return int(_multiplier * (60 * 60 * 24 * (365 / 12) + 3)) # Don't know why, but TV adds 3 secs here
|
|
162
|
+
elif _modifier == '':
|
|
163
|
+
return _multiplier * 60
|
|
164
|
+
else:
|
|
165
|
+
raise ValueError("Not supported timeframe!")
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
@module_property
|
|
169
|
+
def isdaily() -> bool:
|
|
170
|
+
"""
|
|
171
|
+
Check if the current timeframe is daily
|
|
172
|
+
|
|
173
|
+
:return: True if the current timeframe is daily
|
|
174
|
+
"""
|
|
175
|
+
modifier, _ = _process_tf(_syminfo.period)
|
|
176
|
+
return modifier == 'D'
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
@module_property
|
|
180
|
+
def isdwm() -> bool:
|
|
181
|
+
"""
|
|
182
|
+
Check if the current timeframe is intraday, daily, weekly or monthly
|
|
183
|
+
|
|
184
|
+
:return: True if the current timeframe is intraday, daily, weekly or monthly
|
|
185
|
+
"""
|
|
186
|
+
modifier, _ = _process_tf(_syminfo.period)
|
|
187
|
+
return modifier == 'D' or modifier == 'W' or modifier == 'M'
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
@module_property
|
|
191
|
+
def isintraday() -> bool:
|
|
192
|
+
"""
|
|
193
|
+
Check if the current timeframe is intraday
|
|
194
|
+
|
|
195
|
+
:return: True if the current timeframe is intraday
|
|
196
|
+
"""
|
|
197
|
+
modifier, _ = _process_tf(_syminfo.period)
|
|
198
|
+
return modifier == '' or modifier == 'S' or modifier == 'T'
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
@module_property
|
|
202
|
+
def isminutes() -> bool:
|
|
203
|
+
"""
|
|
204
|
+
Check if the current timeframe is minutes
|
|
205
|
+
|
|
206
|
+
:return: True if the current timeframe is minutes
|
|
207
|
+
"""
|
|
208
|
+
modifier, _ = _process_tf(_syminfo.period)
|
|
209
|
+
return modifier == ''
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
@module_property
|
|
213
|
+
def ismonthly() -> bool:
|
|
214
|
+
"""
|
|
215
|
+
Check if the current timeframe is monthly
|
|
216
|
+
|
|
217
|
+
:return: True if the current timeframe is monthly
|
|
218
|
+
"""
|
|
219
|
+
modifier, _ = _process_tf(_syminfo.period)
|
|
220
|
+
return modifier == 'M'
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
@module_property
|
|
224
|
+
def isseconds() -> bool:
|
|
225
|
+
"""
|
|
226
|
+
Check if the current timeframe is seconds
|
|
227
|
+
|
|
228
|
+
:return: True if the current timeframe is seconds
|
|
229
|
+
"""
|
|
230
|
+
modifier, _ = _process_tf(_syminfo.period)
|
|
231
|
+
return modifier == 'S'
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
@module_property
|
|
235
|
+
def isticks() -> bool:
|
|
236
|
+
"""
|
|
237
|
+
Check if the current timeframe is ticks
|
|
238
|
+
|
|
239
|
+
:return: True if the current timeframe is ticks
|
|
240
|
+
"""
|
|
241
|
+
modifier, _ = _process_tf(_syminfo.period)
|
|
242
|
+
return modifier == 'T'
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
@module_property
|
|
246
|
+
def isweekly() -> bool:
|
|
247
|
+
"""
|
|
248
|
+
Check if the current timeframe is weekly
|
|
249
|
+
|
|
250
|
+
:return: True if the current timeframe is weekly
|
|
251
|
+
"""
|
|
252
|
+
modifier, _ = _process_tf(_syminfo.period)
|
|
253
|
+
return modifier == 'W'
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
# noinspection PyProtectedMember
|
|
257
|
+
@module_property
|
|
258
|
+
def main_period() -> str:
|
|
259
|
+
"""
|
|
260
|
+
Get the main period
|
|
261
|
+
|
|
262
|
+
:return: The main period
|
|
263
|
+
"""
|
|
264
|
+
# Inside a request.security child ``_script`` is None, but the main period
|
|
265
|
+
# must still report the chart TF (propagated via ``_main_timeframe``), not the
|
|
266
|
+
# context's own period, so ``timeframe.change(timeframe.main_period)`` rolls
|
|
267
|
+
# over on chart bars rather than on every intrabar.
|
|
268
|
+
if lib._main_timeframe is not None:
|
|
269
|
+
return lib._main_timeframe
|
|
270
|
+
if lib._script is None:
|
|
271
|
+
return str(_syminfo.period)
|
|
272
|
+
return lib._script.timeframe or str(_syminfo.period)
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
@module_property
|
|
276
|
+
def multiplier() -> int:
|
|
277
|
+
"""
|
|
278
|
+
Get the current timeframe multiplier
|
|
279
|
+
|
|
280
|
+
:return: The current timeframe multiplier
|
|
281
|
+
"""
|
|
282
|
+
_, _multiplier = _process_tf(_syminfo.period)
|
|
283
|
+
return _multiplier
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
@module_property
|
|
287
|
+
def period() -> str:
|
|
288
|
+
"""
|
|
289
|
+
Get the current period
|
|
290
|
+
|
|
291
|
+
:return: The current period
|
|
292
|
+
"""
|
|
293
|
+
return str(_syminfo.period)
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
from ..types.volume_row import VolumeRow
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
# noinspection PyShadowingBuiltins
|
|
5
|
+
def up_price(id: VolumeRow) -> float:
|
|
6
|
+
"""
|
|
7
|
+
Upper price boundary of the row.
|
|
8
|
+
|
|
9
|
+
:param id: VolumeRow object
|
|
10
|
+
:return: Upper price
|
|
11
|
+
"""
|
|
12
|
+
return id.up_price()
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
# noinspection PyShadowingBuiltins
|
|
16
|
+
def down_price(id: VolumeRow) -> float:
|
|
17
|
+
"""
|
|
18
|
+
Lower price boundary of the row.
|
|
19
|
+
|
|
20
|
+
:param id: VolumeRow object
|
|
21
|
+
:return: Lower price
|
|
22
|
+
"""
|
|
23
|
+
return id.down_price()
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
# noinspection PyShadowingBuiltins
|
|
27
|
+
def buy_volume(id: VolumeRow) -> float:
|
|
28
|
+
"""
|
|
29
|
+
Buy volume for this row.
|
|
30
|
+
|
|
31
|
+
:param id: VolumeRow object
|
|
32
|
+
:return: Buy volume
|
|
33
|
+
"""
|
|
34
|
+
return id.buy_volume()
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
# noinspection PyShadowingBuiltins
|
|
38
|
+
def sell_volume(id: VolumeRow) -> float:
|
|
39
|
+
"""
|
|
40
|
+
Sell volume for this row.
|
|
41
|
+
|
|
42
|
+
:param id: VolumeRow object
|
|
43
|
+
:return: Sell volume
|
|
44
|
+
"""
|
|
45
|
+
return id.sell_volume()
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
# noinspection PyShadowingBuiltins
|
|
49
|
+
def delta(id: VolumeRow) -> float:
|
|
50
|
+
"""
|
|
51
|
+
Volume delta (buy - sell) for this row.
|
|
52
|
+
|
|
53
|
+
:param id: VolumeRow object
|
|
54
|
+
:return: Volume delta
|
|
55
|
+
"""
|
|
56
|
+
return id.delta()
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
# noinspection PyShadowingBuiltins
|
|
60
|
+
def total_volume(id: VolumeRow) -> float:
|
|
61
|
+
"""
|
|
62
|
+
Total volume for this row.
|
|
63
|
+
|
|
64
|
+
:param id: VolumeRow object
|
|
65
|
+
:return: Total volume
|
|
66
|
+
"""
|
|
67
|
+
return id.total_volume()
|
pynecore/lib/xloc.py
ADDED
pynecore/lib/yloc.py
ADDED
|
File without changes
|