tick-backtest 0.1.1__tar.gz

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 (133) hide show
  1. tick_backtest-0.1.1/LICENSE +201 -0
  2. tick_backtest-0.1.1/MANIFEST.in +21 -0
  3. tick_backtest-0.1.1/PKG-INFO +346 -0
  4. tick_backtest-0.1.1/README.md +310 -0
  5. tick_backtest-0.1.1/pyproject.toml +93 -0
  6. tick_backtest-0.1.1/setup.cfg +4 -0
  7. tick_backtest-0.1.1/setup.py +33 -0
  8. tick_backtest-0.1.1/src/tick_backtest/__init__.py +90 -0
  9. tick_backtest-0.1.1/src/tick_backtest/_build.py +157 -0
  10. tick_backtest-0.1.1/src/tick_backtest/analysis/__init__.py +34 -0
  11. tick_backtest-0.1.1/src/tick_backtest/analysis/backtest_analysis.py +335 -0
  12. tick_backtest-0.1.1/src/tick_backtest/analysis/metric_stratification/__init__.py +45 -0
  13. tick_backtest-0.1.1/src/tick_backtest/analysis/metric_stratification/compile_report.py +140 -0
  14. tick_backtest-0.1.1/src/tick_backtest/analysis/metric_stratification/nice_graphs.py +253 -0
  15. tick_backtest-0.1.1/src/tick_backtest/analysis/metric_stratification/workflow.py +257 -0
  16. tick_backtest-0.1.1/src/tick_backtest/analysis/trade_analysis.py +367 -0
  17. tick_backtest-0.1.1/src/tick_backtest/analysis/trade_regression.py +167 -0
  18. tick_backtest-0.1.1/src/tick_backtest/analysis/trade_visualizer.py +367 -0
  19. tick_backtest-0.1.1/src/tick_backtest/api.py +152 -0
  20. tick_backtest-0.1.1/src/tick_backtest/backtest/__init__.py +14 -0
  21. tick_backtest-0.1.1/src/tick_backtest/backtest/backtest.py +336 -0
  22. tick_backtest-0.1.1/src/tick_backtest/backtest/backtest_coordinator.py +105 -0
  23. tick_backtest-0.1.1/src/tick_backtest/backtest/workflow.py +399 -0
  24. tick_backtest-0.1.1/src/tick_backtest/cli.py +102 -0
  25. tick_backtest-0.1.1/src/tick_backtest/config/backtest/test_backtest.yaml +24 -0
  26. tick_backtest-0.1.1/src/tick_backtest/config/metrics/test_metrics.yaml +53 -0
  27. tick_backtest-0.1.1/src/tick_backtest/config/strategy/test_strategy.yaml +31 -0
  28. tick_backtest-0.1.1/src/tick_backtest/config/templates/demo/backtest.yaml +13 -0
  29. tick_backtest-0.1.1/src/tick_backtest/config/templates/demo/metrics.yaml +39 -0
  30. tick_backtest-0.1.1/src/tick_backtest/config/templates/demo/strategy.yaml +17 -0
  31. tick_backtest-0.1.1/src/tick_backtest/config/templates/minimal/backtest.yaml +13 -0
  32. tick_backtest-0.1.1/src/tick_backtest/config/templates/minimal/metrics.yaml +13 -0
  33. tick_backtest-0.1.1/src/tick_backtest/config/templates/minimal/strategy.yaml +19 -0
  34. tick_backtest-0.1.1/src/tick_backtest/config_parsers/__init__.py +14 -0
  35. tick_backtest-0.1.1/src/tick_backtest/config_parsers/backtest/config_dataclass.py +35 -0
  36. tick_backtest-0.1.1/src/tick_backtest/config_parsers/backtest/config_parser.py +157 -0
  37. tick_backtest-0.1.1/src/tick_backtest/config_parsers/metrics/config_dataclass.py +41 -0
  38. tick_backtest-0.1.1/src/tick_backtest/config_parsers/metrics/config_parser.py +110 -0
  39. tick_backtest-0.1.1/src/tick_backtest/config_parsers/metrics/config_registry.py +35 -0
  40. tick_backtest-0.1.1/src/tick_backtest/config_parsers/metrics/dataclasses/__init__.py +14 -0
  41. tick_backtest-0.1.1/src/tick_backtest/config_parsers/metrics/dataclasses/drift_sign_config.py +49 -0
  42. tick_backtest-0.1.1/src/tick_backtest/config_parsers/metrics/dataclasses/ewma_config.py +58 -0
  43. tick_backtest-0.1.1/src/tick_backtest/config_parsers/metrics/dataclasses/ewma_slope_config.py +68 -0
  44. tick_backtest-0.1.1/src/tick_backtest/config_parsers/metrics/dataclasses/ewma_vol_config.py +97 -0
  45. tick_backtest-0.1.1/src/tick_backtest/config_parsers/metrics/dataclasses/session_config.py +25 -0
  46. tick_backtest-0.1.1/src/tick_backtest/config_parsers/metrics/dataclasses/spread_config.py +50 -0
  47. tick_backtest-0.1.1/src/tick_backtest/config_parsers/metrics/dataclasses/tick_rate_config.py +38 -0
  48. tick_backtest-0.1.1/src/tick_backtest/config_parsers/metrics/dataclasses/zscore_config.py +39 -0
  49. tick_backtest-0.1.1/src/tick_backtest/config_parsers/strategy/__init__.py +21 -0
  50. tick_backtest-0.1.1/src/tick_backtest/config_parsers/strategy/config_dataclass.py +114 -0
  51. tick_backtest-0.1.1/src/tick_backtest/config_parsers/strategy/config_parser.py +144 -0
  52. tick_backtest-0.1.1/src/tick_backtest/config_parsers/strategy/config_registry.py +31 -0
  53. tick_backtest-0.1.1/src/tick_backtest/config_parsers/strategy/entry_configs.py +164 -0
  54. tick_backtest-0.1.1/src/tick_backtest/config_parsers/utils/utils.py +113 -0
  55. tick_backtest-0.1.1/src/tick_backtest/config_validation/__init__.py +23 -0
  56. tick_backtest-0.1.1/src/tick_backtest/config_validation/backtest.py +121 -0
  57. tick_backtest-0.1.1/src/tick_backtest/config_validation/metrics.py +108 -0
  58. tick_backtest-0.1.1/src/tick_backtest/config_validation/schema_registry.py +65 -0
  59. tick_backtest-0.1.1/src/tick_backtest/config_validation/strategy.py +170 -0
  60. tick_backtest-0.1.1/src/tick_backtest/data_feed/__init__.py +14 -0
  61. tick_backtest-0.1.1/src/tick_backtest/data_feed/_data_feed.pyx +238 -0
  62. tick_backtest-0.1.1/src/tick_backtest/data_feed/_data_feed_py.py +194 -0
  63. tick_backtest-0.1.1/src/tick_backtest/data_feed/data_feed.py +66 -0
  64. tick_backtest-0.1.1/src/tick_backtest/data_feed/tick.py +41 -0
  65. tick_backtest-0.1.1/src/tick_backtest/data_feed/validation.py +147 -0
  66. tick_backtest-0.1.1/src/tick_backtest/demo_data/EURUSD/EURUSD_2000-01.parquet +0 -0
  67. tick_backtest-0.1.1/src/tick_backtest/demo_data/EURUSD/EURUSD_2000-02.parquet +0 -0
  68. tick_backtest-0.1.1/src/tick_backtest/demo_data/GBPUSD/GBPUSD_2000-01.parquet +0 -0
  69. tick_backtest-0.1.1/src/tick_backtest/demo_data/GBPUSD/GBPUSD_2000-02.parquet +0 -0
  70. tick_backtest-0.1.1/src/tick_backtest/exceptions.py +30 -0
  71. tick_backtest-0.1.1/src/tick_backtest/logging_utils.py +229 -0
  72. tick_backtest-0.1.1/src/tick_backtest/metrics/__init__.py +14 -0
  73. tick_backtest-0.1.1/src/tick_backtest/metrics/indicators/__init__.py +14 -0
  74. tick_backtest-0.1.1/src/tick_backtest/metrics/indicators/_drift_sign_metric.pyx +97 -0
  75. tick_backtest-0.1.1/src/tick_backtest/metrics/indicators/_ewma_metric.pyx +112 -0
  76. tick_backtest-0.1.1/src/tick_backtest/metrics/indicators/_ewma_slope_metric.pyx +142 -0
  77. tick_backtest-0.1.1/src/tick_backtest/metrics/indicators/_ewma_vol_metric.pyx +111 -0
  78. tick_backtest-0.1.1/src/tick_backtest/metrics/indicators/_session_metric.pyx +68 -0
  79. tick_backtest-0.1.1/src/tick_backtest/metrics/indicators/_spread_metric.pyx +105 -0
  80. tick_backtest-0.1.1/src/tick_backtest/metrics/indicators/_threshold_reversion_metric.pyx +359 -0
  81. tick_backtest-0.1.1/src/tick_backtest/metrics/indicators/_tick_rate_metric.pyx +78 -0
  82. tick_backtest-0.1.1/src/tick_backtest/metrics/indicators/_zscore_metric.pyx +92 -0
  83. tick_backtest-0.1.1/src/tick_backtest/metrics/indicators/drift_sign_metric.py +29 -0
  84. tick_backtest-0.1.1/src/tick_backtest/metrics/indicators/ewma_metric.py +83 -0
  85. tick_backtest-0.1.1/src/tick_backtest/metrics/indicators/ewma_slope_metric.py +82 -0
  86. tick_backtest-0.1.1/src/tick_backtest/metrics/indicators/ewma_vol_metric.py +29 -0
  87. tick_backtest-0.1.1/src/tick_backtest/metrics/indicators/session_metric.py +29 -0
  88. tick_backtest-0.1.1/src/tick_backtest/metrics/indicators/spread_metric.py +86 -0
  89. tick_backtest-0.1.1/src/tick_backtest/metrics/indicators/threshold_reversion_metric.py +29 -0
  90. tick_backtest-0.1.1/src/tick_backtest/metrics/indicators/tick_rate_metric.py +63 -0
  91. tick_backtest-0.1.1/src/tick_backtest/metrics/indicators/zscore_metric.py +29 -0
  92. tick_backtest-0.1.1/src/tick_backtest/metrics/manager/__init__.py +14 -0
  93. tick_backtest-0.1.1/src/tick_backtest/metrics/manager/_metrics_manager.pyx +94 -0
  94. tick_backtest-0.1.1/src/tick_backtest/metrics/manager/metric_registry.py +33 -0
  95. tick_backtest-0.1.1/src/tick_backtest/metrics/manager/metrics_manager.py +71 -0
  96. tick_backtest-0.1.1/src/tick_backtest/metrics/primitives/__init__.py +14 -0
  97. tick_backtest-0.1.1/src/tick_backtest/metrics/primitives/_base_metric.pxd +21 -0
  98. tick_backtest-0.1.1/src/tick_backtest/metrics/primitives/_base_metric.pyx +34 -0
  99. tick_backtest-0.1.1/src/tick_backtest/metrics/primitives/_ewma.pyx +62 -0
  100. tick_backtest-0.1.1/src/tick_backtest/metrics/primitives/_ewma_py.py +45 -0
  101. tick_backtest-0.1.1/src/tick_backtest/metrics/primitives/_tick_conversion.pxd +17 -0
  102. tick_backtest-0.1.1/src/tick_backtest/metrics/primitives/_tick_conversion.pyx +54 -0
  103. tick_backtest-0.1.1/src/tick_backtest/metrics/primitives/_tick_types.pxd +21 -0
  104. tick_backtest-0.1.1/src/tick_backtest/metrics/primitives/_time_rolling_window.pyx +188 -0
  105. tick_backtest-0.1.1/src/tick_backtest/metrics/primitives/_time_rolling_window_py.py +102 -0
  106. tick_backtest-0.1.1/src/tick_backtest/metrics/primitives/_time_weighted_histogram.pyx +220 -0
  107. tick_backtest-0.1.1/src/tick_backtest/metrics/primitives/_time_weighted_histogram_py.py +92 -0
  108. tick_backtest-0.1.1/src/tick_backtest/metrics/primitives/base_metric.py +29 -0
  109. tick_backtest-0.1.1/src/tick_backtest/metrics/primitives/ewma.py +33 -0
  110. tick_backtest-0.1.1/src/tick_backtest/metrics/primitives/time_rolling_window.py +37 -0
  111. tick_backtest-0.1.1/src/tick_backtest/metrics/primitives/time_weighted_histogram.py +33 -0
  112. tick_backtest-0.1.1/src/tick_backtest/position/__init__.py +14 -0
  113. tick_backtest-0.1.1/src/tick_backtest/position/position.py +70 -0
  114. tick_backtest-0.1.1/src/tick_backtest/py.typed +1 -0
  115. tick_backtest-0.1.1/src/tick_backtest/scripts/__init__.py +14 -0
  116. tick_backtest-0.1.1/src/tick_backtest/scripts/analyse_reversion_sweep.py +309 -0
  117. tick_backtest-0.1.1/src/tick_backtest/scripts/build_reversion_sweep.py +180 -0
  118. tick_backtest-0.1.1/src/tick_backtest/signals/__init__.py +14 -0
  119. tick_backtest-0.1.1/src/tick_backtest/signals/entries/__init__.py +33 -0
  120. tick_backtest-0.1.1/src/tick_backtest/signals/entries/base.py +48 -0
  121. tick_backtest-0.1.1/src/tick_backtest/signals/entries/ewma_crossover.py +98 -0
  122. tick_backtest-0.1.1/src/tick_backtest/signals/entries/null.py +37 -0
  123. tick_backtest-0.1.1/src/tick_backtest/signals/entries/threshold_reversion.py +116 -0
  124. tick_backtest-0.1.1/src/tick_backtest/signals/predicates.py +65 -0
  125. tick_backtest-0.1.1/src/tick_backtest/signals/signal_data.py +29 -0
  126. tick_backtest-0.1.1/src/tick_backtest/signals/signal_generator.py +110 -0
  127. tick_backtest-0.1.1/src/tick_backtest.egg-info/PKG-INFO +346 -0
  128. tick_backtest-0.1.1/src/tick_backtest.egg-info/SOURCES.txt +131 -0
  129. tick_backtest-0.1.1/src/tick_backtest.egg-info/dependency_links.txt +1 -0
  130. tick_backtest-0.1.1/src/tick_backtest.egg-info/entry_points.txt +2 -0
  131. tick_backtest-0.1.1/src/tick_backtest.egg-info/not-zip-safe +1 -0
  132. tick_backtest-0.1.1/src/tick_backtest.egg-info/requires.txt +8 -0
  133. tick_backtest-0.1.1/src/tick_backtest.egg-info/top_level.txt +1 -0
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2025 Edward Clewer
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,21 @@
1
+ # Copyright 2025 Edward Clewer
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ include LICENSE
16
+ include README.md
17
+ recursive-include src/tick_backtest *.pyx *.pxd *.c
18
+ recursive-include src/tick_backtest/config *.yaml
19
+ include src/tick_backtest/py.typed
20
+ global-exclude *.so *.pyd
21
+ global-exclude __pycache__ *.py[cod]
@@ -0,0 +1,346 @@
1
+ Metadata-Version: 2.4
2
+ Name: tick-backtest
3
+ Version: 0.1.1
4
+ Summary: Local backtesting toolkit with Cython-accelerated primitives.
5
+ Author: Edward Clewer
6
+ Maintainer: Edward Clewer
7
+ License-Expression: Apache-2.0
8
+ Project-URL: Homepage, https://github.com/edwardclewer/tick_backtest
9
+ Project-URL: Documentation, https://edwardclewer.github.io/tick_backtest/
10
+ Project-URL: Source, https://github.com/edwardclewer/tick_backtest
11
+ Project-URL: Issues, https://github.com/edwardclewer/tick_backtest/issues
12
+ Project-URL: Changelog, https://github.com/edwardclewer/tick_backtest/blob/main/CHANGELOG.md
13
+ Keywords: backtesting,foreign-exchange,quantitative-finance,trading,cython
14
+ Classifier: Development Status :: 3 - Alpha
15
+ Classifier: Environment :: Console
16
+ Classifier: Intended Audience :: Financial and Insurance Industry
17
+ Classifier: Intended Audience :: Science/Research
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Programming Language :: Python
20
+ Classifier: Programming Language :: Python :: 3
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Cython
23
+ Classifier: Topic :: Office/Business :: Financial :: Investment
24
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
25
+ Requires-Python: >=3.12
26
+ Description-Content-Type: text/markdown
27
+ License-File: LICENSE
28
+ Requires-Dist: numpy<3.0,>=1.26
29
+ Requires-Dist: pandas<2.3,>=1.5
30
+ Requires-Dist: pyarrow<16.0,>=10.0
31
+ Requires-Dist: matplotlib<3.9,>=3.7
32
+ Requires-Dist: pyyaml<6.1,>=6.0
33
+ Provides-Extra: tests
34
+ Requires-Dist: pytest<9.0,>=8.0; extra == "tests"
35
+ Dynamic: license-file
36
+
37
+ <!--
38
+ Copyright 2025 Edward Clewer
39
+
40
+ Licensed under the Apache License, Version 2.0 (the "License");
41
+ you may not use this file except in compliance with the License.
42
+ You may obtain a copy of the License at
43
+
44
+ http://www.apache.org/licenses/LICENSE-2.0
45
+
46
+ Unless required by applicable law or agreed to in writing, software
47
+ distributed under the License is distributed on an "AS IS" BASIS,
48
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
49
+ See the License for the specific language governing permissions and
50
+ limitations under the License.
51
+ -->
52
+
53
+ # Tick Backtest
54
+
55
+ *Deterministic tick-level FX backtesting for reproducible research.*
56
+
57
+ Tick Backtest is a configuration-first Python 3.12 toolkit for reproducible FX strategy research. You provide Parquet ticks and YAML configs; the stack validates every setting, executes deterministic backtests, and writes manifests, logs, reports, and analysis artefacts to disk.
58
+
59
+ ### Highlights
60
+ - **Performance:** ~8 million ticks/minute/core on AMD 5950X (Parquet → metrics → signals → trades)
61
+ - **Deterministic runs:** Deterministic runs: config, git hash, dependency snapshot, and shard hashes captured per run
62
+ - **Resilient pipelines:** Resilient pipelines: per-pair failure isolation, tick validation, and structured telemetry
63
+ - **Declarative research:** Declarative research: swap YAML configs instead of editing code
64
+ - **Report ready:** Report ready: trade tables, Markdown summaries, metric stratification CSV/PNG artefacts
65
+ - **CLI + API parity:** Every supported command is exposed both as `tick-backtest ...` and `tick_backtest.api.*(...)`
66
+
67
+ Documentation is hosted here: [Documentation Site](https://edwardclewer.github.io/tick_backtest/).
68
+ Release process details are documented in [docs/releasing.md](docs/releasing.md).
69
+
70
+ ---
71
+
72
+ ## Quickstart
73
+
74
+ 1. **Install prerequisites**
75
+ ```bash
76
+ python3.12 -m venv .venv
77
+ source .venv/bin/activate
78
+ pip install tick-backtest
79
+ ```
80
+
81
+ 2. **Write a starter config**
82
+ ```bash
83
+ tick-backtest example-config --output ./demo --include-demo-data
84
+ ```
85
+
86
+ 3. **Run the bundled demo project**
87
+ ```bash
88
+ tick-backtest run ./demo/backtest.yaml
89
+ ```
90
+
91
+ 4. **Generate report artefacts for a single trade file**
92
+ ```bash
93
+ tick-backtest report ./demo/output/<RUN_ID>/output/EURUSD/trades.parquet
94
+ ```
95
+
96
+ 5. **Run multivariate trade analysis**
97
+ ```bash
98
+ tick-backtest analyze ./demo/output/<RUN_ID>/output/EURUSD/trades.parquet
99
+ ```
100
+
101
+ The same surface is available from Python:
102
+ ```python
103
+ from tick_backtest import api
104
+
105
+ api.example_config("./demo", include_demo_data=True)
106
+ api.run("./demo/backtest.yaml")
107
+ api.report("./demo/output/<RUN_ID>/output/EURUSD/trades.parquet")
108
+ api.analyze("./demo/output/<RUN_ID>/output/EURUSD/trades.parquet")
109
+ ```
110
+
111
+ The generated demo project includes:
112
+ - `backtest.yaml`, `metrics.yaml`, and `strategy.yaml`
113
+ - `demo_data/` with bundled EURUSD and GBPUSD parquet shards
114
+ - `output/` as the run destination declared in the emitted config
115
+
116
+ Config surfaces are intentionally split:
117
+ - `src/tick_backtest/config/templates/` and `src/tick_backtest/demo_data/` are the public packaged assets used by installed users.
118
+ - `config/` at the repository root is for checkout-only development, smoke tests, and CI golden runs.
119
+
120
+ For your own data instead of the bundled demo, emit the generic starter templates:
121
+ ```bash
122
+ tick-backtest example-config --output ./tick-backtest-config
123
+ ```
124
+ Then edit the generated YAML files:
125
+ ```yaml
126
+ # tick-backtest-config/backtest.yaml
127
+ data_base_path: "/abs/path/to/your/parquet/shards"
128
+ output_base_path: "/abs/path/to/backtest/output"
129
+ metrics_config_path: "./metrics.yaml"
130
+ strategy_config_path: "./strategy.yaml"
131
+ ```
132
+
133
+ Inspect outputs under the configured `output_base_path`:
134
+
135
+ | Path | Purpose |
136
+ | --- | --- |
137
+ | `manifest.json` | Immutable run snapshot (configs, git hash, shard hashes, status). |
138
+ | `output/logs/<RUN_ID>.log` | Structured NDJSON log with validation summaries and errors. |
139
+ | `output/<PAIR>/trades.parquet` | Trade-level dataset including metrics and PnL. |
140
+ | `output/<PAIR>/analysis/report.md` | Markdown analysis summary with equity plots. |
141
+ | `configs/*.yaml` | Copies of backtest/metrics/strategy configs with SHA256 digests. |
142
+
143
+ ---
144
+
145
+ ## Public Commands
146
+
147
+ | Command | Input | Output location |
148
+ | --- | --- | --- |
149
+ | `tick-backtest run <backtest.yaml>` | Backtest config | Writes a run directory under `output_base_path/<RUN_ID>/` |
150
+ | `tick-backtest report <trades.parquet>` | Trade database | Writes trade report artefacts and metric stratification beside the parquet file |
151
+ | `tick-backtest analyze <trades.parquet>` | Trade database | Writes `multivariate_analysis/` beside the parquet file |
152
+ | `tick-backtest example-config [--output DIR] [--include-demo-data]` | Optional destination dir | Prints starter YAML or writes a template set or runnable demo project |
153
+
154
+ ## Configuration Cheat Sheet
155
+
156
+ Tick Backtest is driven by three YAML files that are validated against strict schemas (unknown keys and duplicates are rejected).
157
+
158
+ <details>
159
+ <summary><strong>Backtest YAML</strong></summary>
160
+
161
+ ```yaml
162
+ schema_version: "1.0"
163
+ pairs: [EURUSD, GBPUSD]
164
+ start: 2012-02
165
+ end: 2013-02
166
+ pip_size: 0.0001
167
+ warmup_seconds: 1800
168
+ data_base_path: "/data/dukascopy/"
169
+ output_base_path: "/results/backtests/"
170
+ metrics_config_path: "config/metrics/default_metrics.yaml"
171
+ strategy_config_path: "config/strategy/default_strategy.yaml"
172
+ ```
173
+ Key fields: pair list, inclusive year-month span, data/output roots, warmup length, and the metric/strategy config locations.
174
+
175
+ </details>
176
+
177
+ <details>
178
+ <summary><strong>Metrics YAML</strong></summary>
179
+
180
+ ```yaml
181
+ metrics:
182
+ - name: z30m
183
+ type: zscore
184
+ enabled: true
185
+ params:
186
+ lookback_seconds: 1800
187
+ - name: ewma_vol_5m
188
+ type: ewma_vol
189
+ params:
190
+ tau_seconds: 300
191
+ percentile_horizon_seconds: 300
192
+ bins: 256
193
+ base_vol: 0.0001
194
+ stddev_cap: 5.0
195
+ ```
196
+ Entries wire directly into registries; unknown types or duplicate names raise immediately.
197
+
198
+ </details>
199
+
200
+ <details>
201
+ <summary><strong>Strategy YAML</strong></summary>
202
+
203
+ ```yaml
204
+ strategy:
205
+ name: threshold_reversion_strategy
206
+ entry:
207
+ engine: threshold_reversion
208
+ params:
209
+ threshold_pips: 10
210
+ tp_pips: 10
211
+ sl_pips: 20
212
+ trade_timeout_seconds: 7200
213
+ predicates:
214
+ - metric: tick_rate_30s.tick_rate_per_min
215
+ operator: "<"
216
+ value: 200
217
+ exit:
218
+ name: default_exit
219
+ predicates: []
220
+ ```
221
+ Entry engines and predicates gate trade opens; exit predicates can force closures.
222
+
223
+ </details>
224
+
225
+ Need full schemas or extension guidance? See the [Configuration Guide](https://edwardclewer.github.io/tick_backtest/configs/).
226
+
227
+ ---
228
+
229
+ ## Python API
230
+
231
+ | Function | Purpose |
232
+ | --- | --- |
233
+ | `tick_backtest.api.run(config_path, *, output_root=None)` | Run the backtest engine and write run artefacts only |
234
+ | `tick_backtest.api.report(trades_path)` | Generate trade report artefacts and metric stratification outputs |
235
+ | `tick_backtest.api.analyze(trades_path)` | Generate multivariate regression-style analysis outputs |
236
+ | `tick_backtest.api.example_config(dest=None, *, template="minimal", include_demo_data=False)` | Print or write starter YAML templates, optionally with bundled demo data |
237
+
238
+ The API is intentionally filesystem-oriented. It writes artefacts to disk and does not aim to return in-memory result objects.
239
+
240
+ ---
241
+
242
+ ## Repository Development
243
+
244
+ If you are working from a checkout rather than an installed package:
245
+
246
+ ```bash
247
+ python3.12 -m venv .venv
248
+ source .venv/bin/activate
249
+ pip install -r requirements.txt
250
+ pip install -e .
251
+ pytest
252
+ ```
253
+
254
+ Legacy repo scripts under `scripts/` still exist for internal development and CI coverage, but installed usage should go through `tick-backtest` or `tick_backtest.api`.
255
+
256
+ ## Release Posture
257
+
258
+ The project is versioned for public releases starting at `0.1.0`. Tagged releases publish via GitHub Actions using staged TestPyPI then PyPI trusted publishing. See [docs/releasing.md](docs/releasing.md) and [CHANGELOG.md](CHANGELOG.md).
259
+
260
+ ---
261
+
262
+ ## Architecture Snapshot
263
+ - `config/` – versioned YAML templates validated before runtime.
264
+ - `src/tick_backtest/config_parsers/` – schema validation → immutable dataclasses.
265
+ - `src/tick_backtest/data_feed/` – compiled tick loader with Python fallback; wrapped by `TickValidator`.
266
+ - `src/tick_backtest/backtest/` – `BacktestCoordinator` orchestrates per-pair runs; `Backtest` executes signals and positions.
267
+ - `src/tick_backtest/metrics/` – registries and indicator implementations (compiled with Python fallbacks).
268
+ - `src/tick_backtest/signals/` – predicate-aware entry/exit engines.
269
+ - `src/tick_backtest/analysis/` – reporting, stratification, and plotting utilities.
270
+ - `tests/` – unit, integration, and regression coverage across parsers, primitives, and pipeline stages.
271
+
272
+ **Data & validation flow**
273
+ 1. Configs are parsed with forbid-by-default schemas (`config_validation/*`).
274
+ 2. Tick feeds stream from Parquet; invalid ticks are skipped but logged.
275
+ 3. Per-pair runs are isolated; errors are captured without aborting the batch.
276
+ 4. Outputs, manifests, and environment snapshots land under `output/backtests/<RUN_ID>/`.
277
+
278
+ **Design Choice**: sequential execution avoids lookahead; scale comes from multi-pair orchestration and sweep automation.
279
+ Dive deeper in the [Developer Notes](https://edwardclewer.github.io/tick_backtest/dev/internals/).
280
+
281
+ ---
282
+
283
+ ## Troubleshooting Essentials
284
+
285
+ | Symptom | Likely Cause | Fix |
286
+ | --- | --- | --- |
287
+ | `ConfigError: unknown field ...` | Extra keys in YAML | Remove or rename; see [Configuration Guide](https://edwardclewer.github.io/tick_backtest/configs/). |
288
+ | `pyarrow` import error | Wheel missing | Install pinned version from `requirements.txt` and rerun. |
289
+ | Run finishes but no trades | Warmup consumed data or predicates blocked | Check `output/logs/<RUN_ID>.log` and entry predicates. |
290
+ | Manifest shows `missing_file` | `data_base_path` doesn’t match shard layout | Adjust path or supply expected Parquet shards. |
291
+ | Percentile metrics return `NaN` | Histogram warming up | Feed more ticks; expected during first few minutes. |
292
+
293
+ ---
294
+
295
+ ## Compatibility & Dependencies
296
+ - Python 3.12
297
+ - `numpy >= 1.26, < 3.0`
298
+ - `pandas >= 1.5, < 2.3`
299
+ - `pyarrow >= 10.0, < 16.0`
300
+ - `matplotlib >= 3.7, < 3.9`
301
+ - `pyyaml >= 6.0, < 6.1`
302
+
303
+ Running offline? Pre-install these wheels in your environment. Backtests abort if `pip freeze` fails (dependency snapshot is required).
304
+
305
+ ---
306
+
307
+ ## Testing & CI
308
+
309
+ ```bash
310
+ python3.12 -m venv .venv
311
+ source .venv/bin/activate
312
+ pip install -r requirements.txt
313
+ pip install -e .
314
+ pytest
315
+ ```
316
+
317
+ Coverage highlights:
318
+ - `tests/config_parsers` – YAML schema governance & regression checks.
319
+ - `tests/data_feed` – tick validation and resilience.
320
+ - `tests/metrics` – primitives plus indicator mathematics with reference helpers.
321
+ - `tests/integration/test_backtest_run.py` – end-to-end pipeline regression.
322
+
323
+ GitHub Actions builds wheels, runs tests, validates distribution metadata, and publishes docs via `.github/workflows/mkdocs.yml`.
324
+
325
+ ---
326
+
327
+ ## Extending the Stack
328
+ - **Add a metric** – create a dataclass under `metrics/dataclasses`, register it in `metrics/config_registry.py`, implement runtime logic. Validation blocks duplicates.
329
+ - **Add a signal engine** – add a class in `signals/entries`, register it in `ENTRY_ENGINE_REGISTRY`, and expose parameters in strategy YAML.
330
+ - **Support new data layouts** – extend `tick_backtest.data_feed` for alternative Parquet conventions; the validator enforces monotonic timestamps and finite spreads.
331
+
332
+ See the [Developer Notes](https://edwardclewer.github.io/tick_backtest/dev/internals/) for dependency maps, testing expectations, and release checklists.
333
+
334
+ ---
335
+
336
+ ## Next Steps
337
+ 1. Generate a starter config with `tick-backtest example-config`.
338
+ 2. Point it at your own Parquet tick data.
339
+ 3. Run `tick-backtest run` and inspect the generated manifest and pair-level artefacts.
340
+ 4. Explore the [documentation](https://edwardclewer.github.io/tick_backtest/) for advanced configuration and internals.
341
+
342
+ ---
343
+
344
+ **Author**: Edward Clewer
345
+ **License**: Apache License 2.0
346
+ **Docs**: [Docs](https://edwardclewer.github.io/tick_backtest/)