gjqh-DataFetch 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 HongYuan
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.
@@ -0,0 +1,20 @@
1
+ Metadata-Version: 2.4
2
+ Name: gjqh_DataFetch
3
+ Version: 0.0.1
4
+ Summary: A simple and foolish trading API for internal use compatible with IS and XT trading systems.
5
+ Author-email: HongYuan <yuanhong2@gtht.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/pypa/sampleproject
8
+ Project-URL: Issues, https://github.com/pypa/sampleproject/issues
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.9
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE.txt
14
+ Dynamic: license-file
15
+
16
+ # Example Package
17
+
18
+ This is a simple example package. You can use
19
+ [GitHub-flavored Markdown](https://guides.github.com/features/mastering-markdown/)
20
+ to write your content.
@@ -0,0 +1,5 @@
1
+ # Example Package
2
+
3
+ This is a simple example package. You can use
4
+ [GitHub-flavored Markdown](https://guides.github.com/features/mastering-markdown/)
5
+ to write your content.
@@ -0,0 +1,27 @@
1
+ [build-system]
2
+ requires = ["setuptools >= 77.0.3"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "gjqh_DataFetch"
7
+ version = "0.0.1"
8
+ authors = [
9
+ { name="HongYuan", email="yuanhong2@gtht.com" },
10
+ ]
11
+ description = "A simple and foolish trading API for internal use compatible with IS and XT trading systems."
12
+ readme = "README.md"
13
+ requires-python = ">=3.9"
14
+ classifiers = [
15
+ "Programming Language :: Python :: 3",
16
+ "Operating System :: OS Independent",
17
+ ]
18
+ license = "MIT"
19
+ license-files = ["LICENSE.txt"]
20
+
21
+ [project.urls]
22
+ Homepage = "https://github.com/pypa/sampleproject"
23
+ Issues = "https://github.com/pypa/sampleproject/issues"
24
+
25
+
26
+ [tool.setuptools.package-data]
27
+ "gjqh_DataFetch" = ["*.so"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1 @@
1
+ from .DataFetch import DataFetch
@@ -0,0 +1,131 @@
1
+
2
+ # 需要将DataFetch.cp38-win_amd64.pyd置于本文件的同级目录下。
3
+ # pip install clickhouse-connect; pip install pandas
4
+
5
+ from gjqh_DataFetch import DataFetch
6
+ import pandas as pd
7
+ import json
8
+
9
+ # 01 类初始化
10
+ # account_id : 资金账号;
11
+ # acquire_key : 密码 用于查询数据库 默认123456;
12
+ # user_id : 用户名 用于在数据库内进行操作留痕 建议填写
13
+
14
+ x = DataFetch(account_id='1086000', acquire_key='123456', user_id='yh')
15
+
16
+
17
+ # 02 新增信号/覆盖信号 适用情况:1,当前tradingday首次导入数据 2,当前tradingday下, 某个contract 的持仓量/方向/日盘夜盘等特征 需要修改
18
+ # 字段格式要求: 可参考 factors.t_order_dtl 中的字段格式 枚举值需符合规定
19
+ # 除 trade_time, signal_date 外 均为必填项
20
+
21
+ ###########
22
+ # 更新
23
+ # 对锁 :平今对锁 数据集 mat_01 增加参数 传入 feature = 1
24
+
25
+
26
+ # 一些更新
27
+ # 单次上传只能上传同一个交易日(tradingday 唯一)
28
+
29
+ ### fun_update_signal 函数参数
30
+ # 1 continuous_holding 参数:适用于日内某几个合约调仓
31
+
32
+ # continuous_holding = False : 未上传合约会被平仓
33
+ # continuous_holding = True : 同一tradingday下,每个合约取最近一次上传的仓位。当前tradingday下未曾上传的合约不交易。
34
+ # input_data 中未传入的合约不交易 : 需要在调用 fun_update_signal 时候 增加 参数 continous_holding=True (默认continous_holding=False)
35
+
36
+ # 2 use_redis 参数
37
+ # 使用 redis 交易: 需要在调用 fun_update_signal 时候 增加 参数 use_redis=True (默认use_redis=False)
38
+ ###########
39
+
40
+
41
+
42
+ mat_01 = pd.DataFrame(data=[['20230804', 'AP2310', 5, 'L', 'intraday_trading', '', '20230803'],
43
+ ['20230804', 'AP2311', 5, 'L', 'intraday_trading', 'D', '']],
44
+ columns=['trading_day', 'contract', 'position', 'direction', 'order_typ', 'trade_time', 'signal_date'])
45
+
46
+ mat_01 = pd.DataFrame(data=[['20230804', 'AP2310', 5, 'L', 'intraday_trading'],
47
+ ['20230804', 'AP2311', 5, 'L', 'intraday_trading']],
48
+ columns=['trading_day', 'contract', 'position', 'direction', 'order_typ'])
49
+
50
+ mat_02 = json.loads(mat_01.to_json(orient='records'))
51
+ a01 = x.fun_update_signal(input_data=mat_02, use_redis=True, continuous_holding=True)
52
+
53
+
54
+ # 03 删除数据
55
+ # 仅适用于仿真非redis上传仓位的情况
56
+ # 实盘 redis 请使用 fun_update_signal 进行目标仓位调整
57
+
58
+ a02 = x.fun_delete_signal(trading_day='20230723', trade_time='D', order_typ='intraday_trading', contract=['AP2311'])
59
+ a03 = x.fun_delete_signal(trading_day='20230723', trade_time='D', order_typ='intraday_trading')
60
+ a041 = x.fun_delete_signal(trading_day='20230804', trade_time='', order_typ='intraday_trading', contract=['AP2310'])
61
+
62
+
63
+ # 04 查询导入的仓位(这里不显示已删除数据)trading_day >= start_date and trading_day <= end_date
64
+ a04 = x.fun_read_signal(start_date='20230719', end_date='20230720')
65
+
66
+
67
+ # 05 06 查询时间段内的成交明细以及持仓情况(t+1更新) Factors.t_deal_dtl m_strTradeDate >= start_date and m_strTradeDate <= end_date
68
+ a05 = x.fun_read_deal(start_date='20230721', end_date='20230721')
69
+ a06 = x.fun_read_position(start_date='20230721', end_date='20230721')
70
+
71
+
72
+ # 07 更改当前资金账号的交易状态 Factors.t_account_info 生效时间:从当前时间点开始
73
+ a07 = x.fun_update_sts(trade_tag='T')
74
+
75
+
76
+ #############
77
+ # 20240122更新
78
+
79
+ # 08 读取当前仓位 (盘中 / 盘后)
80
+
81
+ a08 = x.fun_redis_position() # 返回的是盘中由持仓查询回调返回的最新仓位。code = 0 即查询成功
82
+
83
+ #############
84
+
85
+ # 20240208 更新
86
+
87
+ # 09 新增 读取 净值情况
88
+
89
+ a09 = x.fun_read_equity() # 返回的是历史净值及份额 目前暂不支持时间区间删选 返回的是全量净值情况
90
+ a09 = x.fun_margin_used() # 返回的是实时净值 balance
91
+
92
+ ## 10 因子值查询
93
+ test = DataFetch.factors_value(typ='value', start_date= '20240905', end_date = '20240906')
94
+ print(test['data'])
95
+
96
+ test = DataFetch.factors_value(typ='weight', start_date= '20240905', end_date = '20240906')
97
+ print(test['data'])
98
+
99
+
100
+ # 11 拆单 参数自定义 (在redis场景下)
101
+ # if_twap 1 : True; 0: False
102
+ # time_gap : 相邻报单时间间隔 -- 单位 s
103
+ # volume : 拆单手数
104
+ ## 程序有一个初始值(初始值不区分品种) 可以用下述参数覆盖原始 # 只需要上传一次 之后一直生效 不需要每天上传
105
+
106
+ df_01 = pd.DataFrame(data=[['SA', 1, 0.5, 5],
107
+ ['RM', 1, 0.5, 5],
108
+ ['BU', 1, 0.5, 5],
109
+ ['P', 1, 0.5, 5],
110
+ ['I', 1, 0.5, 5],
111
+ ['Y', 1, 0.5, 5],
112
+ ['J', 1, 0.5, 5],
113
+ ['TA', 1, 0.5, 5],
114
+ ['JM', 1, 0.5, 5],
115
+ ['MA', 1, 0.5, 5],
116
+ ['M', 1, 0.5, 5],
117
+ ['CF', 1, 0.5, 5],
118
+ ['LU', 1, 0.5, 5],
119
+ ['RU', 1, 0.5, 5],
120
+ ['EB', 1, 0.5, 5],
121
+ ['SR', 1, 0.5, 5],
122
+ ['FG', 1, 0.5, 5],
123
+ ['OI', 1, 0.5, 5],
124
+ ['RB', 1, 0.5, 5],
125
+ ['HC', 1, 0.5, 5],
126
+ ],
127
+ columns=['commodity', 'if_twap', 'time_gap', 'volume'])
128
+
129
+ df_02 = json.loads(df_01.to_json(orient='records'))
130
+ a01 = x.fun_update_TWAP_info(input_data=df_02)
131
+
@@ -0,0 +1,20 @@
1
+ Metadata-Version: 2.4
2
+ Name: gjqh_DataFetch
3
+ Version: 0.0.1
4
+ Summary: A simple and foolish trading API for internal use compatible with IS and XT trading systems.
5
+ Author-email: HongYuan <yuanhong2@gtht.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/pypa/sampleproject
8
+ Project-URL: Issues, https://github.com/pypa/sampleproject/issues
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.9
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE.txt
14
+ Dynamic: license-file
15
+
16
+ # Example Package
17
+
18
+ This is a simple example package. You can use
19
+ [GitHub-flavored Markdown](https://guides.github.com/features/mastering-markdown/)
20
+ to write your content.
@@ -0,0 +1,10 @@
1
+ LICENSE.txt
2
+ README.md
3
+ pyproject.toml
4
+ src/gjqh_DataFetch/DataFetch.cpython-39-x86_64-linux-gnu.so
5
+ src/gjqh_DataFetch/__init__.py
6
+ src/gjqh_DataFetch/example.py
7
+ src/gjqh_DataFetch.egg-info/PKG-INFO
8
+ src/gjqh_DataFetch.egg-info/SOURCES.txt
9
+ src/gjqh_DataFetch.egg-info/dependency_links.txt
10
+ src/gjqh_DataFetch.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ gjqh_DataFetch