oracle3 1.1.2__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 (136) hide show
  1. oracle3-1.1.2/LICENSE +190 -0
  2. oracle3-1.1.2/PKG-INFO +166 -0
  3. oracle3-1.1.2/README.md +115 -0
  4. oracle3-1.1.2/coinjure/__init__.py +0 -0
  5. oracle3-1.1.2/coinjure/matching/__init__.py +66 -0
  6. oracle3-1.1.2/coinjure/matching/_cache.py +35 -0
  7. oracle3-1.1.2/coinjure/matching/_category.py +347 -0
  8. oracle3-1.1.2/coinjure/matching/_date.py +123 -0
  9. oracle3-1.1.2/coinjure/matching/_fetchers.py +284 -0
  10. oracle3-1.1.2/coinjure/matching/_pipeline.py +263 -0
  11. oracle3-1.1.2/coinjure/matching/_resolution.py +66 -0
  12. oracle3-1.1.2/coinjure/matching/_template.py +240 -0
  13. oracle3-1.1.2/coinjure/matching/_text.py +63 -0
  14. oracle3-1.1.2/coinjure/matching/_types.py +72 -0
  15. oracle3-1.1.2/oracle3/__init__.py +3 -0
  16. oracle3-1.1.2/oracle3/agent/__init__.py +9 -0
  17. oracle3-1.1.2/oracle3/agent/coordinator.py +328 -0
  18. oracle3-1.1.2/oracle3/alerts/__init__.py +6 -0
  19. oracle3-1.1.2/oracle3/alerts/alerter.py +173 -0
  20. oracle3-1.1.2/oracle3/alerts/telegram_alerter.py +45 -0
  21. oracle3-1.1.2/oracle3/analytics/performance_analyzer.py +336 -0
  22. oracle3-1.1.2/oracle3/backtest/backtester.py +123 -0
  23. oracle3-1.1.2/oracle3/blinks/__init__.py +1 -0
  24. oracle3-1.1.2/oracle3/blinks/generator.py +62 -0
  25. oracle3-1.1.2/oracle3/blinks/server.py +242 -0
  26. oracle3-1.1.2/oracle3/cli/__init__.py +1 -0
  27. oracle3-1.1.2/oracle3/cli/agent_commands.py +1008 -0
  28. oracle3-1.1.2/oracle3/cli/cli.py +444 -0
  29. oracle3-1.1.2/oracle3/cli/control.py +416 -0
  30. oracle3-1.1.2/oracle3/cli/data_commands.py +260 -0
  31. oracle3-1.1.2/oracle3/cli/market_commands.py +655 -0
  32. oracle3-1.1.2/oracle3/cli/monitor.py +733 -0
  33. oracle3-1.1.2/oracle3/cli/news_commands.py +246 -0
  34. oracle3-1.1.2/oracle3/cli/research_commands.py +2369 -0
  35. oracle3-1.1.2/oracle3/cli/textual_monitor.py +1129 -0
  36. oracle3-1.1.2/oracle3/cli/trade_commands.py +231 -0
  37. oracle3-1.1.2/oracle3/cli/utils.py +120 -0
  38. oracle3-1.1.2/oracle3/config/__init__.py +23 -0
  39. oracle3-1.1.2/oracle3/config/config.py +185 -0
  40. oracle3-1.1.2/oracle3/core/trading_engine.py +822 -0
  41. oracle3-1.1.2/oracle3/dashboard/__init__.py +5 -0
  42. oracle3-1.1.2/oracle3/dashboard/server.py +423 -0
  43. oracle3-1.1.2/oracle3/dashboard/static/demo.html +1691 -0
  44. oracle3-1.1.2/oracle3/dashboard/static/index.html +1255 -0
  45. oracle3-1.1.2/oracle3/dashboard/static/live.html +1208 -0
  46. oracle3-1.1.2/oracle3/data/backtest/dflow_recorder.py +218 -0
  47. oracle3-1.1.2/oracle3/data/backtest/historical_data_source.py +162 -0
  48. oracle3-1.1.2/oracle3/data/backtest/history_reader.py +66 -0
  49. oracle3-1.1.2/oracle3/data/backtest/kalshi_replay_data_source.py +212 -0
  50. oracle3-1.1.2/oracle3/data/base_fetcher.py +144 -0
  51. oracle3-1.1.2/oracle3/data/composite_data_source.py +82 -0
  52. oracle3-1.1.2/oracle3/data/data_source.py +26 -0
  53. oracle3-1.1.2/oracle3/data/live/coingecko_x402_data_source.py +213 -0
  54. oracle3-1.1.2/oracle3/data/live/dflow_data_source.py +322 -0
  55. oracle3-1.1.2/oracle3/data/live/dflow_ws_data_source.py +269 -0
  56. oracle3-1.1.2/oracle3/data/live/google_news_data_source.py +517 -0
  57. oracle3-1.1.2/oracle3/data/live/kalshi_data_source.py +308 -0
  58. oracle3-1.1.2/oracle3/data/live/live_data_source.py +1073 -0
  59. oracle3-1.1.2/oracle3/data/live/onchain_signal_source.py +207 -0
  60. oracle3-1.1.2/oracle3/data/live/polymarket_orderflow.py +473 -0
  61. oracle3-1.1.2/oracle3/data/live/twitter_fetcher.py +515 -0
  62. oracle3-1.1.2/oracle3/data/market_data_manager.py +233 -0
  63. oracle3-1.1.2/oracle3/data/preprocessing/__init__.py +1 -0
  64. oracle3-1.1.2/oracle3/data/preprocessing/news_processor.py +678 -0
  65. oracle3-1.1.2/oracle3/engine/__init__.py +1 -0
  66. oracle3-1.1.2/oracle3/engine/control.py +363 -0
  67. oracle3-1.1.2/oracle3/engine/registry.py +351 -0
  68. oracle3-1.1.2/oracle3/events/events.py +165 -0
  69. oracle3-1.1.2/oracle3/live/live_trader.py +789 -0
  70. oracle3-1.1.2/oracle3/market/__init__.py +25 -0
  71. oracle3-1.1.2/oracle3/market/relations.py +405 -0
  72. oracle3-1.1.2/oracle3/market/validation.py +639 -0
  73. oracle3-1.1.2/oracle3/mock/__init__.py +0 -0
  74. oracle3-1.1.2/oracle3/mock/mock_mode.py +96 -0
  75. oracle3-1.1.2/oracle3/onchain/__init__.py +5 -0
  76. oracle3-1.1.2/oracle3/onchain/logger.py +182 -0
  77. oracle3-1.1.2/oracle3/onchain/reputation.py +236 -0
  78. oracle3-1.1.2/oracle3/order/order_book.py +50 -0
  79. oracle3-1.1.2/oracle3/position/position_manager.py +189 -0
  80. oracle3-1.1.2/oracle3/pricing/__init__.py +76 -0
  81. oracle3-1.1.2/oracle3/pricing/calibrator.py +369 -0
  82. oracle3-1.1.2/oracle3/pricing/contract_scorer.py +269 -0
  83. oracle3-1.1.2/oracle3/pricing/distortion.py +338 -0
  84. oracle3-1.1.2/oracle3/pricing/fair_value.py +330 -0
  85. oracle3-1.1.2/oracle3/pricing/greeks.py +224 -0
  86. oracle3-1.1.2/oracle3/pricing/premium_tracker.py +339 -0
  87. oracle3-1.1.2/oracle3/pricing/wang_mle.py +620 -0
  88. oracle3-1.1.2/oracle3/risk/correlation_risk_manager.py +301 -0
  89. oracle3-1.1.2/oracle3/risk/onchain_risk_manager.py +208 -0
  90. oracle3-1.1.2/oracle3/risk/risk_manager.py +345 -0
  91. oracle3-1.1.2/oracle3/storage/__init__.py +6 -0
  92. oracle3-1.1.2/oracle3/storage/serializers.py +202 -0
  93. oracle3-1.1.2/oracle3/storage/state_store.py +177 -0
  94. oracle3-1.1.2/oracle3/strategy/__init__.py +19 -0
  95. oracle3-1.1.2/oracle3/strategy/agent_strategy.py +331 -0
  96. oracle3-1.1.2/oracle3/strategy/contrib/__init__.py +25 -0
  97. oracle3-1.1.2/oracle3/strategy/contrib/adaptive_onchain_strategy.py +585 -0
  98. oracle3-1.1.2/oracle3/strategy/contrib/allocation_strategy.py +159 -0
  99. oracle3-1.1.2/oracle3/strategy/contrib/coint_spread_strategy.py +409 -0
  100. oracle3-1.1.2/oracle3/strategy/contrib/conditional_arb_strategy.py +364 -0
  101. oracle3-1.1.2/oracle3/strategy/contrib/cross_market_arbitrage_strategy.py +820 -0
  102. oracle3-1.1.2/oracle3/strategy/contrib/debate_strategy.py +850 -0
  103. oracle3-1.1.2/oracle3/strategy/contrib/event_sum_arb_strategy.py +250 -0
  104. oracle3-1.1.2/oracle3/strategy/contrib/exclusivity_arb_strategy.py +289 -0
  105. oracle3-1.1.2/oracle3/strategy/contrib/fair_value_strategy.py +278 -0
  106. oracle3-1.1.2/oracle3/strategy/contrib/implication_arb_strategy.py +276 -0
  107. oracle3-1.1.2/oracle3/strategy/contrib/lead_lag_strategy.py +722 -0
  108. oracle3-1.1.2/oracle3/strategy/contrib/llm_news_strategy.py +384 -0
  109. oracle3-1.1.2/oracle3/strategy/contrib/multi_agent_strategy.py +106 -0
  110. oracle3-1.1.2/oracle3/strategy/contrib/premium_decay_strategy.py +397 -0
  111. oracle3-1.1.2/oracle3/strategy/contrib/prompts.py +222 -0
  112. oracle3-1.1.2/oracle3/strategy/contrib/solana_agent_strategy.py +458 -0
  113. oracle3-1.1.2/oracle3/strategy/contrib/structural_arb_strategy.py +356 -0
  114. oracle3-1.1.2/oracle3/strategy/loader.py +52 -0
  115. oracle3-1.1.2/oracle3/strategy/market_making_strategy.py +168 -0
  116. oracle3-1.1.2/oracle3/strategy/momentum_mean_reversion_strategy.py +213 -0
  117. oracle3-1.1.2/oracle3/strategy/orderbook_imbalance_strategy.py +161 -0
  118. oracle3-1.1.2/oracle3/strategy/quant_strategy.py +34 -0
  119. oracle3-1.1.2/oracle3/strategy/simple_strategy.py +1017 -0
  120. oracle3-1.1.2/oracle3/strategy/strategy.py +373 -0
  121. oracle3-1.1.2/oracle3/strategy/test_strategy.py +66 -0
  122. oracle3-1.1.2/oracle3/ticker/ticker.py +139 -0
  123. oracle3-1.1.2/oracle3/trader/atomic_trader.py +275 -0
  124. oracle3-1.1.2/oracle3/trader/flash_loan.py +263 -0
  125. oracle3-1.1.2/oracle3/trader/jito_submitter.py +253 -0
  126. oracle3-1.1.2/oracle3/trader/kalshi_trader.py +296 -0
  127. oracle3-1.1.2/oracle3/trader/paper_trader.py +192 -0
  128. oracle3-1.1.2/oracle3/trader/polymarket_trader.py +356 -0
  129. oracle3-1.1.2/oracle3/trader/solana_trader.py +426 -0
  130. oracle3-1.1.2/oracle3/trader/spread_executor.py +308 -0
  131. oracle3-1.1.2/oracle3/trader/trader.py +136 -0
  132. oracle3-1.1.2/oracle3/trader/types.py +119 -0
  133. oracle3-1.1.2/oracle3/trading/__init__.py +5 -0
  134. oracle3-1.1.2/oracle3/trading/allocator.py +211 -0
  135. oracle3-1.1.2/oracle3/trading/sizing.py +218 -0
  136. oracle3-1.1.2/pyproject.toml +222 -0
oracle3-1.1.2/LICENSE ADDED
@@ -0,0 +1,190 @@
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 the 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 the 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 any 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
+ Copyright 2025 Yicheng Yang
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
oracle3-1.1.2/PKG-INFO ADDED
@@ -0,0 +1,166 @@
1
+ Metadata-Version: 2.4
2
+ Name: oracle3
3
+ Version: 1.1.2
4
+ Summary: Autonomous on-chain trading agent for Solana prediction markets — LLM reasoning, quantitative signals, and atomic execution
5
+ License: Apache-2.0
6
+ License-File: LICENSE
7
+ Keywords: solana,dflow,polymarket,kalshi,prediction-market,trading,llm,ai-agent,algorithmic-trading
8
+ Author: Yicheng Yang
9
+ Author-email: yy85@illinois.edu
10
+ Requires-Python: >=3.10,<4.0
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: Financial and Insurance Industry
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: License :: OSI Approved :: Apache Software License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3.14
22
+ Classifier: Topic :: Office/Business :: Financial :: Investment
23
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
24
+ Classifier: Typing :: Typed
25
+ Provides-Extra: blinks
26
+ Provides-Extra: llm
27
+ Requires-Dist: beartype (>=0.22.9,<0.23.0)
28
+ Requires-Dist: beautifulsoup4 (>=4.12.0)
29
+ Requires-Dist: click (>=8.1.7,<9.0.0)
30
+ Requires-Dist: cryptography
31
+ Requires-Dist: fastapi (>=0.100.0) ; extra == "blinks"
32
+ Requires-Dist: feedparser (>=6.0.0)
33
+ Requires-Dist: httpx (>=0.24.0)
34
+ Requires-Dist: kalshi-python
35
+ Requires-Dist: litellm (>=1.0.0) ; extra == "llm"
36
+ Requires-Dist: openai (>=1.0.0)
37
+ Requires-Dist: openai-agents
38
+ Requires-Dist: py-clob-client
39
+ Requires-Dist: pydantic (>=2.8.2,<3.0.0)
40
+ Requires-Dist: requests (>=2.28.0)
41
+ Requires-Dist: rich (>=13.7.0,<14.0.0)
42
+ Requires-Dist: solana (>=0.34.0)
43
+ Requires-Dist: solders (>=0.21.0)
44
+ Requires-Dist: tenacity (>=8.2.0)
45
+ Requires-Dist: textual (>=0.50.0)
46
+ Requires-Dist: uvicorn (>=0.20.0) ; extra == "blinks"
47
+ Project-URL: Homepage, https://github.com/YichengYang-Ethan/oracle3
48
+ Project-URL: Repository, https://github.com/YichengYang-Ethan/oracle3
49
+ Description-Content-Type: text/markdown
50
+
51
+ # Oracle3
52
+
53
+ **Autonomous prediction market trading agent across Kalshi, Polymarket, and Solana.**
54
+
55
+ [![Tests](https://github.com/YichengYang-Ethan/oracle3/actions/workflows/pytest.yml/badge.svg)](https://github.com/YichengYang-Ethan/oracle3/actions)
56
+ [![Lint](https://github.com/YichengYang-Ethan/oracle3/actions/workflows/ruff.yml/badge.svg)](https://github.com/YichengYang-Ethan/oracle3/actions)
57
+ [![Type Check](https://github.com/YichengYang-Ethan/oracle3/actions/workflows/mypy.yml/badge.svg)](https://github.com/YichengYang-Ethan/oracle3/actions)
58
+ [![codecov](https://codecov.io/gh/YichengYang-Ethan/oracle3/branch/main/graph/badge.svg)](https://codecov.io/gh/YichengYang-Ethan/oracle3)
59
+ ![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue)
60
+ [![License](https://img.shields.io/badge/license-Apache%202.0-green)](LICENSE)
61
+ [![Discussions](https://img.shields.io/github/discussions/YichengYang-Ethan/oracle3)](https://github.com/YichengYang-Ethan/oracle3/discussions)
62
+ [![Last Commit](https://img.shields.io/github/last-commit/YichengYang-Ethan/oracle3)](https://github.com/YichengYang-Ethan/oracle3/commits/main)
63
+ [![Docs](https://img.shields.io/badge/docs-mkdocs-blue)](https://yichengyang-ethan.github.io/oracle3/)
64
+ [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.20062548.svg)](https://doi.org/10.5281/zenodo.20062548)
65
+
66
+ ## Why this exists
67
+
68
+ Prediction markets price binary contracts at systematically biased levels — a true 50/50 contract typically trades around **0.57** (favorite-longshot bias, $\hat{\lambda} \approx 0.183$). Most trading bots ignore this distortion entirely. Oracle3 operationalizes a peer-reviewed pricing model, calibrated on **291,309 resolved contracts** across six venues, to systematically harvest the bias through arbitrage detection and Kelly-sized model trades.
69
+
70
+ This system deploys the exact $\lambda$ estimates and covariate model from [prediction-market-pricing](https://github.com/YichengYang-Ethan/prediction-market-pricing) (Yang, 2026) as its real-time pricing engine.
71
+
72
+ ## How oracle3 differs from existing prediction-market tools
73
+
74
+ | | Oracle3 | polymarket-whales | prediction-market-maker | py-clob-client |
75
+ |---|---------|-------------------|-------------------------|----------------|
76
+ | Pricing model | Wang Transform (calibrated MLE) | None | Bid-ask MM | None |
77
+ | Constraint-based arbitrage | 8 strategies | None | None | N/A |
78
+ | Multi-venue | Kalshi + Polymarket + Solana | Polymarket only | Polymarket only | Polymarket only |
79
+ | On-chain execution | Solana via DFlow + Jito | No | No | N/A (SDK) |
80
+ | Working paper | Yang (2026), SSRN | No | No | No |
81
+ | Tests | 633 | 0 | 0 | 50+ |
82
+ | License | Apache 2.0 | MIT | MIT | MIT |
83
+
84
+ ## Architecture
85
+
86
+ ```mermaid
87
+ graph TD
88
+ A[Wang Transform Pricing Engine<br/>MLE coefficients from paper] --> B[Fair Value Estimator<br/>Model Greeks · Kelly Sizing]
89
+ B --> C[Strategy Layer]
90
+ C --> D[8 Constraint-Based Arbitrage]
91
+ C --> E[2 Model-Driven Strategies]
92
+ C --> F[LLM Agent Strategies]
93
+ D --> G[Trading Engine<br/>SpreadExecutor · Risk Manager · Position Tracker]
94
+ E --> G
95
+ F --> G
96
+ G --> H[Kalshi]
97
+ G --> I[Polymarket]
98
+ G --> J[Solana / DFlow]
99
+ ```
100
+
101
+ ## Strategies
102
+
103
+ **Constraint-based arbitrage** — each exploits a violated probability axiom:
104
+
105
+ | Strategy | Invariant |
106
+ |----------|-----------|
107
+ | Cross-Market | Same event, same price across exchanges |
108
+ | Exclusivity | $P(A) + P(B) \leq 1$ for mutually exclusive events |
109
+ | Implication | $P(A) \leq P(B)$ when A implies B |
110
+ | Conditional | $P(A \mid B) \in [L, U]$ within derived bounds |
111
+ | Event Sum | $\sum P(\text{outcome}_i) = 1$ within an event |
112
+ | Structural | $P(A) = \beta \cdot P(B) + \alpha$ from calibrated model |
113
+
114
+ **Statistical arbitrage**: cointegration spread (self-calibrating z-score), lead-lag (cross-correlation).
115
+
116
+ **Model-driven**: fair value divergence (Wang-model edge), premium decay (rides predictable premium lifecycle).
117
+
118
+ ## Pricing Engine
119
+
120
+ Deploys the Wang Transform from Yang (2026), calibrated on 291,309 contracts across 6 platforms:
121
+
122
+ $$p^{\text{mkt}} = \Phi\bigl(\Phi^{-1}(p^*) + \lambda\bigr), \quad \hat{\lambda} = 0.183 \; (p < 10^{-15})$$
123
+
124
+ - **Hierarchical model**: $\lambda_i = 0.259 - 0.072 \ln(1+V) + 0.143 \ln(1+D) - 0.477 |p-0.5|$
125
+ - **Model Greeks**: $\partial p / \partial \lambda$, Kelly fraction, edge decay rate
126
+ - **Online calibrator**: hybrid batch MLE + streaming EWMA with category shrinkage
127
+ - **Correlation-aware risk**: EWMA correlation matrix, effective exposure limits
128
+
129
+ > Yang, Y. (2026). *Pricing Prediction Markets: Risk Premiums, Incomplete Markets, and a Decomposition Framework.* Working Paper, UIUC. [[Replication package]](https://github.com/YichengYang-Ethan/prediction-market-pricing)
130
+
131
+ ## Quick Start
132
+
133
+ ```bash
134
+ git clone https://github.com/YichengYang-Ethan/oracle3.git && cd oracle3
135
+ poetry install
136
+
137
+ oracle3 market list --exchange polymarket --limit 10
138
+ oracle3 dashboard --exchange solana --initial-capital 10000
139
+ ```
140
+
141
+ See [docs](https://yichengyang-ethan.github.io/oracle3/) for full CLI reference.
142
+
143
+ ## Key Technical Choices
144
+
145
+ - **Event-driven async engine** with snapshot persistence and Unix socket control (pause/resume/killswitch)
146
+ - **SpreadExecutor** with automatic LIFO unwind on partial fills — no naked multi-leg positions
147
+ - **Dual-layer risk**: local position/drawdown/exposure limits + Solana `simulateTransaction` pre-flight
148
+ - **On-chain audit trail** via Solana Memo program; Jito bundle submission for MEV protection
149
+ - **633 tests**, ruff, mypy, codespell CI on every push
150
+
151
+ ## Star History
152
+
153
+ [![Star History Chart](https://api.star-history.com/svg?repos=YichengYang-Ethan/oracle3&type=Date)](https://star-history.com/#YichengYang-Ethan/oracle3&Date)
154
+
155
+ ## Contributors
156
+
157
+ [![Contributors](https://contrib.rocks/image?repo=YichengYang-Ethan/oracle3)](https://github.com/YichengYang-Ethan/oracle3/graphs/contributors)
158
+
159
+ If oracle3 helps your research or trading, please ⭐ star the repo — it helps others find it.
160
+
161
+ ## License
162
+
163
+ Apache 2.0 — see [LICENSE](LICENSE) for details.
164
+
165
+ *This software is for research and educational purposes. Trading involves financial risk.*
166
+
@@ -0,0 +1,115 @@
1
+ # Oracle3
2
+
3
+ **Autonomous prediction market trading agent across Kalshi, Polymarket, and Solana.**
4
+
5
+ [![Tests](https://github.com/YichengYang-Ethan/oracle3/actions/workflows/pytest.yml/badge.svg)](https://github.com/YichengYang-Ethan/oracle3/actions)
6
+ [![Lint](https://github.com/YichengYang-Ethan/oracle3/actions/workflows/ruff.yml/badge.svg)](https://github.com/YichengYang-Ethan/oracle3/actions)
7
+ [![Type Check](https://github.com/YichengYang-Ethan/oracle3/actions/workflows/mypy.yml/badge.svg)](https://github.com/YichengYang-Ethan/oracle3/actions)
8
+ [![codecov](https://codecov.io/gh/YichengYang-Ethan/oracle3/branch/main/graph/badge.svg)](https://codecov.io/gh/YichengYang-Ethan/oracle3)
9
+ ![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue)
10
+ [![License](https://img.shields.io/badge/license-Apache%202.0-green)](LICENSE)
11
+ [![Discussions](https://img.shields.io/github/discussions/YichengYang-Ethan/oracle3)](https://github.com/YichengYang-Ethan/oracle3/discussions)
12
+ [![Last Commit](https://img.shields.io/github/last-commit/YichengYang-Ethan/oracle3)](https://github.com/YichengYang-Ethan/oracle3/commits/main)
13
+ [![Docs](https://img.shields.io/badge/docs-mkdocs-blue)](https://yichengyang-ethan.github.io/oracle3/)
14
+ [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.20062548.svg)](https://doi.org/10.5281/zenodo.20062548)
15
+
16
+ ## Why this exists
17
+
18
+ Prediction markets price binary contracts at systematically biased levels — a true 50/50 contract typically trades around **0.57** (favorite-longshot bias, $\hat{\lambda} \approx 0.183$). Most trading bots ignore this distortion entirely. Oracle3 operationalizes a peer-reviewed pricing model, calibrated on **291,309 resolved contracts** across six venues, to systematically harvest the bias through arbitrage detection and Kelly-sized model trades.
19
+
20
+ This system deploys the exact $\lambda$ estimates and covariate model from [prediction-market-pricing](https://github.com/YichengYang-Ethan/prediction-market-pricing) (Yang, 2026) as its real-time pricing engine.
21
+
22
+ ## How oracle3 differs from existing prediction-market tools
23
+
24
+ | | Oracle3 | polymarket-whales | prediction-market-maker | py-clob-client |
25
+ |---|---------|-------------------|-------------------------|----------------|
26
+ | Pricing model | Wang Transform (calibrated MLE) | None | Bid-ask MM | None |
27
+ | Constraint-based arbitrage | 8 strategies | None | None | N/A |
28
+ | Multi-venue | Kalshi + Polymarket + Solana | Polymarket only | Polymarket only | Polymarket only |
29
+ | On-chain execution | Solana via DFlow + Jito | No | No | N/A (SDK) |
30
+ | Working paper | Yang (2026), SSRN | No | No | No |
31
+ | Tests | 633 | 0 | 0 | 50+ |
32
+ | License | Apache 2.0 | MIT | MIT | MIT |
33
+
34
+ ## Architecture
35
+
36
+ ```mermaid
37
+ graph TD
38
+ A[Wang Transform Pricing Engine<br/>MLE coefficients from paper] --> B[Fair Value Estimator<br/>Model Greeks · Kelly Sizing]
39
+ B --> C[Strategy Layer]
40
+ C --> D[8 Constraint-Based Arbitrage]
41
+ C --> E[2 Model-Driven Strategies]
42
+ C --> F[LLM Agent Strategies]
43
+ D --> G[Trading Engine<br/>SpreadExecutor · Risk Manager · Position Tracker]
44
+ E --> G
45
+ F --> G
46
+ G --> H[Kalshi]
47
+ G --> I[Polymarket]
48
+ G --> J[Solana / DFlow]
49
+ ```
50
+
51
+ ## Strategies
52
+
53
+ **Constraint-based arbitrage** — each exploits a violated probability axiom:
54
+
55
+ | Strategy | Invariant |
56
+ |----------|-----------|
57
+ | Cross-Market | Same event, same price across exchanges |
58
+ | Exclusivity | $P(A) + P(B) \leq 1$ for mutually exclusive events |
59
+ | Implication | $P(A) \leq P(B)$ when A implies B |
60
+ | Conditional | $P(A \mid B) \in [L, U]$ within derived bounds |
61
+ | Event Sum | $\sum P(\text{outcome}_i) = 1$ within an event |
62
+ | Structural | $P(A) = \beta \cdot P(B) + \alpha$ from calibrated model |
63
+
64
+ **Statistical arbitrage**: cointegration spread (self-calibrating z-score), lead-lag (cross-correlation).
65
+
66
+ **Model-driven**: fair value divergence (Wang-model edge), premium decay (rides predictable premium lifecycle).
67
+
68
+ ## Pricing Engine
69
+
70
+ Deploys the Wang Transform from Yang (2026), calibrated on 291,309 contracts across 6 platforms:
71
+
72
+ $$p^{\text{mkt}} = \Phi\bigl(\Phi^{-1}(p^*) + \lambda\bigr), \quad \hat{\lambda} = 0.183 \; (p < 10^{-15})$$
73
+
74
+ - **Hierarchical model**: $\lambda_i = 0.259 - 0.072 \ln(1+V) + 0.143 \ln(1+D) - 0.477 |p-0.5|$
75
+ - **Model Greeks**: $\partial p / \partial \lambda$, Kelly fraction, edge decay rate
76
+ - **Online calibrator**: hybrid batch MLE + streaming EWMA with category shrinkage
77
+ - **Correlation-aware risk**: EWMA correlation matrix, effective exposure limits
78
+
79
+ > Yang, Y. (2026). *Pricing Prediction Markets: Risk Premiums, Incomplete Markets, and a Decomposition Framework.* Working Paper, UIUC. [[Replication package]](https://github.com/YichengYang-Ethan/prediction-market-pricing)
80
+
81
+ ## Quick Start
82
+
83
+ ```bash
84
+ git clone https://github.com/YichengYang-Ethan/oracle3.git && cd oracle3
85
+ poetry install
86
+
87
+ oracle3 market list --exchange polymarket --limit 10
88
+ oracle3 dashboard --exchange solana --initial-capital 10000
89
+ ```
90
+
91
+ See [docs](https://yichengyang-ethan.github.io/oracle3/) for full CLI reference.
92
+
93
+ ## Key Technical Choices
94
+
95
+ - **Event-driven async engine** with snapshot persistence and Unix socket control (pause/resume/killswitch)
96
+ - **SpreadExecutor** with automatic LIFO unwind on partial fills — no naked multi-leg positions
97
+ - **Dual-layer risk**: local position/drawdown/exposure limits + Solana `simulateTransaction` pre-flight
98
+ - **On-chain audit trail** via Solana Memo program; Jito bundle submission for MEV protection
99
+ - **633 tests**, ruff, mypy, codespell CI on every push
100
+
101
+ ## Star History
102
+
103
+ [![Star History Chart](https://api.star-history.com/svg?repos=YichengYang-Ethan/oracle3&type=Date)](https://star-history.com/#YichengYang-Ethan/oracle3&Date)
104
+
105
+ ## Contributors
106
+
107
+ [![Contributors](https://contrib.rocks/image?repo=YichengYang-Ethan/oracle3)](https://github.com/YichengYang-Ethan/oracle3/graphs/contributors)
108
+
109
+ If oracle3 helps your research or trading, please ⭐ star the repo — it helps others find it.
110
+
111
+ ## License
112
+
113
+ Apache 2.0 — see [LICENSE](LICENSE) for details.
114
+
115
+ *This software is for research and educational purposes. Trading involves financial risk.*
File without changes
@@ -0,0 +1,66 @@
1
+ """Cross-platform market matching pipeline.
2
+
3
+ Usage::
4
+
5
+ from coinjure.matching import MarketMatchingPipeline
6
+
7
+ pipeline = MarketMatchingPipeline()
8
+ matches = await pipeline.scan()
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ from typing import TYPE_CHECKING
14
+
15
+ from ._pipeline import MarketMatchingPipeline
16
+ from ._types import MatchConfidence, MatchResult, NormalizedMarket, StageScores
17
+
18
+ if TYPE_CHECKING:
19
+ from examples.strategies.cross_platform_arb_strategy import MatchedMarket
20
+
21
+ __all__ = [
22
+ 'MarketMatchingPipeline',
23
+ 'MatchConfidence',
24
+ 'MatchResult',
25
+ 'NormalizedMarket',
26
+ 'StageScores',
27
+ ]
28
+
29
+
30
+ def match_result_to_matched_market(result: MatchResult) -> MatchedMarket:
31
+ """Bridge function to convert a MatchResult to a legacy MatchedMarket.
32
+
33
+ Requires oracle3 to be importable. Returns a MatchedMarket instance
34
+ from ``examples.strategies.cross_platform_arb_strategy``.
35
+ """
36
+ from oracle3.ticker.ticker import KalshiTicker, PolyMarketTicker
37
+
38
+ poly = result.poly_market
39
+ kalshi = result.kalshi_market
40
+
41
+ poly_ticker = PolyMarketTicker(
42
+ symbol=poly.get_extra_str('token_id', poly.market_id) or poly.market_id,
43
+ name=poly.title,
44
+ token_id=poly.get_extra_str('token_id'),
45
+ market_id=poly.market_id,
46
+ event_id=poly.event_id,
47
+ no_token_id=poly.get_extra_str('no_token_id'),
48
+ )
49
+ kalshi_ticker = KalshiTicker(
50
+ symbol=kalshi.market_id,
51
+ name=kalshi.title,
52
+ market_ticker=kalshi.get_extra_str('market_ticker', kalshi.market_id),
53
+ event_ticker=kalshi.get_extra_str('event_ticker', kalshi.event_id),
54
+ series_ticker=kalshi.series_ticker,
55
+ )
56
+
57
+ # Import MatchedMarket from the strategy module
58
+ from examples.strategies.cross_platform_arb_strategy import MatchedMarket
59
+
60
+ return MatchedMarket(
61
+ poly_ticker=poly_ticker,
62
+ kalshi_ticker=kalshi_ticker,
63
+ similarity=result.score,
64
+ label=result.label,
65
+ confidence=result.confidence.value,
66
+ )
@@ -0,0 +1,35 @@
1
+ """Simple in-memory TTL cache."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import time
6
+ from typing import TypeVar
7
+
8
+ T = TypeVar('T')
9
+
10
+
11
+ class TTLCache:
12
+ """Thread-safe-ish TTL cache for API responses."""
13
+
14
+ def __init__(self, ttl_seconds: float = 300.0) -> None:
15
+ self._ttl = ttl_seconds
16
+ self._store: dict[str, tuple[float, object]] = {}
17
+
18
+ def get(self, key: str) -> object | None:
19
+ """Return cached value if not expired, else None."""
20
+ entry = self._store.get(key)
21
+ if entry is None:
22
+ return None
23
+ ts, value = entry
24
+ if time.monotonic() - ts > self._ttl:
25
+ del self._store[key]
26
+ return None
27
+ return value
28
+
29
+ def set(self, key: str, value: object) -> None:
30
+ """Store a value with the current timestamp."""
31
+ self._store[key] = (time.monotonic(), value)
32
+
33
+ def clear(self) -> None:
34
+ """Clear all entries."""
35
+ self._store.clear()