tradefloor 0.5.0__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.
- tradefloor-0.5.0/LICENSE-APACHE +202 -0
- tradefloor-0.5.0/LICENSE-MIT +21 -0
- tradefloor-0.5.0/NOTICE +6 -0
- tradefloor-0.5.0/PKG-INFO +183 -0
- tradefloor-0.5.0/README.md +147 -0
- tradefloor-0.5.0/pyproject.toml +74 -0
- tradefloor-0.5.0/python/tradefloor/__init__.py +673 -0
- tradefloor-0.5.0/python/tradefloor/_core.pyi +369 -0
- tradefloor-0.5.0/python/tradefloor/atlas.py +1335 -0
- tradefloor-0.5.0/python/tradefloor/baselines.py +525 -0
- tradefloor-0.5.0/python/tradefloor/checkpoint.py +304 -0
- tradefloor-0.5.0/python/tradefloor/edgar.py +857 -0
- tradefloor-0.5.0/python/tradefloor/envelope.py +1037 -0
- tradefloor-0.5.0/python/tradefloor/facts.py +1318 -0
- tradefloor-0.5.0/python/tradefloor/gym.py +323 -0
- tradefloor-0.5.0/python/tradefloor/harness.py +614 -0
- tradefloor-0.5.0/python/tradefloor/loss.py +389 -0
- tradefloor-0.5.0/python/tradefloor/manifest.py +869 -0
- tradefloor-0.5.0/python/tradefloor/mcp.py +1488 -0
- tradefloor-0.5.0/python/tradefloor/portfolio.py +347 -0
- tradefloor-0.5.0/python/tradefloor/pretium.pdb +0 -0
- tradefloor-0.5.0/python/tradefloor/py.typed +0 -0
- tradefloor-0.5.0/python/tradefloor/ranking.py +496 -0
- tradefloor-0.5.0/python/tradefloor/replay.py +135 -0
- tradefloor-0.5.0/python/tradefloor/scenario.py +1031 -0
- tradefloor-0.5.0/python/tradefloor/spec.py +815 -0
- tradefloor-0.5.0/python/tradefloor/sweep.py +150 -0
- tradefloor-0.5.0/python/tradefloor/tca.py +428 -0
- tradefloor-0.5.0/python/tradefloor/universe_util.py +40 -0
- tradefloor-0.5.0/rust/Cargo.lock +1140 -0
- tradefloor-0.5.0/rust/Cargo.toml +131 -0
- tradefloor-0.5.0/rust/LICENSE-APACHE +202 -0
- tradefloor-0.5.0/rust/LICENSE-MIT +21 -0
- tradefloor-0.5.0/rust/NOTICE +6 -0
- tradefloor-0.5.0/rust/README.md +83 -0
- tradefloor-0.5.0/rust/src/economy/central_bank.rs +376 -0
- tradefloor-0.5.0/rust/src/economy/cycle.rs +160 -0
- tradefloor-0.5.0/rust/src/economy/daily.rs +891 -0
- tradefloor-0.5.0/rust/src/economy/invariants.rs +556 -0
- tradefloor-0.5.0/rust/src/economy/mod.rs +46 -0
- tradefloor-0.5.0/rust/src/economy/state.rs +532 -0
- tradefloor-0.5.0/rust/src/engine.rs +2946 -0
- tradefloor-0.5.0/rust/src/fair_value.rs +412 -0
- tradefloor-0.5.0/rust/src/lib.rs +83 -0
- tradefloor-0.5.0/rust/src/market/daily.rs +511 -0
- tradefloor-0.5.0/rust/src/market/factor_vol.rs +887 -0
- tradefloor-0.5.0/rust/src/market/factors.rs +1099 -0
- tradefloor-0.5.0/rust/src/market/garch.rs +536 -0
- tradefloor-0.5.0/rust/src/market/hours.rs +217 -0
- tradefloor-0.5.0/rust/src/market/index_value.rs +201 -0
- tradefloor-0.5.0/rust/src/market/mod.rs +71 -0
- tradefloor-0.5.0/rust/src/market/tick.rs +1034 -0
- tradefloor-0.5.0/rust/src/market_maker.rs +452 -0
- tradefloor-0.5.0/rust/src/mathx.rs +364 -0
- tradefloor-0.5.0/rust/src/microstructure.rs +892 -0
- tradefloor-0.5.0/rust/src/mispricing.rs +680 -0
- tradefloor-0.5.0/rust/src/order_book.rs +691 -0
- tradefloor-0.5.0/rust/src/params.rs +2989 -0
- tradefloor-0.5.0/rust/src/python.rs +555 -0
- tradefloor-0.5.0/rust/src/python_arrow.rs +657 -0
- tradefloor-0.5.0/rust/src/python_batch.rs +319 -0
- tradefloor-0.5.0/rust/src/python_book.rs +368 -0
- tradefloor-0.5.0/rust/src/python_engine.rs +2660 -0
- tradefloor-0.5.0/rust/src/python_log.rs +215 -0
- tradefloor-0.5.0/rust/src/python_params.rs +224 -0
- tradefloor-0.5.0/rust/src/rng.rs +787 -0
- tradefloor-0.5.0/rust/src/sectors.rs +184 -0
- tradefloor-0.5.0/rust/src/types.rs +19 -0
- tradefloor-0.5.0/rust/src/units.rs +147 -0
- tradefloor-0.5.0/rust/src/universe.rs +361 -0
- tradefloor-0.5.0/rust/src/wasm.rs +244 -0
- tradefloor-0.5.0/rust/sync-goldens.py +210 -0
- tradefloor-0.5.0/rust/tests/circuit_breaker.rs +382 -0
- tradefloor-0.5.0/rust/tests/roster_mutation.rs +249 -0
- tradefloor-0.5.0/rust/tests/stream_alignment.rs +212 -0
|
@@ -0,0 +1,202 @@
|
|
|
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 {yyyy} {name of copyright owner}
|
|
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.
|
|
202
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Simon Coombes
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
tradefloor-0.5.0/NOTICE
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tradefloor
|
|
3
|
+
Version: 0.5.0
|
|
4
|
+
Classifier: Development Status :: 3 - Alpha
|
|
5
|
+
Classifier: Intended Audience :: Science/Research
|
|
6
|
+
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Programming Language :: Rust
|
|
9
|
+
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
10
|
+
Classifier: Topic :: Scientific/Engineering
|
|
11
|
+
Requires-Dist: pyarrow>=14 ; extra == 'arrow'
|
|
12
|
+
Requires-Dist: anthropic>=0.40 ; extra == 'claude'
|
|
13
|
+
Requires-Dist: pydantic>=2 ; extra == 'claude'
|
|
14
|
+
Requires-Dist: mcp>=2.0 ; extra == 'mcp'
|
|
15
|
+
Requires-Dist: numpy>=1.24 ; extra == 'rl'
|
|
16
|
+
Requires-Dist: gymnasium>=0.29 ; extra == 'rl'
|
|
17
|
+
Provides-Extra: arrow
|
|
18
|
+
Provides-Extra: claude
|
|
19
|
+
Provides-Extra: mcp
|
|
20
|
+
Provides-Extra: rl
|
|
21
|
+
License-File: LICENSE-APACHE
|
|
22
|
+
License-File: LICENSE-MIT
|
|
23
|
+
License-File: NOTICE
|
|
24
|
+
Summary: A reproducible evaluation environment for financial AI agents.
|
|
25
|
+
Keywords: simulation,finance,market,orderbook,deterministic,backtesting
|
|
26
|
+
Home-Page: https://tradefloor.dev
|
|
27
|
+
Author: Simon Coombes
|
|
28
|
+
License-Expression: MIT OR Apache-2.0
|
|
29
|
+
Requires-Python: >=3.11
|
|
30
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
31
|
+
Project-URL: Changelog, https://github.com/simoncoombes/tradefloor/releases
|
|
32
|
+
Project-URL: Documentation, https://tradefloor.dev
|
|
33
|
+
Project-URL: Homepage, https://tradefloor.dev
|
|
34
|
+
Project-URL: Repository, https://github.com/simoncoombes/tradefloor
|
|
35
|
+
|
|
36
|
+
# tradefloor
|
|
37
|
+
|
|
38
|
+
> Formerly **pretium**. Versions through 0.4.3 were published under that
|
|
39
|
+
> name and remain installable forever; results recorded against them replay
|
|
40
|
+
> under those exact versions. The rename changed no behaviour: 0.5.0
|
|
41
|
+
> reproduces the same known-answer digest on every platform.
|
|
42
|
+
|
|
43
|
+
[](https://github.com/simoncoombes/tradefloor/actions/workflows/determinism.yml)
|
|
44
|
+
[](#licence)
|
|
45
|
+
[](https://www.python.org/downloads/)
|
|
46
|
+
|
|
47
|
+
A market simulator you can run a strategy against. Rust core, Python API.
|
|
48
|
+
|
|
49
|
+
Give it a seed and a list of companies. It runs a market forward: prices, a
|
|
50
|
+
limit order book, fills, and an economy that moves each day. Your orders match
|
|
51
|
+
against real depth, so your trades move the price.
|
|
52
|
+
|
|
53
|
+
Real market data cannot tell you what happens if you trade differently, or what
|
|
54
|
+
caused a move. This can, because it computed every price.
|
|
55
|
+
|
|
56
|
+
## Install
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
pip install tradefloor
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Wheels for Linux, macOS and Windows on CPython 3.11+. No dependencies. The same
|
|
63
|
+
engine is a Rust crate: `cargo add tradefloor`.
|
|
64
|
+
|
|
65
|
+
The API can still change before 1.0. A published result cannot: new
|
|
66
|
+
coefficients ship as a new preset, so a run you cited last month replays this
|
|
67
|
+
month.
|
|
68
|
+
|
|
69
|
+
## First run
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
import tradefloor as tf
|
|
73
|
+
|
|
74
|
+
universe = tf.Universe.random(40, seed=111)
|
|
75
|
+
|
|
76
|
+
spec = tf.StrategySpec.momentum(lookback_days=1.0, top_k=5)
|
|
77
|
+
scores = tf.evaluate({"mine": spec}, seed=7, universe=universe, days=10)
|
|
78
|
+
|
|
79
|
+
scores["mine"].return_pct # what it made
|
|
80
|
+
scores["mine"].impact_bps # what its own footprint cost
|
|
81
|
+
scores["mine"].strategy_fingerprint # sha256, cite this
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
That is one market draw. It tells you as much about the seed as about the
|
|
85
|
+
strategy. `tf.rank` runs many seeds and compares them with a paired sign test.
|
|
86
|
+
|
|
87
|
+
## What you get
|
|
88
|
+
|
|
89
|
+
| | |
|
|
90
|
+
|---|---|
|
|
91
|
+
| `engine.truth()` | why each price moved: nine factors that sum to the move, to 1e-16 |
|
|
92
|
+
| counterfactual TCA | the same seed with your orders and without them |
|
|
93
|
+
| `tf.rank` | many seeds, paired sign tests |
|
|
94
|
+
| `RunManifest` | version, preset, seed, universe, macro, scenario. `reproduce()` stops on a mismatch |
|
|
95
|
+
| MCP server | eleven read-only tools for a coding agent |
|
|
96
|
+
| more | a Gymnasium environment, Arrow output, checkpoints, SEC EDGAR data, a browser build |
|
|
97
|
+
|
|
98
|
+
No historical dataset carries the labels `truth()` gives you. Real data shows
|
|
99
|
+
you that a stock fell. It never shows you that 60% of the fall was order flow.
|
|
100
|
+
|
|
101
|
+
To drive it from an agent:
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
pip install "tradefloor[mcp]"
|
|
105
|
+
claude mcp add tradefloor -- tradefloor-mcp
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Strategies, universes and scenarios are data, so a tool argument cannot reach
|
|
109
|
+
code. Each result carries its own caveats. See
|
|
110
|
+
[the MCP page](https://simoncoombes.github.io/tradefloor/mcp.html).
|
|
111
|
+
|
|
112
|
+
## How real it is
|
|
113
|
+
|
|
114
|
+
`tf.facts.measure()` scores fourteen statistics against real-market bands. The
|
|
115
|
+
default preset, `pt-v14`, holds all fourteen at one year and at two years. It
|
|
116
|
+
holds all fourteen on a roster it never saw, and thirteen on new seeds.
|
|
117
|
+
|
|
118
|
+
Five of the fourteen were calibration targets, and the bands both tuned the
|
|
119
|
+
model and graded it. So this is a stated envelope, not a test against market
|
|
120
|
+
data that was held back.
|
|
121
|
+
|
|
122
|
+
Five limits are measured and written down:
|
|
123
|
+
|
|
124
|
+
| limit | what it means |
|
|
125
|
+
|---|---|
|
|
126
|
+
| horizon | one year is certified. Two and five years are measured, not certified |
|
|
127
|
+
| volatility memory | it decays too fast |
|
|
128
|
+
| scenario size | the response has the right sign, but one run cannot size it |
|
|
129
|
+
| macro crises | an inflation crisis or a policy crisis needs a scenario to drive it |
|
|
130
|
+
| roster | certification used a sector-balanced roster, which no real index is |
|
|
131
|
+
|
|
132
|
+
`tf.envelope.check()` refuses a question that falls outside a limit, and
|
|
133
|
+
[the realism envelope](https://simoncoombes.github.io/tradefloor/realism-envelope.html) says
|
|
134
|
+
what each one forbids.
|
|
135
|
+
|
|
136
|
+
Good results here do not predict real returns. The prices come from a known
|
|
137
|
+
model, so a strategy shaped like that model looks excellent and teaches you
|
|
138
|
+
nothing. A strategy that fails here tells you more. There is one venue, no
|
|
139
|
+
latency, and no counterparty that adapts to you.
|
|
140
|
+
|
|
141
|
+
## Same seed, same market
|
|
142
|
+
|
|
143
|
+
Each release builds five targets, runs one fixed simulation in each, and
|
|
144
|
+
compares digests. A disagreement stops the release. The crate ships its own
|
|
145
|
+
`exp`, `log`, `sin` and `cos`, so the platform libm cannot change a result.
|
|
146
|
+
|
|
147
|
+
`pt-v14` became the default on 2026-08-28. Name your preset and your run
|
|
148
|
+
replays exactly. Every preset from `pt-v1` on is still selectable.
|
|
149
|
+
|
|
150
|
+
```python
|
|
151
|
+
eng = tf.Engine(seed=42, universe=u, model="pt-v10")
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Examples
|
|
155
|
+
|
|
156
|
+
Ten [`examples/`](https://github.com/simoncoombes/tradefloor/tree/main/examples) in reading order, run by the test suite:
|
|
157
|
+
|
|
158
|
+
| | |
|
|
159
|
+
|---|---|
|
|
160
|
+
| [`00-a-year-in-one-market`](https://github.com/simoncoombes/tradefloor/blob/main/examples/00-a-year-in-one-market.ipynb) | Start here: one company, one year, two crises, one chart |
|
|
161
|
+
| [`01-first-simulation`](https://github.com/simoncoombes/tradefloor/blob/main/examples/01-first-simulation.ipynb) | Universe, engine, order book, determinism |
|
|
162
|
+
| [`02-evaluating-a-strategy`](https://github.com/simoncoombes/tradefloor/blob/main/examples/02-evaluating-a-strategy.ipynb) | Specs, baselines, ranking across seeds |
|
|
163
|
+
| [`03-why-did-the-price-move`](https://github.com/simoncoombes/tradefloor/blob/main/examples/03-why-did-the-price-move.ipynb) | The nine factors that sum to every move |
|
|
164
|
+
| [`04-how-realistic-is-this`](https://github.com/simoncoombes/tradefloor/blob/main/examples/04-how-realistic-is-this.ipynb) | The realism panel and the limits |
|
|
165
|
+
| [`05-training-an-agent`](https://github.com/simoncoombes/tradefloor/blob/main/examples/05-training-an-agent.ipynb) | The Gymnasium environment, and what size costs |
|
|
166
|
+
| [`06-execution-and-impact`](https://github.com/simoncoombes/tradefloor/blob/main/examples/06-execution-and-impact.ipynb) | TCA and the counterfactual run |
|
|
167
|
+
| [`07-research-workflow.py`](https://github.com/simoncoombes/tradefloor/blob/main/examples/07-research-workflow.py) | A whole study in one file. It runs in about five seconds |
|
|
168
|
+
| [`08-claude-agent.py`](https://github.com/simoncoombes/tradefloor/blob/main/examples/08-claude-agent.py) | An LLM agent trading the market through the harness |
|
|
169
|
+
| [`09-a-pandemic-shaped-market`](https://github.com/simoncoombes/tradefloor/blob/main/examples/09-a-pandemic-shaped-market.ipynb) | A real 2020-21 macro path, and which fields transmit |
|
|
170
|
+
|
|
171
|
+
## More
|
|
172
|
+
|
|
173
|
+
Full docs: [**simoncoombes.github.io/tradefloor**](https://simoncoombes.github.io/tradefloor/).
|
|
174
|
+
|
|
175
|
+
To contribute, see [CONTRIBUTING.md](https://github.com/simoncoombes/tradefloor/blob/main/CONTRIBUTING.md) and [RELEASING.md](https://github.com/simoncoombes/tradefloor/blob/main/RELEASING.md). One rule shapes the
|
|
176
|
+
rest: a change to the simulated trajectory is a breaking change, whatever its
|
|
177
|
+
size.
|
|
178
|
+
|
|
179
|
+
To cite the software, see [CITATION.cff](https://github.com/simoncoombes/tradefloor/blob/main/CITATION.cff). To cite a result, use its
|
|
180
|
+
`RunManifest`.
|
|
181
|
+
|
|
182
|
+
Licence: MIT OR Apache-2.0, at your option. See [LICENSE-MIT](https://github.com/simoncoombes/tradefloor/blob/main/LICENSE-MIT) and [LICENSE-APACHE](https://github.com/simoncoombes/tradefloor/blob/main/LICENSE-APACHE).
|
|
183
|
+
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# tradefloor
|
|
2
|
+
|
|
3
|
+
> Formerly **pretium**. Versions through 0.4.3 were published under that
|
|
4
|
+
> name and remain installable forever; results recorded against them replay
|
|
5
|
+
> under those exact versions. The rename changed no behaviour: 0.5.0
|
|
6
|
+
> reproduces the same known-answer digest on every platform.
|
|
7
|
+
|
|
8
|
+
[](https://github.com/simoncoombes/tradefloor/actions/workflows/determinism.yml)
|
|
9
|
+
[](#licence)
|
|
10
|
+
[](https://www.python.org/downloads/)
|
|
11
|
+
|
|
12
|
+
A market simulator you can run a strategy against. Rust core, Python API.
|
|
13
|
+
|
|
14
|
+
Give it a seed and a list of companies. It runs a market forward: prices, a
|
|
15
|
+
limit order book, fills, and an economy that moves each day. Your orders match
|
|
16
|
+
against real depth, so your trades move the price.
|
|
17
|
+
|
|
18
|
+
Real market data cannot tell you what happens if you trade differently, or what
|
|
19
|
+
caused a move. This can, because it computed every price.
|
|
20
|
+
|
|
21
|
+
## Install
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
pip install tradefloor
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Wheels for Linux, macOS and Windows on CPython 3.11+. No dependencies. The same
|
|
28
|
+
engine is a Rust crate: `cargo add tradefloor`.
|
|
29
|
+
|
|
30
|
+
The API can still change before 1.0. A published result cannot: new
|
|
31
|
+
coefficients ship as a new preset, so a run you cited last month replays this
|
|
32
|
+
month.
|
|
33
|
+
|
|
34
|
+
## First run
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
import tradefloor as tf
|
|
38
|
+
|
|
39
|
+
universe = tf.Universe.random(40, seed=111)
|
|
40
|
+
|
|
41
|
+
spec = tf.StrategySpec.momentum(lookback_days=1.0, top_k=5)
|
|
42
|
+
scores = tf.evaluate({"mine": spec}, seed=7, universe=universe, days=10)
|
|
43
|
+
|
|
44
|
+
scores["mine"].return_pct # what it made
|
|
45
|
+
scores["mine"].impact_bps # what its own footprint cost
|
|
46
|
+
scores["mine"].strategy_fingerprint # sha256, cite this
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
That is one market draw. It tells you as much about the seed as about the
|
|
50
|
+
strategy. `tf.rank` runs many seeds and compares them with a paired sign test.
|
|
51
|
+
|
|
52
|
+
## What you get
|
|
53
|
+
|
|
54
|
+
| | |
|
|
55
|
+
|---|---|
|
|
56
|
+
| `engine.truth()` | why each price moved: nine factors that sum to the move, to 1e-16 |
|
|
57
|
+
| counterfactual TCA | the same seed with your orders and without them |
|
|
58
|
+
| `tf.rank` | many seeds, paired sign tests |
|
|
59
|
+
| `RunManifest` | version, preset, seed, universe, macro, scenario. `reproduce()` stops on a mismatch |
|
|
60
|
+
| MCP server | eleven read-only tools for a coding agent |
|
|
61
|
+
| more | a Gymnasium environment, Arrow output, checkpoints, SEC EDGAR data, a browser build |
|
|
62
|
+
|
|
63
|
+
No historical dataset carries the labels `truth()` gives you. Real data shows
|
|
64
|
+
you that a stock fell. It never shows you that 60% of the fall was order flow.
|
|
65
|
+
|
|
66
|
+
To drive it from an agent:
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
pip install "tradefloor[mcp]"
|
|
70
|
+
claude mcp add tradefloor -- tradefloor-mcp
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Strategies, universes and scenarios are data, so a tool argument cannot reach
|
|
74
|
+
code. Each result carries its own caveats. See
|
|
75
|
+
[the MCP page](https://simoncoombes.github.io/tradefloor/mcp.html).
|
|
76
|
+
|
|
77
|
+
## How real it is
|
|
78
|
+
|
|
79
|
+
`tf.facts.measure()` scores fourteen statistics against real-market bands. The
|
|
80
|
+
default preset, `pt-v14`, holds all fourteen at one year and at two years. It
|
|
81
|
+
holds all fourteen on a roster it never saw, and thirteen on new seeds.
|
|
82
|
+
|
|
83
|
+
Five of the fourteen were calibration targets, and the bands both tuned the
|
|
84
|
+
model and graded it. So this is a stated envelope, not a test against market
|
|
85
|
+
data that was held back.
|
|
86
|
+
|
|
87
|
+
Five limits are measured and written down:
|
|
88
|
+
|
|
89
|
+
| limit | what it means |
|
|
90
|
+
|---|---|
|
|
91
|
+
| horizon | one year is certified. Two and five years are measured, not certified |
|
|
92
|
+
| volatility memory | it decays too fast |
|
|
93
|
+
| scenario size | the response has the right sign, but one run cannot size it |
|
|
94
|
+
| macro crises | an inflation crisis or a policy crisis needs a scenario to drive it |
|
|
95
|
+
| roster | certification used a sector-balanced roster, which no real index is |
|
|
96
|
+
|
|
97
|
+
`tf.envelope.check()` refuses a question that falls outside a limit, and
|
|
98
|
+
[the realism envelope](https://simoncoombes.github.io/tradefloor/realism-envelope.html) says
|
|
99
|
+
what each one forbids.
|
|
100
|
+
|
|
101
|
+
Good results here do not predict real returns. The prices come from a known
|
|
102
|
+
model, so a strategy shaped like that model looks excellent and teaches you
|
|
103
|
+
nothing. A strategy that fails here tells you more. There is one venue, no
|
|
104
|
+
latency, and no counterparty that adapts to you.
|
|
105
|
+
|
|
106
|
+
## Same seed, same market
|
|
107
|
+
|
|
108
|
+
Each release builds five targets, runs one fixed simulation in each, and
|
|
109
|
+
compares digests. A disagreement stops the release. The crate ships its own
|
|
110
|
+
`exp`, `log`, `sin` and `cos`, so the platform libm cannot change a result.
|
|
111
|
+
|
|
112
|
+
`pt-v14` became the default on 2026-08-28. Name your preset and your run
|
|
113
|
+
replays exactly. Every preset from `pt-v1` on is still selectable.
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
eng = tf.Engine(seed=42, universe=u, model="pt-v10")
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Examples
|
|
120
|
+
|
|
121
|
+
Ten [`examples/`](https://github.com/simoncoombes/tradefloor/tree/main/examples) in reading order, run by the test suite:
|
|
122
|
+
|
|
123
|
+
| | |
|
|
124
|
+
|---|---|
|
|
125
|
+
| [`00-a-year-in-one-market`](https://github.com/simoncoombes/tradefloor/blob/main/examples/00-a-year-in-one-market.ipynb) | Start here: one company, one year, two crises, one chart |
|
|
126
|
+
| [`01-first-simulation`](https://github.com/simoncoombes/tradefloor/blob/main/examples/01-first-simulation.ipynb) | Universe, engine, order book, determinism |
|
|
127
|
+
| [`02-evaluating-a-strategy`](https://github.com/simoncoombes/tradefloor/blob/main/examples/02-evaluating-a-strategy.ipynb) | Specs, baselines, ranking across seeds |
|
|
128
|
+
| [`03-why-did-the-price-move`](https://github.com/simoncoombes/tradefloor/blob/main/examples/03-why-did-the-price-move.ipynb) | The nine factors that sum to every move |
|
|
129
|
+
| [`04-how-realistic-is-this`](https://github.com/simoncoombes/tradefloor/blob/main/examples/04-how-realistic-is-this.ipynb) | The realism panel and the limits |
|
|
130
|
+
| [`05-training-an-agent`](https://github.com/simoncoombes/tradefloor/blob/main/examples/05-training-an-agent.ipynb) | The Gymnasium environment, and what size costs |
|
|
131
|
+
| [`06-execution-and-impact`](https://github.com/simoncoombes/tradefloor/blob/main/examples/06-execution-and-impact.ipynb) | TCA and the counterfactual run |
|
|
132
|
+
| [`07-research-workflow.py`](https://github.com/simoncoombes/tradefloor/blob/main/examples/07-research-workflow.py) | A whole study in one file. It runs in about five seconds |
|
|
133
|
+
| [`08-claude-agent.py`](https://github.com/simoncoombes/tradefloor/blob/main/examples/08-claude-agent.py) | An LLM agent trading the market through the harness |
|
|
134
|
+
| [`09-a-pandemic-shaped-market`](https://github.com/simoncoombes/tradefloor/blob/main/examples/09-a-pandemic-shaped-market.ipynb) | A real 2020-21 macro path, and which fields transmit |
|
|
135
|
+
|
|
136
|
+
## More
|
|
137
|
+
|
|
138
|
+
Full docs: [**simoncoombes.github.io/tradefloor**](https://simoncoombes.github.io/tradefloor/).
|
|
139
|
+
|
|
140
|
+
To contribute, see [CONTRIBUTING.md](https://github.com/simoncoombes/tradefloor/blob/main/CONTRIBUTING.md) and [RELEASING.md](https://github.com/simoncoombes/tradefloor/blob/main/RELEASING.md). One rule shapes the
|
|
141
|
+
rest: a change to the simulated trajectory is a breaking change, whatever its
|
|
142
|
+
size.
|
|
143
|
+
|
|
144
|
+
To cite the software, see [CITATION.cff](https://github.com/simoncoombes/tradefloor/blob/main/CITATION.cff). To cite a result, use its
|
|
145
|
+
`RunManifest`.
|
|
146
|
+
|
|
147
|
+
Licence: MIT OR Apache-2.0, at your option. See [LICENSE-MIT](https://github.com/simoncoombes/tradefloor/blob/main/LICENSE-MIT) and [LICENSE-APACHE](https://github.com/simoncoombes/tradefloor/blob/main/LICENSE-APACHE).
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["maturin>=1.5,<2.0"]
|
|
3
|
+
build-backend = "maturin"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "tradefloor"
|
|
7
|
+
version = "0.5.0"
|
|
8
|
+
description = "A reproducible evaluation environment for financial AI agents."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
# Dual-licensed, the Rust-ecosystem norm. See LICENSE-APACHE and LICENSE-MIT
|
|
12
|
+
# at the repository root, and DECISIONS.md in pretium-design for the
|
|
13
|
+
# reasoning that superseded an earlier Apache-2.0-only decision.
|
|
14
|
+
license = "MIT OR Apache-2.0"
|
|
15
|
+
# Declared explicitly, and it has to be. Left to itself maturin finds the
|
|
16
|
+
# crate's own copies under rust/, records them in PKG-INFO by basename
|
|
17
|
+
# ("License-File: LICENSE-APACHE") but packages them at rust/LICENSE-APACHE.
|
|
18
|
+
# PyPI checks the declared path, finds nothing there, and rejects the sdist
|
|
19
|
+
# with a 400 while accepting every wheel, because a wheel carries its
|
|
20
|
+
# licences in .dist-info by a different mechanism. That asymmetry is why
|
|
21
|
+
# 0.1.0 published five wheels and no source distribution.
|
|
22
|
+
license-files = ["LICENSE-APACHE", "LICENSE-MIT", "NOTICE"]
|
|
23
|
+
authors = [{ name = "Simon Coombes" }]
|
|
24
|
+
keywords = ["simulation", "finance", "market", "orderbook", "deterministic", "backtesting"]
|
|
25
|
+
classifiers = [
|
|
26
|
+
"Development Status :: 3 - Alpha",
|
|
27
|
+
"Intended Audience :: Science/Research",
|
|
28
|
+
"Intended Audience :: Financial and Insurance Industry",
|
|
29
|
+
"Programming Language :: Python :: 3",
|
|
30
|
+
"Programming Language :: Rust",
|
|
31
|
+
"Topic :: Office/Business :: Financial :: Investment",
|
|
32
|
+
"Topic :: Scientific/Engineering",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
[project.urls]
|
|
36
|
+
Homepage = "https://tradefloor.dev"
|
|
37
|
+
Repository = "https://github.com/simoncoombes/tradefloor"
|
|
38
|
+
Documentation = "https://tradefloor.dev"
|
|
39
|
+
# PyPI has no changelog field, so a project page can only point at one.
|
|
40
|
+
# Without this a visitor has no route from the package to its release notes.
|
|
41
|
+
Changelog = "https://github.com/simoncoombes/tradefloor/releases"
|
|
42
|
+
|
|
43
|
+
[project.optional-dependencies]
|
|
44
|
+
# The core package depends on NOTHING. These are for surfaces that genuinely
|
|
45
|
+
# need them: the RL environment needs arrays, and the Arrow tables are read
|
|
46
|
+
# through whichever dataframe library the consumer already has.
|
|
47
|
+
rl = ["numpy>=1.24", "gymnasium>=0.29"]
|
|
48
|
+
arrow = ["pyarrow>=14"]
|
|
49
|
+
# examples/08-claude-agent.py drives an agent with the Claude API. Optional
|
|
50
|
+
# because nothing in the library calls it -- it is one example, and it needs
|
|
51
|
+
# an API key and spends money per decision.
|
|
52
|
+
claude = ["anthropic>=0.40", "pydantic>=2"]
|
|
53
|
+
# The MCP server, which lets an LLM agent drive the simulator over tool calls.
|
|
54
|
+
# Optional for the same reason as the rest: nothing in the library imports it,
|
|
55
|
+
# and a user who only wants the simulator should not install a server stack.
|
|
56
|
+
mcp = ["mcp>=2.0"]
|
|
57
|
+
|
|
58
|
+
[project.scripts]
|
|
59
|
+
# Speaks MCP over stdio. Point an MCP client at `tradefloor-mcp` with no
|
|
60
|
+
# arguments; see docs/mcp.md for a client configuration block.
|
|
61
|
+
tradefloor-mcp = "tradefloor.mcp:main"
|
|
62
|
+
|
|
63
|
+
[tool.maturin]
|
|
64
|
+
manifest-path = "rust/Cargo.toml"
|
|
65
|
+
# Mixed layout: the compiled extension is tradefloor._core and the Python package
|
|
66
|
+
# in python/ wraps it. Keeps the public name `tradefloor` while leaving room for
|
|
67
|
+
# pure-Python surface.
|
|
68
|
+
python-source = "python"
|
|
69
|
+
module-name = "tradefloor._core"
|
|
70
|
+
features = ["python"]
|
|
71
|
+
# The stub file and the PEP 561 marker must be INSTALLED, not merely present
|
|
72
|
+
# in the source tree. A stub that does not ship types nothing, and the failure
|
|
73
|
+
# is silent -- a type checker just falls back to Any.
|
|
74
|
+
include = ["python/tradefloor/py.typed", "python/tradefloor/_core.pyi"]
|