quantbt-engine 1.0.7__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.
- quantbt/__init__.py +862 -0
- quantbt/adapters/__init__.py +5 -0
- quantbt/adapters/nautilus/__init__.py +42 -0
- quantbt/adapters/nautilus/_dependency.py +53 -0
- quantbt/adapters/nautilus/backend.py +639 -0
- quantbt/adapters/nautilus/instruments.py +275 -0
- quantbt/adapters/nautilus/options.py +465 -0
- quantbt/adapters/nautilus/reports.py +231 -0
- quantbt/backends/__init__.py +29 -0
- quantbt/backends/_native_event_rust.py +2168 -0
- quantbt/backends/native_event.py +5048 -0
- quantbt/backends/native_option.py +796 -0
- quantbt/backends/native_portfolio.py +928 -0
- quantbt/backends/native_vectorized.py +1299 -0
- quantbt/backtester.py +485 -0
- quantbt/benchmarks/__init__.py +1 -0
- quantbt/benchmarks/compare_phase9_parity.py +302 -0
- quantbt/benchmarks/gamma_scalping_backtestsample.py +802 -0
- quantbt/benchmarks/profile_phase7.py +415 -0
- quantbt/benchmarks/run_arbitrage_phase_e.py +160 -0
- quantbt/benchmarks/run_optimization_overhead.py +195 -0
- quantbt/benchmarks/run_options_engine.py +272 -0
- quantbt/benchmarks/run_pct_equity_nautilus_smoke.py +227 -0
- quantbt/benchmarks/run_phase12_arbitrage_cert.py +402 -0
- quantbt/benchmarks/run_phase12_benchmark_nautilus_cert.py +430 -0
- quantbt/benchmarks/run_phase13_portfolio_report.py +97 -0
- quantbt/benchmarks/run_phase13_wfo_cache.py +162 -0
- quantbt/benchmarks/run_phase14_service_loop.py +694 -0
- quantbt/benchmarks/run_phase15a_nautilus_certification.py +514 -0
- quantbt/benchmarks/run_phase15b_synthetic_depth.py +175 -0
- quantbt/benchmarks/run_phase16_performance_debt.py +389 -0
- quantbt/benchmarks/run_phase30e_reactive_runner.py +161 -0
- quantbt/benchmarks/run_phase31_intrabar.py +441 -0
- quantbt/benchmarks/run_phase34a_native_event_memory.py +179 -0
- quantbt/benchmarks/run_phase34b_native_event_prepared_score.py +173 -0
- quantbt/benchmarks/run_phase34c_native_event_single_pass.py +176 -0
- quantbt/benchmarks/run_phase7.py +654 -0
- quantbt/benchmarks/run_portfolio_real_parity.py +537 -0
- quantbt/core/__init__.py +323 -0
- quantbt/core/arbitrage.py +767 -0
- quantbt/core/basket.py +234 -0
- quantbt/core/certification.py +274 -0
- quantbt/core/constraints.py +155 -0
- quantbt/core/engine.py +1144 -0
- quantbt/core/event.py +869 -0
- quantbt/core/execution_contract.py +197 -0
- quantbt/core/execution_depth.py +613 -0
- quantbt/core/intrabar_kernel.py +1906 -0
- quantbt/core/intrabar_reference.py +907 -0
- quantbt/core/intrabar_session.py +156 -0
- quantbt/core/market_tape.py +480 -0
- quantbt/core/native_event_capabilities.py +121 -0
- quantbt/core/native_event_parity.py +336 -0
- quantbt/core/order_compiler.py +422 -0
- quantbt/core/orders.py +319 -0
- quantbt/core/portfolio.py +392 -0
- quantbt/core/preprocessor.py +256 -0
- quantbt/core/reactive.py +173 -0
- quantbt/core/results.py +341 -0
- quantbt/core/schema.py +211 -0
- quantbt/core/scopes.py +96 -0
- quantbt/core/structured_orders.py +378 -0
- quantbt/core/types.py +87 -0
- quantbt/core/vectorized.py +203 -0
- quantbt/endpoint.py +4465 -0
- quantbt/engines.py +1014 -0
- quantbt/metrics/__init__.py +45 -0
- quantbt/metrics/options_analytics.py +46 -0
- quantbt/metrics/performance.py +541 -0
- quantbt/optimization/__init__.py +94 -0
- quantbt/optimization/callbacks.py +116 -0
- quantbt/optimization/candidate_selection.py +397 -0
- quantbt/optimization/config.py +84 -0
- quantbt/optimization/constraints.py +22 -0
- quantbt/optimization/evaluator.py +21 -0
- quantbt/optimization/evaluators/__init__.py +32 -0
- quantbt/optimization/evaluators/arbitrage.py +22 -0
- quantbt/optimization/evaluators/generic.py +34 -0
- quantbt/optimization/evaluators/grid_dca.py +22 -0
- quantbt/optimization/evaluators/intrabar.py +54 -0
- quantbt/optimization/evaluators/native_event.py +51 -0
- quantbt/optimization/evaluators/options.py +22 -0
- quantbt/optimization/evaluators/portfolio.py +42 -0
- quantbt/optimization/evaluators/signal.py +43 -0
- quantbt/optimization/multiseed.py +176 -0
- quantbt/optimization/objectives.py +221 -0
- quantbt/optimization/optimizer.py +500 -0
- quantbt/optimization/result.py +80 -0
- quantbt/optimization/samplers.py +84 -0
- quantbt/optimization/space.py +223 -0
- quantbt/options/__init__.py +215 -0
- quantbt/options/cache.py +116 -0
- quantbt/options/conventions.py +158 -0
- quantbt/options/data.py +177 -0
- quantbt/options/execution.py +600 -0
- quantbt/options/fees.py +135 -0
- quantbt/options/greeks.py +173 -0
- quantbt/options/hedging.py +232 -0
- quantbt/options/iv.py +188 -0
- quantbt/options/ledger.py +263 -0
- quantbt/options/lifecycle.py +94 -0
- quantbt/options/margin.py +311 -0
- quantbt/options/packages.py +147 -0
- quantbt/options/pricing.py +191 -0
- quantbt/options/schema.py +227 -0
- quantbt/options/selectors.py +281 -0
- quantbt/options/strategy.py +249 -0
- quantbt/options/surface.py +142 -0
- quantbt/options/tape.py +226 -0
- quantbt/options/templates/__init__.py +33 -0
- quantbt/options/templates/packages.py +354 -0
- quantbt/portfolio.py +606 -0
- quantbt/py.typed +1 -0
- quantbt/reporting/__init__.py +38 -0
- quantbt/reporting/arbitrage_audit.py +211 -0
- quantbt/reporting/nautilus_bundle.py +758 -0
- quantbt/reporting/nautilus_certification.py +226 -0
- quantbt/reporting/nautilus_diagnostics.py +225 -0
- quantbt/reporting/parity.py +496 -0
- quantbt/reporting/portfolio_audit.py +206 -0
- quantbt/reporting/portfolio_nautilus.py +140 -0
- quantbt/sizing/__init__.py +3 -0
- quantbt/sizing/fast.py +67 -0
- quantbt/sizing/modes.py +162 -0
- quantbt/viz/__init__.py +4 -0
- quantbt/viz/plots.py +310 -0
- quantbt/viz/themes.py +102 -0
- quantbt/walkforward.py +3136 -0
- quantbt_engine-1.0.7.dist-info/METADATA +891 -0
- quantbt_engine-1.0.7.dist-info/RECORD +133 -0
- quantbt_engine-1.0.7.dist-info/WHEEL +5 -0
- quantbt_engine-1.0.7.dist-info/licenses/LICENSE +21 -0
- quantbt_engine-1.0.7.dist-info/top_level.txt +1 -0
quantbt/core/__init__.py
ADDED
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
from .engine import _engine_units, _engine_pct_equity, _engine_dca_ladder, _engine_portfolio
|
|
2
|
+
from .event import _engine_event_v1
|
|
3
|
+
from .vectorized import _engine_units_v2
|
|
4
|
+
from .types import BacktestResult
|
|
5
|
+
from .results import (
|
|
6
|
+
BacktestResultV2,
|
|
7
|
+
NativeAccountingArrays,
|
|
8
|
+
NativeEventScalarScoreResult,
|
|
9
|
+
NativeEventScoreResult,
|
|
10
|
+
)
|
|
11
|
+
from .execution_contract import (
|
|
12
|
+
EXECUTION_CONTRACT_REGISTRY,
|
|
13
|
+
AmbiguityPolicy,
|
|
14
|
+
ExecutionContract,
|
|
15
|
+
FillPhase,
|
|
16
|
+
FundingPhase,
|
|
17
|
+
IntrabarSameBarPolicy,
|
|
18
|
+
LiquidationPriority,
|
|
19
|
+
MarketFillPolicy,
|
|
20
|
+
SignalPhase,
|
|
21
|
+
StopGapPolicy,
|
|
22
|
+
TakeProfitGapPolicy,
|
|
23
|
+
TrailingUpdatePhase,
|
|
24
|
+
get_execution_contract,
|
|
25
|
+
)
|
|
26
|
+
from .market_tape import MarketValidationCertificate, PreparedMarketTape, prepare_market_tape
|
|
27
|
+
from .intrabar_reference import (
|
|
28
|
+
IntrabarEventFlag,
|
|
29
|
+
IntrabarFill,
|
|
30
|
+
IntrabarFillReason,
|
|
31
|
+
IntrabarIntentTape,
|
|
32
|
+
IntrabarLevelMode,
|
|
33
|
+
IntrabarReferenceResult,
|
|
34
|
+
IntrabarSizingMode,
|
|
35
|
+
run_intrabar_reference,
|
|
36
|
+
)
|
|
37
|
+
from .intrabar_session import (
|
|
38
|
+
EntryPositionPolicy,
|
|
39
|
+
IntrabarSessionTape,
|
|
40
|
+
ProtectiveExitReentryPolicy,
|
|
41
|
+
SessionCounterBasis,
|
|
42
|
+
SessionExecutionPolicy,
|
|
43
|
+
)
|
|
44
|
+
from .intrabar_kernel import (
|
|
45
|
+
FillReplayTape,
|
|
46
|
+
NativeFillReplayResult,
|
|
47
|
+
NativeIntrabarKernelResult,
|
|
48
|
+
run_fill_replay_kernel,
|
|
49
|
+
run_intrabar_kernel,
|
|
50
|
+
run_intrabar_session_kernel,
|
|
51
|
+
)
|
|
52
|
+
from .certification import (
|
|
53
|
+
AlphaExecutionClassification,
|
|
54
|
+
CertificationLevel,
|
|
55
|
+
alpha_report_markdown,
|
|
56
|
+
build_alpha_certification_report,
|
|
57
|
+
certify_result_metadata,
|
|
58
|
+
classify_alpha_source,
|
|
59
|
+
scan_alpha_directory,
|
|
60
|
+
)
|
|
61
|
+
from .native_event_capabilities import (
|
|
62
|
+
NATIVE_EVENT_CAPABILITY_MATRIX,
|
|
63
|
+
NATIVE_EVENT_CAPABILITY_MATRIX_VERSION,
|
|
64
|
+
capability_matrix_fingerprint,
|
|
65
|
+
native_event_capability_matrix,
|
|
66
|
+
normalize_native_event_capabilities,
|
|
67
|
+
validate_native_event_capability_matrix,
|
|
68
|
+
)
|
|
69
|
+
from .native_event_parity import (
|
|
70
|
+
DEFAULT_NUMERIC_ATOL,
|
|
71
|
+
NativeEventParityCertificate,
|
|
72
|
+
NativeEventParityError,
|
|
73
|
+
assert_native_event_full_parity,
|
|
74
|
+
)
|
|
75
|
+
from .orders import (
|
|
76
|
+
BasketIntent,
|
|
77
|
+
Fill,
|
|
78
|
+
OrderAction,
|
|
79
|
+
OrderActivationPolicy,
|
|
80
|
+
OrderCommand,
|
|
81
|
+
OrderIntent,
|
|
82
|
+
Trade,
|
|
83
|
+
order_intents_to_lifecycle_commands,
|
|
84
|
+
)
|
|
85
|
+
from .basket import FrozenBasketPlan, build_frozen_basket_orders
|
|
86
|
+
from .execution_depth import (
|
|
87
|
+
NautilusExecutionDepthConfig,
|
|
88
|
+
PackageDepthPreflightResult,
|
|
89
|
+
SUPPORTED_DEPTH_MODELS,
|
|
90
|
+
l2_replay_available,
|
|
91
|
+
simulate_nautilus_order_package_depth,
|
|
92
|
+
)
|
|
93
|
+
from .structured_orders import (
|
|
94
|
+
BracketOrderSpec,
|
|
95
|
+
DcaGridSpec,
|
|
96
|
+
StructuredOrderPlan,
|
|
97
|
+
build_bracket_order_plan,
|
|
98
|
+
build_dca_grid_order_plan,
|
|
99
|
+
)
|
|
100
|
+
from .reactive import (
|
|
101
|
+
NativeActiveOrderSnapshot,
|
|
102
|
+
NativeCommandBatch,
|
|
103
|
+
NativeEventStrategy,
|
|
104
|
+
NativeEventStrategyError,
|
|
105
|
+
NativeEventStrategyProtocol,
|
|
106
|
+
NativeFillEvent,
|
|
107
|
+
NativeOrderEvent,
|
|
108
|
+
NativeStrategyContext,
|
|
109
|
+
)
|
|
110
|
+
from .arbitrage import (
|
|
111
|
+
ArbExecutionPolicy,
|
|
112
|
+
ArbitrageLeg,
|
|
113
|
+
ArbitragePlan,
|
|
114
|
+
ArbitrageSpec,
|
|
115
|
+
ArbitrageType,
|
|
116
|
+
BasisArbitrageSpec,
|
|
117
|
+
CalendarSpreadSpec,
|
|
118
|
+
CarryModel,
|
|
119
|
+
CarryModelKind,
|
|
120
|
+
ContractType,
|
|
121
|
+
CostModel,
|
|
122
|
+
CostModelKind,
|
|
123
|
+
CrossExchangeArbSpec,
|
|
124
|
+
FundingArbitrageSpec,
|
|
125
|
+
HedgePolicy,
|
|
126
|
+
HedgePolicyKind,
|
|
127
|
+
IndexBasketArbSpec,
|
|
128
|
+
LifecycleModel,
|
|
129
|
+
LifecycleModelKind,
|
|
130
|
+
MarginModel,
|
|
131
|
+
MarginModelKind,
|
|
132
|
+
OptionsVolArbSpec,
|
|
133
|
+
PackageExecutionKind,
|
|
134
|
+
PackageRejection,
|
|
135
|
+
SignalModel,
|
|
136
|
+
SignalModelKind,
|
|
137
|
+
SizingPolicy,
|
|
138
|
+
SizingPolicyKind,
|
|
139
|
+
SpotPerpCashCarrySpec,
|
|
140
|
+
SpreadFormula,
|
|
141
|
+
SpreadFormulaKind,
|
|
142
|
+
StatArbPairSpec,
|
|
143
|
+
TriangularArbSpec,
|
|
144
|
+
build_arbitrage_order_plan,
|
|
145
|
+
round_down_to_step,
|
|
146
|
+
)
|
|
147
|
+
from .schema import (
|
|
148
|
+
AccountConfig,
|
|
149
|
+
AssetType,
|
|
150
|
+
BasketExecutionPolicy,
|
|
151
|
+
BasketLegSpec,
|
|
152
|
+
BasketSpec,
|
|
153
|
+
ExecutionConfig,
|
|
154
|
+
FeeModel,
|
|
155
|
+
FillPricePolicy,
|
|
156
|
+
InstrumentSpec,
|
|
157
|
+
LiquiditySide,
|
|
158
|
+
MarginMode,
|
|
159
|
+
OmsMode,
|
|
160
|
+
OrderSide,
|
|
161
|
+
OrderType,
|
|
162
|
+
SameBarPolicy,
|
|
163
|
+
SignalSpec,
|
|
164
|
+
TimeInForce,
|
|
165
|
+
)
|
|
166
|
+
from .preprocessor import (
|
|
167
|
+
validate_datetime,
|
|
168
|
+
align_series,
|
|
169
|
+
prepare_funding,
|
|
170
|
+
make_funding_mask,
|
|
171
|
+
build_arrays,
|
|
172
|
+
)
|
|
173
|
+
|
|
174
|
+
__all__ = [
|
|
175
|
+
"_engine_units",
|
|
176
|
+
"_engine_event_v1",
|
|
177
|
+
"_engine_units_v2",
|
|
178
|
+
"_engine_pct_equity",
|
|
179
|
+
"_engine_dca_ladder",
|
|
180
|
+
"_engine_portfolio",
|
|
181
|
+
"BacktestResult",
|
|
182
|
+
"BacktestResultV2",
|
|
183
|
+
"DEFAULT_NUMERIC_ATOL",
|
|
184
|
+
"NativeAccountingArrays",
|
|
185
|
+
"NativeEventScoreResult",
|
|
186
|
+
"NativeEventScalarScoreResult",
|
|
187
|
+
"NativeEventParityCertificate",
|
|
188
|
+
"NativeEventParityError",
|
|
189
|
+
"BracketOrderSpec",
|
|
190
|
+
"AccountConfig",
|
|
191
|
+
"AlphaExecutionClassification",
|
|
192
|
+
"NATIVE_EVENT_CAPABILITY_MATRIX",
|
|
193
|
+
"NATIVE_EVENT_CAPABILITY_MATRIX_VERSION",
|
|
194
|
+
"AmbiguityPolicy",
|
|
195
|
+
"ArbExecutionPolicy",
|
|
196
|
+
"ArbitrageLeg",
|
|
197
|
+
"ArbitragePlan",
|
|
198
|
+
"ArbitrageSpec",
|
|
199
|
+
"ArbitrageType",
|
|
200
|
+
"AssetType",
|
|
201
|
+
"BasisArbitrageSpec",
|
|
202
|
+
"BasketExecutionPolicy",
|
|
203
|
+
"BasketIntent",
|
|
204
|
+
"BasketLegSpec",
|
|
205
|
+
"BasketSpec",
|
|
206
|
+
"CalendarSpreadSpec",
|
|
207
|
+
"CertificationLevel",
|
|
208
|
+
"CarryModel",
|
|
209
|
+
"CarryModelKind",
|
|
210
|
+
"ContractType",
|
|
211
|
+
"CostModel",
|
|
212
|
+
"CostModelKind",
|
|
213
|
+
"CrossExchangeArbSpec",
|
|
214
|
+
"DcaGridSpec",
|
|
215
|
+
"EXECUTION_CONTRACT_REGISTRY",
|
|
216
|
+
"ExecutionConfig",
|
|
217
|
+
"ExecutionContract",
|
|
218
|
+
"FeeModel",
|
|
219
|
+
"Fill",
|
|
220
|
+
"FillPricePolicy",
|
|
221
|
+
"FillPhase",
|
|
222
|
+
"FundingPhase",
|
|
223
|
+
"FundingArbitrageSpec",
|
|
224
|
+
"FrozenBasketPlan",
|
|
225
|
+
"HedgePolicy",
|
|
226
|
+
"HedgePolicyKind",
|
|
227
|
+
"IndexBasketArbSpec",
|
|
228
|
+
"InstrumentSpec",
|
|
229
|
+
"IntrabarEventFlag",
|
|
230
|
+
"IntrabarFill",
|
|
231
|
+
"IntrabarFillReason",
|
|
232
|
+
"IntrabarIntentTape",
|
|
233
|
+
"IntrabarLevelMode",
|
|
234
|
+
"IntrabarReferenceResult",
|
|
235
|
+
"IntrabarSessionTape",
|
|
236
|
+
"IntrabarSizingMode",
|
|
237
|
+
"EntryPositionPolicy",
|
|
238
|
+
"ProtectiveExitReentryPolicy",
|
|
239
|
+
"SessionCounterBasis",
|
|
240
|
+
"SessionExecutionPolicy",
|
|
241
|
+
"IntrabarSameBarPolicy",
|
|
242
|
+
"FillReplayTape",
|
|
243
|
+
"LifecycleModel",
|
|
244
|
+
"LifecycleModelKind",
|
|
245
|
+
"LiquiditySide",
|
|
246
|
+
"LiquidationPriority",
|
|
247
|
+
"MarginMode",
|
|
248
|
+
"MarginModel",
|
|
249
|
+
"MarginModelKind",
|
|
250
|
+
"MarketFillPolicy",
|
|
251
|
+
"MarketValidationCertificate",
|
|
252
|
+
"NautilusExecutionDepthConfig",
|
|
253
|
+
"NativeFillReplayResult",
|
|
254
|
+
"NativeIntrabarKernelResult",
|
|
255
|
+
"NativeActiveOrderSnapshot",
|
|
256
|
+
"NativeCommandBatch",
|
|
257
|
+
"NativeEventStrategyError",
|
|
258
|
+
"NativeEventStrategy",
|
|
259
|
+
"NativeEventStrategyProtocol",
|
|
260
|
+
"NativeFillEvent",
|
|
261
|
+
"NativeOrderEvent",
|
|
262
|
+
"NativeStrategyContext",
|
|
263
|
+
"OmsMode",
|
|
264
|
+
"OrderAction",
|
|
265
|
+
"OrderActivationPolicy",
|
|
266
|
+
"OrderCommand",
|
|
267
|
+
"OrderIntent",
|
|
268
|
+
"OrderSide",
|
|
269
|
+
"OrderType",
|
|
270
|
+
"OptionsVolArbSpec",
|
|
271
|
+
"PackageExecutionKind",
|
|
272
|
+
"PackageDepthPreflightResult",
|
|
273
|
+
"PackageRejection",
|
|
274
|
+
"PreparedMarketTape",
|
|
275
|
+
"SameBarPolicy",
|
|
276
|
+
"SignalModel",
|
|
277
|
+
"SignalModelKind",
|
|
278
|
+
"SignalSpec",
|
|
279
|
+
"SignalPhase",
|
|
280
|
+
"SizingPolicy",
|
|
281
|
+
"SizingPolicyKind",
|
|
282
|
+
"SpotPerpCashCarrySpec",
|
|
283
|
+
"SpreadFormula",
|
|
284
|
+
"SpreadFormulaKind",
|
|
285
|
+
"StatArbPairSpec",
|
|
286
|
+
"StopGapPolicy",
|
|
287
|
+
"StructuredOrderPlan",
|
|
288
|
+
"TakeProfitGapPolicy",
|
|
289
|
+
"TimeInForce",
|
|
290
|
+
"Trade",
|
|
291
|
+
"TrailingUpdatePhase",
|
|
292
|
+
"TriangularArbSpec",
|
|
293
|
+
"alpha_report_markdown",
|
|
294
|
+
"build_arbitrage_order_plan",
|
|
295
|
+
"build_alpha_certification_report",
|
|
296
|
+
"build_bracket_order_plan",
|
|
297
|
+
"build_dca_grid_order_plan",
|
|
298
|
+
"build_frozen_basket_orders",
|
|
299
|
+
"certify_result_metadata",
|
|
300
|
+
"classify_alpha_source",
|
|
301
|
+
"get_execution_contract",
|
|
302
|
+
"order_intents_to_lifecycle_commands",
|
|
303
|
+
"prepare_market_tape",
|
|
304
|
+
"round_down_to_step",
|
|
305
|
+
"run_intrabar_reference",
|
|
306
|
+
"run_intrabar_kernel",
|
|
307
|
+
"run_intrabar_session_kernel",
|
|
308
|
+
"run_fill_replay_kernel",
|
|
309
|
+
"scan_alpha_directory",
|
|
310
|
+
"SUPPORTED_DEPTH_MODELS",
|
|
311
|
+
"l2_replay_available",
|
|
312
|
+
"simulate_nautilus_order_package_depth",
|
|
313
|
+
"validate_datetime",
|
|
314
|
+
"align_series",
|
|
315
|
+
"prepare_funding",
|
|
316
|
+
"make_funding_mask",
|
|
317
|
+
"build_arrays",
|
|
318
|
+
"assert_native_event_full_parity",
|
|
319
|
+
"capability_matrix_fingerprint",
|
|
320
|
+
"native_event_capability_matrix",
|
|
321
|
+
"normalize_native_event_capabilities",
|
|
322
|
+
"validate_native_event_capability_matrix",
|
|
323
|
+
]
|