kaq-quant-common 0.2.1__py3-none-any.whl → 0.2.3__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.
@@ -88,6 +88,19 @@ class OrderHelper:
88
88
  redis = self._server._redis
89
89
  if redis is None:
90
90
  return
91
+
92
+ # 先从 redis 读取现有的 position 数据,获取 funding_rate_records 字段
93
+ funding_rate_records = None
94
+ try:
95
+ existing_position_json = redis.client.hget(self._redis_key_position, position_id)
96
+ if existing_position_json:
97
+ existing_position = json.loads(existing_position_json)
98
+ if existing_position and "funding_rate_records" in existing_position:
99
+ funding_rate_records = existing_position.get("funding_rate_records")
100
+ except Exception as e:
101
+ # 读取失败不影响后续流程,记录日志
102
+ self._logger.warning(f"Failed to get funding_rate_records for position {position_id}: {e}")
103
+
91
104
  data = {
92
105
  "id": position_id,
93
106
  "exchange": exchange,
@@ -107,6 +120,11 @@ class OrderHelper:
107
120
  "close_time": close_time,
108
121
  "status": PositionStatus.CLOSE.value,
109
122
  }
123
+
124
+ # 如果存在 funding_rate_records,添加到 data 中
125
+ if funding_rate_records is not None:
126
+ data["funding_rate_records"] = funding_rate_records
127
+
110
128
  redis.client.hdel(self._redis_key_position, position_id)
111
129
  redis.client.rpush(self._redis_key_position_history, json.dumps(data))
112
130
 
@@ -94,7 +94,9 @@ class KaqQuantDdbStreamWriteRepository:
94
94
  for row in arr:
95
95
  parts = []
96
96
  for i, v in enumerate(row):
97
- if i in str_idx:
97
+ if v is None or pd.isna(v):
98
+ parts.append("NULL")
99
+ elif i in str_idx:
98
100
  parts.append(f"'{v}'") # 直接拼接最快
99
101
  else:
100
102
  parts.append(str(v))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kaq_quant_common
3
- Version: 0.2.1
3
+ Version: 0.2.3
4
4
  Summary:
5
5
  Author: kevinfuture
6
6
  Author-email: liuenbofuture@foxmail.com
@@ -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=q2opRLHrysvgqoFpAC70WNQpFJsbviHqjRldXj6tiMY,12267
9
+ kaq_quant_common/api/rest/instruction/helper/order_helper.py,sha256=eZ-iEZ7HegHYkqpflwKicbdLlp12gcV2wEtBVNLMBiQ,13195
10
10
  kaq_quant_common/api/rest/instruction/instruction_client.py,sha256=NwTEypC4eajGq8oWIgvKSbIAO-KMPH4jQ-7J2b9iN4g,4037
11
11
  kaq_quant_common/api/rest/instruction/instruction_server_base.py,sha256=pq1wghAlgtm10aWz70-x1OAqtoRH3lBu-HsIuVRHkqY,6223
12
12
  kaq_quant_common/api/rest/instruction/models/__init__.py,sha256=fx5pnfcf9L5KvAqhsQBZkl9fUf9oABuroLGZqDNycpc,312
@@ -41,7 +41,7 @@ kaq_quant_common/resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJ
41
41
  kaq_quant_common/resources/kaq_ddb_pool_stream_read_resources.py,sha256=Y-rtGpBF3bNh2mPZ2Lze6D9JZnpkqh24OEh7okikh1w,2536
42
42
  kaq_quant_common/resources/kaq_ddb_stream_init_resources.py,sha256=0MxxbajocTFzcRD344rfZQPKOwwuqCbyoT6dQpIox-o,3349
43
43
  kaq_quant_common/resources/kaq_ddb_stream_read_resources.py,sha256=WShsXMoL8o-JZvrtAd7H2Cg-vrE47QbsdGgURaQwiZs,3165
44
- kaq_quant_common/resources/kaq_ddb_stream_write_resources.py,sha256=1ngYODoBPV9906oWsW6T4rH1xeVsfPiqhxsg3Md9b04,12551
44
+ kaq_quant_common/resources/kaq_ddb_stream_write_resources.py,sha256=_-bNnxnG5I98JOlV46FYXlYoJRkzlMzWREHUonornF4,12638
45
45
  kaq_quant_common/resources/kaq_mysql_init_resources.py,sha256=UcqWey6LgoMqvLq1SxK33nS6-rkViGYhzUPxcrucOks,827
46
46
  kaq_quant_common/resources/kaq_mysql_resources.py,sha256=282jpXvYlEQNx-hicYTNBHDii85KYgN7BQQSMS9aPFM,13211
47
47
  kaq_quant_common/resources/kaq_postgresql_resources.py,sha256=iG1eYkciI0xUIBdEpGqKGOLBFxvVrfbBoTuaOmhQ0v0,1762
@@ -61,6 +61,6 @@ kaq_quant_common/utils/signal_utils.py,sha256=zBSyEltNTKqkQCsrETd47kEBb3Q_OWUBUn
61
61
  kaq_quant_common/utils/sqlite_utils.py,sha256=UDDFKfwL0N-jFifl40HdyOCENh2YQfW5so6hRaSJpv0,5722
62
62
  kaq_quant_common/utils/uuid_utils.py,sha256=pm_pnXpd8n9CI66x3A20cOEUiriJyqHaKGCeLrgkBxU,71
63
63
  kaq_quant_common/utils/yml_utils.py,sha256=gcKjb_-uuUajBGAl5QBPIZTg2wXm7qeeJvtHflj_zOE,4513
64
- kaq_quant_common-0.2.1.dist-info/METADATA,sha256=BQR0H2Zhcjyow-c0bEgxlkTrbuR7FEh7I8HJmTszrqk,1970
65
- kaq_quant_common-0.2.1.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
66
- kaq_quant_common-0.2.1.dist-info/RECORD,,
64
+ kaq_quant_common-0.2.3.dist-info/METADATA,sha256=wk6Okdv4qKVJxUnM54tR6sTtw4zMR2Qicwv5NZOXsXk,1970
65
+ kaq_quant_common-0.2.3.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
66
+ kaq_quant_common-0.2.3.dist-info/RECORD,,