gjdatac-api 0.3.7__tar.gz → 0.3.8__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.
Potentially problematic release.
This version of gjdatac-api might be problematic. Click here for more details.
- {gjdatac_api-0.3.7 → gjdatac_api-0.3.8}/PKG-INFO +1 -1
- {gjdatac_api-0.3.7 → gjdatac_api-0.3.8}/gjdatac_api/data_api_class.py +54 -14
- {gjdatac_api-0.3.7 → gjdatac_api-0.3.8}/gjdatac_api/dict_data.py +1 -1
- {gjdatac_api-0.3.7 → gjdatac_api-0.3.8}/gjdatac_api/dolphindb_info.py +5 -0
- {gjdatac_api-0.3.7 → gjdatac_api-0.3.8}/gjdatac_api.egg-info/PKG-INFO +1 -1
- {gjdatac_api-0.3.7 → gjdatac_api-0.3.8}/setup.py +1 -1
- {gjdatac_api-0.3.7 → gjdatac_api-0.3.8}/gjdatac_api/__init__.py +0 -0
- {gjdatac_api-0.3.7 → gjdatac_api-0.3.8}/gjdatac_api/instrument_class.py +0 -0
- {gjdatac_api-0.3.7 → gjdatac_api-0.3.8}/gjdatac_api.egg-info/SOURCES.txt +0 -0
- {gjdatac_api-0.3.7 → gjdatac_api-0.3.8}/gjdatac_api.egg-info/dependency_links.txt +0 -0
- {gjdatac_api-0.3.7 → gjdatac_api-0.3.8}/gjdatac_api.egg-info/requires.txt +0 -0
- {gjdatac_api-0.3.7 → gjdatac_api-0.3.8}/gjdatac_api.egg-info/top_level.txt +0 -0
- {gjdatac_api-0.3.7 → gjdatac_api-0.3.8}/setup.cfg +0 -0
|
@@ -1078,7 +1078,7 @@ class GJDataC:
|
|
|
1078
1078
|
option_contract_db_table_name,
|
|
1079
1079
|
option_contract_db_path)
|
|
1080
1080
|
data["type"] = "option"
|
|
1081
|
-
data["exercise_type"] = data["
|
|
1081
|
+
data["exercise_type"] = data["option_stype"]
|
|
1082
1082
|
else:
|
|
1083
1083
|
raise Exception("asset_type is not valid")
|
|
1084
1084
|
data["commodity"] = ""
|
|
@@ -1123,24 +1123,64 @@ class GJDataC:
|
|
|
1123
1123
|
|
|
1124
1124
|
def get_instruments_deal_commodity_trading_hour(self, data):
|
|
1125
1125
|
"""
|
|
1126
|
-
|
|
1127
|
-
|
|
1126
|
+
从合约基础信息表获取 commodity,从 qc_product 表获取 trading_hour
|
|
1127
|
+
期货查 qc_futinstrument,期权查 qc_optinstrument
|
|
1128
1128
|
:param data: 数据
|
|
1129
1129
|
:return: data: 处理后的数据
|
|
1130
1130
|
"""
|
|
1131
1131
|
|
|
1132
1132
|
try:
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1133
|
+
unique_ids = data['order_book_id'].unique().tolist()
|
|
1134
|
+
|
|
1135
|
+
# 根据合约类型选择基础信息表
|
|
1136
|
+
if 'type' in data.columns and data['type'].iloc[0] == 'option':
|
|
1137
|
+
table_name = option_contract_db_table_name
|
|
1138
|
+
else:
|
|
1139
|
+
table_name = future_contract_db_table_name
|
|
1140
|
+
contract_data, db_session = self.connect_db(table_name, future_contract_db_path)
|
|
1141
|
+
|
|
1142
|
+
filtered = contract_data.select("*").where(
|
|
1143
|
+
"instrument_id in {}".format(unique_ids)
|
|
1144
|
+
).toDF()
|
|
1145
|
+
|
|
1146
|
+
if not filtered.empty:
|
|
1147
|
+
# 从基础信息表取 product_id 作为 commodity
|
|
1148
|
+
lookup = filtered[['instrument_id', 'product_id']].rename(
|
|
1149
|
+
columns={'product_id': '_commodity'}
|
|
1150
|
+
)
|
|
1151
|
+
lookup = lookup.drop_duplicates(subset=['instrument_id'], keep='first')
|
|
1152
|
+
|
|
1153
|
+
data = data.merge(
|
|
1154
|
+
lookup,
|
|
1155
|
+
left_on='order_book_id',
|
|
1156
|
+
right_on='instrument_id',
|
|
1157
|
+
how='left'
|
|
1158
|
+
)
|
|
1159
|
+
data['commodity'] = data['_commodity']
|
|
1160
|
+
data.drop(columns=['instrument_id', '_commodity'], inplace=True, errors='ignore')
|
|
1161
|
+
|
|
1162
|
+
# 用 product_id 关联 qc_product 表获取 trade_section 作为 trading_hour
|
|
1163
|
+
unique_products = data['commodity'].dropna().unique().tolist()
|
|
1164
|
+
if unique_products:
|
|
1165
|
+
product_data, product_session = self.connect_db(product_db_table_name, product_db_path)
|
|
1166
|
+
product_filtered = product_data.select("*").where(
|
|
1167
|
+
"product_id in {}".format(unique_products)
|
|
1168
|
+
).toDF()
|
|
1169
|
+
if not product_filtered.empty:
|
|
1170
|
+
product_lookup = product_filtered[['product_id', 'trade_section']].rename(
|
|
1171
|
+
columns={'trade_section': '_trading_hour'}
|
|
1172
|
+
)
|
|
1173
|
+
product_lookup = product_lookup.drop_duplicates(subset=['product_id'], keep='first')
|
|
1174
|
+
data = data.merge(
|
|
1175
|
+
product_lookup,
|
|
1176
|
+
left_on='commodity',
|
|
1177
|
+
right_on='product_id',
|
|
1178
|
+
how='left'
|
|
1179
|
+
)
|
|
1180
|
+
data['trading_hour'] = data['_trading_hour']
|
|
1181
|
+
data.drop(columns=['product_id', '_trading_hour'], inplace=True, errors='ignore')
|
|
1182
|
+
product_session.close()
|
|
1183
|
+
|
|
1144
1184
|
db_session.close()
|
|
1145
1185
|
except ValueError as e:
|
|
1146
1186
|
print(e)
|
|
@@ -145,7 +145,7 @@ get_instruments_type_dict = {
|
|
|
145
145
|
# "": "commodity",
|
|
146
146
|
"open_date": "listed_date", "expire_date": "maturity_date", "delivery_month": "delivery_month",
|
|
147
147
|
"start_deliv_date": "start_delivery", "end_deliv_date": "end_delivery", "delisting_date": "de_listed_date",
|
|
148
|
-
"
|
|
148
|
+
"option_type": "option_type", "strike_price": "strike_price",
|
|
149
149
|
"underlying_instrument_id": "underlying_order_book_id",
|
|
150
150
|
"volume_multiple": "contract_multiplier",
|
|
151
151
|
# "trading_hour": "trading_hour"
|
|
@@ -5,7 +5,7 @@ with open('description_info.md', 'r', encoding='utf-8') as f:
|
|
|
5
5
|
|
|
6
6
|
setup(
|
|
7
7
|
name='gjdatac_api', # 你的包名
|
|
8
|
-
version='0.3.
|
|
8
|
+
version='0.3.8', # 版本号
|
|
9
9
|
description='数据接口打包', # 包的简要描述
|
|
10
10
|
long_description=long_description, # 包的详细描述
|
|
11
11
|
long_description_content_type='text/markdown', # 描述文件的类型
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|