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,24 @@
|
|
|
1
|
+
from libcpp cimport bool as c_bool
|
|
2
|
+
|
|
3
|
+
from cbase.allocator_protocol cimport AllocatorConfigContext, allocator_protocol, heap_allocator, shm_allocator_ctx
|
|
4
|
+
|
|
5
|
+
cdef c_bool MD_CFG_LOCKED
|
|
6
|
+
cdef c_bool MD_CFG_SHARED
|
|
7
|
+
cdef c_bool MD_CFG_FREELIST
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
cdef class MDConfigContext(AllocatorConfigContext):
|
|
11
|
+
pass
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
cdef heap_allocator* HEAP_ALLOCATOR
|
|
15
|
+
cdef shm_allocator_ctx* SHM_ALLOCATOR
|
|
16
|
+
|
|
17
|
+
cdef allocator_protocol* MD_DEFAULT_ALLOCATOR
|
|
18
|
+
cdef allocator_protocol* MD_SHM_ALLOCATOR
|
|
19
|
+
cdef allocator_protocol* MD_HEAP_ALLOCATOR
|
|
20
|
+
|
|
21
|
+
cdef MDConfigContext MD_SHARED
|
|
22
|
+
cdef MDConfigContext MD_LOCKED
|
|
23
|
+
cdef MDConfigContext MD_LOCKFREE
|
|
24
|
+
cdef MDConfigContext MD_FREELIST
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
from cbase.allocator_protocol import AllocatorConfigContext
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class MDConfigContext(AllocatorConfigContext):
|
|
7
|
+
"""Market-data specific configuration context.
|
|
8
|
+
|
|
9
|
+
Extends ``AllocatorConfigContext`` to additionally update module-level
|
|
10
|
+
``MD_CFG_*`` globals, and binds to ``MD_DEFAULT_ALLOCATOR`` by default.
|
|
11
|
+
|
|
12
|
+
Accepted keyword arguments (in addition to those inherited):
|
|
13
|
+
|
|
14
|
+
* ``locked: bool`` — also updates ``MD_CFG_LOCKED``
|
|
15
|
+
* ``shared: bool`` — also updates ``MD_CFG_SHARED``
|
|
16
|
+
* ``freelist: bool`` — also updates ``MD_CFG_FREELIST``
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
def __init__(self, **kwargs: Any) -> None:
|
|
20
|
+
"""
|
|
21
|
+
Initialize the context with configuration changes.
|
|
22
|
+
|
|
23
|
+
Args:
|
|
24
|
+
**kwargs: Configuration key-value pairs to set temporarily
|
|
25
|
+
"""
|
|
26
|
+
...
|
|
27
|
+
|
|
28
|
+
def __or__(self, other: MDConfigContext) -> MDConfigContext:
|
|
29
|
+
"""
|
|
30
|
+
Combine two MDConfigContext instances.
|
|
31
|
+
|
|
32
|
+
Args:
|
|
33
|
+
other: Another MDConfigContext instance
|
|
34
|
+
|
|
35
|
+
Returns:
|
|
36
|
+
A new MDConfigContext with combined configurations
|
|
37
|
+
"""
|
|
38
|
+
...
|
|
39
|
+
|
|
40
|
+
def __invert__(self) -> MDConfigContext:
|
|
41
|
+
"""
|
|
42
|
+
Invert the MDConfigContext.
|
|
43
|
+
|
|
44
|
+
Returns:
|
|
45
|
+
A new MDConfigContext that reverts the configurations.
|
|
46
|
+
"""
|
|
47
|
+
...
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
MD_SHARED: MDConfigContext
|
|
51
|
+
"""
|
|
52
|
+
MDConfigContext instance to set flag for PyAlgoEngine to use SHM allocator.
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
MD_LOCKED: MDConfigContext
|
|
56
|
+
"""
|
|
57
|
+
MDConfigContext instance to set flag for PyAlgoEngine to use thread safe mode.
|
|
58
|
+
"""
|
|
59
|
+
|
|
60
|
+
MD_LOCKFREE: MDConfigContext
|
|
61
|
+
"""
|
|
62
|
+
MDConfigContext instance to set flag for PyAlgoEngine to disable thread safe mode.
|
|
63
|
+
"""
|
|
64
|
+
|
|
65
|
+
MD_FREELIST: MDConfigContext
|
|
66
|
+
"""
|
|
67
|
+
MDConfigContext instance to set flag for PyAlgoEngine to use freelist.
|
|
68
|
+
"""
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
from libc.stdlib cimport calloc
|
|
2
|
+
|
|
3
|
+
from cbase.allocator_protocol.c_heap_allocator cimport c_heap_allocator_new
|
|
4
|
+
from cbase.allocator_protocol.c_shm_comp cimport c_shm_allocator_new, AP_SHM_ALLOCATOR_DEFAULT_REGION_SIZE
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
cdef c_bool MD_CFG_LOCKED = False
|
|
8
|
+
cdef c_bool MD_CFG_SHARED = True
|
|
9
|
+
cdef c_bool MD_CFG_FREELIST = True
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
cdef class MDConfigContext(AllocatorConfigContext):
|
|
13
|
+
cdef void c_bind(self, allocator_protocol* schematic=NULL):
|
|
14
|
+
self.allocator_schematic = schematic if schematic else MD_DEFAULT_ALLOCATOR
|
|
15
|
+
|
|
16
|
+
cdef void c_activate(self):
|
|
17
|
+
if 'locked' in self.overrides:
|
|
18
|
+
global MD_CFG_LOCKED
|
|
19
|
+
MD_CFG_LOCKED = self.overrides['locked']
|
|
20
|
+
|
|
21
|
+
if 'shared' in self.overrides:
|
|
22
|
+
global MD_CFG_SHARED
|
|
23
|
+
MD_CFG_SHARED = self.overrides['shared']
|
|
24
|
+
|
|
25
|
+
if 'freelist' in self.overrides:
|
|
26
|
+
global MD_CFG_FREELIST
|
|
27
|
+
MD_CFG_FREELIST = self.overrides['freelist']
|
|
28
|
+
|
|
29
|
+
AllocatorConfigContext.c_activate(self)
|
|
30
|
+
|
|
31
|
+
cdef void c_deactivate(self):
|
|
32
|
+
if 'locked' in self.originals:
|
|
33
|
+
global MD_CFG_LOCKED
|
|
34
|
+
MD_CFG_LOCKED = self.originals.get('locked')
|
|
35
|
+
|
|
36
|
+
if 'shared' in self.originals:
|
|
37
|
+
global MD_CFG_SHARED
|
|
38
|
+
MD_CFG_SHARED = self.originals.get('shared')
|
|
39
|
+
|
|
40
|
+
if 'freelist' in self.originals:
|
|
41
|
+
global MD_CFG_FREELIST
|
|
42
|
+
MD_CFG_FREELIST = self.originals.get('freelist')
|
|
43
|
+
|
|
44
|
+
AllocatorConfigContext.c_deactivate(self)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
cdef heap_allocator* HEAP_ALLOCATOR = c_heap_allocator_new()
|
|
48
|
+
if not HEAP_ALLOCATOR:
|
|
49
|
+
raise OSError("Initialize MD heap allocator failed")
|
|
50
|
+
|
|
51
|
+
cdef shm_allocator_ctx* SHM_ALLOCATOR = c_shm_allocator_new(AP_SHM_ALLOCATOR_DEFAULT_REGION_SIZE, <char*> b"c_md_shm")
|
|
52
|
+
if not SHM_ALLOCATOR:
|
|
53
|
+
raise OSError("Initialize MD SHM allocator failed (prefix='c_md_shm')")
|
|
54
|
+
|
|
55
|
+
cdef allocator_protocol* MD_DEFAULT_ALLOCATOR = <allocator_protocol*> calloc(1, sizeof(allocator_protocol))
|
|
56
|
+
cdef allocator_protocol* MD_SHM_ALLOCATOR = <allocator_protocol*> calloc(1, sizeof(allocator_protocol))
|
|
57
|
+
cdef allocator_protocol* MD_HEAP_ALLOCATOR = <allocator_protocol*> calloc(1, sizeof(allocator_protocol))
|
|
58
|
+
|
|
59
|
+
MD_DEFAULT_ALLOCATOR.with_lock = MD_CFG_LOCKED
|
|
60
|
+
MD_DEFAULT_ALLOCATOR.with_shm = MD_CFG_SHARED
|
|
61
|
+
MD_DEFAULT_ALLOCATOR.with_freelist = MD_CFG_FREELIST
|
|
62
|
+
MD_DEFAULT_ALLOCATOR.shm_allocator_ctx = SHM_ALLOCATOR
|
|
63
|
+
MD_DEFAULT_ALLOCATOR.shm_allocator = SHM_ALLOCATOR.shm_allocator
|
|
64
|
+
MD_DEFAULT_ALLOCATOR.heap_allocator = HEAP_ALLOCATOR
|
|
65
|
+
|
|
66
|
+
MD_SHM_ALLOCATOR.with_lock = True
|
|
67
|
+
MD_SHM_ALLOCATOR.with_shm = True
|
|
68
|
+
MD_SHM_ALLOCATOR.with_freelist = True
|
|
69
|
+
MD_SHM_ALLOCATOR.shm_allocator_ctx = SHM_ALLOCATOR
|
|
70
|
+
MD_SHM_ALLOCATOR.shm_allocator = SHM_ALLOCATOR.shm_allocator
|
|
71
|
+
MD_SHM_ALLOCATOR.heap_allocator = NULL
|
|
72
|
+
|
|
73
|
+
MD_HEAP_ALLOCATOR.with_lock = True
|
|
74
|
+
MD_HEAP_ALLOCATOR.with_shm = False
|
|
75
|
+
MD_HEAP_ALLOCATOR.with_freelist = True
|
|
76
|
+
MD_HEAP_ALLOCATOR.shm_allocator_ctx = NULL
|
|
77
|
+
MD_HEAP_ALLOCATOR.shm_allocator = NULL
|
|
78
|
+
MD_HEAP_ALLOCATOR.heap_allocator = HEAP_ALLOCATOR
|
|
79
|
+
|
|
80
|
+
cdef MDConfigContext MD_SHARED = MDConfigContext(shared=True)
|
|
81
|
+
cdef MDConfigContext MD_LOCKED = MDConfigContext(locked=True)
|
|
82
|
+
cdef MDConfigContext MD_LOCKFREE = MDConfigContext(locked=False)
|
|
83
|
+
cdef MDConfigContext MD_FREELIST = MDConfigContext(freelist=True)
|
|
84
|
+
|
|
85
|
+
globals()['MD_SHARED'] = MD_SHARED
|
|
86
|
+
globals()['MD_LOCKED'] = MD_LOCKED
|
|
87
|
+
globals()['MD_LOCKFREE'] = MD_LOCKFREE
|
|
88
|
+
globals()['MD_FREELIST'] = MD_FREELIST
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
# -- Runtime config accessor (reads live cdef globals) --------------------
|
|
92
|
+
class _RuntimeAllocatorConfig:
|
|
93
|
+
"""Property-based accessor for live MD_CFG_* globals.
|
|
94
|
+
|
|
95
|
+
Unlike the compile-time CONFIG mappingproxy, these properties read the
|
|
96
|
+
CURRENT value, which may change when an MDConfigContext is active.
|
|
97
|
+
"""
|
|
98
|
+
@property
|
|
99
|
+
def MD_CFG_LOCKED(self):
|
|
100
|
+
return MD_CFG_LOCKED
|
|
101
|
+
|
|
102
|
+
@property
|
|
103
|
+
def MD_CFG_SHARED(self):
|
|
104
|
+
return MD_CFG_SHARED
|
|
105
|
+
|
|
106
|
+
@property
|
|
107
|
+
def MD_CFG_FREELIST(self):
|
|
108
|
+
return MD_CFG_FREELIST
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
RUNTIME_ALLOCATOR_CONFIG = _RuntimeAllocatorConfig()
|