kaq-quant-common 0.1.80__py3-none-any.whl → 0.1.81__py3-none-any.whl
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.
- kaq_quant_common/api/rest/instruction/helper/order_helper.py +17 -6
- kaq_quant_common/resources/kaq_ddb_pool_stream_read_resources.py +18 -2
- kaq_quant_common/utils/dagster_utils.py +1 -1
- {kaq_quant_common-0.1.80.dist-info → kaq_quant_common-0.1.81.dist-info}/METADATA +1 -1
- {kaq_quant_common-0.1.80.dist-info → kaq_quant_common-0.1.81.dist-info}/RECORD +6 -6
- {kaq_quant_common-0.1.80.dist-info → kaq_quant_common-0.1.81.dist-info}/WHEEL +0 -0
|
@@ -113,12 +113,16 @@ class OrderHelper:
|
|
|
113
113
|
def process_order(self, order: OrderInfo, get_order_result: Callable):
|
|
114
114
|
# 获取交易所
|
|
115
115
|
exchange = self._server._exchange
|
|
116
|
+
|
|
117
|
+
# 记录时间,统计成交耗时
|
|
118
|
+
start_time = time.time()
|
|
119
|
+
|
|
116
120
|
#
|
|
117
|
-
if not self._do_process_order(exchange, order, get_order_result, True):
|
|
121
|
+
if not self._do_process_order(exchange, order, get_order_result, True, start_time):
|
|
118
122
|
# 马上执行,没有成功,开启线程执行
|
|
119
123
|
thread = threading.Thread(
|
|
120
124
|
target=self._do_process_order,
|
|
121
|
-
args=(exchange, order, get_order_result, False),
|
|
125
|
+
args=(exchange, order, get_order_result, False, start_time),
|
|
122
126
|
)
|
|
123
127
|
thread.name = f"process_order_{order.instruction_id}_{exchange}_{order.symbol}_{order.order_id}"
|
|
124
128
|
thread.daemon = True
|
|
@@ -130,6 +134,7 @@ class OrderHelper:
|
|
|
130
134
|
order: OrderInfo,
|
|
131
135
|
get_order_result: Callable,
|
|
132
136
|
first=True,
|
|
137
|
+
start_time: float = 0,
|
|
133
138
|
):
|
|
134
139
|
# 获取mysql
|
|
135
140
|
mysql = self._server._mysql
|
|
@@ -175,11 +180,11 @@ class OrderHelper:
|
|
|
175
180
|
"""
|
|
176
181
|
execute_ret = mysql.execute_sql(sql, True)
|
|
177
182
|
|
|
178
|
-
# 记录时间,统计成交耗时
|
|
179
|
-
start_time = time.time()
|
|
180
|
-
|
|
181
183
|
# 步骤2.查询订单状态 直到订单成交后
|
|
184
|
+
# 统计查询次数
|
|
185
|
+
query_counter = 0
|
|
182
186
|
while True:
|
|
187
|
+
query_counter += 1
|
|
183
188
|
# 获取订单结果
|
|
184
189
|
order_info = None
|
|
185
190
|
try:
|
|
@@ -195,10 +200,16 @@ class OrderHelper:
|
|
|
195
200
|
# 等待
|
|
196
201
|
time.sleep(1)
|
|
197
202
|
|
|
203
|
+
if not first:
|
|
204
|
+
# 需要加上第一查询
|
|
205
|
+
query_counter += 1
|
|
206
|
+
|
|
198
207
|
# 记录时间,统计成交耗时
|
|
199
208
|
end_time = time.time()
|
|
200
209
|
cost_time = end_time - start_time
|
|
201
|
-
self._logger.info(
|
|
210
|
+
self._logger.info(
|
|
211
|
+
f"{ins_id}_{exchange}_{symbol} step 2. {side_str}订单 {order_id} 成交 耗时 {int(cost_time * 1000)}ms, 查询次数 {query_counter}"
|
|
212
|
+
)
|
|
202
213
|
|
|
203
214
|
# 步骤3.把最终持仓写进去
|
|
204
215
|
# 平均成交价格 转float
|
|
@@ -7,6 +7,7 @@ import pandas as pd
|
|
|
7
7
|
import threading
|
|
8
8
|
from kaq_quant_common.utils.logger_utils import get_logger
|
|
9
9
|
import traceback
|
|
10
|
+
from dolphindb.settings import PROTOCOL_PICKLE
|
|
10
11
|
|
|
11
12
|
mutex = threading.Lock()
|
|
12
13
|
|
|
@@ -14,7 +15,7 @@ class KaqQuantDdbPoolStreamReadRepository:
|
|
|
14
15
|
'''
|
|
15
16
|
连接池方式连接DolphinDB数据库, 支持流数据表读取
|
|
16
17
|
'''
|
|
17
|
-
def __init__(self, host, port, user, passwd, pool_size=1):
|
|
18
|
+
def __init__(self, host, port, user, passwd, pool_size=1, protocal=PROTOCOL_PICKLE):
|
|
18
19
|
self.logger = get_logger(self)
|
|
19
20
|
try:
|
|
20
21
|
mutex.acquire()
|
|
@@ -27,6 +28,7 @@ class KaqQuantDdbPoolStreamReadRepository:
|
|
|
27
28
|
reConnect=True,
|
|
28
29
|
# tryReconnectNums=5, # 若不开启高可用,须与 reconnect 参数搭配使用,对单节点进行有限次重连。若不填写该参数,默认进行无限重连。
|
|
29
30
|
sqlStd=SqlStd.DolphinDB,
|
|
31
|
+
protocol=protocal
|
|
30
32
|
)
|
|
31
33
|
except Exception as e:
|
|
32
34
|
self.logger.error(f'KaqQuantDdbPoolStreamReadRepository.__init__ is occured error: {str(e)} - {str(traceback.format_exc())}')
|
|
@@ -49,7 +51,21 @@ class KaqQuantDdbPoolStreamReadRepository:
|
|
|
49
51
|
big_df.columns = colums
|
|
50
52
|
return big_df, None
|
|
51
53
|
except Exception as e:
|
|
52
|
-
self.logger.error(f'KaqQuantDdbPoolStreamReadRepository.
|
|
54
|
+
self.logger.error(f'KaqQuantDdbPoolStreamReadRepository.query is occured error: {str(e)} - {str(traceback.format_exc())}')
|
|
55
|
+
return pd.DataFrame()
|
|
56
|
+
|
|
57
|
+
async def fetch(self, query: str) -> pd.DataFrame:
|
|
58
|
+
'''
|
|
59
|
+
从流数据表中获取数据
|
|
60
|
+
'''
|
|
61
|
+
try:
|
|
62
|
+
data = await self.pool.run(query, pickleTableToList=False, clearMemory=True)
|
|
63
|
+
if data is None:
|
|
64
|
+
return pd.DataFrame()
|
|
65
|
+
big_df = pd.DataFrame(data)
|
|
66
|
+
return big_df
|
|
67
|
+
except Exception as e:
|
|
68
|
+
self.logger.error(f'KaqQuantDdbPoolStreamReadRepository.fetch is occured error: {str(e)} - {str(traceback.format_exc())}')
|
|
53
69
|
return pd.DataFrame()
|
|
54
70
|
|
|
55
71
|
|
|
@@ -14,6 +14,6 @@ def check_dagster_job_running(context: RunStatusSensorContext, job_name: str):
|
|
|
14
14
|
DagsterRunStatus.STARTING,
|
|
15
15
|
DagsterRunStatus.STARTED,
|
|
16
16
|
]:
|
|
17
|
-
context.log.info(f"Job {job_name} is already running")
|
|
17
|
+
# context.log.info(f"Job {job_name} is already running")
|
|
18
18
|
return False
|
|
19
19
|
return True
|
|
@@ -6,7 +6,7 @@ kaq_quant_common/api/common/auth.py,sha256=XqirJRL4D01YfSrBY4hyugw-Op6OJveNE--An
|
|
|
6
6
|
kaq_quant_common/api/rest/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
7
|
kaq_quant_common/api/rest/api_client_base.py,sha256=LYpqjjVGbVRVyP8qdmlgMelUtEY-jGA0JlMJy9d1r4w,1673
|
|
8
8
|
kaq_quant_common/api/rest/api_server_base.py,sha256=URrvzerHIE6XQLERYFcFH1ftLbCYTz3sENAxFD0HWY0,4653
|
|
9
|
-
kaq_quant_common/api/rest/instruction/helper/order_helper.py,sha256=
|
|
9
|
+
kaq_quant_common/api/rest/instruction/helper/order_helper.py,sha256=8tsuzv86uVBqOQKeVKlF83_Ye0qoGoZjO6wpUlYnOPI,11832
|
|
10
10
|
kaq_quant_common/api/rest/instruction/instruction_client.py,sha256=-OH3_KNDkvsJ9zBsyhsitDm5d3U2xYBKLIDQwHp2B2U,3293
|
|
11
11
|
kaq_quant_common/api/rest/instruction/instruction_server_base.py,sha256=bM17HoGqAsrw01ecI-xe7NznTS38R_dL0vgSvHPkHKw,4895
|
|
12
12
|
kaq_quant_common/api/rest/instruction/models/__init__.py,sha256=fx5pnfcf9L5KvAqhsQBZkl9fUf9oABuroLGZqDNycpc,312
|
|
@@ -36,7 +36,7 @@ kaq_quant_common/common/redis_table_monitor.py,sha256=nckt1-Jq2hU2fBA-OWSRyoSwOC
|
|
|
36
36
|
kaq_quant_common/common/ws_wrapper.py,sha256=JNJ0CIjDXgCsRjOLSbCi7ysYDHw7tT_aK7V4ADqw3vA,452
|
|
37
37
|
kaq_quant_common/config/config.yaml,sha256=ST_QBLo7kwVaoNOvuN3mpeSF7LPNSWdD7EjxrBYZYBs,230
|
|
38
38
|
kaq_quant_common/resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
39
|
-
kaq_quant_common/resources/kaq_ddb_pool_stream_read_resources.py,sha256=
|
|
39
|
+
kaq_quant_common/resources/kaq_ddb_pool_stream_read_resources.py,sha256=v8k-hDzR_eK1LBe1J0aYH_tpqJ_w5mY6-FvODVHYCtA,3349
|
|
40
40
|
kaq_quant_common/resources/kaq_ddb_stream_init_resources.py,sha256=0FY0cmqedrLSYoaHJah2QiO0L7l3lsQJzIfXXpd9WSQ,3347
|
|
41
41
|
kaq_quant_common/resources/kaq_ddb_stream_read_resources.py,sha256=yqeruZELmxAKjVsdnZ7ieAeV3Wt7KpFYJdt8Vn_Y_qA,3163
|
|
42
42
|
kaq_quant_common/resources/kaq_ddb_stream_write_resources.py,sha256=JSPJeq3YboDgXNcakCo5n7x-AnBc6tFem4VTUWIdpfA,4096
|
|
@@ -47,7 +47,7 @@ kaq_quant_common/resources/kaq_quant_hive_resources.py,sha256=r114aeRzWkp6ReFPOk
|
|
|
47
47
|
kaq_quant_common/resources/kaq_redis_resources.py,sha256=MFBdl0v6ehbtUVhQw0XzH_DmpxNTfjWqlOG210NWYAo,4480
|
|
48
48
|
kaq_quant_common/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
49
49
|
kaq_quant_common/utils/dagster_job_check_utils.py,sha256=tiijAt_jAc08DJOAa3z43sOTCi-4lizPI-IqWqbBI20,1488
|
|
50
|
-
kaq_quant_common/utils/dagster_utils.py,sha256=
|
|
50
|
+
kaq_quant_common/utils/dagster_utils.py,sha256=Zp9tYKVoF-9i9KcC00hrhKwiECOY7a3HyfLkZBR0o8A,668
|
|
51
51
|
kaq_quant_common/utils/date_util.py,sha256=ur-h8kUVqNYUW2P2t4cZL8oRRXXo8oPMV9S_w5lZCPM,6928
|
|
52
52
|
kaq_quant_common/utils/enums_utils.py,sha256=UH7epXLxRJ9fLNzzFe5ksfv1fdACfkeCD3id2h64wdE,2023
|
|
53
53
|
kaq_quant_common/utils/error_utils.py,sha256=u9jGnfQItSSgCeFJf8_67ud_F_uV_sY5Dh5HcbILJDs,423
|
|
@@ -59,6 +59,6 @@ kaq_quant_common/utils/signal_utils.py,sha256=zBSyEltNTKqkQCsrETd47kEBb3Q_OWUBUn
|
|
|
59
59
|
kaq_quant_common/utils/sqlite_utils.py,sha256=UDDFKfwL0N-jFifl40HdyOCENh2YQfW5so6hRaSJpv0,5722
|
|
60
60
|
kaq_quant_common/utils/uuid_utils.py,sha256=pm_pnXpd8n9CI66x3A20cOEUiriJyqHaKGCeLrgkBxU,71
|
|
61
61
|
kaq_quant_common/utils/yml_utils.py,sha256=gcKjb_-uuUajBGAl5QBPIZTg2wXm7qeeJvtHflj_zOE,4513
|
|
62
|
-
kaq_quant_common-0.1.
|
|
63
|
-
kaq_quant_common-0.1.
|
|
64
|
-
kaq_quant_common-0.1.
|
|
62
|
+
kaq_quant_common-0.1.81.dist-info/METADATA,sha256=zJ9K9XzpDQcpeUdcLgyuMF93hiMAYSe6OYtu3lW_7dE,1971
|
|
63
|
+
kaq_quant_common-0.1.81.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
64
|
+
kaq_quant_common-0.1.81.dist-info/RECORD,,
|
|
File without changes
|