cjtrade 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.
Files changed (216) hide show
  1. cjtrade-0.5.0/LICENSE +21 -0
  2. cjtrade-0.5.0/PKG-INFO +304 -0
  3. cjtrade-0.5.0/README.md +241 -0
  4. cjtrade-0.5.0/pyproject.toml +142 -0
  5. cjtrade-0.5.0/src/cjtrade/README.md +106 -0
  6. cjtrade-0.5.0/src/cjtrade/__init__.py +9 -0
  7. cjtrade-0.5.0/src/cjtrade/apps/ArenaX/README.md +215 -0
  8. cjtrade-0.5.0/src/cjtrade/apps/ArenaX/__init__.py +1 -0
  9. cjtrade-0.5.0/src/cjtrade/apps/ArenaX/backtest_backend.py +82 -0
  10. cjtrade-0.5.0/src/cjtrade/apps/ArenaX/base_backend.py +1260 -0
  11. cjtrade-0.5.0/src/cjtrade/apps/ArenaX/brokerside_server.py +1199 -0
  12. cjtrade-0.5.0/src/cjtrade/apps/ArenaX/brokerside_server_admin_shell.py +431 -0
  13. cjtrade-0.5.0/src/cjtrade/apps/ArenaX/configs/backtest.cjsys +63 -0
  14. cjtrade-0.5.0/src/cjtrade/apps/ArenaX/configs/demo.cjsys +66 -0
  15. cjtrade-0.5.0/src/cjtrade/apps/ArenaX/configs/paper.cjsys +54 -0
  16. cjtrade-0.5.0/src/cjtrade/apps/ArenaX/configs/parse_cjsys_config.sh +22 -0
  17. cjtrade-0.5.0/src/cjtrade/apps/ArenaX/configs/real.cjsys +64 -0
  18. cjtrade-0.5.0/src/cjtrade/apps/ArenaX/demo_backend.py +83 -0
  19. cjtrade-0.5.0/src/cjtrade/apps/ArenaX/img/admin_shell.png +0 -0
  20. cjtrade-0.5.0/src/cjtrade/apps/ArenaX/img/arch.png +0 -0
  21. cjtrade-0.5.0/src/cjtrade/apps/ArenaX/img/arenax.png +0 -0
  22. cjtrade-0.5.0/src/cjtrade/apps/ArenaX/img/server.png +0 -0
  23. cjtrade-0.5.0/src/cjtrade/apps/ArenaX/market_data.py +417 -0
  24. cjtrade-0.5.0/src/cjtrade/apps/ArenaX/oder_result_helper.py +101 -0
  25. cjtrade-0.5.0/src/cjtrade/apps/ArenaX/paper_backend.py +200 -0
  26. cjtrade-0.5.0/src/cjtrade/apps/ArenaX/real_backend.py +287 -0
  27. cjtrade-0.5.0/src/cjtrade/apps/ArenaX/static/cj.ico +0 -0
  28. cjtrade-0.5.0/src/cjtrade/apps/ArenaX/tests/__init__.py +0 -0
  29. cjtrade-0.5.0/src/cjtrade/apps/ArenaX/tests/price_downloader.py +101 -0
  30. cjtrade-0.5.0/src/cjtrade/apps/ArenaX/tests/test_server_time.sh +111 -0
  31. cjtrade-0.5.0/src/cjtrade/apps/ArenaX/time_in_force.py +149 -0
  32. cjtrade-0.5.0/src/cjtrade/apps/ArenaX/trading_calendar.py +104 -0
  33. cjtrade-0.5.0/src/cjtrade/apps/CJEdit/README.md +23 -0
  34. cjtrade-0.5.0/src/cjtrade/apps/CJEdit/__init__.py +0 -0
  35. cjtrade-0.5.0/src/cjtrade/apps/CJEdit/editor.py +75 -0
  36. cjtrade-0.5.0/src/cjtrade/apps/CJEdit/img/cjedit_1.png +0 -0
  37. cjtrade-0.5.0/src/cjtrade/apps/CJEdit/img/cjedit_2.png +0 -0
  38. cjtrade-0.5.0/src/cjtrade/apps/CJEdit/main.py +38 -0
  39. cjtrade-0.5.0/src/cjtrade/apps/CJEdit/pages/index.toml +35 -0
  40. cjtrade-0.5.0/src/cjtrade/apps/CJEdit/template.py +103 -0
  41. cjtrade-0.5.0/src/cjtrade/apps/CJNews/README.md +32 -0
  42. cjtrade-0.5.0/src/cjtrade/apps/CJNews/img/search_interface.png +0 -0
  43. cjtrade-0.5.0/src/cjtrade/apps/CJNews/img/search_result.png +0 -0
  44. cjtrade-0.5.0/src/cjtrade/apps/CJNews/main.py +85 -0
  45. cjtrade-0.5.0/src/cjtrade/apps/CJShell/README.md +48 -0
  46. cjtrade-0.5.0/src/cjtrade/apps/CJShell/cjshell.py +1055 -0
  47. cjtrade-0.5.0/src/cjtrade/apps/CJShell/cjshell_legacy.py +995 -0
  48. cjtrade-0.5.0/src/cjtrade/apps/CJShell/img/llm.png +0 -0
  49. cjtrade-0.5.0/src/cjtrade/apps/CJShell/img/lspos.png +0 -0
  50. cjtrade-0.5.0/src/cjtrade/apps/CJShell/img/order.png +0 -0
  51. cjtrade-0.5.0/src/cjtrade/apps/CJShell/img/shell_help.png +0 -0
  52. cjtrade-0.5.0/src/cjtrade/apps/CJTrade/README.md +45 -0
  53. cjtrade-0.5.0/src/cjtrade/apps/CJTrade/__init__.py +0 -0
  54. cjtrade-0.5.0/src/cjtrade/apps/CJTrade/bot_a.py +26 -0
  55. cjtrade-0.5.0/src/cjtrade/apps/CJTrade/bot_b.py +40 -0
  56. cjtrade-0.5.0/src/cjtrade/apps/CJTrade/bot_c.py +34 -0
  57. cjtrade-0.5.0/src/cjtrade/apps/CJTrade/bot_custom.py +72 -0
  58. cjtrade-0.5.0/src/cjtrade/apps/CJTrade/bot_runner.py +505 -0
  59. cjtrade-0.5.0/src/cjtrade/apps/CJTrade/form.toml +79 -0
  60. cjtrade-0.5.0/src/cjtrade/apps/CJTrade/main.py +2067 -0
  61. cjtrade-0.5.0/src/cjtrade/apps/CJTrade/protocol.py +499 -0
  62. cjtrade-0.5.0/src/cjtrade/apps/CJTrade/status_api.py +574 -0
  63. cjtrade-0.5.0/src/cjtrade/apps/FinHub/README.md +185 -0
  64. cjtrade-0.5.0/src/cjtrade/apps/FinHub/__init__.py +0 -0
  65. cjtrade-0.5.0/src/cjtrade/apps/FinHub/auth.py +72 -0
  66. cjtrade-0.5.0/src/cjtrade/apps/FinHub/clients/__init__.py +52 -0
  67. cjtrade-0.5.0/src/cjtrade/apps/FinHub/clients/_segments.py +23 -0
  68. cjtrade-0.5.0/src/cjtrade/apps/FinHub/clients/arenax_client.py +308 -0
  69. cjtrade-0.5.0/src/cjtrade/apps/FinHub/clients/engine_client.py +144 -0
  70. cjtrade-0.5.0/src/cjtrade/apps/FinHub/clients/strategy_tool.py +131 -0
  71. cjtrade-0.5.0/src/cjtrade/apps/FinHub/clients/supervisor.py +632 -0
  72. cjtrade-0.5.0/src/cjtrade/apps/FinHub/config.py +79 -0
  73. cjtrade-0.5.0/src/cjtrade/apps/FinHub/database.py +42 -0
  74. cjtrade-0.5.0/src/cjtrade/apps/FinHub/img/finhub.png +0 -0
  75. cjtrade-0.5.0/src/cjtrade/apps/FinHub/main.py +1220 -0
  76. cjtrade-0.5.0/src/cjtrade/apps/FinHub/models.py +226 -0
  77. cjtrade-0.5.0/src/cjtrade/apps/FinHub/schemas.py +226 -0
  78. cjtrade-0.5.0/src/cjtrade/apps/FinHub/static/app.js +1636 -0
  79. cjtrade-0.5.0/src/cjtrade/apps/FinHub/static/login.js +48 -0
  80. cjtrade-0.5.0/src/cjtrade/apps/FinHub/static/register.js +53 -0
  81. cjtrade-0.5.0/src/cjtrade/apps/FinHub/static/style.css +119 -0
  82. cjtrade-0.5.0/src/cjtrade/apps/FinHub/static/vendor/codemirror.bundle.js +14 -0
  83. cjtrade-0.5.0/src/cjtrade/apps/FinHub/templates/index.html +590 -0
  84. cjtrade-0.5.0/src/cjtrade/apps/FinHub/templates/login.html +40 -0
  85. cjtrade-0.5.0/src/cjtrade/apps/FinHub/templates/register.html +55 -0
  86. cjtrade-0.5.0/src/cjtrade/apps/FinHub/tools/editor/README.md +63 -0
  87. cjtrade-0.5.0/src/cjtrade/apps/FinHub/tools/editor/entry.js +189 -0
  88. cjtrade-0.5.0/src/cjtrade/apps/FinHub/tools/editor/verify.mjs +129 -0
  89. cjtrade-0.5.0/src/cjtrade/apps/README.md +16 -0
  90. cjtrade-0.5.0/src/cjtrade/apps/insight.py +1613 -0
  91. cjtrade-0.5.0/src/cjtrade/apps/oneshot_backtest.py +493 -0
  92. cjtrade-0.5.0/src/cjtrade/apps/preload_prices.py +124 -0
  93. cjtrade-0.5.0/src/cjtrade/apps/strategy_tool.py +114 -0
  94. cjtrade-0.5.0/src/cjtrade/pkgs/__init__.py +0 -0
  95. cjtrade-0.5.0/src/cjtrade/pkgs/analytics/__init__.py +0 -0
  96. cjtrade-0.5.0/src/cjtrade/pkgs/analytics/backtest/__init__.py +4 -0
  97. cjtrade-0.5.0/src/cjtrade/pkgs/analytics/backtest/engine.py +347 -0
  98. cjtrade-0.5.0/src/cjtrade/pkgs/analytics/evaluation/__init__.py +1 -0
  99. cjtrade-0.5.0/src/cjtrade/pkgs/analytics/evaluation/multi_strategy_report.py +489 -0
  100. cjtrade-0.5.0/src/cjtrade/pkgs/analytics/evaluation/quantstats.py +485 -0
  101. cjtrade-0.5.0/src/cjtrade/pkgs/analytics/fundamental/__init__.py +333 -0
  102. cjtrade-0.5.0/src/cjtrade/pkgs/analytics/fundamental/models/__init__.py +1 -0
  103. cjtrade-0.5.0/src/cjtrade/pkgs/analytics/fundamental/models/announcement.py +56 -0
  104. cjtrade-0.5.0/src/cjtrade/pkgs/analytics/fundamental/models/company_info.py +27 -0
  105. cjtrade-0.5.0/src/cjtrade/pkgs/analytics/fundamental/models/financial_data.py +97 -0
  106. cjtrade-0.5.0/src/cjtrade/pkgs/analytics/fundamental/providers/__init__.py +1 -0
  107. cjtrade-0.5.0/src/cjtrade/pkgs/analytics/fundamental/providers/twse.py +690 -0
  108. cjtrade-0.5.0/src/cjtrade/pkgs/analytics/fundamental/utils/__init__.py +1 -0
  109. cjtrade-0.5.0/src/cjtrade/pkgs/analytics/fundamental/utils/parser.py +342 -0
  110. cjtrade-0.5.0/src/cjtrade/pkgs/analytics/informational/__init__.py +0 -0
  111. cjtrade-0.5.0/src/cjtrade/pkgs/analytics/informational/news_client.py +78 -0
  112. cjtrade-0.5.0/src/cjtrade/pkgs/analytics/informational/news_providers/__init__.py +14 -0
  113. cjtrade-0.5.0/src/cjtrade/pkgs/analytics/informational/news_providers/_base.py +47 -0
  114. cjtrade-0.5.0/src/cjtrade/pkgs/analytics/informational/news_providers/cnyes.py +317 -0
  115. cjtrade-0.5.0/src/cjtrade/pkgs/analytics/informational/news_providers/mock.py +94 -0
  116. cjtrade-0.5.0/src/cjtrade/pkgs/analytics/informational/news_providers/news_api.py +121 -0
  117. cjtrade-0.5.0/src/cjtrade/pkgs/analytics/informational/news_providers/statement_dog.py +33 -0
  118. cjtrade-0.5.0/src/cjtrade/pkgs/analytics/informational/sentiment_analysis.py +37 -0
  119. cjtrade-0.5.0/src/cjtrade/pkgs/analytics/technical/__init__.py +28 -0
  120. cjtrade-0.5.0/src/cjtrade/pkgs/analytics/technical/models/__init__.py +3 -0
  121. cjtrade-0.5.0/src/cjtrade/pkgs/analytics/technical/models/market_state.py +23 -0
  122. cjtrade-0.5.0/src/cjtrade/pkgs/analytics/technical/models/signal.py +21 -0
  123. cjtrade-0.5.0/src/cjtrade/pkgs/analytics/technical/strategies/fixed_price.py +46 -0
  124. cjtrade-0.5.0/src/cjtrade/pkgs/analytics/technical/talib_wrapper.py +56 -0
  125. cjtrade-0.5.0/src/cjtrade/pkgs/brokers/README.md +222 -0
  126. cjtrade-0.5.0/src/cjtrade/pkgs/brokers/__init__.py +0 -0
  127. cjtrade-0.5.0/src/cjtrade/pkgs/brokers/account_client.py +554 -0
  128. cjtrade-0.5.0/src/cjtrade/pkgs/brokers/arenax/__init__.py +0 -0
  129. cjtrade-0.5.0/src/cjtrade/pkgs/brokers/arenax/arenax_broker_api.py +660 -0
  130. cjtrade-0.5.0/src/cjtrade/pkgs/brokers/arenax/arenax_middleware.py +729 -0
  131. cjtrade-0.5.0/src/cjtrade/pkgs/brokers/arenax/doc/mock_backend_arch.png +0 -0
  132. cjtrade-0.5.0/src/cjtrade/pkgs/brokers/base_broker_api.py +350 -0
  133. cjtrade-0.5.0/src/cjtrade/pkgs/brokers/sinopac/__init__.py +10 -0
  134. cjtrade-0.5.0/src/cjtrade/pkgs/brokers/sinopac/_internal_func.py +565 -0
  135. cjtrade-0.5.0/src/cjtrade/pkgs/brokers/sinopac/sinopac_broker_api.py +1209 -0
  136. cjtrade-0.5.0/src/cjtrade/pkgs/chart/__init__.py +13 -0
  137. cjtrade-0.5.0/src/cjtrade/pkgs/chart/_chart_base.py +60 -0
  138. cjtrade-0.5.0/src/cjtrade/pkgs/chart/_plotly.py +563 -0
  139. cjtrade-0.5.0/src/cjtrade/pkgs/chart/kbar_client.py +206 -0
  140. cjtrade-0.5.0/src/cjtrade/pkgs/chart/models/__init__.py +5 -0
  141. cjtrade-0.5.0/src/cjtrade/pkgs/chart/models/kbar_data.py +66 -0
  142. cjtrade-0.5.0/src/cjtrade/pkgs/chart/templates/chart_template.html +195 -0
  143. cjtrade-0.5.0/src/cjtrade/pkgs/config/__init__.py +0 -0
  144. cjtrade-0.5.0/src/cjtrade/pkgs/config/config_loader.py +212 -0
  145. cjtrade-0.5.0/src/cjtrade/pkgs/db/db_api.py +615 -0
  146. cjtrade-0.5.0/src/cjtrade/pkgs/db/db_base.py +58 -0
  147. cjtrade-0.5.0/src/cjtrade/pkgs/db/duckdb.py +57 -0
  148. cjtrade-0.5.0/src/cjtrade/pkgs/db/sql/create_arenax_local_price_db.sql +51 -0
  149. cjtrade-0.5.0/src/cjtrade/pkgs/db/sql/create_cj_order_map.sql +9 -0
  150. cjtrade-0.5.0/src/cjtrade/pkgs/db/sql/create_fill_ledger.sql +40 -0
  151. cjtrade-0.5.0/src/cjtrade/pkgs/db/sql/create_order_ledger.sql +36 -0
  152. cjtrade-0.5.0/src/cjtrade/pkgs/db/sqlcmd.py +58 -0
  153. cjtrade-0.5.0/src/cjtrade/pkgs/db/sqlite.py +77 -0
  154. cjtrade-0.5.0/src/cjtrade/pkgs/llm/__init__.py +0 -0
  155. cjtrade-0.5.0/src/cjtrade/pkgs/llm/_llm_base.py +34 -0
  156. cjtrade-0.5.0/src/cjtrade/pkgs/llm/azure_openai.py +76 -0
  157. cjtrade-0.5.0/src/cjtrade/pkgs/llm/chatpdf.py +77 -0
  158. cjtrade-0.5.0/src/cjtrade/pkgs/llm/gemini.py +54 -0
  159. cjtrade-0.5.0/src/cjtrade/pkgs/llm/llm_pool.py +80 -0
  160. cjtrade-0.5.0/src/cjtrade/pkgs/llm/mock_llm.py +34 -0
  161. cjtrade-0.5.0/src/cjtrade/pkgs/logger.py +200 -0
  162. cjtrade-0.5.0/src/cjtrade/pkgs/marketdata/__init__.py +36 -0
  163. cjtrade-0.5.0/src/cjtrade/pkgs/marketdata/aggregate.py +137 -0
  164. cjtrade-0.5.0/src/cjtrade/pkgs/marketdata/arenax.py +65 -0
  165. cjtrade-0.5.0/src/cjtrade/pkgs/marketdata/base.py +312 -0
  166. cjtrade-0.5.0/src/cjtrade/pkgs/marketdata/cache.py +116 -0
  167. cjtrade-0.5.0/src/cjtrade/pkgs/marketdata/compose.py +184 -0
  168. cjtrade-0.5.0/src/cjtrade/pkgs/marketdata/factory.py +90 -0
  169. cjtrade-0.5.0/src/cjtrade/pkgs/marketdata/finmind.py +195 -0
  170. cjtrade-0.5.0/src/cjtrade/pkgs/marketdata/offline.py +35 -0
  171. cjtrade-0.5.0/src/cjtrade/pkgs/marketdata/sinopac.py +85 -0
  172. cjtrade-0.5.0/src/cjtrade/pkgs/marketdata/yfinance.py +123 -0
  173. cjtrade-0.5.0/src/cjtrade/pkgs/models/__init__.py +7 -0
  174. cjtrade-0.5.0/src/cjtrade/pkgs/models/backtest.py +332 -0
  175. cjtrade-0.5.0/src/cjtrade/pkgs/models/cost.py +184 -0
  176. cjtrade-0.5.0/src/cjtrade/pkgs/models/event.py +349 -0
  177. cjtrade-0.5.0/src/cjtrade/pkgs/models/kbar.py +79 -0
  178. cjtrade-0.5.0/src/cjtrade/pkgs/models/order.py +174 -0
  179. cjtrade-0.5.0/src/cjtrade/pkgs/models/position.py +45 -0
  180. cjtrade-0.5.0/src/cjtrade/pkgs/models/product.py +75 -0
  181. cjtrade-0.5.0/src/cjtrade/pkgs/models/quote.py +196 -0
  182. cjtrade-0.5.0/src/cjtrade/pkgs/models/rank_type.py +10 -0
  183. cjtrade-0.5.0/src/cjtrade/pkgs/models/tick.py +37 -0
  184. cjtrade-0.5.0/src/cjtrade/pkgs/models/trade.py +59 -0
  185. cjtrade-0.5.0/src/cjtrade/pkgs/paths.py +242 -0
  186. cjtrade-0.5.0/src/cjtrade/pkgs/risk/__init__.py +5 -0
  187. cjtrade-0.5.0/src/cjtrade/pkgs/risk/pre_trade.py +249 -0
  188. cjtrade-0.5.0/src/cjtrade/pkgs/strategy/__init__.py +7 -0
  189. cjtrade-0.5.0/src/cjtrade/pkgs/strategy/adx.py +480 -0
  190. cjtrade-0.5.0/src/cjtrade/pkgs/strategy/authoring.py +802 -0
  191. cjtrade-0.5.0/src/cjtrade/pkgs/strategy/base_strategy.py +287 -0
  192. cjtrade-0.5.0/src/cjtrade/pkgs/strategy/baseline_0050.py +158 -0
  193. cjtrade-0.5.0/src/cjtrade/pkgs/strategy/bb.py +264 -0
  194. cjtrade-0.5.0/src/cjtrade/pkgs/strategy/dca.py +292 -0
  195. cjtrade-0.5.0/src/cjtrade/pkgs/strategy/donchian.py +271 -0
  196. cjtrade-0.5.0/src/cjtrade/pkgs/strategy/parameters/__init__.py +36 -0
  197. cjtrade-0.5.0/src/cjtrade/pkgs/strategy/parameters/config.py +96 -0
  198. cjtrade-0.5.0/src/cjtrade/pkgs/strategy/parameters/manager.py +279 -0
  199. cjtrade-0.5.0/src/cjtrade/pkgs/strategy/parameters/presets.py +178 -0
  200. cjtrade-0.5.0/src/cjtrade/pkgs/strategy/parameters/schema.py +286 -0
  201. cjtrade-0.5.0/src/cjtrade/pkgs/strategy/snr.py +236 -0
  202. cjtrade-0.5.0/src/cjtrade/pkgs/strategy/user_strategy.py +1015 -0
  203. cjtrade-0.5.0/src/cjtrade/pkgs/ui/__init__.py +15 -0
  204. cjtrade-0.5.0/src/cjtrade/pkgs/ui/__main__.py +36 -0
  205. cjtrade-0.5.0/src/cjtrade/pkgs/ui/base_renderer.py +40 -0
  206. cjtrade-0.5.0/src/cjtrade/pkgs/ui/engine.py +338 -0
  207. cjtrade-0.5.0/src/cjtrade/pkgs/ui/renderers/__init__.py +0 -0
  208. cjtrade-0.5.0/src/cjtrade/pkgs/ui/renderers/cli.py +349 -0
  209. cjtrade-0.5.0/src/cjtrade/pkgs/ui/renderers/web.py +388 -0
  210. cjtrade-0.5.0/src/cjtrade/pkgs/ui/renderers/zenity.py +233 -0
  211. cjtrade-0.5.0/src/cjtrade/pkgs/ui/schema.py +252 -0
  212. cjtrade-0.5.0/src/cjtrade/pkgs/ui/user_state.py +88 -0
  213. cjtrade-0.5.0/src/cjtrade/pkgs/utils/date.py +211 -0
  214. cjtrade-0.5.0/src/cjtrade/pkgs/utils/extras.py +37 -0
  215. cjtrade-0.5.0/src/cjtrade/pkgs/utils/ncal.py +128 -0
  216. cjtrade-0.5.0/src/cjtrade/py.typed +0 -0
cjtrade-0.5.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Shou-Chi Chen
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.
cjtrade-0.5.0/PKG-INFO ADDED
@@ -0,0 +1,304 @@
1
+ Metadata-Version: 2.4
2
+ Name: cjtrade
3
+ Version: 0.5.0
4
+ Summary: Taiwan stock trading framework: brokers, market data, a simulated exchange and backtesting
5
+ Keywords: trading,backtesting,taiwan,twse,sinopac,shioaji,quant
6
+ Author: Shou-Chi Chen
7
+ Author-email: Shou-Chi Chen <tuxsogi@gmail.com>
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Intended Audience :: Financial and Insurance Industry
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Topic :: Office/Business :: Financial :: Investment
18
+ Classifier: Typing :: Typed
19
+ Requires-Dist: aiohttp>=3.13.0
20
+ Requires-Dist: apiflask>=2.2.0
21
+ Requires-Dist: duckdb>=1.4.3
22
+ Requires-Dist: flask>=3.1.2
23
+ Requires-Dist: msgpack>=1.1.1
24
+ Requires-Dist: numpy>=2.0
25
+ Requires-Dist: pandas>=2.2
26
+ Requires-Dist: platformdirs>=4.4.0
27
+ Requires-Dist: plotly>=6.5.1
28
+ Requires-Dist: python-dotenv>=1.1.1
29
+ Requires-Dist: pyzmq>=26.0
30
+ Requires-Dist: quantstats>=0.0.81
31
+ Requires-Dist: requests>=2.32
32
+ Requires-Dist: ta-lib>=0.6.7
33
+ Requires-Dist: toml>=0.10.2
34
+ Requires-Dist: yfinance>=0.2.66
35
+ Requires-Dist: pyreadline3 ; sys_platform == 'win32'
36
+ Requires-Dist: cjtrade[sinopac,llm,news,finhub] ; extra == 'all'
37
+ Requires-Dist: bcrypt==4.0.1 ; extra == 'finhub'
38
+ Requires-Dist: email-validator>=2.3.0 ; extra == 'finhub'
39
+ Requires-Dist: fastapi>=0.136.1 ; extra == 'finhub'
40
+ Requires-Dist: httpx>=0.28.1 ; extra == 'finhub'
41
+ Requires-Dist: jinja2>=3.1.6 ; extra == 'finhub'
42
+ Requires-Dist: passlib[bcrypt]>=1.7.4 ; extra == 'finhub'
43
+ Requires-Dist: pydantic-settings>=2.14.0 ; extra == 'finhub'
44
+ Requires-Dist: python-jose[cryptography]>=3.5.0 ; extra == 'finhub'
45
+ Requires-Dist: python-multipart>=0.0.27 ; extra == 'finhub'
46
+ Requires-Dist: sqlalchemy>=2.0.49 ; extra == 'finhub'
47
+ Requires-Dist: uvicorn[standard]>=0.46.0 ; extra == 'finhub'
48
+ Requires-Dist: google-genai>=1.56.0 ; extra == 'llm'
49
+ Requires-Dist: openai>=2.26.0 ; extra == 'llm'
50
+ Requires-Dist: newsapi-python>=0.2.7 ; extra == 'news'
51
+ Requires-Dist: shioaji>=1.2.8 ; extra == 'sinopac'
52
+ Requires-Python: >=3.12
53
+ Project-URL: Documentation, https://jackiesogi.github.io/CJTrade/
54
+ Project-URL: Homepage, https://github.com/jackiesogi/CJTrade
55
+ Project-URL: Issues, https://github.com/jackiesogi/CJTrade/issues
56
+ Project-URL: Source, https://github.com/jackiesogi/CJTrade
57
+ Provides-Extra: all
58
+ Provides-Extra: finhub
59
+ Provides-Extra: llm
60
+ Provides-Extra: news
61
+ Provides-Extra: sinopac
62
+ Description-Content-Type: text/markdown
63
+
64
+ # CJTrade
65
+
66
+ [![CI](https://github.com/jackiesogi/CJTrade/actions/workflows/ci.yml/badge.svg)](https://github.com/jackiesogi/CJTrade/actions/workflows/ci.yml)
67
+ [![Docs](https://img.shields.io/badge/docs-jackiesogi.github.io%2FCJTrade-blue)](https://jackiesogi.github.io/CJTrade/)
68
+ [![License: MIT](https://img.shields.io/badge/license-MIT-green)](https://github.com/jackiesogi/CJTrade/blob/master/LICENSE)
69
+
70
+ A Python framework for building trading systems for the Taiwan Stock Exchange
71
+ (TWSE). Write a strategy once against the CJTrade API, then run it against a
72
+ simulated broker, a historical replay, or a real brokerage account without
73
+ changing it.
74
+
75
+ **Documentation:** <https://jackiesogi.github.io/CJTrade/>
76
+ ([繁體中文](https://jackiesogi.github.io/CJTrade/zh-TW/))
77
+
78
+ ![CJTrade](https://raw.githubusercontent.com/jackiesogi/CJTrade/master/doc/assets/img/combined.png)
79
+
80
+ ## Features
81
+
82
+ - **One broker API.** `AccountClient` covers accounts, orders, quotes and
83
+ historical bars, the same way for every broker.
84
+ - **ArenaX, a built-in simulated broker.** A local server for demos, paper
85
+ trading and backtests, with TWSE commission and tax applied to every fill.
86
+ - **Reproducible backtesting.** A fast in-memory backtester, and a trading
87
+ engine that replays real bar timestamps so two runs give the same orders.
88
+ - **Strategy authoring.** A strategy is one file using a small vocabulary
89
+ (`on_bar`, `buy`, `sell`, `ta.*`, `param.*`), checked before it runs.
90
+ - **Risk controls.** Per-strategy capital limits, order-rate limits,
91
+ duplicate-order detection and a loss kill switch.
92
+ - **FinHub, a web UI.** Start runs, watch each bot, and trade by hand from
93
+ the browser.
94
+ - **Analytics.** Technical indicators (TA-Lib), TWSE fundamentals, news,
95
+ LLM clients, quantstats reports and run diagnostics.
96
+
97
+ | Broker | Status |
98
+ |---|---|
99
+ | **ArenaX** (simulated) | `demo`, `backtest`, `paper` backends |
100
+ | **Sinopac** 永豐金證券 | Live trading and market data through `shioaji` |
101
+ | Cathay, Yuanta, Mega, Interactive Brokers | Planned |
102
+
103
+ ## Installation
104
+
105
+ Requires Python 3.12+ and [uv](https://docs.astral.sh/uv/getting-started/installation/).
106
+ The apps and scripts target Linux and macOS, and the shell scripts need `jq`.
107
+
108
+ <!-- cjcheck: static -->
109
+ ```sh
110
+ git clone https://github.com/jackiesogi/CJTrade
111
+ cd CJTrade
112
+ uv sync
113
+ ```
114
+
115
+ `uv sync` installs everything, including the optional integrations. To use
116
+ CJTrade as a library instead, install the core and the extras you need:
117
+
118
+ <!-- cjcheck: skip reason="installs from PyPI into the current environment" -->
119
+ ```sh
120
+ pip install 'cjtrade[sinopac,llm]'
121
+ ```
122
+
123
+ The shell scripts (`scripts/`, `poc/`, `tests/`) are not in the package; use
124
+ a checkout for those.
125
+
126
+ | Extra | Adds |
127
+ |---|---|
128
+ | `sinopac` | The Sinopac broker (`shioaji`), also needed by ArenaX's `backtest` and `paper` backends |
129
+ | `llm` | Gemini and Azure OpenAI clients |
130
+ | `news` | The NewsAPI news source |
131
+ | `finhub` | The FinHub web UI |
132
+ | `all` | All of the above |
133
+
134
+ Reports, account snapshots and the price cache are written to per-user
135
+ platform directories, not the checkout. Set `CJTRADE_HOME` to keep them in
136
+ one place.
137
+
138
+ ## Quick start
139
+
140
+ Start the simulated broker and leave it running:
141
+
142
+ <!-- cjcheck: static -->
143
+ ```sh
144
+ uv run arenaxd
145
+ ```
146
+
147
+ Then connect to it from Python:
148
+
149
+ <!-- cjcheck: static -->
150
+ ```python
151
+ from cjtrade.pkgs.brokers.account_client import AccountClient, BrokerType
152
+ from cjtrade.pkgs.models.product import Product
153
+
154
+ client = AccountClient(BrokerType.ARENAX, api_key="testkey123")
155
+ client.connect()
156
+
157
+ print(client.get_balance())
158
+ print(client.get_snapshots([Product("2330")])[0].close)
159
+ result = client.buy_stock("2330", 1, 1000.0) # 1 share, limit 1000
160
+ print(result.status)
161
+
162
+ client.disconnect()
163
+ ```
164
+
165
+ Or explore the same API interactively with the shell:
166
+
167
+ <!-- cjcheck: static -->
168
+ ```sh
169
+ bash scripts/gen_config.sh arenax # writes arenax_system.cjconf
170
+ uv run cjshell --broker=arenax
171
+ ```
172
+
173
+ The [Get started guide](https://jackiesogi.github.io/CJTrade/get-started/connect/)
174
+ walks through accounts, orders, market data, strategies and backtests.
175
+
176
+ ### Sinopac
177
+
178
+ Generate a config file, fill in the credentials from
179
+ [Sinopac's API portal](https://ai.sinotrade.com.tw/python/Main/index.aspx#pag4),
180
+ and connect:
181
+
182
+ <!-- cjcheck: static -->
183
+ ```sh
184
+ bash scripts/gen_config.sh sinopac # then edit sinopac_system.cjconf
185
+ uv run cjshell --broker=sinopac
186
+ ```
187
+
188
+ > [!CAUTION]
189
+ > A Sinopac session places **real orders**, and the shell does not ask for
190
+ > confirmation. Set `SIMULATION = y` in the config file to use Sinopac's
191
+ > sandbox.
192
+
193
+ ## Backtesting
194
+
195
+ | Method | How time moves | Reproducible | Use it for |
196
+ |---|---|---|---|
197
+ | `oneshot` | Walks a pre-fetched bar series | Yes | Parameter sweeps, quick screening |
198
+ | Trading engine (`cjtrade`) | Steps through real bar timestamps | Yes | Results you intend to compare |
199
+
200
+ Strategy windows are counted in **bars**, so changing `--interval` changes
201
+ the strategy: a 100-bar window is 100 minutes at `1m` and 100 days at `1d`.
202
+
203
+ ### `oneshot`
204
+
205
+ <!-- cjcheck: static -->
206
+ ```sh
207
+ bash poc/backtest.sh --renderer=cli \
208
+ --watch-list 2317,2357 --fund 1000000 \
209
+ --start 2024-12-16 --days 60 --interval 1d \
210
+ --strategy BollingerStrategy --mode demo
211
+ ```
212
+
213
+ The script starts `arenaxd` if needed and asks for anything not given on the
214
+ command line. Built-in strategies: `BollingerStrategy`, `ADXAdaptiveStrategy`,
215
+ `DCA_Monthly`, `DonchianBreakoutStrategy`, `SupportResistanceStrategy`,
216
+ `BaselineStrategy`.
217
+
218
+ ### Trading engine
219
+
220
+ `cjtrade` is the trading app. Each strategy runs as its own process; only
221
+ the main process holds the broker session and the risk gate. Every bar, the
222
+ main process publishes each symbol's closed 1m bars
223
+ (`client.market.get_kbars`) to its bots. Before stepping to the next bar, it
224
+ waits for every bot to answer the current one, so `--speed=0` and `--speed=60` produce the same bars, orders and fills.
225
+
226
+ <!-- cjcheck: static -->
227
+ ```sh
228
+ uv run arenaxd --backend=backtest --port=8802 > /dev/null 2>&1 &
229
+ sleep 15
230
+ uv run cjtrade --broker=arenax \
231
+ --mode=backtest --watch-list=2357 \
232
+ --fund=1000000 --days=30 --start-date=2025-09-01 --speed=0
233
+ ```
234
+
235
+ The bots that run are listed in `BOT_ROSTER` in
236
+ [`src/cjtrade/apps/CJTrade/main.py`](https://github.com/jackiesogi/CJTrade/blob/master/src/cjtrade/apps/CJTrade/main.py), or in a file
237
+ passed with `--roster=`. A status page is served on
238
+ `http://127.0.0.1:8898/status` while a run is in progress, loopback only.
239
+
240
+ > [!NOTE]
241
+ > By default the `backtest` backend reads prices from Sinopac, so it needs
242
+ > the `sinopac` extra and credentials; `arenaxd --data=finmind,yfinance`
243
+ > runs it without a broker account, and `--data=offline --price-db=FILE`
244
+ > runs it on bars preloaded with `preload-prices`, with no network at all.
245
+
246
+ ### Reading the result
247
+
248
+ Each run leaves a result file and an HTML tearsheet. `insight` joins the
249
+ result with the price history for the same window and writes a diagnostic
250
+ report:
251
+
252
+ <!-- cjcheck: static -->
253
+ ```sh
254
+ uv run insight # the most recent run
255
+ uv run insight --list # every run on this machine
256
+ ```
257
+
258
+ ### FinHub
259
+
260
+ The web UI for the trading app. It starts the broker and the engine itself,
261
+ shows each bot while it runs, and keeps a record of every run:
262
+
263
+ <!-- cjcheck: static -->
264
+ ```sh
265
+ uv run finhub # http://127.0.0.1:8000, loopback only
266
+ ```
267
+
268
+ See [`src/cjtrade/apps/FinHub/README.md`](https://github.com/jackiesogi/CJTrade/blob/master/src/cjtrade/apps/FinHub/README.md)
269
+ for its settings.
270
+
271
+ ## Writing a strategy
272
+
273
+ <!-- cjcheck: static -->
274
+ ```sh
275
+ uv run strategy-tool templates # available templates
276
+ uv run strategy-tool template --kind bb # a complete starter file (JSON)
277
+ uv run strategy-tool check < my_strategy.py # diagnostics before you run it
278
+ ```
279
+
280
+ See [Write a strategy](https://jackiesogi.github.io/CJTrade/get-started/strategy/)
281
+ for the full vocabulary.
282
+
283
+ ## Development
284
+
285
+ <!-- cjcheck: static -->
286
+ ```sh
287
+ uv run pytest # unit + integration
288
+ uv run python scripts/check_readme_examples.py # README commands still work
289
+ uv run --group docs mkdocs serve # docs at http://127.0.0.1:8000
290
+ ```
291
+
292
+ The same checks run as pre-commit hooks and in CI. Developer notes, design
293
+ records and the to-do list are in [`ref/`](https://github.com/jackiesogi/CJTrade/tree/master/ref/); every command and
294
+ script is listed in [`ref/TOOLS.md`](https://github.com/jackiesogi/CJTrade/blob/master/ref/TOOLS.md), and the branch,
295
+ commit and PR conventions are in [`CLAUDE.md`](https://github.com/jackiesogi/CJTrade/blob/master/CLAUDE.md) §11.
296
+
297
+ ## License
298
+
299
+ [MIT](https://github.com/jackiesogi/CJTrade/blob/master/LICENSE).
300
+
301
+ CJTrade is not investment advice, and nothing it prints is a recommendation to
302
+ buy or sell. It can place real orders on a real account; you are responsible
303
+ for every order it sends and for any loss that follows. Test a strategy on
304
+ ArenaX, then on Sinopac's sandbox, before trading real money.
@@ -0,0 +1,241 @@
1
+ # CJTrade
2
+
3
+ [![CI](https://github.com/jackiesogi/CJTrade/actions/workflows/ci.yml/badge.svg)](https://github.com/jackiesogi/CJTrade/actions/workflows/ci.yml)
4
+ [![Docs](https://img.shields.io/badge/docs-jackiesogi.github.io%2FCJTrade-blue)](https://jackiesogi.github.io/CJTrade/)
5
+ [![License: MIT](https://img.shields.io/badge/license-MIT-green)](https://github.com/jackiesogi/CJTrade/blob/master/LICENSE)
6
+
7
+ A Python framework for building trading systems for the Taiwan Stock Exchange
8
+ (TWSE). Write a strategy once against the CJTrade API, then run it against a
9
+ simulated broker, a historical replay, or a real brokerage account without
10
+ changing it.
11
+
12
+ **Documentation:** <https://jackiesogi.github.io/CJTrade/>
13
+ ([繁體中文](https://jackiesogi.github.io/CJTrade/zh-TW/))
14
+
15
+ ![CJTrade](https://raw.githubusercontent.com/jackiesogi/CJTrade/master/doc/assets/img/combined.png)
16
+
17
+ ## Features
18
+
19
+ - **One broker API.** `AccountClient` covers accounts, orders, quotes and
20
+ historical bars, the same way for every broker.
21
+ - **ArenaX, a built-in simulated broker.** A local server for demos, paper
22
+ trading and backtests, with TWSE commission and tax applied to every fill.
23
+ - **Reproducible backtesting.** A fast in-memory backtester, and a trading
24
+ engine that replays real bar timestamps so two runs give the same orders.
25
+ - **Strategy authoring.** A strategy is one file using a small vocabulary
26
+ (`on_bar`, `buy`, `sell`, `ta.*`, `param.*`), checked before it runs.
27
+ - **Risk controls.** Per-strategy capital limits, order-rate limits,
28
+ duplicate-order detection and a loss kill switch.
29
+ - **FinHub, a web UI.** Start runs, watch each bot, and trade by hand from
30
+ the browser.
31
+ - **Analytics.** Technical indicators (TA-Lib), TWSE fundamentals, news,
32
+ LLM clients, quantstats reports and run diagnostics.
33
+
34
+ | Broker | Status |
35
+ |---|---|
36
+ | **ArenaX** (simulated) | `demo`, `backtest`, `paper` backends |
37
+ | **Sinopac** 永豐金證券 | Live trading and market data through `shioaji` |
38
+ | Cathay, Yuanta, Mega, Interactive Brokers | Planned |
39
+
40
+ ## Installation
41
+
42
+ Requires Python 3.12+ and [uv](https://docs.astral.sh/uv/getting-started/installation/).
43
+ The apps and scripts target Linux and macOS, and the shell scripts need `jq`.
44
+
45
+ <!-- cjcheck: static -->
46
+ ```sh
47
+ git clone https://github.com/jackiesogi/CJTrade
48
+ cd CJTrade
49
+ uv sync
50
+ ```
51
+
52
+ `uv sync` installs everything, including the optional integrations. To use
53
+ CJTrade as a library instead, install the core and the extras you need:
54
+
55
+ <!-- cjcheck: skip reason="installs from PyPI into the current environment" -->
56
+ ```sh
57
+ pip install 'cjtrade[sinopac,llm]'
58
+ ```
59
+
60
+ The shell scripts (`scripts/`, `poc/`, `tests/`) are not in the package; use
61
+ a checkout for those.
62
+
63
+ | Extra | Adds |
64
+ |---|---|
65
+ | `sinopac` | The Sinopac broker (`shioaji`), also needed by ArenaX's `backtest` and `paper` backends |
66
+ | `llm` | Gemini and Azure OpenAI clients |
67
+ | `news` | The NewsAPI news source |
68
+ | `finhub` | The FinHub web UI |
69
+ | `all` | All of the above |
70
+
71
+ Reports, account snapshots and the price cache are written to per-user
72
+ platform directories, not the checkout. Set `CJTRADE_HOME` to keep them in
73
+ one place.
74
+
75
+ ## Quick start
76
+
77
+ Start the simulated broker and leave it running:
78
+
79
+ <!-- cjcheck: static -->
80
+ ```sh
81
+ uv run arenaxd
82
+ ```
83
+
84
+ Then connect to it from Python:
85
+
86
+ <!-- cjcheck: static -->
87
+ ```python
88
+ from cjtrade.pkgs.brokers.account_client import AccountClient, BrokerType
89
+ from cjtrade.pkgs.models.product import Product
90
+
91
+ client = AccountClient(BrokerType.ARENAX, api_key="testkey123")
92
+ client.connect()
93
+
94
+ print(client.get_balance())
95
+ print(client.get_snapshots([Product("2330")])[0].close)
96
+ result = client.buy_stock("2330", 1, 1000.0) # 1 share, limit 1000
97
+ print(result.status)
98
+
99
+ client.disconnect()
100
+ ```
101
+
102
+ Or explore the same API interactively with the shell:
103
+
104
+ <!-- cjcheck: static -->
105
+ ```sh
106
+ bash scripts/gen_config.sh arenax # writes arenax_system.cjconf
107
+ uv run cjshell --broker=arenax
108
+ ```
109
+
110
+ The [Get started guide](https://jackiesogi.github.io/CJTrade/get-started/connect/)
111
+ walks through accounts, orders, market data, strategies and backtests.
112
+
113
+ ### Sinopac
114
+
115
+ Generate a config file, fill in the credentials from
116
+ [Sinopac's API portal](https://ai.sinotrade.com.tw/python/Main/index.aspx#pag4),
117
+ and connect:
118
+
119
+ <!-- cjcheck: static -->
120
+ ```sh
121
+ bash scripts/gen_config.sh sinopac # then edit sinopac_system.cjconf
122
+ uv run cjshell --broker=sinopac
123
+ ```
124
+
125
+ > [!CAUTION]
126
+ > A Sinopac session places **real orders**, and the shell does not ask for
127
+ > confirmation. Set `SIMULATION = y` in the config file to use Sinopac's
128
+ > sandbox.
129
+
130
+ ## Backtesting
131
+
132
+ | Method | How time moves | Reproducible | Use it for |
133
+ |---|---|---|---|
134
+ | `oneshot` | Walks a pre-fetched bar series | Yes | Parameter sweeps, quick screening |
135
+ | Trading engine (`cjtrade`) | Steps through real bar timestamps | Yes | Results you intend to compare |
136
+
137
+ Strategy windows are counted in **bars**, so changing `--interval` changes
138
+ the strategy: a 100-bar window is 100 minutes at `1m` and 100 days at `1d`.
139
+
140
+ ### `oneshot`
141
+
142
+ <!-- cjcheck: static -->
143
+ ```sh
144
+ bash poc/backtest.sh --renderer=cli \
145
+ --watch-list 2317,2357 --fund 1000000 \
146
+ --start 2024-12-16 --days 60 --interval 1d \
147
+ --strategy BollingerStrategy --mode demo
148
+ ```
149
+
150
+ The script starts `arenaxd` if needed and asks for anything not given on the
151
+ command line. Built-in strategies: `BollingerStrategy`, `ADXAdaptiveStrategy`,
152
+ `DCA_Monthly`, `DonchianBreakoutStrategy`, `SupportResistanceStrategy`,
153
+ `BaselineStrategy`.
154
+
155
+ ### Trading engine
156
+
157
+ `cjtrade` is the trading app. Each strategy runs as its own process; only
158
+ the main process holds the broker session and the risk gate. Every bar, the
159
+ main process publishes each symbol's closed 1m bars
160
+ (`client.market.get_kbars`) to its bots. Before stepping to the next bar, it
161
+ waits for every bot to answer the current one, so `--speed=0` and `--speed=60` produce the same bars, orders and fills.
162
+
163
+ <!-- cjcheck: static -->
164
+ ```sh
165
+ uv run arenaxd --backend=backtest --port=8802 > /dev/null 2>&1 &
166
+ sleep 15
167
+ uv run cjtrade --broker=arenax \
168
+ --mode=backtest --watch-list=2357 \
169
+ --fund=1000000 --days=30 --start-date=2025-09-01 --speed=0
170
+ ```
171
+
172
+ The bots that run are listed in `BOT_ROSTER` in
173
+ [`src/cjtrade/apps/CJTrade/main.py`](https://github.com/jackiesogi/CJTrade/blob/master/src/cjtrade/apps/CJTrade/main.py), or in a file
174
+ passed with `--roster=`. A status page is served on
175
+ `http://127.0.0.1:8898/status` while a run is in progress, loopback only.
176
+
177
+ > [!NOTE]
178
+ > By default the `backtest` backend reads prices from Sinopac, so it needs
179
+ > the `sinopac` extra and credentials; `arenaxd --data=finmind,yfinance`
180
+ > runs it without a broker account, and `--data=offline --price-db=FILE`
181
+ > runs it on bars preloaded with `preload-prices`, with no network at all.
182
+
183
+ ### Reading the result
184
+
185
+ Each run leaves a result file and an HTML tearsheet. `insight` joins the
186
+ result with the price history for the same window and writes a diagnostic
187
+ report:
188
+
189
+ <!-- cjcheck: static -->
190
+ ```sh
191
+ uv run insight # the most recent run
192
+ uv run insight --list # every run on this machine
193
+ ```
194
+
195
+ ### FinHub
196
+
197
+ The web UI for the trading app. It starts the broker and the engine itself,
198
+ shows each bot while it runs, and keeps a record of every run:
199
+
200
+ <!-- cjcheck: static -->
201
+ ```sh
202
+ uv run finhub # http://127.0.0.1:8000, loopback only
203
+ ```
204
+
205
+ See [`src/cjtrade/apps/FinHub/README.md`](https://github.com/jackiesogi/CJTrade/blob/master/src/cjtrade/apps/FinHub/README.md)
206
+ for its settings.
207
+
208
+ ## Writing a strategy
209
+
210
+ <!-- cjcheck: static -->
211
+ ```sh
212
+ uv run strategy-tool templates # available templates
213
+ uv run strategy-tool template --kind bb # a complete starter file (JSON)
214
+ uv run strategy-tool check < my_strategy.py # diagnostics before you run it
215
+ ```
216
+
217
+ See [Write a strategy](https://jackiesogi.github.io/CJTrade/get-started/strategy/)
218
+ for the full vocabulary.
219
+
220
+ ## Development
221
+
222
+ <!-- cjcheck: static -->
223
+ ```sh
224
+ uv run pytest # unit + integration
225
+ uv run python scripts/check_readme_examples.py # README commands still work
226
+ uv run --group docs mkdocs serve # docs at http://127.0.0.1:8000
227
+ ```
228
+
229
+ The same checks run as pre-commit hooks and in CI. Developer notes, design
230
+ records and the to-do list are in [`ref/`](https://github.com/jackiesogi/CJTrade/tree/master/ref/); every command and
231
+ script is listed in [`ref/TOOLS.md`](https://github.com/jackiesogi/CJTrade/blob/master/ref/TOOLS.md), and the branch,
232
+ commit and PR conventions are in [`CLAUDE.md`](https://github.com/jackiesogi/CJTrade/blob/master/CLAUDE.md) §11.
233
+
234
+ ## License
235
+
236
+ [MIT](https://github.com/jackiesogi/CJTrade/blob/master/LICENSE).
237
+
238
+ CJTrade is not investment advice, and nothing it prints is a recommendation to
239
+ buy or sell. It can place real orders on a real account; you are responsible
240
+ for every order it sends and for any loss that follows. Test a strategy on
241
+ ArenaX, then on Sinopac's sandbox, before trading real money.