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/session.py
ADDED
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
from datetime import datetime, timedelta
|
|
2
|
+
|
|
3
|
+
from ..types.session import Session
|
|
4
|
+
|
|
5
|
+
from ..core.module_property import module_property
|
|
6
|
+
|
|
7
|
+
from . import syminfo
|
|
8
|
+
from . import timeframe
|
|
9
|
+
from .. import lib
|
|
10
|
+
|
|
11
|
+
__all__ = [
|
|
12
|
+
"regular",
|
|
13
|
+
"extended",
|
|
14
|
+
"isfirstbar_regular",
|
|
15
|
+
"isfirstbar",
|
|
16
|
+
"islastbar_regular",
|
|
17
|
+
"islastbar",
|
|
18
|
+
"ismarket",
|
|
19
|
+
"ispremarket",
|
|
20
|
+
"ispostmarket"
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
#
|
|
24
|
+
# Constants
|
|
25
|
+
#
|
|
26
|
+
|
|
27
|
+
regular = Session('regular')
|
|
28
|
+
extended = Session('extended')
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
#
|
|
32
|
+
# Functions
|
|
33
|
+
#
|
|
34
|
+
|
|
35
|
+
def _is_in_session(opening_hours, dt: datetime, tf_sec: int) -> bool:
|
|
36
|
+
"""
|
|
37
|
+
Check if a candle overlaps any interval in the given opening_hours list.
|
|
38
|
+
|
|
39
|
+
Pure function: takes the calendar data explicitly so live-runtime callers
|
|
40
|
+
(framework live_runner, broker plugin watchdogs) do not have to depend on
|
|
41
|
+
the global ``lib.syminfo`` state. The list contains ``SymInfoInterval``
|
|
42
|
+
tuples ``(day, start_time, end_time)`` where ``day`` is Python weekday
|
|
43
|
+
(0=Mon..6=Sun) and the times are in the symbol's source timezone.
|
|
44
|
+
|
|
45
|
+
Slot-aware: returns True when the ``[dt, dt+tf_sec)`` candle window has a
|
|
46
|
+
positive-duration overlap with a session. For point-in-time "is the market
|
|
47
|
+
open right now?" decisions, use :func:`_is_point_in_session` instead.
|
|
48
|
+
|
|
49
|
+
Overnight sessions are handled by inspecting both the current weekday
|
|
50
|
+
interval and any previous-weekday interval whose end crosses midnight,
|
|
51
|
+
so a post-midnight candle still matches when the calendar encodes the
|
|
52
|
+
overnight wrap under its source-side start weekday.
|
|
53
|
+
|
|
54
|
+
:param opening_hours: Iterable of ``SymInfoInterval``-like tuples.
|
|
55
|
+
:param dt: Start datetime of the candle (must be in the same timezone the
|
|
56
|
+
opening_hours times are expressed in).
|
|
57
|
+
:param tf_sec: Timeframe in seconds.
|
|
58
|
+
:return: True if the candle overlaps any session, else False.
|
|
59
|
+
"""
|
|
60
|
+
candle_start = dt
|
|
61
|
+
candle_end = dt + timedelta(seconds=tf_sec)
|
|
62
|
+
weekday = dt.weekday()
|
|
63
|
+
prev_weekday = (weekday - 1) % 7
|
|
64
|
+
|
|
65
|
+
for day, ss, se in opening_hours:
|
|
66
|
+
# Overnight interval owned by the previous weekday wraps into today.
|
|
67
|
+
if day == prev_weekday and se < ss:
|
|
68
|
+
ssdt = dt.replace(hour=ss.hour, minute=ss.minute, second=ss.second,
|
|
69
|
+
microsecond=0) - timedelta(days=1)
|
|
70
|
+
sedt = ssdt.replace(hour=se.hour, minute=se.minute, second=se.second,
|
|
71
|
+
microsecond=0) + timedelta(days=1)
|
|
72
|
+
if candle_end > ssdt and candle_start < sedt:
|
|
73
|
+
return True
|
|
74
|
+
continue
|
|
75
|
+
if day != weekday:
|
|
76
|
+
continue
|
|
77
|
+
ssdt = dt.replace(hour=ss.hour, minute=ss.minute, second=ss.second, microsecond=0)
|
|
78
|
+
sedt = dt.replace(hour=se.hour, minute=se.minute, second=se.second, microsecond=0)
|
|
79
|
+
if sedt < ssdt: # Overnight session that started today
|
|
80
|
+
sedt += timedelta(days=1)
|
|
81
|
+
if candle_end > ssdt and candle_start < sedt:
|
|
82
|
+
return True
|
|
83
|
+
|
|
84
|
+
return False
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def _is_point_in_session(opening_hours, dt: datetime) -> bool:
|
|
88
|
+
"""
|
|
89
|
+
Check if a single instant ``dt`` falls inside any opening_hours interval.
|
|
90
|
+
|
|
91
|
+
Point-in-time variant of :func:`_is_in_session`: no timeframe span is
|
|
92
|
+
applied, so the result reflects "is the market open at this exact
|
|
93
|
+
moment?". Use this for reconnect/watchdog gates that consult wall-clock
|
|
94
|
+
now; use :func:`_is_in_session` for slot-aware decisions (bar synth,
|
|
95
|
+
REST recovery of a specific missing slot).
|
|
96
|
+
|
|
97
|
+
Overnight sessions are handled by inspecting both the current weekday
|
|
98
|
+
interval and any previous-weekday interval whose end crosses midnight.
|
|
99
|
+
|
|
100
|
+
:param opening_hours: Iterable of ``SymInfoInterval``-like tuples.
|
|
101
|
+
:param dt: Instant to check (must be in the same timezone the
|
|
102
|
+
opening_hours times are expressed in).
|
|
103
|
+
:return: True if ``dt`` is inside an open session, else False.
|
|
104
|
+
"""
|
|
105
|
+
weekday = dt.weekday()
|
|
106
|
+
prev_weekday = (weekday - 1) % 7
|
|
107
|
+
for day, ss, se in opening_hours:
|
|
108
|
+
# Overnight interval owned by the previous weekday wraps into today.
|
|
109
|
+
if day == prev_weekday and se < ss:
|
|
110
|
+
ssdt = dt.replace(hour=ss.hour, minute=ss.minute, second=ss.second,
|
|
111
|
+
microsecond=0) - timedelta(days=1)
|
|
112
|
+
sedt = ssdt.replace(hour=se.hour, minute=se.minute, second=se.second,
|
|
113
|
+
microsecond=0) + timedelta(days=1)
|
|
114
|
+
if ssdt <= dt < sedt:
|
|
115
|
+
return True
|
|
116
|
+
continue
|
|
117
|
+
if day != weekday:
|
|
118
|
+
continue
|
|
119
|
+
ssdt = dt.replace(hour=ss.hour, minute=ss.minute, second=ss.second, microsecond=0)
|
|
120
|
+
sedt = dt.replace(hour=se.hour, minute=se.minute, second=se.second, microsecond=0)
|
|
121
|
+
if sedt < ssdt: # Overnight session that started today
|
|
122
|
+
sedt += timedelta(days=1)
|
|
123
|
+
if ssdt <= dt < sedt:
|
|
124
|
+
return True
|
|
125
|
+
return False
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
# noinspection PyProtectedMember
|
|
129
|
+
def _check_session(dt: datetime, tf_sec: int) -> bool:
|
|
130
|
+
"""
|
|
131
|
+
Check if candle overlaps with any trading session.
|
|
132
|
+
|
|
133
|
+
:param dt: Start datetime of the candle
|
|
134
|
+
:param tf_sec: Timeframe in seconds
|
|
135
|
+
:return: True if candle overlaps with any session
|
|
136
|
+
"""
|
|
137
|
+
return _is_in_session(syminfo._opening_hours, dt, tf_sec)
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
#
|
|
141
|
+
# Module properties
|
|
142
|
+
#
|
|
143
|
+
|
|
144
|
+
# noinspection PyProtectedMember
|
|
145
|
+
@module_property
|
|
146
|
+
def isfirstbar_regular() -> bool:
|
|
147
|
+
"""
|
|
148
|
+
Check if the current candle is the first of the trading session.
|
|
149
|
+
The result is the same whether extended session information is used or not.
|
|
150
|
+
|
|
151
|
+
:return: True if the current candle is the first of the trading session
|
|
152
|
+
"""
|
|
153
|
+
tf_sec = timeframe.in_seconds(syminfo.period)
|
|
154
|
+
for ss in syminfo._session_starts:
|
|
155
|
+
if ss.day == lib._datetime.weekday():
|
|
156
|
+
ssdt = lib._datetime.replace(hour=ss.time.hour, minute=ss.time.minute, second=ss.time.second,
|
|
157
|
+
microsecond=ss.time.microsecond)
|
|
158
|
+
if lib._datetime <= ssdt < lib._datetime + timedelta(seconds=tf_sec):
|
|
159
|
+
return True
|
|
160
|
+
return False
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
# noinspection PyProtectedMember
|
|
164
|
+
# TODO: implement this when extended session will be supported
|
|
165
|
+
@module_property
|
|
166
|
+
def isfirstbar() -> bool:
|
|
167
|
+
"""
|
|
168
|
+
Check if the current candle is the first of the trading session.
|
|
169
|
+
If extended session information is used, only returns true on the first bar of the pre-market bars.
|
|
170
|
+
NOTE: extended session information is not yet supported.
|
|
171
|
+
|
|
172
|
+
:return: True if the current candle is the first of the trading session
|
|
173
|
+
"""
|
|
174
|
+
# TODO: support pre market sessions
|
|
175
|
+
tf_sec = timeframe.in_seconds(syminfo.period)
|
|
176
|
+
for ss in syminfo._session_starts:
|
|
177
|
+
if ss.day == lib._datetime.weekday():
|
|
178
|
+
ssdt = lib._datetime.replace(hour=ss.time.hour, minute=ss.time.minute, second=ss.time.second,
|
|
179
|
+
microsecond=ss.time.microsecond)
|
|
180
|
+
if lib._datetime <= ssdt < lib._datetime + timedelta(seconds=tf_sec):
|
|
181
|
+
return True
|
|
182
|
+
return False
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
# noinspection PyProtectedMember
|
|
186
|
+
@module_property
|
|
187
|
+
def islastbar_regular() -> bool:
|
|
188
|
+
"""
|
|
189
|
+
Check if the current candle is the last of the trading session.
|
|
190
|
+
The result is the same whether extended session information is used or not.
|
|
191
|
+
|
|
192
|
+
:return: True if the current candle is the last of the trading session
|
|
193
|
+
"""
|
|
194
|
+
tf_sec = timeframe.in_seconds(syminfo.period)
|
|
195
|
+
for se in syminfo._session_ends:
|
|
196
|
+
if se.day == lib._datetime.weekday():
|
|
197
|
+
sedt = lib._datetime.replace(hour=se.time.hour, minute=se.time.minute, second=se.time.second,
|
|
198
|
+
microsecond=se.time.microsecond)
|
|
199
|
+
# A session end at/before the bar's start denotes the day boundary
|
|
200
|
+
# (00:00 = 24:00 for 24/7 markets); roll it to the next day so it
|
|
201
|
+
# lands on the closing bar's end instead of the day's own start.
|
|
202
|
+
if sedt <= lib._datetime:
|
|
203
|
+
sedt += timedelta(days=1)
|
|
204
|
+
if lib._datetime < sedt <= lib._datetime + timedelta(seconds=tf_sec):
|
|
205
|
+
return True
|
|
206
|
+
return False
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
# noinspection PyProtectedMember
|
|
210
|
+
@module_property
|
|
211
|
+
def islastbar() -> bool:
|
|
212
|
+
"""
|
|
213
|
+
Check if the current candle is the last of the trading session.
|
|
214
|
+
If extended session information is used, only returns true on the last bar of the post-market bars.
|
|
215
|
+
NOTE: extended session information is not yet supported.
|
|
216
|
+
|
|
217
|
+
:return: True if the current candle is the last of the trading session
|
|
218
|
+
"""
|
|
219
|
+
tf_sec = timeframe.in_seconds(syminfo.period)
|
|
220
|
+
for se in syminfo._session_ends:
|
|
221
|
+
if se.day == lib._datetime.weekday():
|
|
222
|
+
sedt = lib._datetime.replace(hour=se.time.hour, minute=se.time.minute, second=se.time.second,
|
|
223
|
+
microsecond=se.time.microsecond)
|
|
224
|
+
# A session end at/before the bar's start denotes the day boundary
|
|
225
|
+
# (00:00 = 24:00 for 24/7 markets); roll it to the next day so it
|
|
226
|
+
# lands on the closing bar's end instead of the day's own start.
|
|
227
|
+
if sedt <= lib._datetime:
|
|
228
|
+
sedt += timedelta(days=1)
|
|
229
|
+
if lib._datetime < sedt <= lib._datetime + timedelta(seconds=tf_sec):
|
|
230
|
+
return True
|
|
231
|
+
return False
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
# noinspection PyProtectedMember
|
|
235
|
+
@module_property
|
|
236
|
+
def ismarket() -> bool:
|
|
237
|
+
"""
|
|
238
|
+
Check if the current candle is within a trading session.
|
|
239
|
+
|
|
240
|
+
:return: True if the current candle is within a trading session
|
|
241
|
+
"""
|
|
242
|
+
tf_sec = timeframe.in_seconds(syminfo.period)
|
|
243
|
+
return _check_session(lib._datetime, tf_sec)
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
@module_property
|
|
247
|
+
def ispremarket() -> bool:
|
|
248
|
+
"""
|
|
249
|
+
Check if the current candle is within the pre-market session.
|
|
250
|
+
It is not yet implemented.
|
|
251
|
+
|
|
252
|
+
:return: It is always False at the moment
|
|
253
|
+
"""
|
|
254
|
+
# TODO: implement this
|
|
255
|
+
return False
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
@module_property
|
|
259
|
+
def ispostmarket() -> bool:
|
|
260
|
+
"""
|
|
261
|
+
Check if the current candle is within the post-market session.
|
|
262
|
+
It is not yet implemented.
|
|
263
|
+
|
|
264
|
+
:return: It is always False at the moment
|
|
265
|
+
"""
|
|
266
|
+
# TODO: implement this
|
|
267
|
+
return False
|
pynecore/lib/session.pyi
ADDED
pynecore/lib/shape.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from ..types.shape import Shape
|
|
2
|
+
|
|
3
|
+
#
|
|
4
|
+
# Constants
|
|
5
|
+
#
|
|
6
|
+
|
|
7
|
+
arrowdown = Shape('shape_arrow_down')
|
|
8
|
+
arrowup = Shape('shape_arrow_up')
|
|
9
|
+
circle = Shape('shape_circle')
|
|
10
|
+
cross = Shape('shape_cross')
|
|
11
|
+
diamond = Shape('shape_diamond')
|
|
12
|
+
flag = Shape('shape_flag')
|
|
13
|
+
labeldown = Shape('shape_label_down')
|
|
14
|
+
labelup = Shape('shape_label_up')
|
|
15
|
+
square = Shape('shape_square')
|
|
16
|
+
triangledown = Shape('shape_triangle_down')
|
|
17
|
+
triangleup = Shape('shape_triangle_up')
|
|
18
|
+
xcross = Shape('shape_xcross')
|
pynecore/lib/size.py
ADDED
pynecore/lib/splits.py
ADDED