futures-settlement-analysis 0.1.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 (39) hide show
  1. futures_settlement_analysis-0.1.0/.claude/settings.local.json +29 -0
  2. futures_settlement_analysis-0.1.0/.gitignore +174 -0
  3. futures_settlement_analysis-0.1.0/.gitmodules +3 -0
  4. futures_settlement_analysis-0.1.0/.idea/.gitignore +5 -0
  5. futures_settlement_analysis-0.1.0/.idea/FuturesSettlementAnalysis.iml +10 -0
  6. futures_settlement_analysis-0.1.0/.idea/codeStyles/codeStyleConfig.xml +5 -0
  7. futures_settlement_analysis-0.1.0/.idea/dictionaries/project.xml +3 -0
  8. futures_settlement_analysis-0.1.0/.idea/inspectionProfiles/profiles_settings.xml +6 -0
  9. futures_settlement_analysis-0.1.0/.idea/misc.xml +7 -0
  10. futures_settlement_analysis-0.1.0/.idea/modules.xml +8 -0
  11. futures_settlement_analysis-0.1.0/.idea/vcs.xml +6 -0
  12. futures_settlement_analysis-0.1.0/.idea/workspace.xml +177 -0
  13. futures_settlement_analysis-0.1.0/CHANGELOG.md +18 -0
  14. futures_settlement_analysis-0.1.0/CLAUDE.md +65 -0
  15. futures_settlement_analysis-0.1.0/LICENSE +21 -0
  16. futures_settlement_analysis-0.1.0/PKG-INFO +216 -0
  17. futures_settlement_analysis-0.1.0/README.md +193 -0
  18. futures_settlement_analysis-0.1.0/UnderlyingAssetInformation/.git +1 -0
  19. futures_settlement_analysis-0.1.0/UnderlyingAssetInformation/EXCHANGE.json +10 -0
  20. futures_settlement_analysis-0.1.0/UnderlyingAssetInformation/FUTURE.json +1270 -0
  21. futures_settlement_analysis-0.1.0/UnderlyingAssetInformation/LICENSE +73 -0
  22. futures_settlement_analysis-0.1.0/UnderlyingAssetInformation/OPTION.json +35 -0
  23. futures_settlement_analysis-0.1.0/UnderlyingAssetInformation/README.md +27 -0
  24. futures_settlement_analysis-0.1.0/config.yaml +10 -0
  25. futures_settlement_analysis-0.1.0/docs/development.md +164 -0
  26. futures_settlement_analysis-0.1.0/docs/superpowers/plans/2026-05-13-asset-api-migration-and-option-exercise.md +238 -0
  27. futures_settlement_analysis-0.1.0/docs/usage.md +114 -0
  28. futures_settlement_analysis-0.1.0/main.py +45 -0
  29. futures_settlement_analysis-0.1.0/pyproject.toml +48 -0
  30. futures_settlement_analysis-0.1.0/requirements.txt +5 -0
  31. futures_settlement_analysis-0.1.0/setup.py +42 -0
  32. futures_settlement_analysis-0.1.0/src/futures_analysis/__init__.py +9 -0
  33. futures_settlement_analysis-0.1.0/src/futures_analysis/analysis.py +740 -0
  34. futures_settlement_analysis-0.1.0/src/futures_analysis/data/EXCHANGE.json +10 -0
  35. futures_settlement_analysis-0.1.0/src/futures_analysis/data/FUTURE.json +1270 -0
  36. futures_settlement_analysis-0.1.0/src/futures_analysis/data/OPTION.json +35 -0
  37. futures_settlement_analysis-0.1.0/src/futures_analysis/format.py +365 -0
  38. futures_settlement_analysis-0.1.0/src/futures_analysis/loader.py +647 -0
  39. futures_settlement_analysis-0.1.0/uv.lock +728 -0
@@ -0,0 +1,29 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(pip --version)",
5
+ "Bash(which uv *)",
6
+ "Bash(curl -s --connect-timeout 5 \"http://192.168.0.101:3100/tridro/UnderlyingAssetInformation\")",
7
+ "Bash(grep -v \":0$\")",
8
+ "Bash(curl -s --connect-timeout 5 \"http://192.168.0.101:3100/tridro/UnderlyingAssetInformation/raw/branch/main/FUTURE.json\" -o /tmp/future_remote.json)",
9
+ "Bash(python -c ' *)",
10
+ "Bash(python *)",
11
+ "Bash(curl -s --connect-timeout 5 \"http://192.168.0.101:3100/tridro/UnderlyingAssetInformation/raw/branch/main/FUTURE.json\")",
12
+ "Bash(curl -s --connect-timeout 5 \"http://192.168.0.101:3100/tridro/UnderlyingAssetInformation/raw/branch/main/OPTION.json\")",
13
+ "Bash(ls -d .worktrees)",
14
+ "Bash(ls -d worktrees)",
15
+ "Bash(git check-ignore *)",
16
+ "Bash(git add *)",
17
+ "Bash(git commit *)",
18
+ "Bash(uv sync *)",
19
+ "Bash(uv run *)",
20
+ "Bash(uv add *)",
21
+ "Bash(git checkout *)",
22
+ "Bash(git pull *)",
23
+ "Bash(git merge *)",
24
+ "Bash(git submodule *)",
25
+ "Bash(git worktree *)",
26
+ "Bash(git branch *)"
27
+ ]
28
+ }
29
+ }
@@ -0,0 +1,174 @@
1
+ # ---> Python
2
+ # Byte-compiled / optimized / DLL files
3
+ __pycache__/
4
+ *.py[cod]
5
+ *$py.class
6
+
7
+ # C extensions
8
+ *.so
9
+
10
+ # Distribution / packaging
11
+ .Python
12
+ build/
13
+ develop-eggs/
14
+ dist/
15
+ downloads/
16
+ eggs/
17
+ .eggs/
18
+ lib/
19
+ lib64/
20
+ parts/
21
+ sdist/
22
+ var/
23
+ wheels/
24
+ share/python-wheels/
25
+ *.egg-info/
26
+ .installed.cfg
27
+ *.egg
28
+ MANIFEST
29
+
30
+ # PyInstaller
31
+ # Usually these files are written by a python script from a template
32
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
33
+ *.manifest
34
+ *.spec
35
+
36
+ # Installer logs
37
+ pip-log.txt
38
+ pip-delete-this-directory.txt
39
+
40
+ # Unit test / coverage reports
41
+ htmlcov/
42
+ .tox/
43
+ .nox/
44
+ .coverage
45
+ .coverage.*
46
+ .cache
47
+ nosetests.xml
48
+ coverage.xml
49
+ *.cover
50
+ *.py,cover
51
+ .hypothesis/
52
+ .pytest_cache/
53
+ cover/
54
+
55
+ # Translations
56
+ *.mo
57
+ *.pot
58
+
59
+ # Django stuff:
60
+ *.log
61
+ local_settings.py
62
+ db.sqlite3
63
+ db.sqlite3-journal
64
+
65
+ # Flask stuff:
66
+ instance/
67
+ .webassets-cache
68
+
69
+ # Scrapy stuff:
70
+ .scrapy
71
+
72
+ # Sphinx documentation
73
+ docs/_build/
74
+
75
+ # PyBuilder
76
+ .pybuilder/
77
+ target/
78
+
79
+ # Jupyter Notebook
80
+ .ipynb_checkpoints
81
+
82
+ # IPython
83
+ profile_default/
84
+ ipython_config.py
85
+
86
+ # pyenv
87
+ # For a library or package, you might want to ignore these files since the code is
88
+ # intended to run in multiple environments; otherwise, check them in:
89
+ # .python-version
90
+
91
+ # pipenv
92
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
93
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
94
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
95
+ # install all needed dependencies.
96
+ #Pipfile.lock
97
+
98
+ # UV
99
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
100
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
101
+ # commonly ignored for libraries.
102
+ #uv.lock
103
+
104
+ # poetry
105
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
106
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
107
+ # commonly ignored for libraries.
108
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
109
+ #poetry.lock
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ #pdm.lock
114
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
115
+ # in version control.
116
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
117
+ .pdm.toml
118
+ .pdm-python
119
+ .pdm-build/
120
+
121
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
122
+ __pypackages__/
123
+
124
+ # Celery stuff
125
+ celerybeat-schedule
126
+ celerybeat.pid
127
+
128
+ # SageMath parsed files
129
+ *.sage.py
130
+
131
+ # Environments
132
+ .env
133
+ .venv
134
+ env/
135
+ venv/
136
+ ENV/
137
+ env.bak/
138
+ venv.bak/
139
+
140
+ # Spyder project settings
141
+ .spyderproject
142
+ .spyproject
143
+
144
+ # Rope project settings
145
+ .ropeproject
146
+
147
+ # mkdocs documentation
148
+ /site
149
+
150
+ # mypy
151
+ .mypy_cache/
152
+ .dmypy.json
153
+ dmypy.json
154
+
155
+ # Pyre type checker
156
+ .pyre/
157
+
158
+ # pytype static type analyzer
159
+ .pytype/
160
+
161
+ # Cython debug symbols
162
+ cython_debug/
163
+
164
+ # PyCharm
165
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
166
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
167
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
168
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
169
+ #.idea/
170
+
171
+ .data
172
+ .worktrees/
173
+
174
+ .tests/
@@ -0,0 +1,3 @@
1
+ [submodule "UnderlyingAssetInformation"]
2
+ path = UnderlyingAssetInformation
3
+ url = http://ifilevault.myasustor.com:3100/tridro/underlying-asset-information.git
@@ -0,0 +1,5 @@
1
+ # 默认忽略的文件
2
+ /shelf/
3
+ /workspace.xml
4
+ # 基于编辑器的 HTTP 客户端请求
5
+ /httpRequests/
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="PYTHON_MODULE" version="4">
3
+ <component name="NewModuleRootManager">
4
+ <content url="file://$MODULE_DIR$">
5
+ <excludeFolder url="file://$MODULE_DIR$/.venv" />
6
+ </content>
7
+ <orderEntry type="jdk" jdkName="uv (FuturesSettlementAnalysis)" jdkType="Python SDK" />
8
+ <orderEntry type="sourceFolder" forTests="false" />
9
+ </component>
10
+ </module>
@@ -0,0 +1,5 @@
1
+ <component name="ProjectCodeStyleConfiguration">
2
+ <state>
3
+ <option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
4
+ </state>
5
+ </component>
@@ -0,0 +1,3 @@
1
+ <component name="ProjectDictionaryState">
2
+ <dictionary name="project" />
3
+ </component>
@@ -0,0 +1,6 @@
1
+ <component name="InspectionProjectProfileManager">
2
+ <settings>
3
+ <option name="USE_PROJECT_PROFILE" value="false" />
4
+ <version value="1.0" />
5
+ </settings>
6
+ </component>
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="Black">
4
+ <option name="sdkName" value="uv (FuturesSettlementAnalysis)" />
5
+ </component>
6
+ <component name="ProjectRootManager" version="2" project-jdk-name="uv (FuturesSettlementAnalysis)" project-jdk-type="Python SDK" />
7
+ </project>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/FuturesSettlementAnalysis.iml" filepath="$PROJECT_DIR$/.idea/FuturesSettlementAnalysis.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,177 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="AutoImportSettings">
4
+ <option name="autoReloadType" value="SELECTIVE" />
5
+ </component>
6
+ <component name="ChangeListManager">
7
+ <list default="true" id="9fca5232-d450-46d0-98e0-e3a3f87266fe" name="更改" comment="1. Fix the function logic for calculating the net value.">
8
+ <change beforePath="$PROJECT_DIR$/config.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/config.yaml" afterDir="false" />
9
+ </list>
10
+ <option name="SHOW_DIALOG" value="false" />
11
+ <option name="HIGHLIGHT_CONFLICTS" value="true" />
12
+ <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
13
+ <option name="LAST_RESOLUTION" value="IGNORE" />
14
+ </component>
15
+ <component name="Git.Settings">
16
+ <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
17
+ </component>
18
+ <component name="ProjectColorInfo">{
19
+ &quot;customColor&quot;: &quot;&quot;,
20
+ &quot;associatedIndex&quot;: 8
21
+ }</component>
22
+ <component name="ProjectId" id="37wAantqM0RJQdzZTFnoUlArY6R" />
23
+ <component name="ProjectLevelVcsManager">
24
+ <OptionsSetting value="false" id="Update" />
25
+ </component>
26
+ <component name="ProjectViewState">
27
+ <option name="hideEmptyMiddlePackages" value="true" />
28
+ <option name="showLibraryContents" value="true" />
29
+ </component>
30
+ <component name="PropertiesComponent">{
31
+ &quot;keyToString&quot;: {
32
+ &quot;ModuleVcsDetector.initialDetectionPerformed&quot;: &quot;true&quot;,
33
+ &quot;Python.analysis.executor&quot;: &quot;Run&quot;,
34
+ &quot;Python.main.executor&quot;: &quot;Run&quot;,
35
+ &quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
36
+ &quot;RunOnceActivity.git.unshallow&quot;: &quot;true&quot;,
37
+ &quot;git-widget-placeholder&quot;: &quot;main&quot;,
38
+ &quot;settings.editor.selected.configurable&quot;: &quot;reference.settingsdialog.project.grazie&quot;
39
+ }
40
+ }</component>
41
+ <component name="RunManager">
42
+ <configuration name="main" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
43
+ <module name="FuturesSettlementAnalysis" />
44
+ <option name="ENV_FILES" value="" />
45
+ <option name="INTERPRETER_OPTIONS" value="" />
46
+ <option name="PARENT_ENVS" value="true" />
47
+ <envs>
48
+ <env name="PYTHONUNBUFFERED" value="1" />
49
+ </envs>
50
+ <option name="SDK_HOME" value="" />
51
+ <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
52
+ <option name="IS_MODULE_SDK" value="true" />
53
+ <option name="ADD_CONTENT_ROOTS" value="true" />
54
+ <option name="ADD_SOURCE_ROOTS" value="true" />
55
+ <option name="SCRIPT_NAME" value="$PROJECT_DIR$/main.py" />
56
+ <option name="PARAMETERS" value="" />
57
+ <option name="SHOW_COMMAND_LINE" value="false" />
58
+ <option name="EMULATE_TERMINAL" value="false" />
59
+ <option name="MODULE_MODE" value="false" />
60
+ <option name="REDIRECT_INPUT" value="false" />
61
+ <option name="INPUT_FILE" value="" />
62
+ <method v="2" />
63
+ </configuration>
64
+ <recent_temporary>
65
+ <list>
66
+ <item itemvalue="Python.main" />
67
+ </list>
68
+ </recent_temporary>
69
+ </component>
70
+ <component name="SharedIndexes">
71
+ <attachedChunks>
72
+ <set>
73
+ <option value="bundled-python-sdk-a101402ee41c-968fe969f28a-com.jetbrains.pycharm.pro.sharedIndexes.bundled-PY-252.28238.29" />
74
+ </set>
75
+ </attachedChunks>
76
+ </component>
77
+ <component name="TaskManager">
78
+ <task active="true" id="Default" summary="默认任务">
79
+ <changelist id="9fca5232-d450-46d0-98e0-e3a3f87266fe" name="更改" comment="" />
80
+ <created>1767803827748</created>
81
+ <option name="number" value="Default" />
82
+ <option name="presentableId" value="Default" />
83
+ <updated>1767803827748</updated>
84
+ </task>
85
+ <task id="LOCAL-00001" summary="Fix kurtosis function in analysis.annual_attribution_statistic">
86
+ <option name="closed" value="true" />
87
+ <created>1767808094115</created>
88
+ <option name="number" value="00001" />
89
+ <option name="presentableId" value="LOCAL-00001" />
90
+ <option name="project" value="LOCAL" />
91
+ <updated>1767808094115</updated>
92
+ </task>
93
+ <task id="LOCAL-00002" summary="1. Add CTP statements loading function&#10;2. Fix some mapping methods for combining statements data">
94
+ <option name="closed" value="true" />
95
+ <created>1769406421152</created>
96
+ <option name="number" value="00002" />
97
+ <option name="presentableId" value="LOCAL-00002" />
98
+ <option name="project" value="LOCAL" />
99
+ <updated>1769406421152</updated>
100
+ </task>
101
+ <task id="LOCAL-00003" summary="Modify account_summary data name">
102
+ <option name="closed" value="true" />
103
+ <created>1769411220910</created>
104
+ <option name="number" value="00003" />
105
+ <option name="presentableId" value="LOCAL-00003" />
106
+ <option name="project" value="LOCAL" />
107
+ <updated>1769411220910</updated>
108
+ </task>
109
+ <task id="LOCAL-00004" summary="1. Adjust networth calculation method to adapt CTP statements data&#10;2. Some minor adjustments">
110
+ <option name="closed" value="true" />
111
+ <created>1769411802789</created>
112
+ <option name="number" value="00004" />
113
+ <option name="presentableId" value="LOCAL-00004" />
114
+ <option name="project" value="LOCAL" />
115
+ <updated>1769411802789</updated>
116
+ </task>
117
+ <task id="LOCAL-00005" summary="1. Fix the issue when extract data from cfmmc statements&#10;2. Add statements type hint in case configuration error">
118
+ <option name="closed" value="true" />
119
+ <created>1772469306139</created>
120
+ <option name="number" value="00005" />
121
+ <option name="presentableId" value="LOCAL-00005" />
122
+ <option name="project" value="LOCAL" />
123
+ <updated>1772469306139</updated>
124
+ </task>
125
+ <task id="LOCAL-00006" summary="1. Add precision control for net_worth_calc func">
126
+ <option name="closed" value="true" />
127
+ <created>1772469373733</created>
128
+ <option name="number" value="00006" />
129
+ <option name="presentableId" value="LOCAL-00006" />
130
+ <option name="project" value="LOCAL" />
131
+ <updated>1772469373733</updated>
132
+ </task>
133
+ <task id="LOCAL-00007" summary="1. Fix the function logic for calculating the net value.">
134
+ <option name="closed" value="true" />
135
+ <created>1772816018205</created>
136
+ <option name="number" value="00007" />
137
+ <option name="presentableId" value="LOCAL-00007" />
138
+ <option name="project" value="LOCAL" />
139
+ <updated>1772816018205</updated>
140
+ </task>
141
+ <option name="localTasksCounter" value="8" />
142
+ <servers />
143
+ </component>
144
+ <component name="Vcs.Log.Tabs.Properties">
145
+ <option name="TAB_STATES">
146
+ <map>
147
+ <entry key="MAIN">
148
+ <value>
149
+ <State>
150
+ <option name="FILTERS">
151
+ <map>
152
+ <entry key="branch">
153
+ <value>
154
+ <list>
155
+ <option value="main" />
156
+ </list>
157
+ </value>
158
+ </entry>
159
+ </map>
160
+ </option>
161
+ </State>
162
+ </value>
163
+ </entry>
164
+ </map>
165
+ </option>
166
+ </component>
167
+ <component name="VcsManagerConfiguration">
168
+ <MESSAGE value="Fix kurtosis function in analysis.annual_attribution_statistic" />
169
+ <MESSAGE value="1. Add CTP statements loading function&#10;2. Fix some mapping methods for combining statements data" />
170
+ <MESSAGE value="Modify account_summary data name" />
171
+ <MESSAGE value="1. Adjust networth calculation method to adapt CTP statements data&#10;2. Some minor adjustments" />
172
+ <MESSAGE value="1. Fix the issue when extract data from cfmmc statements&#10;2. Add statements type hint in case configuration error" />
173
+ <MESSAGE value="1. Add precision control for net_worth_calc func" />
174
+ <MESSAGE value="1. Fix the function logic for calculating the net value." />
175
+ <option name="LAST_COMMIT_MESSAGE" value="1. Fix the function logic for calculating the net value." />
176
+ </component>
177
+ </project>
@@ -0,0 +1,18 @@
1
+ # 更新日志
2
+
3
+ ## [0.1.0] - 2026-04-06
4
+
5
+ ### 新增
6
+ - 支持中国期货监控中心(CTP)结算单解析
7
+ - 支持融航系统(Rohon)结算单解析
8
+ - 支持标准CTP格式结算单解析
9
+ - 多维度交易统计:按合约、按品种、按买卖方向
10
+ - 净值曲线计算,支持对数和百分比两种方式
11
+ - 年度归因分析:年化收益率、最大回撤、夏普比率
12
+ - Excel格式输出,包含自动生成的统计图表
13
+ - 批量处理多个结算单文件
14
+
15
+ ### 整理
16
+ - 重新整理项目结构为标准Python包格式
17
+ - 添加完整README文档
18
+ - 添加使用说明和开发文档
@@ -0,0 +1,65 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Overview
6
+
7
+ Futures settlement statement analysis tool (期货结算单分析). Reads settlement statements from Chinese futures brokers (CFMMC, CTP, 融航), computes trade statistics and financial performance metrics, and outputs formatted Excel reports with charts.
8
+
9
+ ## Commands
10
+
11
+ - `uv run main.py` — Run the full analysis pipeline (reads `config.yaml`)
12
+ - `uv sync` — Install/reconcile dependencies
13
+ - `uv add <package>` / `uv remove <package>` — Manage dependencies
14
+ - No test suite, linting, or type-checking configuration exists.
15
+
16
+ ## Architecture
17
+
18
+ Four-module pipeline orchestrated by `main.py`:
19
+
20
+ 1. **`loader.py`** — Data ingestion layer
21
+ - `load_config_file()` — Reads YAML config
22
+ - `load_static_file()` — Reads JSON static data (contract metadata)
23
+ - `load_statement_file()` — Loads `.xls`/`.xlsx`/`.txt` settlement files from a directory
24
+ - `wrangling_statement_data()` — Routes to the appropriate parser based on `statement_type` (`cfmmc`, `rohon`, `ctp`)
25
+ - `futures_statement_extraxt_for_cfmmc()` — Parses CFMMC-format Excel sheets by finding section headers via `index_character()`
26
+ - `futures_statement_extraxt_for_rohon()` — Parses 融航-format sheets
27
+ - `futures_statement_extraxt_for_ctp()` — Parses CTP-format `.txt` files using regex line-by-line. Handles old and new CTP formats (pre/post 2022-09-23). Computes `交易盈亏` using contract multipliers from `static/FUTURE.json`.
28
+ - `combine_statement_data()` — Merges multiple statement files into unified DataFrames (资金状况, 成交明细, 平仓明细, etc.) using a name-mapping approach per statement type.
29
+ - Module-level globals `CWD`, `EXCHANGE`, `FUTURE`, `OPTION` are loaded from `static/` JSON files at import time.
30
+
31
+ 2. **`analysis.py`** — Statistical analysis
32
+ - `data_statistic()` — Groups closed positions by contract, variety, and buy/sell direction; computes P/L, win rates, trade counts, etc.
33
+ - `net_worth_calc()` — Unitizes account equity into NAV series, adjusting for cash flows (deposits/withdrawals). Handles large-flow flagging. First row uses `上日结存`/`期初结存` to initialize.
34
+ - `annual_attribution_statistic()` — Per-year performance metrics: cumulative/annualized return, volatility, max drawdown, Sharpe/Sortino/Calmar ratios, tail ratio, gain-to-pain, skewness, kurtosis. If a benchmark is provided, also computes alpha, beta, Treynor, information ratio, M2, R².
35
+ - `calculate_yield()` — Supports `log` (log return) and `pct` (simple return) methods.
36
+ - `convert_yield()` — Converts between log and percentage returns.
37
+
38
+ 3. **`format.py`** — Excel output
39
+ - `output_excel()` — Writes all data to `.xlsx` with per-sheet formatting
40
+ - `excel_data_format()` — Applies number formats by column/row header keywords (dates, percentages, currency)
41
+ - `excel_create_chart()` — Generates 6 chart sheets: net worth line chart, returns histogram, equity+risk dual-axis chart, trading distribution pie chart, P/L bar chart by variety, radar chart for win/loss ratios
42
+
43
+ 4. **`main.py`** — Entry point; wires the pipeline: load config → load statements → wrangle → combine → analyze → compute net worth → annual stats → output Excel
44
+
45
+ ## Static data (`static/`)
46
+
47
+ - `EXCHANGE.json` — Exchange codes → Chinese names (CFFEX, SHFE, DCE, CZCE, INE, GFEX, SSE, SZSE)
48
+ - `FUTURE.json` — Futures contract metadata keyed by instrument prefix (e.g., `"ih"`, `"if"`, `"rb"`, `"m"`): exchange, product name, multiplier, tick size, margin rates, commissions
49
+ - `OPTION.json` — Options contract metadata, same structure as FUTURE
50
+
51
+ These are loaded at module level in `loader.py` and accessed globally by `analysis.py` and the CTP parser for contract multiplier lookups.
52
+
53
+ ## Configuration (`config.yaml`)
54
+
55
+ | Key | Purpose |
56
+ |-----|---------|
57
+ | `SOURCE_DIR` | Directory with settlement files |
58
+ | `STATEMENT_TYPE` | `cfmmc` / `rohon` / `ctp` |
59
+ | `OUTPUT_DIR` | Where the `.xlsx` result is written |
60
+ | `RISK_FREE_INTEREST_RATE` | Risk-free rate for Sharpe/Sortino/etc. (default 0.02) |
61
+ | `STATISTIC_METHOD` | `log` (log returns) or `pct` (simple returns) |
62
+
63
+ ## Dependencies
64
+
65
+ `pandas`, `openpyxl`, `xlrd` (legacy `.xls`), `orjson` (static file loading), `pyyaml` (config). Managed with `uv` (`uv.lock` checked in).
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Tridro
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.