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.
Files changed (156) hide show
  1. algo_engine/__infra__.pxd +3 -0
  2. algo_engine/__init__.pxd +3 -0
  3. algo_engine/__init__.py +107 -0
  4. algo_engine/apps/__init__.py +17 -0
  5. algo_engine/apps/backtest/__init__.py +20 -0
  6. algo_engine/apps/backtest/doc_server.py +328 -0
  7. algo_engine/apps/backtest/static/styles/dash.css +48 -0
  8. algo_engine/apps/backtest/templates/dash.html +20 -0
  9. algo_engine/apps/backtest/templates/index.html +40 -0
  10. algo_engine/apps/backtest/tester.py +252 -0
  11. algo_engine/apps/backtest/web_app.py +125 -0
  12. algo_engine/apps/bokeh_server.py +245 -0
  13. algo_engine/apps/demo/__init__.py +0 -0
  14. algo_engine/apps/demo/test.py +40 -0
  15. algo_engine/apps/sim_input/__init__.py +23 -0
  16. algo_engine/apps/sim_input/client.py +412 -0
  17. algo_engine/apps/sim_input/sim_keyboard.py +88 -0
  18. algo_engine/apps/sim_input/sim_mouse.py +137 -0
  19. algo_engine/apps/sim_input/window.py +162 -0
  20. algo_engine/backtest/__init__.py +19 -0
  21. algo_engine/backtest/__main__.py +51 -0
  22. algo_engine/backtest/metrics.py +179 -0
  23. algo_engine/backtest/replay.py +635 -0
  24. algo_engine/backtest/sim_match.py +506 -0
  25. algo_engine/base/__infra__.pxd +3 -0
  26. algo_engine/base/__init__.pxd +3 -0
  27. algo_engine/base/__init__.py +60 -0
  28. algo_engine/base/c_allocator_protocol.c +11608 -0
  29. algo_engine/base/c_allocator_protocol.cp315-win_amd64.pyd +0 -0
  30. algo_engine/base/c_allocator_protocol.pxd +24 -0
  31. algo_engine/base/c_allocator_protocol.pyi +68 -0
  32. algo_engine/base/c_allocator_protocol.pyx +111 -0
  33. algo_engine/base/c_intern_string.c +5908 -0
  34. algo_engine/base/c_intern_string.cp315-win_amd64.pyd +0 -0
  35. algo_engine/base/c_intern_string.pxd +14 -0
  36. algo_engine/base/c_intern_string.pyi +22 -0
  37. algo_engine/base/c_intern_string.pyx +17 -0
  38. algo_engine/base/c_market_data/__infra__.pxd +196 -0
  39. algo_engine/base/c_market_data/__init__.pxd +196 -0
  40. algo_engine/base/c_market_data/__init__.py +24 -0
  41. algo_engine/base/c_market_data/c_candlestick.c +18996 -0
  42. algo_engine/base/c_market_data/c_candlestick.cp315-win_amd64.pyd +0 -0
  43. algo_engine/base/c_market_data/c_candlestick.pxd +27 -0
  44. algo_engine/base/c_market_data/c_candlestick.pyi +217 -0
  45. algo_engine/base/c_market_data/c_candlestick.pyx +255 -0
  46. algo_engine/base/c_market_data/c_internal.c +14059 -0
  47. algo_engine/base/c_market_data/c_internal.cp315-win_amd64.pyd +0 -0
  48. algo_engine/base/c_market_data/c_internal.pxd +14 -0
  49. algo_engine/base/c_market_data/c_internal.pyi +47 -0
  50. algo_engine/base/c_market_data/c_internal.pyx +41 -0
  51. algo_engine/base/c_market_data/c_market_data.c +30420 -0
  52. algo_engine/base/c_market_data/c_market_data.cp315-win_amd64.pyd +0 -0
  53. algo_engine/base/c_market_data/c_market_data.h +1464 -0
  54. algo_engine/base/c_market_data/c_market_data.pxd +414 -0
  55. algo_engine/base/c_market_data/c_market_data.pyi +550 -0
  56. algo_engine/base/c_market_data/c_market_data.pyx +701 -0
  57. algo_engine/base/c_market_data/c_market_data_buffer.c +29407 -0
  58. algo_engine/base/c_market_data/c_market_data_buffer.cp315-win_amd64.pyd +0 -0
  59. algo_engine/base/c_market_data/c_market_data_buffer.h +941 -0
  60. algo_engine/base/c_market_data/c_market_data_buffer.pxd +143 -0
  61. algo_engine/base/c_market_data/c_market_data_buffer.pyi +355 -0
  62. algo_engine/base/c_market_data/c_market_data_buffer.pyx +571 -0
  63. algo_engine/base/c_market_data/c_market_data_config.h +29 -0
  64. algo_engine/base/c_market_data/c_tick.c +44303 -0
  65. algo_engine/base/c_market_data/c_tick.cp315-win_amd64.pyd +0 -0
  66. algo_engine/base/c_market_data/c_tick.pxd +53 -0
  67. algo_engine/base/c_market_data/c_tick.pyi +466 -0
  68. algo_engine/base/c_market_data/c_tick.pyx +673 -0
  69. algo_engine/base/c_market_data/c_trade_utils.c +28702 -0
  70. algo_engine/base/c_market_data/c_trade_utils.cp315-win_amd64.pyd +0 -0
  71. algo_engine/base/c_market_data/c_trade_utils.pxd +53 -0
  72. algo_engine/base/c_market_data/c_trade_utils.pyi +602 -0
  73. algo_engine/base/c_market_data/c_trade_utils.pyx +609 -0
  74. algo_engine/base/c_market_data/c_transaction.c +23558 -0
  75. algo_engine/base/c_market_data/c_transaction.cp315-win_amd64.pyd +0 -0
  76. algo_engine/base/c_market_data/c_transaction.pxd +27 -0
  77. algo_engine/base/c_market_data/c_transaction.pyi +433 -0
  78. algo_engine/base/c_market_data/c_transaction.pyx +460 -0
  79. algo_engine/base/console_utils.py +1070 -0
  80. algo_engine/base/finance_decimal.py +258 -0
  81. algo_engine/base/telemetrics.py +18 -0
  82. algo_engine/engine/__infra__.pxd +10 -0
  83. algo_engine/engine/__init__.pxd +10 -0
  84. algo_engine/engine/__init__.py +40 -0
  85. algo_engine/engine/algo_engine.py +904 -0
  86. algo_engine/engine/c_event_engine.c +16325 -0
  87. algo_engine/engine/c_event_engine.cp315-win_amd64.pyd +0 -0
  88. algo_engine/engine/c_event_engine.pxd +25 -0
  89. algo_engine/engine/c_event_engine.pyi +68 -0
  90. algo_engine/engine/c_market_engine.c +24258 -0
  91. algo_engine/engine/c_market_engine.cp315-win_amd64.pyd +0 -0
  92. algo_engine/engine/c_market_engine.pxd +87 -0
  93. algo_engine/engine/c_market_engine.pyi +357 -0
  94. algo_engine/engine/event_engine.py +53 -0
  95. algo_engine/engine/trade_engine.py +2037 -0
  96. algo_engine/exchange_profile/__infra__.pxd +100 -0
  97. algo_engine/exchange_profile/__init__.pxd +100 -0
  98. algo_engine/exchange_profile/__init__.py +53 -0
  99. algo_engine/exchange_profile/c_ex_profile_base.c +87 -0
  100. algo_engine/exchange_profile/c_ex_profile_base.h +1204 -0
  101. algo_engine/exchange_profile/c_ex_profile_cn.c +968 -0
  102. algo_engine/exchange_profile/c_ex_profile_cn.h +39 -0
  103. algo_engine/exchange_profile/c_exchange_profile.c +52375 -0
  104. algo_engine/exchange_profile/c_exchange_profile.cp315-win_amd64.pyd +0 -0
  105. algo_engine/exchange_profile/c_exchange_profile.pxd +336 -0
  106. algo_engine/exchange_profile/c_exchange_profile.pyi +883 -0
  107. algo_engine/exchange_profile/c_exchange_profile.pyx +1495 -0
  108. algo_engine/exchange_profile/c_profile_cn.c +7798 -0
  109. algo_engine/exchange_profile/c_profile_cn.cp315-win_amd64.pyd +0 -0
  110. algo_engine/exchange_profile/c_profile_cn.pxd +1 -0
  111. algo_engine/exchange_profile/c_profile_cn.pyi +3 -0
  112. algo_engine/exchange_profile/c_profile_cn.pyx +1 -0
  113. algo_engine/exchange_profile/c_profile_default.c +7798 -0
  114. algo_engine/exchange_profile/c_profile_default.cp315-win_amd64.pyd +0 -0
  115. algo_engine/exchange_profile/c_profile_default.pxd +1 -0
  116. algo_engine/exchange_profile/c_profile_default.pyi +3 -0
  117. algo_engine/exchange_profile/c_profile_default.pyx +1 -0
  118. algo_engine/exchange_profile/c_profile_dispatcher.c +7798 -0
  119. algo_engine/exchange_profile/c_profile_dispatcher.cp315-win_amd64.pyd +0 -0
  120. algo_engine/exchange_profile/c_profile_dispatcher.pxd +1 -0
  121. algo_engine/exchange_profile/c_profile_dispatcher.pyi +3 -0
  122. algo_engine/exchange_profile/c_profile_dispatcher.pyx +1 -0
  123. algo_engine/includes/algo_engine/base/c_allocator_protocol.c +11608 -0
  124. algo_engine/includes/algo_engine/base/c_intern_string.c +5908 -0
  125. algo_engine/includes/algo_engine/base/c_market_data/c_candlestick.c +18996 -0
  126. algo_engine/includes/algo_engine/base/c_market_data/c_internal.c +14059 -0
  127. algo_engine/includes/algo_engine/base/c_market_data/c_market_data.c +30420 -0
  128. algo_engine/includes/algo_engine/base/c_market_data/c_market_data.h +1464 -0
  129. algo_engine/includes/algo_engine/base/c_market_data/c_market_data_buffer.c +29407 -0
  130. algo_engine/includes/algo_engine/base/c_market_data/c_market_data_buffer.h +941 -0
  131. algo_engine/includes/algo_engine/base/c_market_data/c_market_data_config.h +29 -0
  132. algo_engine/includes/algo_engine/base/c_market_data/c_tick.c +44303 -0
  133. algo_engine/includes/algo_engine/base/c_market_data/c_trade_utils.c +28702 -0
  134. algo_engine/includes/algo_engine/base/c_market_data/c_transaction.c +23558 -0
  135. algo_engine/includes/algo_engine/engine/c_event_engine.c +16325 -0
  136. algo_engine/includes/algo_engine/engine/c_market_engine.c +24258 -0
  137. algo_engine/includes/algo_engine/exchange_profile/c_ex_profile_base.c +87 -0
  138. algo_engine/includes/algo_engine/exchange_profile/c_ex_profile_base.h +1204 -0
  139. algo_engine/includes/algo_engine/exchange_profile/c_ex_profile_cn.c +968 -0
  140. algo_engine/includes/algo_engine/exchange_profile/c_ex_profile_cn.h +39 -0
  141. algo_engine/includes/algo_engine/exchange_profile/c_exchange_profile.c +52375 -0
  142. algo_engine/includes/algo_engine/exchange_profile/c_profile_cn.c +7798 -0
  143. algo_engine/includes/algo_engine/exchange_profile/c_profile_default.c +7798 -0
  144. algo_engine/includes/algo_engine/exchange_profile/c_profile_dispatcher.c +7798 -0
  145. algo_engine/monitor/__init__.py +15 -0
  146. algo_engine/monitor/advanced_data_interface.py +334 -0
  147. algo_engine/strategy/__init__.py +44 -0
  148. algo_engine/strategy/strategy_engine.py +441 -0
  149. algo_engine/utils/__init__.py +3 -0
  150. algo_engine/utils/commit_regularizer.py +49 -0
  151. algo_engine/utils/data_utils.py +296 -0
  152. pyalgoengine-0.12.3.dist-info/METADATA +142 -0
  153. pyalgoengine-0.12.3.dist-info/RECORD +156 -0
  154. pyalgoengine-0.12.3.dist-info/WHEEL +5 -0
  155. pyalgoengine-0.12.3.dist-info/licenses/LICENSE +21 -0
  156. pyalgoengine-0.12.3.dist-info/top_level.txt +2 -0
@@ -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()