PyAlgoEngine 0.12.3__cp315-cp315-win_amd64.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.
- algo_engine/__infra__.pxd +3 -0
- algo_engine/__init__.pxd +3 -0
- algo_engine/__init__.py +107 -0
- algo_engine/apps/__init__.py +17 -0
- algo_engine/apps/backtest/__init__.py +20 -0
- algo_engine/apps/backtest/doc_server.py +328 -0
- algo_engine/apps/backtest/static/styles/dash.css +48 -0
- algo_engine/apps/backtest/templates/dash.html +20 -0
- algo_engine/apps/backtest/templates/index.html +40 -0
- algo_engine/apps/backtest/tester.py +252 -0
- algo_engine/apps/backtest/web_app.py +125 -0
- algo_engine/apps/bokeh_server.py +245 -0
- algo_engine/apps/demo/__init__.py +0 -0
- algo_engine/apps/demo/test.py +40 -0
- algo_engine/apps/sim_input/__init__.py +23 -0
- algo_engine/apps/sim_input/client.py +412 -0
- algo_engine/apps/sim_input/sim_keyboard.py +88 -0
- algo_engine/apps/sim_input/sim_mouse.py +137 -0
- algo_engine/apps/sim_input/window.py +162 -0
- algo_engine/backtest/__init__.py +19 -0
- algo_engine/backtest/__main__.py +51 -0
- algo_engine/backtest/metrics.py +179 -0
- algo_engine/backtest/replay.py +635 -0
- algo_engine/backtest/sim_match.py +506 -0
- algo_engine/base/__infra__.pxd +3 -0
- algo_engine/base/__init__.pxd +3 -0
- algo_engine/base/__init__.py +60 -0
- algo_engine/base/c_allocator_protocol.c +11608 -0
- algo_engine/base/c_allocator_protocol.cp315-win_amd64.pyd +0 -0
- algo_engine/base/c_allocator_protocol.pxd +24 -0
- algo_engine/base/c_allocator_protocol.pyi +68 -0
- algo_engine/base/c_allocator_protocol.pyx +111 -0
- algo_engine/base/c_intern_string.c +5908 -0
- algo_engine/base/c_intern_string.cp315-win_amd64.pyd +0 -0
- algo_engine/base/c_intern_string.pxd +14 -0
- algo_engine/base/c_intern_string.pyi +22 -0
- algo_engine/base/c_intern_string.pyx +17 -0
- algo_engine/base/c_market_data/__infra__.pxd +196 -0
- algo_engine/base/c_market_data/__init__.pxd +196 -0
- algo_engine/base/c_market_data/__init__.py +24 -0
- algo_engine/base/c_market_data/c_candlestick.c +18996 -0
- algo_engine/base/c_market_data/c_candlestick.cp315-win_amd64.pyd +0 -0
- algo_engine/base/c_market_data/c_candlestick.pxd +27 -0
- algo_engine/base/c_market_data/c_candlestick.pyi +217 -0
- algo_engine/base/c_market_data/c_candlestick.pyx +255 -0
- algo_engine/base/c_market_data/c_internal.c +14059 -0
- algo_engine/base/c_market_data/c_internal.cp315-win_amd64.pyd +0 -0
- algo_engine/base/c_market_data/c_internal.pxd +14 -0
- algo_engine/base/c_market_data/c_internal.pyi +47 -0
- algo_engine/base/c_market_data/c_internal.pyx +41 -0
- algo_engine/base/c_market_data/c_market_data.c +30420 -0
- algo_engine/base/c_market_data/c_market_data.cp315-win_amd64.pyd +0 -0
- algo_engine/base/c_market_data/c_market_data.h +1464 -0
- algo_engine/base/c_market_data/c_market_data.pxd +414 -0
- algo_engine/base/c_market_data/c_market_data.pyi +550 -0
- algo_engine/base/c_market_data/c_market_data.pyx +701 -0
- algo_engine/base/c_market_data/c_market_data_buffer.c +29407 -0
- algo_engine/base/c_market_data/c_market_data_buffer.cp315-win_amd64.pyd +0 -0
- algo_engine/base/c_market_data/c_market_data_buffer.h +941 -0
- algo_engine/base/c_market_data/c_market_data_buffer.pxd +143 -0
- algo_engine/base/c_market_data/c_market_data_buffer.pyi +355 -0
- algo_engine/base/c_market_data/c_market_data_buffer.pyx +571 -0
- algo_engine/base/c_market_data/c_market_data_config.h +29 -0
- algo_engine/base/c_market_data/c_tick.c +44303 -0
- algo_engine/base/c_market_data/c_tick.cp315-win_amd64.pyd +0 -0
- algo_engine/base/c_market_data/c_tick.pxd +53 -0
- algo_engine/base/c_market_data/c_tick.pyi +466 -0
- algo_engine/base/c_market_data/c_tick.pyx +673 -0
- algo_engine/base/c_market_data/c_trade_utils.c +28702 -0
- algo_engine/base/c_market_data/c_trade_utils.cp315-win_amd64.pyd +0 -0
- algo_engine/base/c_market_data/c_trade_utils.pxd +53 -0
- algo_engine/base/c_market_data/c_trade_utils.pyi +602 -0
- algo_engine/base/c_market_data/c_trade_utils.pyx +609 -0
- algo_engine/base/c_market_data/c_transaction.c +23558 -0
- algo_engine/base/c_market_data/c_transaction.cp315-win_amd64.pyd +0 -0
- algo_engine/base/c_market_data/c_transaction.pxd +27 -0
- algo_engine/base/c_market_data/c_transaction.pyi +433 -0
- algo_engine/base/c_market_data/c_transaction.pyx +460 -0
- algo_engine/base/console_utils.py +1070 -0
- algo_engine/base/finance_decimal.py +258 -0
- algo_engine/base/telemetrics.py +18 -0
- algo_engine/engine/__infra__.pxd +10 -0
- algo_engine/engine/__init__.pxd +10 -0
- algo_engine/engine/__init__.py +40 -0
- algo_engine/engine/algo_engine.py +904 -0
- algo_engine/engine/c_event_engine.c +16325 -0
- algo_engine/engine/c_event_engine.cp315-win_amd64.pyd +0 -0
- algo_engine/engine/c_event_engine.pxd +25 -0
- algo_engine/engine/c_event_engine.pyi +68 -0
- algo_engine/engine/c_market_engine.c +24258 -0
- algo_engine/engine/c_market_engine.cp315-win_amd64.pyd +0 -0
- algo_engine/engine/c_market_engine.pxd +87 -0
- algo_engine/engine/c_market_engine.pyi +357 -0
- algo_engine/engine/event_engine.py +53 -0
- algo_engine/engine/trade_engine.py +2037 -0
- algo_engine/exchange_profile/__infra__.pxd +100 -0
- algo_engine/exchange_profile/__init__.pxd +100 -0
- algo_engine/exchange_profile/__init__.py +53 -0
- algo_engine/exchange_profile/c_ex_profile_base.c +87 -0
- algo_engine/exchange_profile/c_ex_profile_base.h +1204 -0
- algo_engine/exchange_profile/c_ex_profile_cn.c +968 -0
- algo_engine/exchange_profile/c_ex_profile_cn.h +39 -0
- algo_engine/exchange_profile/c_exchange_profile.c +52375 -0
- algo_engine/exchange_profile/c_exchange_profile.cp315-win_amd64.pyd +0 -0
- algo_engine/exchange_profile/c_exchange_profile.pxd +336 -0
- algo_engine/exchange_profile/c_exchange_profile.pyi +883 -0
- algo_engine/exchange_profile/c_exchange_profile.pyx +1495 -0
- algo_engine/exchange_profile/c_profile_cn.c +7798 -0
- algo_engine/exchange_profile/c_profile_cn.cp315-win_amd64.pyd +0 -0
- algo_engine/exchange_profile/c_profile_cn.pxd +1 -0
- algo_engine/exchange_profile/c_profile_cn.pyi +3 -0
- algo_engine/exchange_profile/c_profile_cn.pyx +1 -0
- algo_engine/exchange_profile/c_profile_default.c +7798 -0
- algo_engine/exchange_profile/c_profile_default.cp315-win_amd64.pyd +0 -0
- algo_engine/exchange_profile/c_profile_default.pxd +1 -0
- algo_engine/exchange_profile/c_profile_default.pyi +3 -0
- algo_engine/exchange_profile/c_profile_default.pyx +1 -0
- algo_engine/exchange_profile/c_profile_dispatcher.c +7798 -0
- algo_engine/exchange_profile/c_profile_dispatcher.cp315-win_amd64.pyd +0 -0
- algo_engine/exchange_profile/c_profile_dispatcher.pxd +1 -0
- algo_engine/exchange_profile/c_profile_dispatcher.pyi +3 -0
- algo_engine/exchange_profile/c_profile_dispatcher.pyx +1 -0
- algo_engine/includes/algo_engine/base/c_allocator_protocol.c +11608 -0
- algo_engine/includes/algo_engine/base/c_intern_string.c +5908 -0
- algo_engine/includes/algo_engine/base/c_market_data/c_candlestick.c +18996 -0
- algo_engine/includes/algo_engine/base/c_market_data/c_internal.c +14059 -0
- algo_engine/includes/algo_engine/base/c_market_data/c_market_data.c +30420 -0
- algo_engine/includes/algo_engine/base/c_market_data/c_market_data.h +1464 -0
- algo_engine/includes/algo_engine/base/c_market_data/c_market_data_buffer.c +29407 -0
- algo_engine/includes/algo_engine/base/c_market_data/c_market_data_buffer.h +941 -0
- algo_engine/includes/algo_engine/base/c_market_data/c_market_data_config.h +29 -0
- algo_engine/includes/algo_engine/base/c_market_data/c_tick.c +44303 -0
- algo_engine/includes/algo_engine/base/c_market_data/c_trade_utils.c +28702 -0
- algo_engine/includes/algo_engine/base/c_market_data/c_transaction.c +23558 -0
- algo_engine/includes/algo_engine/engine/c_event_engine.c +16325 -0
- algo_engine/includes/algo_engine/engine/c_market_engine.c +24258 -0
- algo_engine/includes/algo_engine/exchange_profile/c_ex_profile_base.c +87 -0
- algo_engine/includes/algo_engine/exchange_profile/c_ex_profile_base.h +1204 -0
- algo_engine/includes/algo_engine/exchange_profile/c_ex_profile_cn.c +968 -0
- algo_engine/includes/algo_engine/exchange_profile/c_ex_profile_cn.h +39 -0
- algo_engine/includes/algo_engine/exchange_profile/c_exchange_profile.c +52375 -0
- algo_engine/includes/algo_engine/exchange_profile/c_profile_cn.c +7798 -0
- algo_engine/includes/algo_engine/exchange_profile/c_profile_default.c +7798 -0
- algo_engine/includes/algo_engine/exchange_profile/c_profile_dispatcher.c +7798 -0
- algo_engine/monitor/__init__.py +15 -0
- algo_engine/monitor/advanced_data_interface.py +334 -0
- algo_engine/strategy/__init__.py +44 -0
- algo_engine/strategy/strategy_engine.py +441 -0
- algo_engine/utils/__init__.py +3 -0
- algo_engine/utils/commit_regularizer.py +49 -0
- algo_engine/utils/data_utils.py +296 -0
- pyalgoengine-0.12.3.dist-info/METADATA +142 -0
- pyalgoengine-0.12.3.dist-info/RECORD +156 -0
- pyalgoengine-0.12.3.dist-info/WHEEL +5 -0
- pyalgoengine-0.12.3.dist-info/licenses/LICENSE +21 -0
- pyalgoengine-0.12.3.dist-info/top_level.txt +2 -0
|
Binary file
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
from libcpp cimport bool as c_bool
|
|
2
|
+
|
|
3
|
+
from cpython.datetime cimport datetime as py_datetime, date as py_date, time as py_time
|
|
4
|
+
from libc.stdint cimport uint8_t, uint16_t, uint32_t, int64_t, uintptr_t
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
cdef extern from "algo_engine/exchange_profile/c_ex_profile_base.h":
|
|
8
|
+
const double SECONDS_PER_DAY
|
|
9
|
+
const double SECONDS_PER_HOUR
|
|
10
|
+
const double SECONDS_PER_MINUTE
|
|
11
|
+
const double NANOS_PER_SECOND
|
|
12
|
+
const double MICROS_PER_SECOND
|
|
13
|
+
const int64_t UNIX_EPOCH_ORDINAL
|
|
14
|
+
const size_t EX_PROFILE_ID_SIZE
|
|
15
|
+
const size_t EX_PROFILE_MIN_YEAR
|
|
16
|
+
const size_t EX_PROFILE_MAX_YEAR
|
|
17
|
+
const uint32_t EX_PROFILE_MAX_ORDINAL
|
|
18
|
+
|
|
19
|
+
const uint8_t DAYS_IN_MONTH_TABLE[12]
|
|
20
|
+
const uint16_t DAYS_BEFORE_MONTH_TABLE[12]
|
|
21
|
+
|
|
22
|
+
ctypedef enum session_type:
|
|
23
|
+
SESSION_TYPE_NON_TRADING
|
|
24
|
+
SESSION_TYPE_NORMINAL
|
|
25
|
+
SESSION_TYPE_SUSPENDED
|
|
26
|
+
SESSION_TYPE_HALF_DAY
|
|
27
|
+
SESSION_TYPE_CIRCUIT_BREAK
|
|
28
|
+
|
|
29
|
+
ctypedef enum session_phase:
|
|
30
|
+
SESSION_PHASE_UNKNOWN
|
|
31
|
+
SESSION_PHASE_PREOPEN
|
|
32
|
+
SESSION_PHASE_OPEN_AUCTION
|
|
33
|
+
SESSION_PHASE_CONTINUOUS
|
|
34
|
+
SESSION_PHASE_BREAK
|
|
35
|
+
SESSION_PHASE_SUSPENDED
|
|
36
|
+
SESSION_PHASE_CLOSE_AUCTION
|
|
37
|
+
SESSION_PHASE_CLOSED
|
|
38
|
+
SESSION_PHASE_MASK
|
|
39
|
+
|
|
40
|
+
ctypedef enum auction_phase:
|
|
41
|
+
AUCTION_PHASE_ACTIVE
|
|
42
|
+
AUCTION_PHASE_NO_CANCEL
|
|
43
|
+
AUCTION_PHASE_FROZEN
|
|
44
|
+
AUCTION_PHASE_UNCROSSING
|
|
45
|
+
AUCTION_PHASE_DONE
|
|
46
|
+
AUCTION_PHASE_MASK
|
|
47
|
+
|
|
48
|
+
ctypedef struct session_time_t:
|
|
49
|
+
double elapsed_seconds
|
|
50
|
+
uint32_t nanosecond
|
|
51
|
+
uint8_t hour
|
|
52
|
+
uint8_t minute
|
|
53
|
+
uint8_t second
|
|
54
|
+
uint8_t phase
|
|
55
|
+
|
|
56
|
+
ctypedef struct session_date_t:
|
|
57
|
+
uint16_t year
|
|
58
|
+
uint8_t month
|
|
59
|
+
uint8_t day
|
|
60
|
+
session_type stype
|
|
61
|
+
|
|
62
|
+
ctypedef struct session_datetime_t:
|
|
63
|
+
session_time_t time
|
|
64
|
+
session_date_t date
|
|
65
|
+
double unix_ts
|
|
66
|
+
double ts
|
|
67
|
+
uint32_t ordinal
|
|
68
|
+
|
|
69
|
+
ctypedef struct session_time_range_t:
|
|
70
|
+
session_time_t start
|
|
71
|
+
session_time_t end
|
|
72
|
+
double elapsed_seconds
|
|
73
|
+
|
|
74
|
+
ctypedef struct session_date_range_t:
|
|
75
|
+
session_date_t start
|
|
76
|
+
session_date_t end
|
|
77
|
+
size_t n_days
|
|
78
|
+
session_date_t dates[]
|
|
79
|
+
|
|
80
|
+
ctypedef struct call_auction:
|
|
81
|
+
session_time_t auction_start
|
|
82
|
+
const session_time_range_t* active
|
|
83
|
+
const session_time_range_t* no_cancel
|
|
84
|
+
const session_time_range_t* frozen
|
|
85
|
+
session_time_t uncross
|
|
86
|
+
session_time_t auction_end
|
|
87
|
+
|
|
88
|
+
ctypedef struct session_break:
|
|
89
|
+
session_time_t break_start
|
|
90
|
+
session_time_t break_end
|
|
91
|
+
double break_start_ts
|
|
92
|
+
double break_end_ts
|
|
93
|
+
double break_length_seconds
|
|
94
|
+
session_break* next
|
|
95
|
+
|
|
96
|
+
ctypedef void (*ex_profile_on_activate_func)(const exchange_profile* profile) noexcept nogil
|
|
97
|
+
ctypedef void (*ex_profile_on_deactivate_func)(const exchange_profile* profile) noexcept nogil
|
|
98
|
+
ctypedef session_date_range_t* (*ex_profile_trade_calendar_func)(const session_date_t* start_date, const session_date_t* end_date) noexcept nogil
|
|
99
|
+
ctypedef auction_phase (*ex_profile_resolve_auction_phase_func)(double ts) noexcept nogil
|
|
100
|
+
ctypedef session_phase (*ex_profile_resolve_session_phase_func)(double ts) noexcept nogil
|
|
101
|
+
ctypedef session_type (*ex_profile_resolve_session_type_func)(uint16_t year, uint8_t month, uint8_t day) noexcept nogil
|
|
102
|
+
|
|
103
|
+
ctypedef struct exchange_profile:
|
|
104
|
+
char profile_id[EX_PROFILE_ID_SIZE]
|
|
105
|
+
session_time_t session_start
|
|
106
|
+
session_time_t session_end
|
|
107
|
+
double session_start_ts
|
|
108
|
+
double session_end_ts
|
|
109
|
+
double session_length_seconds
|
|
110
|
+
const call_auction* open_call_auction
|
|
111
|
+
const call_auction* close_call_auction
|
|
112
|
+
const session_break* session_breaks
|
|
113
|
+
const char* time_zone
|
|
114
|
+
double tz_offset_seconds
|
|
115
|
+
# Function pointers for exchange-specific logic
|
|
116
|
+
ex_profile_on_activate_func on_activate
|
|
117
|
+
ex_profile_on_deactivate_func on_deactivate
|
|
118
|
+
ex_profile_trade_calendar_func trade_calendar
|
|
119
|
+
ex_profile_resolve_auction_phase_func resolve_auction_phase
|
|
120
|
+
ex_profile_resolve_session_phase_func resolve_session_phase
|
|
121
|
+
ex_profile_resolve_session_type_func resolve_session_type
|
|
122
|
+
|
|
123
|
+
ctypedef void (*ex_profile_activation_callback)(const exchange_profile* previous_profile, const exchange_profile* new_profile, void* user_data) noexcept
|
|
124
|
+
|
|
125
|
+
ctypedef struct ex_profile_activation_listener:
|
|
126
|
+
uintptr_t listener_id;
|
|
127
|
+
ex_profile_activation_callback callback;
|
|
128
|
+
void* user_data;
|
|
129
|
+
ex_profile_activation_listener* next;
|
|
130
|
+
|
|
131
|
+
extern const exchange_profile* EX_PROFILE
|
|
132
|
+
extern const session_date_range_t* EX_TRADE_CALENDAR_CACHE
|
|
133
|
+
extern ex_profile_activation_listener* EX_PROFILE_ACTIVATION_LISTENERS
|
|
134
|
+
|
|
135
|
+
extern const exchange_profile EX_PROFILE_DEFAULT;
|
|
136
|
+
|
|
137
|
+
double c_utc_offset_seconds() noexcept nogil
|
|
138
|
+
int c_ex_profile_time_compare(const void* t1, const void* t2) noexcept nogil
|
|
139
|
+
double c_ex_profile_time_to_ts(uint8_t hour, uint8_t minute, uint8_t second, uint32_t nanosecond) noexcept nogil
|
|
140
|
+
double c_ex_profile_unix_to_ts(double unix_ts) noexcept nogil
|
|
141
|
+
double c_ex_profile_ts_to_elapsed(double ts) noexcept nogil
|
|
142
|
+
|
|
143
|
+
int c_ex_profile_date_compare(const void* d1, const void* d2) noexcept nogil
|
|
144
|
+
uint32_t c_ex_profile_days_before_year(uint16_t year) noexcept nogil
|
|
145
|
+
c_bool c_ex_profile_is_leap_year(uint16_t year) noexcept nogil
|
|
146
|
+
uint8_t c_ex_profile_days_in_month(uint16_t year, uint8_t month) noexcept nogil
|
|
147
|
+
c_bool c_ex_profile_date_is_valid(const session_date_t* date) noexcept nogil
|
|
148
|
+
uint32_t c_ex_profile_date_to_ordinal(const session_date_t* date) noexcept nogil
|
|
149
|
+
uint32_t c_ex_profile_unix_to_ordinal(double unix_ts, double tz_offset_seconds) noexcept nogil
|
|
150
|
+
int c_ex_profile_date_from_ordinal(uint32_t ordinal, session_date_t* out) noexcept nogil
|
|
151
|
+
int c_ex_profile_date_from_year_day(uint16_t year, uint32_t day_of_year, session_date_t* out) noexcept nogil
|
|
152
|
+
int c_ex_profile_next_day(const session_date_t* date, session_date_t* out) noexcept nogil
|
|
153
|
+
int c_ex_profile_previous_day(const session_date_t* date, session_date_t* out) noexcept nogil
|
|
154
|
+
int c_ex_profile_days_after(const session_date_t* date, size_t days_after, session_date_t* out) noexcept nogil
|
|
155
|
+
int c_ex_profile_days_before(const session_date_t* date, size_t days_before, session_date_t* out) noexcept nogil
|
|
156
|
+
c_bool c_ex_profile_is_weekend(const session_date_t* date) noexcept nogil
|
|
157
|
+
session_date_range_t* c_ex_profile_date_range(const session_date_t* start_date, const session_date_t* end_date) noexcept nogil
|
|
158
|
+
|
|
159
|
+
void c_ex_profile_activate(const exchange_profile* profile) noexcept nogil
|
|
160
|
+
uintptr_t c_ex_profile_register_activation_listener(ex_profile_activation_callback callback, void* user_data)
|
|
161
|
+
int c_ex_profile_deregister_activation_listener(uintptr_t listener_id)
|
|
162
|
+
|
|
163
|
+
session_time_t* c_ex_profile_session_time_new(uint8_t hour, uint8_t minute, uint8_t second, uint32_t nanosecond) noexcept nogil
|
|
164
|
+
int c_ex_profile_session_time_from_ts(double ts, session_time_t* out) noexcept nogil
|
|
165
|
+
int c_ex_profile_session_time_from_unix(double unix_ts, session_time_t* out) noexcept nogil
|
|
166
|
+
session_time_range_t* c_ex_profile_session_trange_between_time(const session_time_t* start_time, const session_time_t* end_time) noexcept nogil
|
|
167
|
+
session_time_range_t* c_ex_profile_session_trange_between_unix(double start_unix_ts, double end_unix_ts) noexcept nogil
|
|
168
|
+
|
|
169
|
+
session_date_t* c_ex_profile_session_date_new(uint16_t year, uint8_t month, uint8_t day) noexcept nogil
|
|
170
|
+
int c_ex_profile_session_date_init(session_date_t* date, uint16_t year, uint8_t month, uint8_t day) noexcept nogil
|
|
171
|
+
int c_ex_profile_session_date_from_unix(double unix_ts, session_date_t* out) noexcept nogil
|
|
172
|
+
double c_ex_profile_session_date_to_unix(const session_date_t* date) noexcept nogil
|
|
173
|
+
size_t c_ex_profile_session_date_index(const session_date_t* date, const session_date_range_t* drange) noexcept nogil
|
|
174
|
+
size_t c_ex_profile_session_ymd_index(uint16_t year, uint8_t month, uint8_t day, const session_date_t* date_array, size_t n_days) noexcept nogil
|
|
175
|
+
session_date_range_t* c_ex_profile_session_drange_between(const session_date_t* start_date, const session_date_t* end_date) noexcept nogil
|
|
176
|
+
int c_ex_profile_session_trading_days_before(const session_date_t* market_date, size_t days, session_date_t* out) noexcept nogil
|
|
177
|
+
int c_ex_profile_session_trading_days_after(const session_date_t* market_date, size_t days, session_date_t* out) noexcept nogil
|
|
178
|
+
int c_ex_profile_nearest_trading_date(const session_date_t* market_date, c_bool previous, session_date_t* out) noexcept nogil
|
|
179
|
+
c_bool c_ex_profile_is_trading_day(const session_date_t* market_date) noexcept nogil
|
|
180
|
+
int c_ex_profile_trading_days_between(const session_date_t* start_date, const session_date_t* end_date, ssize_t* out) noexcept nogil
|
|
181
|
+
|
|
182
|
+
int c_ex_profile_session_datetime_from_unix(double unix_ts, session_datetime_t* out) noexcept nogil
|
|
183
|
+
int c_ex_profile_session_datetime_update(session_datetime_t* dt, double unix_ts) noexcept nogil
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
cdef extern from "algo_engine/exchange_profile/c_ex_profile_cn.h":
|
|
187
|
+
extern const exchange_profile EX_PROFILE_CN
|
|
188
|
+
|
|
189
|
+
c_bool c_ex_profile_cn_date_in_list(const session_date_t* date, const session_date_t* date_list, size_t n) noexcept nogil
|
|
190
|
+
c_bool c_ex_profile_cn_is_holiday(const session_date_t* date) noexcept nogil
|
|
191
|
+
c_bool c_ex_profile_cn_is_circuit_break(const session_date_t* date) noexcept nogil
|
|
192
|
+
void c_ex_profile_cn_get_calendar() noexcept nogil
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
cpdef double local_utc_offset_seconds()
|
|
196
|
+
cdef int c_ex_profile_unix_to_datetime(double unix_ts, session_datetime_t* out)
|
|
197
|
+
cpdef py_datetime unix_to_datetime(double unix_ts)
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
cdef class SessionTime:
|
|
201
|
+
cdef const session_time_t* header
|
|
202
|
+
cdef bint owner
|
|
203
|
+
|
|
204
|
+
@staticmethod
|
|
205
|
+
cdef SessionTime c_from_header(const session_time_t* header, bint owner)
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
cdef class SessionTimeRange:
|
|
209
|
+
cdef const session_time_range_t* header
|
|
210
|
+
cdef bint owner
|
|
211
|
+
|
|
212
|
+
cdef readonly SessionTime start_time
|
|
213
|
+
cdef readonly SessionTime end_time
|
|
214
|
+
|
|
215
|
+
@staticmethod
|
|
216
|
+
cdef SessionTimeRange c_from_header(const session_time_range_t* header, bint owner)
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
cdef class SessionDate(py_date):
|
|
220
|
+
cdef const session_date_t* header
|
|
221
|
+
cdef bint owner
|
|
222
|
+
|
|
223
|
+
@staticmethod
|
|
224
|
+
cdef SessionDate c_from_header(const session_date_t* header, bint owner)
|
|
225
|
+
|
|
226
|
+
cdef const session_date_t* c_sync(self)
|
|
227
|
+
|
|
228
|
+
cpdef SessionDate fork(self)
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
cdef class SessionDateEx:
|
|
232
|
+
cdef const session_date_t* header
|
|
233
|
+
cdef bint owner
|
|
234
|
+
|
|
235
|
+
@staticmethod
|
|
236
|
+
cdef SessionDateEx c_from_header(const session_date_t* header, bint owner)
|
|
237
|
+
|
|
238
|
+
cpdef SessionDateEx fork(self)
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
cdef class SessionDateRange:
|
|
242
|
+
cdef const session_date_range_t* header
|
|
243
|
+
cdef bint owner
|
|
244
|
+
|
|
245
|
+
cdef readonly SessionDate start_date
|
|
246
|
+
cdef readonly SessionDate end_date
|
|
247
|
+
cdef readonly tuple dates
|
|
248
|
+
|
|
249
|
+
@staticmethod
|
|
250
|
+
cdef SessionDateRange c_from_header(const session_date_range_t* header, bint owner)
|
|
251
|
+
|
|
252
|
+
cpdef list to_list(self)
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
cdef class SessionDateTime:
|
|
256
|
+
cdef session_datetime_t* header
|
|
257
|
+
cdef bint owner
|
|
258
|
+
|
|
259
|
+
cdef readonly SessionTime time
|
|
260
|
+
cdef readonly SessionDateEx date
|
|
261
|
+
|
|
262
|
+
@staticmethod
|
|
263
|
+
cdef SessionDateTime c_from_header(session_datetime_t* header, bint owner=?)
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
cdef class CallAuction:
|
|
267
|
+
cdef const call_auction* header
|
|
268
|
+
|
|
269
|
+
@staticmethod
|
|
270
|
+
cdef CallAuction c_from_header(const call_auction* header)
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
cdef class SessionBreak:
|
|
274
|
+
cdef const session_break* header
|
|
275
|
+
|
|
276
|
+
@staticmethod
|
|
277
|
+
cdef SessionBreak c_from_header(const session_break* header)
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
cdef class ExchangeProfile:
|
|
281
|
+
cdef const exchange_profile* header
|
|
282
|
+
cdef uintptr_t listener_id
|
|
283
|
+
|
|
284
|
+
cdef readonly str profile_id
|
|
285
|
+
cdef readonly SessionTime session_start
|
|
286
|
+
cdef readonly SessionTime session_end
|
|
287
|
+
cdef readonly CallAuction open_call_auction
|
|
288
|
+
cdef readonly CallAuction close_call_auction
|
|
289
|
+
cdef readonly tuple[SessionBreak] session_breaks
|
|
290
|
+
cdef readonly object time_zone
|
|
291
|
+
|
|
292
|
+
@staticmethod
|
|
293
|
+
cdef ExchangeProfile c_new_bound_instance()
|
|
294
|
+
|
|
295
|
+
@staticmethod
|
|
296
|
+
cdef ExchangeProfile c_from_header(const exchange_profile* header)
|
|
297
|
+
|
|
298
|
+
@staticmethod
|
|
299
|
+
cdef void c_listener_adapter(const exchange_profile* previous_profile, const exchange_profile* new_profile, void* user_data) noexcept
|
|
300
|
+
|
|
301
|
+
cdef inline void c_bind(self, const exchange_profile* header)
|
|
302
|
+
|
|
303
|
+
cdef inline bint c_time_in_market_session(self, py_time t)
|
|
304
|
+
|
|
305
|
+
cdef inline bint c_timestamp_in_market_session(self, double unix_ts)
|
|
306
|
+
|
|
307
|
+
cdef inline bint c_timestamp_in_auction_session(self, double unix_ts)
|
|
308
|
+
|
|
309
|
+
cdef inline SessionDateRange c_trade_calendar(self, py_date start_date, py_date end_date)
|
|
310
|
+
|
|
311
|
+
cdef inline bint c_date_in_market_session(self, py_date market_date)
|
|
312
|
+
|
|
313
|
+
cdef inline py_datetime c_timestamp_to_datetime(self, double unix_ts)
|
|
314
|
+
|
|
315
|
+
cdef inline py_date c_timestamp_to_date(self, double unix_ts)
|
|
316
|
+
|
|
317
|
+
cdef inline double c_time_to_seconds(self, py_time t, bint break_adjusted)
|
|
318
|
+
|
|
319
|
+
cdef inline double c_timestamp_to_seconds(self, double t, bint break_adjusted)
|
|
320
|
+
|
|
321
|
+
cdef inline double c_break_adjusted(self, double ts)
|
|
322
|
+
|
|
323
|
+
cdef inline double c_trading_time_between(self, py_datetime start_time, py_datetime end_time)
|
|
324
|
+
|
|
325
|
+
cdef inline py_date c_trading_days_before(self, py_date market_date, size_t days)
|
|
326
|
+
|
|
327
|
+
cdef inline py_date c_trading_days_after(self, py_date market_date, size_t days)
|
|
328
|
+
|
|
329
|
+
cdef inline ssize_t c_trading_days_between(self, py_date start_date, py_date end_date)
|
|
330
|
+
|
|
331
|
+
cdef inline py_date c_nearest_trading_date(self, py_date market_date, bint previous)
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
cdef ExchangeProfile PROFILE
|
|
335
|
+
cdef ExchangeProfile PROFILE_DEFAULT
|
|
336
|
+
cdef ExchangeProfile PROFILE_CN
|